composer.phar 2.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of Composer.
  5. *
  6. * (c) Nils Adermann <naderman@naderman.de>
  7. * Jordi Boggiano <j.boggiano@seld.be>
  8. *
  9. * For the full copyright and license information, please view
  10. * the license that is located at the bottom of this file.
  11. */
  12. // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
  13. if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) {
  14. if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
  15. ini_set('apc.cache_by_default', 0);
  16. } else {
  17. fwrite(STDERR, 'Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.'.PHP_EOL);
  18. fwrite(STDERR, 'Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.'.PHP_EOL);
  19. }
  20. }
  21. if (!class_exists('Phar')) {
  22. echo 'PHP\'s phar extension is missing. Composer requires it to run. Enable the extension or recompile php without --disable-phar then try again.' . PHP_EOL;
  23. exit(1);
  24. }
  25. Phar::mapPhar('composer.phar');
  26. require 'phar://composer.phar/bin/composer';
  27. __HALT_COMPILER(); ?>
  28. ¡¤��+������ ���composer.phar����+���src/Composer/Autoload/AutoloadGenerator.php=…��¦Mýa=…��ƒÄb€¤������+���src/Composer/Autoload/ClassMapGenerator.phpè��¦Mýaè��›‰,¤������(���src/Composer/Autoload/PhpFileCleaner.php©��¦Mýa©��®>½¤���������src/Composer/Cache.phpã��¦Mýaã��y)ö1¤������%���src/Composer/Command/AboutCommand.php7��¦Mýa7��°, `¤������'���src/Composer/Command/ArchiveCommand.phpå��¦Mýaå��3Ö ú¤������$���src/Composer/Command/BaseCommand.phpÙ��¦MýaÙ��jŠ¿¤������.���src/Composer/Command/BaseDependencyCommand.phpš��¦Mýaš��:“¤������1���src/Composer/Command/CheckPlatformReqsCommand.phpÄ��¦MýaÄ��À¯ø¤������*���src/Composer/Command/ClearCacheCommand.phpù��¦Mýaù��w¯Ȥ������&���src/Composer/Command/ConfigCommand.php7^��¦Mýa7^��†hôw¤������-���src/Composer/Command/CreateProjectCommand.php‡E��¦Mýa‡E��M ¤������'���src/Composer/Command/DependsCommand.php’��¦Mýa’��&Ž­¤������(���src/Composer/Command/DiagnoseCommand.phpåM��¦MýaåM��¹‡ƒ¬¤������,���src/Composer/Command/DumpAutoloadCommand.php¨��¦Mýa¨��›+�B¤������$���src/Composer/Command/ExecCommand.php¢��¦Mýa¢��ÂíÎÔ¤������$���src/Composer/Command/FundCommand.phpN��¦MýaN��+5F¤������&���src/Composer/Command/GlobalCommand.phpŽ
  29. ��¦MýaŽ
  30. ��;lÛš¤������$���src/Composer/Command/HomeCommand.php ��¦Mýa ��¨S?Y¤������$���src/Composer/Command/InitCommand.php-t��¦Mýa-t��C+ÌĤ������'���src/Composer/Command/InstallCommand.phpó��¦Mýaó���dŤ������(���src/Composer/Command/LicensesCommand.php:��¦Mýa:��±W¬Ü¤������(���src/Composer/Command/OutdatedCommand.phpÓ��¦MýaÓ��ï4굤������)���src/Composer/Command/ProhibitsCommand.php<��¦Mýa<��I¸3¤������)���src/Composer/Command/ReinstallCommand.php#��¦Mýa#��•¶c@¤������&���src/Composer/Command/RemoveCommand.php2*��¦Mýa2*��yÇ⻤������'���src/Composer/Command/RequireCommand.php"C��¦Mýa"C��óŽ
  31. ¤������)���src/Composer/Command/RunScriptCommand.php¦��¦Mýa¦��PšD¤������+���src/Composer/Command/ScriptAliasCommand.php»��¦Mýa»��W–ù»¤������&���src/Composer/Command/SearchCommand.phpe��¦Mýae��‘riw¤������*���src/Composer/Command/SelfUpdateCommand.php÷E��¦Mýa÷E��ÇoV¤������$���src/Composer/Command/ShowCommand.phpÞ’��¦MýaÞ’��*B"§¤������&���src/Composer/Command/StatusCommand.phpé��¦Mýaé��å1‘¤������(���src/Composer/Command/SuggestsCommand.php› ��¦Mýa› ��MÖ­¤������&���src/Composer/Command/UpdateCommand.php5��¦Mýa5���殤������(���src/Composer/Command/ValidateCommand.php���¦Mýa���å¯()¤���������src/Composer/Composer.phpA ��¦MýaA ��Ÿ"ŒY¤���������src/Composer/Config.php1��¦Mýa1��©*øU¤������-���src/Composer/Config/ConfigSourceInterface.php/��¦Mýa/��פ������(���src/Composer/Config/JsonConfigSource.phpâ��¦Mýaâ��¶ØQ
  32. ¤������$���src/Composer/Console/Application.php”B��¦Mýa”B��)Í‹'¤������*���src/Composer/Console/GithubActionError.phpÍ��¦MýaÍ��¼ä!C¤������,���src/Composer/Console/HtmlOutputFormatter.php¸��¦Mýa¸��|(~Ĥ������-���src/Composer/DependencyResolver/Decisions.php©��¦Mýa©��0´­Û¤������1���src/Composer/DependencyResolver/DefaultPolicy.phpú��¦Mýaú��ŸÍI´¤������/���src/Composer/DependencyResolver/GenericRule.phpf��¦Mýaf���’¼æ¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.php¤��¦Mýa¤��ƒ #¤������3���src/Composer/DependencyResolver/LockTransaction.php ��¦Mýa ��›]/¤������5���src/Composer/DependencyResolver/MultiConflictRule.phpõ��¦Mýaõ��ÚLm›¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.php»��¦Mýa»��ïF‡ã¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.phpß��¦Mýaß��=Ù÷À¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.phpå��¦Mýaå��‡°¸/¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÚ���¦MýaÚ���Qâè¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.php��¦Mýa��mÑa¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.php£��¦Mýa£�� Y<¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpK��¦MýaK��ò;!¤������3���src/Composer/DependencyResolver/PolicyInterface.phpm��¦Mýam��¦²ù&¤������(���src/Composer/DependencyResolver/Pool.phpT��¦MýaT��æË竤������/���src/Composer/DependencyResolver/PoolBuilder.php;@��¦Mýa;@��«Ò•é¤������1���src/Composer/DependencyResolver/PoolOptimizer.phpT'��¦MýaT'��ö0|ÿ¤������+���src/Composer/DependencyResolver/Problem.php·I��¦Mýa·I��ÄYˤ������+���src/Composer/DependencyResolver/Request.php&��¦Mýa&��ÍŠcþ¤������(���src/Composer/DependencyResolver/Rule.phpÜ/��¦MýaÜ/��¾cκ¤������1���src/Composer/DependencyResolver/Rule2Literals.phpË��¦MýaË��†­F¤������+���src/Composer/DependencyResolver/RuleSet.phpƒ ��¦Mýaƒ ��
  33. K.x¤������4���src/Composer/DependencyResolver/RuleSetGenerator.phpM��¦MýaM��õ•ˆ¤������3���src/Composer/DependencyResolver/RuleSetIterator.php ��¦Mýa ��•Ÿƒj¤������2���src/Composer/DependencyResolver/RuleWatchChain.phpU��¦MýaU��B#¤������2���src/Composer/DependencyResolver/RuleWatchGraph.phpS ��¦MýaS ��Uؤ������1���src/Composer/DependencyResolver/RuleWatchNode.php<��¦Mýa<��¯T†2¤������*���src/Composer/DependencyResolver/Solver.phpr9��¦Mýar9���¿Óˤ������6���src/Composer/DependencyResolver/SolverBugException.phpœ��¦Mýaœ��^Hᕤ������;���src/Composer/DependencyResolver/SolverProblemsException.php=��¦Mýa=��½¼W¤������/���src/Composer/DependencyResolver/Transaction.phpÿ��¦Mýaÿ��…âß§¤������-���src/Composer/Downloader/ArchiveDownloader.php��¦Mýa��Šbˆå¤������1���src/Composer/Downloader/ChangeReportInterface.phpÌ���¦MýaÌ���¯à¨¿¤������+���src/Composer/Downloader/DownloadManager.phpü��¦Mýaü�� @«^¤������/���src/Composer/Downloader/DownloaderInterface.php ��¦Mýa ��_y¶¤������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ���¦MýaÑ���&Áœ¿¤������*���src/Composer/Downloader/FileDownloader.phpÙ.��¦MýaÙ.���þ^4¤������/���src/Composer/Downloader/FilesystemException.php��¦Mýa��×^x¤������,���src/Composer/Downloader/FossilDownloader.php\ ��¦Mýa\ ��þ$Ф������)���src/Composer/Downloader/GitDownloader.php…B��¦Mýa…B��'„@¤������*���src/Composer/Downloader/GzipDownloader.php��¦Mýa��úÄ›¤������(���src/Composer/Downloader/HgDownloader.php
  34. ��¦Mýa
  35. ��Ôƒ0,¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phps���¦Mýas���Ù¢ ñ¤������*���src/Composer/Downloader/PathDownloader.php���¦Mýa���B+¤������.���src/Composer/Downloader/PerforceDownloader.phpˆ��¦Mýaˆ��¥‡Ø•¤������*���src/Composer/Downloader/PharDownloader.phpI��¦MýaI��Äk0ò¤������)���src/Composer/Downloader/RarDownloader.php6��¦Mýa6��ÏÐFõ¤������)���src/Composer/Downloader/SvnDownloader.php6��¦Mýa6��éu83¤������)���src/Composer/Downloader/TarDownloader.phpG��¦MýaG��/P]¤������.���src/Composer/Downloader/TransportException.php&��¦Mýa&��xc# ¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ���¦MýaÔ���`§ôö¤������)���src/Composer/Downloader/VcsDownloader.phpr��¦Mýar��6®t¥¤������(���src/Composer/Downloader/XzDownloader.phpL��¦MýaL��b]¾Û¤������)���src/Composer/Downloader/ZipDownloader.php¿��¦Mýa¿��×ÈÕF¤������&���src/Composer/EventDispatcher/Event.php¢��¦Mýa¢��ÉNÇŒ¤������0���src/Composer/EventDispatcher/EventDispatcher.php@3��¦Mýa@3��£êáð¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©���¦Mýa©���h·0¤������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv���¦Mýav���wZ8S¤������9���src/Composer/Exception/IrrecoverableDownloadException.phpv���¦Mýav���DM½y¤������)���src/Composer/Exception/NoSslException.phph���¦Mýah���ˆdñÓ¤���������src/Composer/Factory.phppG��¦MýapG��ÓIª:¤������T���src/Composer/Filter/PlatformRequirementFilter/IgnoreAllPlatformRequirementFilter.php'��¦Mýa'��²ª¦ê¤������U���src/Composer/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilter.phpÙ��¦MýaÙ��ì즤������X���src/Composer/Filter/PlatformRequirementFilter/IgnoreNothingPlatformRequirementFilter.phpØ���¦MýaØ���–}±7¤������R���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterFactory.phpð��¦Mýað��:èU¤������T���src/Composer/Filter/PlatformRequirementFilter/PlatformRequirementFilterInterface.php“���¦Mýa“���j£˜"¤���������src/Composer/IO/BaseIO.phpÁ��¦MýaÁ��5ý¹ú¤���������src/Composer/IO/BufferIO.php��¦Mýa��]+±Î¤���������src/Composer/IO/ConsoleIO.phpZ��¦MýaZ���;uì¤���������src/Composer/IO/IOInterface.phpè��¦Mýaè�� 6s¤���������src/Composer/IO/NullIO.php¿��¦Mýa¿��óZ·¤���������src/Composer/Installer.php6}��¦Mýa6}��^ü
  36. ¤������*���src/Composer/Installer/BinaryInstaller.phpA(��¦MýaA(��UŽ“P¤������2���src/Composer/Installer/BinaryPresenceInterface.phpÍ���¦MýaÍ���“ï`U¤������.���src/Composer/Installer/InstallationManager.phpÀ5��¦MýaÀ5��MÌ\L¤������)���src/Composer/Installer/InstallerEvent.phpå��¦Mýaå��ÎE N¤������*���src/Composer/Installer/InstallerEvents.php…���¦Mýa…���nÜ<Á¤������-���src/Composer/Installer/InstallerInterface.phpI��¦MýaI��µªØ\¤������+���src/Composer/Installer/LibraryInstaller.php¿��¦Mýa¿��ÕF¤������/���src/Composer/Installer/MetapackageInstaller.php—��¦Mýa—��‰º@¥¤������(���src/Composer/Installer/NoopInstaller.php&��¦Mýa&��.¶¤������'���src/Composer/Installer/PackageEvent.php–��¦Mýa–��=¯³X¤������(���src/Composer/Installer/PackageEvents.php¸��¦Mýa¸��dbØs¤������*���src/Composer/Installer/PluginInstaller.php¯
  37. ��¦Mýa¯
  38. ��9òs¤������+���src/Composer/Installer/ProjectInstaller.phpl��¦Mýal��f£ƒ¤������4���src/Composer/Installer/SuggestedPackagesReporter.php ��¦Mýa ��ûM$¤���������src/Composer/Json/JsonFile.phpº��¦Mýaº��Êû¤������#���src/Composer/Json/JsonFormatter.phpl��¦Mýal��)šFç¤������%���src/Composer/Json/JsonManipulator.phpj3��¦Mýaj3��Ùøž¤������-���src/Composer/Json/JsonValidationException.phpo��¦Mýao��T3ÌI¤������%���src/Composer/Package/AliasPackage.phpµ��¦Mýaµ��Zdô[¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php(��¦Mýa(��U?Ø0¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.php��¦Mýa��b¼ï¤������0���src/Composer/Package/Archiver/ArchiveManager.php��¦Mýa��߸dŸ¤������3���src/Composer/Package/Archiver/ArchiverInterface.php��¦Mýa��¨·š“¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.phpÂ��¦MýaÂ��)/ʤ������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php��¦Mýa��‹SZ0¤������2���src/Composer/Package/Archiver/GitExcludeFilter.phpú��¦Mýaú��þkí¤������.���src/Composer/Package/Archiver/PharArchiver.php…��¦Mýa…��µôTL¤������-���src/Composer/Package/Archiver/ZipArchiver.phpà��¦Mýaà��År¬¤������$���src/Composer/Package/BasePackage.phpµ��¦Mýaµ��/î|1¤������*���src/Composer/Package/Comparer/Comparer.phpÅ��¦MýaÅ��×Cݤ������-���src/Composer/Package/CompleteAliasPackage.phpˆ ��¦Mýaˆ ��K�W¤������(���src/Composer/Package/CompletePackage.phpR ��¦MýaR ��µ2®¤������1���src/Composer/Package/CompletePackageInterface.phpÙ��¦MýaÙ��¾Bø$¤������+���src/Composer/Package/Dumper/ArrayDumper.php ��¦Mýa ��ôQ!¤���������src/Composer/Package/Link.phpo��¦Mýao��\¤ @¤������+���src/Composer/Package/Loader/ArrayLoader.php”+��¦Mýa”+��\n»¤������7���src/Composer/Package/Loader/InvalidPackageException.phpV��¦MýaV��D¤¤������*���src/Composer/Package/Loader/JsonLoader.php��¦Mýa��Àµo¤������/���src/Composer/Package/Loader/LoaderInterface.php€��¦Mýa€��Ì&<l¤������1���src/Composer/Package/Loader/RootPackageLoader.php¡��¦Mýa¡��­d`¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.phpžL��¦MýažL��ìÄõU¤���������src/Composer/Package/Locker.phpx%��¦Mýax%�� úÑ4¤������ ���src/Composer/Package/Package.php$"��¦Mýa$"��ÀQ¤������)���src/Composer/Package/PackageInterface.phpã ��¦Mýaã ��ka ¤������)���src/Composer/Package/RootAliasPackage.php* ��¦Mýa* ��‰/�†¤������$���src/Composer/Package/RootPackage.phpC��¦MýaC��•d¥a¤������-���src/Composer/Package/RootPackageInterface.phpí��¦Mýaí�� Hèm¤������0���src/Composer/Package/Version/StabilityFilter.phpï��¦Mýaï��'o£ƒ¤������/���src/Composer/Package/Version/VersionGuesser.phpA%��¦MýaA%��Ñmôá¤������.���src/Composer/Package/Version/VersionParser.php±��¦Mýa±��Kj‚¤������0���src/Composer/Package/Version/VersionSelector.php\��¦Mýa\��¹÷–¤������&���src/Composer/Platform/HhvmDetector.php ��¦Mýa ��ÈL¶¤������!���src/Composer/Platform/Runtime.phpK��¦MýaK��Aä³
  39. ¤������!���src/Composer/Platform/Version.phpÓ��¦MýaÓ��‘„˜�¤������-���src/Composer/Plugin/Capability/Capability.phpW���¦MýaW���æ_¨1¤������2���src/Composer/Plugin/Capability/CommandProvider.php—���¦Mýa—���ûOâ>¤���������src/Composer/Plugin/Capable.php���¦Mýa���Æq+¤������$���src/Composer/Plugin/CommandEvent.phpâ��¦Mýaâ��³ÆÇW¤������$���src/Composer/Plugin/PluginEvents.phpe��¦Mýae��*U~r¤������'���src/Composer/Plugin/PluginInterface.php”��¦Mýa”��æ-Òè¤������%���src/Composer/Plugin/PluginManager.phpTH��¦MýaTH��>=Z¤������-���src/Composer/Plugin/PostFileDownloadEvent.phpT��¦MýaT��/œœ3¤������*���src/Composer/Plugin/PreCommandRunEvent.phpõ��¦Mýaõ��:ðd¤������,���src/Composer/Plugin/PreFileDownloadEvent.php5��¦Mýa5��aÕ0z¤������*���src/Composer/Plugin/PrePoolCreateEvent.phpR��¦MýaR��ÿcµ¤������4���src/Composer/Question/StrictConfirmationQuestion.php>��¦Mýa>��[ºÜ§¤������+���src/Composer/Repository/ArrayRepository.php1��¦Mýa1��tÍ뎤������.���src/Composer/Repository/ArtifactRepository.php ��¦Mýa ��·$&ñ¤������.���src/Composer/Repository/ComposerRepository.php'›��¦Mýa'›��7ÜÚ†¤������/���src/Composer/Repository/CompositeRepository.php¥ ��¦Mýa¥ ��ü­¯¤������;���src/Composer/Repository/ConfigurableRepositoryInterface.phpˆ���¦Mýaˆ���Ùs ¤������0���src/Composer/Repository/FilesystemRepository.php“��¦Mýa“��Â@ñ©¤������,���src/Composer/Repository/FilterRepository.php… ��¦Mýa… ��†ª§œ¤������4���src/Composer/Repository/InstalledArrayRepository.php1��¦Mýa1��]«×¤������9���src/Composer/Repository/InstalledFilesystemRepository.php1��¦Mýa1��y&êͤ������/���src/Composer/Repository/InstalledRepository.php+��¦Mýa+��Òkפ������8���src/Composer/Repository/InstalledRepositoryInterface.phpÇ���¦MýaÇ���-BÏó¤������6���src/Composer/Repository/InvalidRepositoryException.phpn���¦Mýan���à“똤������/���src/Composer/Repository/LockArrayRepository.php¤���¦Mýa¤���E™†S¤������-���src/Composer/Repository/PackageRepository.phpê��¦Mýaê��ü§›8¤������*���src/Composer/Repository/PathRepository.phpd��¦Mýad��Õ]·š¤������*���src/Composer/Repository/PearRepository.phpî���¦Mýaî���‹0‚Ǥ������.���src/Composer/Repository/PlatformRepository.phpÓR��¦MýaÓR��‰×N!¤������-���src/Composer/Repository/RepositoryFactory.phpÀ��¦MýaÀ��1Föe¤������/���src/Composer/Repository/RepositoryInterface.phpS��¦MýaS��š(ÀE¤������-���src/Composer/Repository/RepositoryManager.php ��¦Mýa ��‹¶‘¤������7���src/Composer/Repository/RepositorySecurityException.phpo���¦Mýao���pÕ«ª¤������)���src/Composer/Repository/RepositorySet.phpa��¦Mýaa��Û½rͤ������1���src/Composer/Repository/RootPackageRepository.php@��¦Mýa@��X¦Ž¤������,���src/Composer/Repository/Vcs/FossilDriver.php·��¦Mýa·��1¨Ô¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.php9&��¦Mýa9&��øϤ������)���src/Composer/Repository/Vcs/GitDriver.phpÆ��¦MýaÆ��´c~W¤������,���src/Composer/Repository/Vcs/GitHubDriver.php“5��¦Mýa“5��
  40. „9¤������,���src/Composer/Repository/Vcs/GitLabDriver.php!/��¦Mýa!/���gj¤������(���src/Composer/Repository/Vcs/HgDriver.phpI��¦MýaI��]ǻ֤������.���src/Composer/Repository/Vcs/PerforceDriver.php'
  41. ��¦Mýa'
  42. ��ª}‘w¤������)���src/Composer/Repository/Vcs/SvnDriver.phpÛ��¦MýaÛ���O®�¤������)���src/Composer/Repository/Vcs/VcsDriver.php�
  43. ��¦Mýa�
  44. ��( ¤������2���src/Composer/Repository/Vcs/VcsDriverInterface.phpý��¦Mýaý�� Î¤������)���src/Composer/Repository/VcsRepository.phpû3��¦Mýaû3��%Ëc¤������1���src/Composer/Repository/VersionCacheInterface.php”���¦Mýa”���A?Rï¤������3���src/Composer/Repository/WritableArrayRepository.phpØ��¦MýaØ��wͤ������7���src/Composer/Repository/WritableRepositoryInterface.phpY��¦MýaY��l÷A«¤���������src/Composer/Script/Event.phpš��¦Mýaš��Óô©¤������$���src/Composer/Script/ScriptEvents.phpÜ��¦MýaÜ��ÆíÁ¤������ ���src/Composer/SelfUpdate/Keys.php»��¦Mýa»��Ó¤=¤������$���src/Composer/SelfUpdate/Versions.phpK��¦MýaK��üüç¤������ ���src/Composer/Util/AuthHelper.php!��¦Mýa!��Äþø´¤���������src/Composer/Util/Bitbucket.phpè��¦Mýaè��9´Âå¤������$���src/Composer/Util/ComposerMirror.phpt��¦Mýat��êN`¤������%���src/Composer/Util/ConfigValidator.phpQ��¦MýaQ��—G�¤������"���src/Composer/Util/ErrorHandler.php—��¦Mýa—��îé�i¤������ ���src/Composer/Util/Filesystem.phpæ9��¦Mýaæ9��š=Û5¤���������src/Composer/Util/Git.phpƒ5��¦Mýaƒ5��?¿EÀ¤���������src/Composer/Util/GitHub.php÷��¦Mýa÷��|•B¤���������src/Composer/Util/GitLab.phpœ��¦Mýaœ��£yÜǤ���������src/Composer/Util/Hg.php ��¦Mýa ��~ðîá¤������)���src/Composer/Util/Http/CurlDownloader.phpÆF��¦MýaÆF��9Κ¤������'���src/Composer/Util/Http/CurlResponse.phpg��¦Mýag��·ùÿ§¤������&���src/Composer/Util/Http/ProxyHelper.phpM
  45. ��¦MýaM
  46. ��ÝâM¦¤������'���src/Composer/Util/Http/ProxyManager.php6
  47. ��¦Mýa6
  48. ��ñ›¹ú¤������'���src/Composer/Util/Http/RequestProxy.php��¦Mýa��ÁS°¤������#���src/Composer/Util/Http/Response.php„��¦Mýa„��´GH²¤������$���src/Composer/Util/HttpDownloader.php™(��¦Mýa™(��l8¤���������src/Composer/Util/IniHelper.phph��¦Mýah��;FP¤���������src/Composer/Util/Loop.php¶��¦Mýa¶��Ô·}„¤������&���src/Composer/Util/MetadataMinifier.php*��¦Mýa*��hÛ/~¤������$���src/Composer/Util/NoProxyPattern.phpk��¦Mýak��öÁ>¤������#���src/Composer/Util/PackageSorter.phpÛ��¦MýaÛ��TÆjþ¤���������src/Composer/Util/Perforce.phpm3��¦Mýam3��Ÿ0Ùš¤���������src/Composer/Util/Platform.phpú��¦Mýaú��Yð;¤������%���src/Composer/Util/ProcessExecutor.php<��¦Mýa<��ô?Ï'¤������&���src/Composer/Util/RemoteFilesystem.phprN��¦MýarN��®¼Ãê¤���������src/Composer/Util/Silencer.phpê��¦Mýaê��pDà¤������*���src/Composer/Util/StreamContextFactory.php{��¦Mýa{��ÕZ¤���������src/Composer/Util/Svn.php��¦Mýa��¬×5\¤������ ���src/Composer/Util/SyncHelper.php;��¦Mýa;��*î
  49. ‹¤���������src/Composer/Util/Tar.phpb��¦Mýab��å]–¤���������src/Composer/Util/TlsHelper.phpy
  50. ��¦Mýay
  51. ��+þV¿¤���������src/Composer/Util/Url.php@ ��¦Mýa@ ����¹]¤���������src/Composer/Util/Zip.phpæ��¦Mýaæ��¸+¤���������src/bootstrap.php¼��¦Mýa¼��@’H*¤������%���src/Composer/Autoload/ClassLoader.phpÄ>��¦MýaÄ>��Æ5Ky¤������"���src/Composer/InstalledVersions.php�:��¦Mýa�:��TðÓ"¤������#���res/composer-repository-schema.jsonñ��¦Mýañ��|0à„¤���������res/composer-schema.json…²��¦Mýa…²��³�-¤���������vendor/autoload.php‚���¦Mýa‚���… ¤���������vendor/composer/ClassLoader.php\��¦Mýa\��ÜZuœ¤������%���vendor/composer/InstalledVersions.phpi��¦Mýai��û$Ø.¤������%���vendor/composer/autoload_classmap.phpµ���¦Mýaµ���x’ý»¤������"���vendor/composer/autoload_files.phpŒ��¦MýaŒ��� ¤������'���vendor/composer/autoload_namespaces.php¢���¦Mýa¢����R7c¤������!���vendor/composer/autoload_psr4.php���¦Mýa���ñÌÓ=¤������!���vendor/composer/autoload_real.phph��¦Mýah��ü;Y¤������#���vendor/composer/autoload_static.php° ��¦Mýa° ��FÌi'¤������!���vendor/composer/ca-bundle/LICENSE��¦Mýa��G _¤������(���vendor/composer/ca-bundle/res/cacert.pemÁ,�¦MýaÁ,�½_~ޤ������*���vendor/composer/ca-bundle/src/CaBundle.php•$��¦Mýa•$��ÛnÓ¤���������vendor/composer/installed.php��¦Mýa��&ÏÁV¤������)���vendor/composer/metadata-minifier/LICENSE��¦Mýa��½£ëǤ������:���vendor/composer/metadata-minifier/src/MetadataMinifier.phpÐ��¦MýaÐ��Â0&À¤���������vendor/composer/pcre/LICENSE��¦Mýa��½£ëǤ������+���vendor/composer/pcre/src/MatchAllResult.php��¦Mýa��8aÇ”¤������6���vendor/composer/pcre/src/MatchAllWithOffsetsResult.php&��¦Mýa&��‹ |¤������(���vendor/composer/pcre/src/MatchResult.phpë���¦Mýaë���…‘¤������3���vendor/composer/pcre/src/MatchWithOffsetsResult.phpø���¦Mýaø���<»Ó¤������*���vendor/composer/pcre/src/PcreException.php:��¦Mýa:���}�¤������!���vendor/composer/pcre/src/Preg.php��¦Mýa��VÓib¤������"���vendor/composer/pcre/src/Regex.phpë��¦Mýaë��ÙàýU¤������*���vendor/composer/pcre/src/ReplaceResult.php ��¦Mýa ��Ön0¿¤���������vendor/composer/semver/LICENSE��¦Mýa��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��¦Mýa��^_E“¤������/���vendor/composer/semver/src/CompilingMatcher.phpå��¦Mýaå��»ˆgm¤������/���vendor/composer/semver/src/Constraint/Bound.phpw��¦Mýaw��W4]W¤������4���vendor/composer/semver/src/Constraint/Constraint.phpø��¦Mýaø��’‹ˆ½¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php¡��¦Mýa¡��Ž5´y¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php¯��¦Mýa¯��²Eú¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÉ��¦MýaÉ��֯خ¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.phpŠ��¦MýaŠ��ÍÕĤ������'���vendor/composer/semver/src/Interval.phpæ��¦Mýaæ��=[i¤������(���vendor/composer/semver/src/Intervals.php¤+��¦Mýa¤+��@1º«¤������%���vendor/composer/semver/src/Semver.phpù��¦Mýaù��á-i¤������,���vendor/composer/semver/src/VersionParser.php†,��¦Mýa†,��*eÏó¤������%���vendor/composer/spdx-licenses/LICENSE��¦Mýa��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��¦Mýa¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.json¾��¦Mýa¾��eÇõ̤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.php{��¦Mýa{��ž “¤������&���vendor/composer/xdebug-handler/LICENSE+��¦Mýa+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php\��¦Mýa\��pòAl¤������.���vendor/composer/xdebug-handler/src/Process.phpŒ��¦MýaŒ��6¯`Û¤������-���vendor/composer/xdebug-handler/src/Status.php& ��¦Mýa& ��÷º!¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.phpn*��¦Mýan*��osM¯¤������(���vendor/justinrainbow/json-schema/LICENSE"��¦Mýa"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��¦Mýa¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpƒ
  52. ��¦Mýaƒ
  53. ��ž¸=š¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.phpÁ ��¦MýaÁ ��–PFF¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��¦Mýa¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php\��¦Mýa\��_}ý¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpà ��¦Mýaà ��ë’_”¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps��¦Mýas��d Þ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpƒ ��¦Mýaƒ ��e� ¨¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php·��¦Mýa·��%l¬ö¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php& ��¦Mýa& ��78÷¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.phpz��¦Mýaz��ùfÅ~¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��¦Mýaa�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��¦Mýa—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��¦Mýa‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php��¦Mýa��ª%}¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php,"��¦Mýa,"��‰-¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��¦Mýaè��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���¦MýaI���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���¦Mýa•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���¦Mýal���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���¦Mýal���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���¦Mýau���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���¦Mýaw���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��¦MýaÞ��\¸
  54. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���¦Mýao���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���¦Mýa…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���¦Mýa€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���¦Mýaj���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���¦Mýaf���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��¦Mýaþ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��¦Mýa ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php“ ��¦Mýa“ ��&zß^¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��¦Mýa��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���¦Mýaá���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php£��¦Mýa£��Ç’ô¦¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php ��¦Mýa ��£Á¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��¦Mýa,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���¦Mýa®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��¦Mýa ��æP¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php@��¦Mýa@��5Î3¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���¦Mýaƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���¦Mýa…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phps��¦Mýas��ßÁ‘#¤���������vendor/psr/log/LICENSE?��¦Mýa?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��¦Mýa;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���¦Mýa`��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���¦Mýaû���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���¦Mýa|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���¦Mýa§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��¦MýaÈ��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��¦Mýak��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ���¦MýaŸ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���¦Mýap���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��¦Mýa ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��¦Mýa<��þ(åI¤���������vendor/react/promise/LICENSE'��¦Mýa'��¶-º„¤������F���vendor/react/promise/src/React/Promise/CancellablePromiseInterface.php����¦Mýa���� ƒ<�¤������3���vendor/react/promise/src/React/Promise/Deferred.phpð ��¦Mýað ��o(ퟤ������:���vendor/react/promise/src/React/Promise/DeferredPromise.phpÇ��¦MýaÇ��º`W¤������;���vendor/react/promise/src/React/Promise/DeferredResolver.phpÃ��¦MýaÃ��7Ëu¤������;���vendor/react/promise/src/React/Promise/FulfilledPromise.phpÍ��¦MýaÍ��´–U¤������6���vendor/react/promise/src/React/Promise/LazyPromise.php��¦Mýa��Š»¤������2���vendor/react/promise/src/React/Promise/Promise.php��¦Mýa��º6Jµ¤������;���vendor/react/promise/src/React/Promise/PromiseInterface.phpŸ���¦MýaŸ��� ½¨n¤������<���vendor/react/promise/src/React/Promise/PromisorInterface.php\���¦Mýa\���Wèêà¤������:���vendor/react/promise/src/React/Promise/RejectedPromise.php¾��¦Mýa¾��fC¿¤������<���vendor/react/promise/src/React/Promise/ResolverInterface.php¼���¦Mýa¼���û �O¤������/���vendor/react/promise/src/React/Promise/Util.phpè���¦Mýaè���Ëý$:¤������/���vendor/react/promise/src/React/Promise/When.phpÇ��¦MýaÇ��¤o¤������4���vendor/react/promise/src/React/Promise/functions.phpÐ ��¦MýaÐ ��!³O¤������<���vendor/react/promise/src/React/Promise/functions_include.php\���¦Mýa\���1…‰^¤���������vendor/seld/jsonlint/LICENSE$��¦Mýa$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.phpk��¦Mýak��Zù¶Ã¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php62��¦Mýa62��28ˤ������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php#��¦Mýa#��Úá@,¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php%��¦Mýa%��`a„|¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���¦Mýa>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��¦Mýa$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpi��¦Mýai�� �Þ¤������)���vendor/seld/phar-utils/src/Timestamps.phpÈ ��¦MýaÈ ��ÿ4©¤������&���vendor/symfony/console/Application.php+X��¦Mýa+X��«­yX¤������*���vendor/symfony/console/Command/Command.phpä"��¦Mýaä"���¤Ê¤������.���vendor/symfony/console/Command/HelpCommand.phpØ��¦MýaØ��¦Ú-:¤������.���vendor/symfony/console/Command/ListCommand.phpZ��¦MýaZ��»w`¤������(���vendor/symfony/console/ConsoleEvents.phpé���¦Mýaé���RÛÔe¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÏ��¦MýaÏ��<ŽUî¤������0���vendor/symfony/console/Descriptor/Descriptor.php���¦Mýa���¿N•¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü���¦Mýaü���±Qµ¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ��¦MýaÜ ��*û�ɤ������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶��¦Mýa¶��·Ô;ݤ������4���vendor/symfony/console/Descriptor/TextDescriptor.php·��¦Mýa·��c“q€¤������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��¦Mýa��b{<¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°��¦Mýa°��!�Ȥ������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ��¦MýaÅ��ÒxÛ\¤������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php��¦Mýa��á2é¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz��¦Mýaz��³,îL¤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ��¦MýaÔ��È÷ L¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpf���¦Mýaf���¡ABª¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���¦Mýa¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���¦Mýa¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���¦Mýa’���ÍO\e¤������5���vendor/symfony/console/Exception/RuntimeException.php–���¦Mýa–���Ùí,6¤������4���vendor/symfony/console/Formatter/OutputFormatter.php3��¦Mýa3��àפ������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ��¦MýaŒ��òññÀ¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF��¦MýaF��𦴤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„��¦Mýa„��÷½G¤������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@��¦Mýa@��G¨ýU¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy��¦Mýay��Ì8ÆÐ¤������2���vendor/symfony/console/Helper/DescriptorHelper.phpw��¦Mýaw��|¦C¤������.���vendor/symfony/console/Helper/DialogHelper.phpð��¦Mýað��ÔÈ7¤������1���vendor/symfony/console/Helper/FormatterHelper.phpd��¦Mýad��§×,¸¤������(���vendor/symfony/console/Helper/Helper.php©��¦Mýa©��Õ'ƒ±¤������1���vendor/symfony/console/Helper/HelperInterface.phpå���¦Mýaå���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpÊ��¦MýaÊ��áÏW"¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��¦Mýac��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ��¦MýaÓ ��©w‚R¤������-���vendor/symfony/console/Helper/ProgressBar.phpc%��¦Mýac%��C&w¤������0���vendor/symfony/console/Helper/ProgressHelper.phpY��¦MýaY��R!�/¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpM��¦MýaM��ü�‡¤������0���vendor/symfony/console/Helper/QuestionHelper.php[��¦Mýa[��¯6}ñ¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php•
  55. ��¦Mýa•
  56. ���]~R¤������'���vendor/symfony/console/Helper/Table.php¼*��¦Mýa¼*��fêý!¤������+���vendor/symfony/console/Helper/TableCell.php€��¦Mýa€��‹ƒ[¤������-���vendor/symfony/console/Helper/TableHelper.php ��¦Mýa ��›uô™¤������0���vendor/symfony/console/Helper/TableSeparator.phpÊ���¦MýaÊ���az¤������,���vendor/symfony/console/Helper/TableStyle.php
  57. ��¦Mýa
  58. ��_ÍI"¤������*���vendor/symfony/console/Input/ArgvInput.php��¦Mýa��ªèB-¤������+���vendor/symfony/console/Input/ArrayInput.php) ��¦Mýa) ��¥ÑC¤������&���vendor/symfony/console/Input/Input.php£ ��¦Mýa£ ��f¡?¤������.���vendor/symfony/console/Input/InputArgument.php��¦Mýa��D £¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���¦Mýa˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php†��¦Mýa†��¤U)¤¤������/���vendor/symfony/console/Input/InputInterface.php£��¦Mýa£��ÆBŒ'¤������,���vendor/symfony/console/Input/InputOption.php ��¦Mýa ��\¢Ü=¤������,���vendor/symfony/console/Input/StringInput.php™��¦Mýa™��{Šœþ¤���������vendor/symfony/console/LICENSE+��¦Mýa+��²‹ g¤������/���vendor/symfony/console/Logger/ConsoleLogger.php- ��¦Mýa- ��ghT›¤������0���vendor/symfony/console/Output/BufferedOutput.php_��¦Mýa_��‹ >P¤������/���vendor/symfony/console/Output/ConsoleOutput.php±��¦Mýa±��nì!f¤������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà���¦Mýaà���‡†ÆÊ¤������,���vendor/symfony/console/Output/NullOutput.phpÉ��¦MýaÉ��™0ïf¤������(���vendor/symfony/console/Output/Output.php˜ ��¦Mýa˜ ��0p¤������1���vendor/symfony/console/Output/OutputInterface.php��¦Mýa���ì&¤������.���vendor/symfony/console/Output/StreamOutput.php›��¦Mýa›��.¡îî¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpv
  59. ��¦Mýav
  60. ��‹²WP¤������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè��¦Mýaè��/Ô�¤������,���vendor/symfony/console/Question/Question.phpÎ ��¦MýaÎ ��lF¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��¦Mýa�$��•�¥v¤������ ���vendor/symfony/console/Shell.phpã��¦Mýaã��‰ÁŽå¤������,���vendor/symfony/console/Style/OutputStyle.php\��¦Mýa\��wפ¤������/���vendor/symfony/console/Style/StyleInterface.phpÏ��¦MýaÏ��&nÅѤ������-���vendor/symfony/console/Style/SymfonyStyle.phpÛ��¦MýaÛ��§ðcä¤������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ��¦MýaÏ��sž9i¤������/���vendor/symfony/console/Tester/CommandTester.php¨��¦Mýa¨��<œ•¤������(���vendor/symfony/debug/BufferingLogger.phpt��¦Mýat��=�hܤ���������vendor/symfony/debug/Debug.php+��¦Mýa+��.À=©¤������)���vendor/symfony/debug/DebugClassLoader.php°��¦Mýa°��^æ*ñ¤������%���vendor/symfony/debug/ErrorHandler.phpýG��¦MýaýG��¿zL¤������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–��¦Mýa–��i‰æô¤������8���vendor/symfony/debug/Exception/ContextErrorException.php˜��¦Mýa˜��-
  61. d2¤������1���vendor/symfony/debug/Exception/DummyException.php��¦Mýa��®+Ãê¤������6���vendor/symfony/debug/Exception/FatalErrorException.php ��¦Mýa ��4ç$¤¤������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW��¦MýaW��?àèK¤������3���vendor/symfony/debug/Exception/FlattenException.php»��¦Mýa»��+a&¤������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~���¦Mýa~���ë¨oâ¤������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš��¦Mýaš���ñJÀ¤������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜��¦Mýa˜��nöêØ¤������)���vendor/symfony/debug/ExceptionHandler.php$3��¦Mýa$3��Eë×£¤������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php5��¦Mýa5��ŠÁ*V¤������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php��¦Mýa��ĹBV¤������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx��¦Mýax��~ò"¤������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpN��¦MýaN��'€³ˆ¤���������vendor/symfony/debug/LICENSE+��¦Mýa+��²‹ g¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi���¦Mýai���$ ÿ›¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼��¦Mýa¼��pí\¶¤������3���vendor/symfony/filesystem/Exception/IOException.php‡��¦Mýa‡��€ü#Ѥ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���¦Mýa¦���jÙwM¤������(���vendor/symfony/filesystem/Filesystem.phpM4��¦MýaM4��ãz_¤������!���vendor/symfony/filesystem/LICENSE+��¦Mýa+��²‹ g¤������)���vendor/symfony/filesystem/LockHandler.phpò��¦Mýaò��~3ŸZ¤������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ��¦Mýa\ ��hˆB¤������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.phpƒ��¦Mýaƒ��kM Þ¤������2���vendor/symfony/finder/Adapter/AdapterInterface.php›��¦Mýa›��Mþ¤������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php2��¦Mýa2��ƒ€D)¤������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php��¦Mýa��¦äàO¤������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô��¦Mýaô��Þdè;¤������/���vendor/symfony/finder/Comparator/Comparator.php���¦Mýa���¾üœµ¤������3���vendor/symfony/finder/Comparator/DateComparator.php#��¦Mýa#��°Τ������5���vendor/symfony/finder/Comparator/NumberComparator.php{��¦Mýa{��€ÚùY¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���¦Mýa„���½¾sœ¤������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬��¦Mýa¬��wR¤������6���vendor/symfony/finder/Exception/ExceptionInterface.php„���¦Mýa„���Gz-¤������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)��¦Mýa)��x§e¤������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº��¦Mýaº��˜þ˜¤������/���vendor/symfony/finder/Expression/Expression.php��¦Mýa��i¥:Ť������)���vendor/symfony/finder/Expression/Glob.phpf��¦Mýaf��DÞcj¤������*���vendor/symfony/finder/Expression/Regex.php��¦Mýa��§;M)¤������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ��¦MýaÍ��\p4†¤������ ���vendor/symfony/finder/Finder.phpc.��¦Mýac.��:ˆ5g¤���������vendor/symfony/finder/Glob.phpL��¦MýaL��jÍ9פ������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]��¦Mýa]��ÎoÅÆ¤������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx��¦Mýax��ôP¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî��¦Mýaî��üÍ�q¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí��¦Mýaí��nõH¤������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#��¦Mýa#��G?T½¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ��¦MýaZ��(&ø¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5��¦Mýa5��ší¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr��¦Mýar��tu¤������1���vendor/symfony/finder/Iterator/FilterIterator.phpÂ��¦MýaÂ���㯤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php*��¦Mýa*��Œž�¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ��¦MýaÐ��‚c¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ��¦Mýa ��O}Cä¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe��¦Mýae��Ÿ’áé¤������3���vendor/symfony/finder/Iterator/SortableIterator.php+��¦Mýa+��õÝË ¤���������vendor/symfony/finder/LICENSE+��¦Mýa+��²‹ g¤������'���vendor/symfony/finder/Shell/Command.php> ��¦Mýa> ��_~u ¤������%���vendor/symfony/finder/Shell/Shell.phpq��¦Mýaq��·ÓŠ0¤������%���vendor/symfony/finder/SplFileInfo.php��¦Mýa��þ�íù¤������'���vendor/symfony/polyfill-ctype/Ctype.phpH ��¦MýaH ��³�Õݤ������%���vendor/symfony/polyfill-ctype/LICENSE+��¦Mýa+��…»E:¤������+���vendor/symfony/polyfill-ctype/bootstrap.phpú��¦Mýaú��|p:¤������(���vendor/symfony/polyfill-mbstring/LICENSE+��¦Mýa+��øÛ{¤������-���vendor/symfony/polyfill-mbstring/Mbstring.php~G��¦Mýa~G��úì¡T¤������D���vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8Ë��¦MýaË��Ú�.‚¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷T��¦Mýa÷T��ß2ª?¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��¦Mýaã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpîU��¦MýaîU��`þ8Q¤������.���vendor/symfony/polyfill-mbstring/bootstrap.php��¦Mýa��þJ¾¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpf���¦Mýaf���]ö>T¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���¦Mýa¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���¦Mýa”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��¦Mýax��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php��¦Mýa��﫤������5���vendor/symfony/process/Exception/RuntimeException.php˜���¦Mýa˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.phpœ��¦Mýaœ��çÁ̤���������vendor/symfony/process/LICENSE+��¦Mýa+��²‹ g¤������.���vendor/symfony/process/PhpExecutableFinder.phpÍ��¦MýaÍ��í0ã¤������%���vendor/symfony/process/PhpProcess.phpù��¦Mýaù��c¶ßĤ������.���vendor/symfony/process/Pipes/AbstractPipes.php¸��¦Mýa¸��xÓ,§¤������/���vendor/symfony/process/Pipes/PipesInterface.phpD��¦MýaD��vØî¡¤������*���vendor/symfony/process/Pipes/UnixPipes.php7��¦Mýa7��bÜp„¤������-���vendor/symfony/process/Pipes/WindowsPipes.phpi ��¦Mýai ��Ó
  62.  Ä¤������"���vendor/symfony/process/Process.php R��¦Mýa R��×Ó¥¹¤������)���vendor/symfony/process/ProcessBuilder.phpá
  63. ��¦Mýaá
  64. ��ñ6I•¤������'���vendor/symfony/process/ProcessUtils.phpJ��¦MýaJ��{ñC¤������ ���bin/composerx
  65. ��¦Mýax
  66. ��µä—~¤���������LICENSE.��¦Mýa.�� Õ¤������<?php
  67. namespace Composer\Autoload;
  68. use Composer\Config;
  69. use Composer\EventDispatcher\EventDispatcher;
  70. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  71. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  72. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  73. use Composer\Installer\InstallationManager;
  74. use Composer\IO\IOInterface;
  75. use Composer\Package\AliasPackage;
  76. use Composer\Package\PackageInterface;
  77. use Composer\Package\RootPackageInterface;
  78. use Composer\Pcre\Preg;
  79. use Composer\Repository\InstalledRepositoryInterface;
  80. use Composer\Semver\Constraint\Bound;
  81. use Composer\Util\Filesystem;
  82. use Composer\Util\Platform;
  83. use Composer\Script\ScriptEvents;
  84. use Composer\Util\PackageSorter;
  85. use Composer\Json\JsonFile;
  86. class AutoloadGenerator
  87. {
  88. private $eventDispatcher;
  89. private $io;
  90. private $devMode = null;
  91. private $classMapAuthoritative = false;
  92. private $apcu = false;
  93. private $apcuPrefix;
  94. private $runScripts = false;
  95. private $platformRequirementFilter;
  96. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  97. {
  98. $this->eventDispatcher = $eventDispatcher;
  99. $this->io = $io;
  100. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  101. }
  102. public function setDevMode($devMode = true)
  103. {
  104. $this->devMode = (bool) $devMode;
  105. }
  106. public function setClassMapAuthoritative($classMapAuthoritative)
  107. {
  108. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  109. }
  110. public function setApcu($apcu, $apcuPrefix = null)
  111. {
  112. $this->apcu = (bool) $apcu;
  113. $this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
  114. }
  115. public function setRunScripts($runScripts = true)
  116. {
  117. $this->runScripts = (bool) $runScripts;
  118. }
  119. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  120. {
  121. trigger_error('AutoloadGenerator::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  122. $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  123. }
  124. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter)
  125. {
  126. $this->platformRequirementFilter = $platformRequirementFilter;
  127. }
  128. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
  129. {
  130. if ($this->classMapAuthoritative) {
  131. $scanPsrPackages = true;
  132. }
  133. if (null === $this->devMode) {
  134. $this->devMode = false;
  135. $installedJson = new JsonFile($config->get('vendor-dir').'/composer/installed.json');
  136. if ($installedJson->exists()) {
  137. $installedJson = $installedJson->read();
  138. if (isset($installedJson['dev'])) {
  139. $this->devMode = $installedJson['dev'];
  140. }
  141. }
  142. }
  143. if ($this->runScripts) {
  144. if (!isset($_SERVER['COMPOSER_DEV_MODE'])) {
  145. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  146. }
  147. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  148. 'optimize' => (bool) $scanPsrPackages,
  149. ));
  150. }
  151. $filesystem = new Filesystem();
  152. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  153. $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
  154. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  155. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  156. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  157. $targetDir = $vendorPath.'/'.$targetDir;
  158. $filesystem->ensureDirectoryExists($targetDir);
  159. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  160. $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
  161. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  162. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  163. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  164. $namespacesFile = <<<EOF
  165. <?php
  166. // autoload_namespaces.php @generated by Composer
  167. \$vendorDir = $vendorPathCode52;
  168. \$baseDir = $appBaseDirCode;
  169. return array(
  170. EOF;
  171. $psr4File = <<<EOF
  172. <?php
  173. // autoload_psr4.php @generated by Composer
  174. \$vendorDir = $vendorPathCode52;
  175. \$baseDir = $appBaseDirCode;
  176. return array(
  177. EOF;
  178. $devPackageNames = $localRepo->getDevPackageNames();
  179. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  180. if ($this->devMode) {
  181. $filteredDevPackages = false;
  182. } else {
  183. $filteredDevPackages = $devPackageNames ?: true;
  184. }
  185. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  186. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  187. $exportedPaths = array();
  188. foreach ($paths as $path) {
  189. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  190. }
  191. $exportedPrefix = var_export($namespace, true);
  192. $namespacesFile .= " $exportedPrefix => ";
  193. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  194. }
  195. $namespacesFile .= ");\n";
  196. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  197. $exportedPaths = array();
  198. foreach ($paths as $path) {
  199. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  200. }
  201. $exportedPrefix = var_export($namespace, true);
  202. $psr4File .= " $exportedPrefix => ";
  203. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  204. }
  205. $psr4File .= ");\n";
  206. $classmapFile = <<<EOF
  207. <?php
  208. // autoload_classmap.php @generated by Composer
  209. \$vendorDir = $vendorPathCode52;
  210. \$baseDir = $appBaseDirCode;
  211. return array(
  212. EOF;
  213. $targetDirLoader = null;
  214. $mainAutoload = $rootPackage->getAutoload();
  215. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  216. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  217. $prefixes = implode(', ', array_map(function ($prefix) {
  218. return var_export($prefix, true);
  219. }, array_keys($mainAutoload['psr-0'])));
  220. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  221. $targetDirLoader = <<<EOF
  222. public static function autoload(\$class)
  223. {
  224. \$dir = $baseDirFromTargetDirCode . '/';
  225. \$prefixes = array($prefixes);
  226. foreach (\$prefixes as \$prefix) {
  227. if (0 !== strpos(\$class, \$prefix)) {
  228. continue;
  229. }
  230. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  231. if (!\$path = stream_resolve_include_path(\$path)) {
  232. return false;
  233. }
  234. require \$path;
  235. return true;
  236. }
  237. }
  238. EOF;
  239. }
  240. $excluded = null;
  241. if (!empty($autoloads['exclude-from-classmap'])) {
  242. $excluded = $autoloads['exclude-from-classmap'];
  243. }
  244. $classMap = array();
  245. $ambiguousClasses = array();
  246. $scannedFiles = array();
  247. foreach ($autoloads['classmap'] as $dir) {
  248. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, null, null, $classMap, $ambiguousClasses, $scannedFiles);
  249. }
  250. if ($scanPsrPackages) {
  251. $namespacesToScan = array();
  252. foreach (array('psr-4', 'psr-0') as $psrType) {
  253. foreach ($autoloads[$psrType] as $namespace => $paths) {
  254. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  255. }
  256. }
  257. krsort($namespacesToScan);
  258. foreach ($namespacesToScan as $namespace => $groups) {
  259. foreach ($groups as $group) {
  260. foreach ($group['paths'] as $dir) {
  261. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  262. if (!is_dir($dir)) {
  263. continue;
  264. }
  265. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespace, $group['type'], $classMap, $ambiguousClasses, $scannedFiles);
  266. }
  267. }
  268. }
  269. }
  270. foreach ($ambiguousClasses as $className => $ambiguousPaths) {
  271. $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);
  272. $this->io->writeError(
  273. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  274. ' was found '. (count($ambiguousPaths) + 1) .'x: in "'.$cleanPath.'" and "'. implode('", "', $ambiguousPaths) .'", the first will be used.</warning>'
  275. );
  276. }
  277. $classMap['Composer\\InstalledVersions'] = "\$vendorDir . '/composer/InstalledVersions.php',\n";
  278. ksort($classMap);
  279. foreach ($classMap as $class => $code) {
  280. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  281. }
  282. $classmapFile .= ");\n";
  283. if (!$suffix) {
  284. if (!$config->get('autoloader-suffix') && Filesystem::isReadable($vendorPath.'/autoload.php')) {
  285. $content = file_get_contents($vendorPath.'/autoload.php');
  286. if (Preg::isMatch('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  287. $suffix = $match[1];
  288. }
  289. }
  290. if (!$suffix) {
  291. $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
  292. }
  293. }
  294. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  295. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  296. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  297. $includePathFilePath = $targetDir.'/include_paths.php';
  298. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  299. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  300. } elseif (file_exists($includePathFilePath)) {
  301. unlink($includePathFilePath);
  302. }
  303. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  304. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  305. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  306. } elseif (file_exists($includeFilesFilePath)) {
  307. unlink($includeFilesFilePath);
  308. }
  309. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
  310. $checkPlatform = $config->get('platform-check') && !($this->platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter);
  311. $platformCheckContent = null;
  312. if ($checkPlatform) {
  313. $platformCheckContent = $this->getPlatformCheck($packageMap, $config->get('platform-check'), $devPackageNames);
  314. if (null === $platformCheckContent) {
  315. $checkPlatform = false;
  316. }
  317. }
  318. if ($checkPlatform) {
  319. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  320. } elseif (file_exists($targetDir.'/platform_check.php')) {
  321. unlink($targetDir.'/platform_check.php');
  322. }
  323. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  324. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
  325. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  326. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  327. if ($this->runScripts) {
  328. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  329. 'optimize' => (bool) $scanPsrPackages,
  330. ));
  331. }
  332. return count($classMap);
  333. }
  334. private function addClassMapCode(Filesystem $filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles)
  335. {
  336. foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
  337. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  338. if (!isset($classMap[$class])) {
  339. $classMap[$class] = $pathCode;
  340. } elseif ($this->io && $classMap[$class] !== $pathCode && !Preg::isMatch('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  341. $ambiguousClasses[$class][] = $path;
  342. }
  343. }
  344. return $classMap;
  345. }
  346. private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles)
  347. {
  348. if ($excluded) {
  349. if (file_exists($dir)) {
  350. $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));
  351. foreach ($excluded as $index => $pattern) {
  352. $pattern = Preg::replace('{^(([^.+*?\[^\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\[^\]$(){}=!<>|:#-])*).*}', '$1', $pattern);
  353. if (0 !== strpos($pattern, $dirMatch) && 0 !== strpos($dirMatch, $pattern)) {
  354. unset($excluded[$index]);
  355. }
  356. }
  357. }
  358. $excluded = $excluded ? '{(' . implode('|', $excluded) . ')}' : null;
  359. }
  360. return ClassMapGenerator::createMap($dir, $excluded, $showAmbiguousWarning ? $this->io : null, $namespaceFilter, $autoloadType, $scannedFiles);
  361. }
  362. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  363. {
  364. $packageMap = array(array($rootPackage, ''));
  365. foreach ($packages as $package) {
  366. if ($package instanceof AliasPackage) {
  367. continue;
  368. }
  369. $this->validatePackage($package);
  370. $packageMap[] = array(
  371. $package,
  372. $installationManager->getInstallPath($package),
  373. );
  374. }
  375. return $packageMap;
  376. }
  377. protected function validatePackage(PackageInterface $package)
  378. {
  379. $autoload = $package->getAutoload();
  380. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  381. $name = $package->getName();
  382. $package->getTargetDir();
  383. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  384. }
  385. if (!empty($autoload['psr-4'])) {
  386. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  387. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  388. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  389. }
  390. }
  391. }
  392. }
  393. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  394. {
  395. $rootPackageMap = array_shift($packageMap);
  396. if (is_array($filteredDevPackages)) {
  397. $packageMap = array_filter($packageMap, function ($item) use ($filteredDevPackages) {
  398. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  399. });
  400. } elseif ($filteredDevPackages) {
  401. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  402. }
  403. $sortedPackageMap = $this->sortPackageMap($packageMap);
  404. $sortedPackageMap[] = $rootPackageMap;
  405. array_unshift($packageMap, $rootPackageMap);
  406. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $rootPackage);
  407. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $rootPackage);
  408. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $rootPackage);
  409. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  410. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  411. krsort($psr0);
  412. krsort($psr4);
  413. return array(
  414. 'psr-0' => $psr0,
  415. 'psr-4' => $psr4,
  416. 'classmap' => $classmap,
  417. 'files' => $files,
  418. 'exclude-from-classmap' => $exclude,
  419. );
  420. }
  421. public function createLoader(array $autoloads, $vendorDir = null)
  422. {
  423. $loader = new ClassLoader($vendorDir);
  424. if (isset($autoloads['psr-0'])) {
  425. foreach ($autoloads['psr-0'] as $namespace => $path) {
  426. $loader->add($namespace, $path);
  427. }
  428. }
  429. if (isset($autoloads['psr-4'])) {
  430. foreach ($autoloads['psr-4'] as $namespace => $path) {
  431. $loader->addPsr4($namespace, $path);
  432. }
  433. }
  434. if (isset($autoloads['classmap'])) {
  435. $excluded = null;
  436. if (!empty($autoloads['exclude-from-classmap'])) {
  437. $excluded = $autoloads['exclude-from-classmap'];
  438. }
  439. $scannedFiles = array();
  440. foreach ($autoloads['classmap'] as $dir) {
  441. try {
  442. $loader->addClassMap($this->generateClassMap($dir, $excluded, null, null, false, $scannedFiles));
  443. } catch (\RuntimeException $e) {
  444. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  445. }
  446. }
  447. }
  448. return $loader;
  449. }
  450. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  451. {
  452. $includePaths = array();
  453. foreach ($packageMap as $item) {
  454. list($package, $installPath) = $item;
  455. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  456. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  457. }
  458. foreach ($package->getIncludePaths() as $includePath) {
  459. $includePath = trim($includePath, '/');
  460. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  461. }
  462. }
  463. if (!$includePaths) {
  464. return null;
  465. }
  466. $includePathsCode = '';
  467. foreach ($includePaths as $path) {
  468. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  469. }
  470. return <<<EOF
  471. <?php
  472. // include_paths.php @generated by Composer
  473. \$vendorDir = $vendorPathCode;
  474. \$baseDir = $appBaseDirCode;
  475. return array(
  476. $includePathsCode);
  477. EOF;
  478. }
  479. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  480. {
  481. $filesCode = '';
  482. foreach ($files as $fileIdentifier => $functionFile) {
  483. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  484. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  485. }
  486. if (!$filesCode) {
  487. return null;
  488. }
  489. return <<<EOF
  490. <?php
  491. // autoload_files.php @generated by Composer
  492. \$vendorDir = $vendorPathCode;
  493. \$baseDir = $appBaseDirCode;
  494. return array(
  495. $filesCode);
  496. EOF;
  497. }
  498. protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
  499. {
  500. if (!$filesystem->isAbsolutePath($path)) {
  501. $path = $basePath . '/' . $path;
  502. }
  503. $path = $filesystem->normalizePath($path);
  504. $baseDir = '';
  505. if (strpos($path.'/', $vendorPath.'/') === 0) {
  506. $path = substr($path, strlen($vendorPath));
  507. $baseDir = '$vendorDir';
  508. if ($path !== false) {
  509. $baseDir .= " . ";
  510. }
  511. } else {
  512. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  513. if (!$filesystem->isAbsolutePath($path)) {
  514. $baseDir = '$baseDir . ';
  515. $path = '/' . $path;
  516. }
  517. }
  518. if (strpos($path, '.phar') !== false) {
  519. $baseDir = "'phar://' . " . $baseDir;
  520. }
  521. return $baseDir . var_export($path, true);
  522. }
  523. protected function getPlatformCheck(array $packageMap, $checkPlatform, array $devPackageNames)
  524. {
  525. $lowestPhpVersion = Bound::zero();
  526. $requiredExtensions = array();
  527. $extensionProviders = array();
  528. foreach ($packageMap as $item) {
  529. $package = $item[0];
  530. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  531. if (Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  532. $extensionProviders[$match[1]][] = $link->getConstraint();
  533. }
  534. }
  535. }
  536. foreach ($packageMap as $item) {
  537. $package = $item[0];
  538. if (in_array($package->getName(), $devPackageNames, true)) {
  539. continue;
  540. }
  541. foreach ($package->getRequires() as $link) {
  542. if ($this->platformRequirementFilter->isIgnored($link->getTarget())) {
  543. continue;
  544. }
  545. if ('php' === $link->getTarget()) {
  546. $constraint = $link->getConstraint();
  547. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  548. $lowestPhpVersion = $constraint->getLowerBound();
  549. }
  550. }
  551. if ($checkPlatform === true && Preg::isMatch('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  552. if (isset($extensionProviders[$match[1]])) {
  553. foreach ($extensionProviders[$match[1]] as $provided) {
  554. if ($provided->matches($link->getConstraint())) {
  555. continue 2;
  556. }
  557. }
  558. }
  559. if ($match[1] === 'zend-opcache') {
  560. $match[1] = 'zend opcache';
  561. }
  562. $extension = var_export($match[1], true);
  563. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  564. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  565. } else {
  566. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  567. }
  568. }
  569. }
  570. }
  571. ksort($requiredExtensions);
  572. $formatToPhpVersionId = function (Bound $bound) {
  573. if ($bound->isZero()) {
  574. return 0;
  575. }
  576. if ($bound->isPositiveInfinity()) {
  577. return 99999;
  578. }
  579. $version = str_replace('-', '.', $bound->getVersion());
  580. $chunks = array_map('intval', explode('.', $version));
  581. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  582. };
  583. $formatToHumanReadable = function (Bound $bound) {
  584. if ($bound->isZero()) {
  585. return 0;
  586. }
  587. if ($bound->isPositiveInfinity()) {
  588. return 99999;
  589. }
  590. $version = str_replace('-', '.', $bound->getVersion());
  591. $chunks = explode('.', $version);
  592. $chunks = array_slice($chunks, 0, 3);
  593. return implode('.', $chunks);
  594. };
  595. $requiredPhp = '';
  596. $requiredPhpError = '';
  597. if (!$lowestPhpVersion->isZero()) {
  598. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  599. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  600. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  601. }
  602. if ($requiredPhp) {
  603. $requiredPhp = <<<PHP_CHECK
  604. if (!($requiredPhp)) {
  605. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  606. }
  607. PHP_CHECK;
  608. }
  609. $requiredExtensions = implode('', $requiredExtensions);
  610. if ('' !== $requiredExtensions) {
  611. $requiredExtensions = <<<EXT_CHECKS
  612. \$missingExtensions = array();
  613. $requiredExtensions
  614. if (\$missingExtensions) {
  615. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  616. }
  617. EXT_CHECKS;
  618. }
  619. if (!$requiredPhp && !$requiredExtensions) {
  620. return null;
  621. }
  622. return <<<PLATFORM_CHECK
  623. <?php
  624. // platform_check.php @generated by Composer
  625. \$issues = array();
  626. ${requiredPhp}${requiredExtensions}
  627. if (\$issues) {
  628. if (!headers_sent()) {
  629. header('HTTP/1.1 500 Internal Server Error');
  630. }
  631. if (!ini_get('display_errors')) {
  632. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  633. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  634. } elseif (!headers_sent()) {
  635. echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, \$issues)) . PHP_EOL.PHP_EOL;
  636. }
  637. }
  638. trigger_error(
  639. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  640. E_USER_ERROR
  641. );
  642. }
  643. PLATFORM_CHECK;
  644. }
  645. protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
  646. {
  647. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  648. if ("'" === $lastChar || '"' === $lastChar) {
  649. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  650. } else {
  651. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  652. }
  653. return <<<AUTOLOAD
  654. <?php
  655. // autoload.php @generated by Composer
  656. require_once $vendorPathToTargetDirCode;
  657. return ComposerAutoloaderInit$suffix::getLoader();
  658. AUTOLOAD;
  659. }
  660. protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)
  661. {
  662. $file = <<<HEADER
  663. <?php
  664. // autoload_real.php @generated by Composer
  665. class ComposerAutoloaderInit$suffix
  666. {
  667. private static \$loader;
  668. public static function loadClassLoader(\$class)
  669. {
  670. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  671. require __DIR__ . '/ClassLoader.php';
  672. }
  673. }
  674. /**
  675. * @return \Composer\Autoload\ClassLoader
  676. */
  677. public static function getLoader()
  678. {
  679. if (null !== self::\$loader) {
  680. return self::\$loader;
  681. }
  682. HEADER;
  683. if ($checkPlatform) {
  684. $file .= <<<'PLATFORM_CHECK'
  685. require __DIR__ . '/platform_check.php';
  686. PLATFORM_CHECK;
  687. }
  688. $file .= <<<CLASSLOADER_INIT
  689. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  690. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(\\dirname(__FILE__)));
  691. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  692. CLASSLOADER_INIT;
  693. if ($useIncludePath) {
  694. $file .= <<<'INCLUDE_PATH'
  695. $includePaths = require __DIR__ . '/include_paths.php';
  696. $includePaths[] = get_include_path();
  697. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  698. INCLUDE_PATH;
  699. }
  700. $file .= <<<STATIC_INIT
  701. \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  702. if (\$useStaticLoader) {
  703. require __DIR__ . '/autoload_static.php';
  704. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  705. } else {
  706. STATIC_INIT;
  707. if (!$this->classMapAuthoritative) {
  708. $file .= <<<'PSR04'
  709. $map = require __DIR__ . '/autoload_namespaces.php';
  710. foreach ($map as $namespace => $path) {
  711. $loader->set($namespace, $path);
  712. }
  713. $map = require __DIR__ . '/autoload_psr4.php';
  714. foreach ($map as $namespace => $path) {
  715. $loader->setPsr4($namespace, $path);
  716. }
  717. PSR04;
  718. }
  719. if ($useClassMap) {
  720. $file .= <<<'CLASSMAP'
  721. $classMap = require __DIR__ . '/autoload_classmap.php';
  722. if ($classMap) {
  723. $loader->addClassMap($classMap);
  724. }
  725. CLASSMAP;
  726. }
  727. $file .= " }\n\n";
  728. if ($this->classMapAuthoritative) {
  729. $file .= <<<'CLASSMAPAUTHORITATIVE'
  730. $loader->setClassMapAuthoritative(true);
  731. CLASSMAPAUTHORITATIVE;
  732. }
  733. if ($this->apcu) {
  734. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  735. $file .= <<<APCU
  736. \$loader->setApcuPrefix($apcuPrefix);
  737. APCU;
  738. }
  739. if ($useGlobalIncludePath) {
  740. $file .= <<<'INCLUDEPATH'
  741. $loader->setUseIncludePath(true);
  742. INCLUDEPATH;
  743. }
  744. if ($targetDirLoader) {
  745. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  746. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  747. REGISTER_TARGET_DIR_AUTOLOAD;
  748. }
  749. $file .= <<<REGISTER_LOADER
  750. \$loader->register($prependAutoloader);
  751. REGISTER_LOADER;
  752. if ($useIncludeFiles) {
  753. $file .= <<<INCLUDE_FILES
  754. if (\$useStaticLoader) {
  755. \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
  756. } else {
  757. \$includeFiles = require __DIR__ . '/autoload_files.php';
  758. }
  759. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  760. composerRequire$suffix(\$fileIdentifier, \$file);
  761. }
  762. INCLUDE_FILES;
  763. }
  764. $file .= <<<METHOD_FOOTER
  765. return \$loader;
  766. }
  767. METHOD_FOOTER;
  768. $file .= $targetDirLoader;
  769. if ($useIncludeFiles) {
  770. return $file . <<<FOOTER
  771. }
  772. /**
  773. * @param string \$fileIdentifier
  774. * @param string \$file
  775. * @return void
  776. */
  777. function composerRequire$suffix(\$fileIdentifier, \$file)
  778. {
  779. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  780. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  781. require \$file;
  782. }
  783. }
  784. FOOTER;
  785. }
  786. return $file . <<<FOOTER
  787. }
  788. FOOTER;
  789. }
  790. protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
  791. {
  792. $staticPhpVersion = 50600;
  793. $file = <<<HEADER
  794. <?php
  795. // autoload_static.php @generated by Composer
  796. namespace Composer\Autoload;
  797. class ComposerStaticInit$suffix
  798. {
  799. HEADER;
  800. $loader = new ClassLoader();
  801. $map = require $targetDir . '/autoload_namespaces.php';
  802. foreach ($map as $namespace => $path) {
  803. $loader->set($namespace, $path);
  804. }
  805. $map = require $targetDir . '/autoload_psr4.php';
  806. foreach ($map as $namespace => $path) {
  807. $loader->setPsr4($namespace, $path);
  808. }
  809. $classMap = require $targetDir . '/autoload_classmap.php';
  810. if ($classMap) {
  811. $loader->addClassMap($classMap);
  812. }
  813. $filesystem = new Filesystem();
  814. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  815. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  816. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  817. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  818. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  819. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  820. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  821. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  822. $initializer = '';
  823. $prefix = "\0Composer\Autoload\ClassLoader\0";
  824. $prefixLen = strlen($prefix);
  825. if (file_exists($targetDir . '/autoload_files.php')) {
  826. $maps = array('files' => require $targetDir . '/autoload_files.php');
  827. } else {
  828. $maps = array();
  829. }
  830. foreach ((array) $loader as $prop => $value) {
  831. if ($value && 0 === strpos($prop, $prefix)) {
  832. $maps[substr($prop, $prefixLen)] = $value;
  833. }
  834. }
  835. foreach ($maps as $prop => $value) {
  836. if (count($value) > 32767) {
  837. $staticPhpVersion = 70000;
  838. }
  839. $value = strtr(
  840. var_export($value, true),
  841. array(
  842. $absoluteVendorPathCode => $vendorPathCode,
  843. $absoluteVendorPharPathCode => $vendorPharPathCode,
  844. $absoluteAppBaseDirCode => $appBaseDirCode,
  845. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  846. )
  847. );
  848. $value = ltrim(Preg::replace('/^ */m', ' $0$0', $value));
  849. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  850. if ('files' !== $prop) {
  851. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  852. }
  853. }
  854. return $file . <<<INITIALIZER
  855. public static function getInitializer(ClassLoader \$loader)
  856. {
  857. return \Closure::bind(function () use (\$loader) {
  858. $initializer
  859. }, null, ClassLoader::class);
  860. }
  861. }
  862. INITIALIZER;
  863. }
  864. protected function parseAutoloadsType(array $packageMap, $type, RootPackageInterface $rootPackage)
  865. {
  866. $autoloads = array();
  867. foreach ($packageMap as $item) {
  868. list($package, $installPath) = $item;
  869. $autoload = $package->getAutoload();
  870. if ($this->devMode && $package === $rootPackage) {
  871. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  872. }
  873. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  874. continue;
  875. }
  876. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  877. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  878. }
  879. foreach ($autoload[$type] as $namespace => $paths) {
  880. foreach ((array) $paths as $path) {
  881. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !Filesystem::isReadable($installPath.'/'.$path)) {
  882. if ($package === $rootPackage) {
  883. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  884. $path = ltrim(Preg::replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  885. } else {
  886. $path = $package->getTargetDir() . '/' . $path;
  887. }
  888. }
  889. if ($type === 'exclude-from-classmap') {
  890. $path = Preg::replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  891. $path = strtr($path, array('\\*\\*' => '.+?', '\\*' => '[^/]+?'));
  892. $updir = null;
  893. $path = Preg::replaceCallback(
  894. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  895. function ($matches) use (&$updir) {
  896. if (isset($matches[1])) {
  897. $updir = str_replace('\\.', '.', $matches[1]);
  898. }
  899. return '';
  900. },
  901. $path
  902. );
  903. if (empty($installPath)) {
  904. $installPath = strtr(getcwd(), '\\', '/');
  905. }
  906. $resolvedPath = realpath($installPath . '/' . $updir);
  907. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  908. continue;
  909. }
  910. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  911. if ($type === 'files') {
  912. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  913. continue;
  914. }
  915. if ($type === 'classmap') {
  916. $autoloads[] = $relativePath;
  917. continue;
  918. }
  919. $autoloads[$namespace][] = $relativePath;
  920. }
  921. }
  922. }
  923. return $autoloads;
  924. }
  925. protected function getFileIdentifier(PackageInterface $package, $path)
  926. {
  927. return md5($package->getName() . ':' . $path);
  928. }
  929. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  930. {
  931. $packages = array();
  932. $include = array();
  933. $replacedBy = array();
  934. foreach ($packageMap as $item) {
  935. $package = $item[0];
  936. $name = $package->getName();
  937. $packages[$name] = $package;
  938. foreach ($package->getReplaces() as $replace) {
  939. $replacedBy[$replace->getTarget()] = $name;
  940. }
  941. }
  942. $add = function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy) {
  943. foreach ($package->getRequires() as $link) {
  944. $target = $link->getTarget();
  945. if (isset($replacedBy[$target])) {
  946. $target = $replacedBy[$target];
  947. }
  948. if (!isset($include[$target])) {
  949. $include[$target] = true;
  950. if (isset($packages[$target])) {
  951. $add($packages[$target]);
  952. }
  953. }
  954. }
  955. };
  956. $add($rootPackage);
  957. return array_filter(
  958. $packageMap,
  959. function ($item) use ($include) {
  960. $package = $item[0];
  961. foreach ($package->getNames() as $name) {
  962. if (isset($include[$name])) {
  963. return true;
  964. }
  965. }
  966. return false;
  967. }
  968. );
  969. }
  970. protected function sortPackageMap(array $packageMap)
  971. {
  972. $packages = array();
  973. $paths = array();
  974. foreach ($packageMap as $item) {
  975. list($package, $path) = $item;
  976. $name = $package->getName();
  977. $packages[$name] = $package;
  978. $paths[$name] = $path;
  979. }
  980. $sortedPackages = PackageSorter::sortPackages($packages);
  981. $sortedPackageMap = array();
  982. foreach ($sortedPackages as $package) {
  983. $name = $package->getName();
  984. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  985. }
  986. return $sortedPackageMap;
  987. }
  988. }
  989. function composerRequire($fileIdentifier, $file)
  990. {
  991. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  992. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  993. require $file;
  994. }
  995. }
  996. <?php
  997. namespace Composer\Autoload;
  998. use Composer\Pcre\Preg;
  999. use Symfony\Component\Finder\Finder;
  1000. use Composer\IO\IOInterface;
  1001. use Composer\Util\Filesystem;
  1002. class ClassMapGenerator
  1003. {
  1004. public static function dump($dirs, $file)
  1005. {
  1006. $maps = array();
  1007. foreach ($dirs as $dir) {
  1008. $maps = array_merge($maps, static::createMap($dir));
  1009. }
  1010. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  1011. }
  1012. public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
  1013. {
  1014. $basePath = $path;
  1015. if (is_string($path)) {
  1016. if (is_file($path)) {
  1017. $path = array(new \SplFileInfo($path));
  1018. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  1019. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  1020. } else {
  1021. throw new \RuntimeException(
  1022. 'Could not scan for classes inside "'.$path.
  1023. '" which does not appear to be a file nor a folder'
  1024. );
  1025. }
  1026. } elseif (null !== $autoloadType) {
  1027. throw new \RuntimeException('Path must be a string when specifying an autoload type');
  1028. }
  1029. $map = array();
  1030. $filesystem = new Filesystem();
  1031. $cwd = realpath(getcwd());
  1032. foreach ($path as $file) {
  1033. $filePath = $file->getPathname();
  1034. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  1035. continue;
  1036. }
  1037. if (!$filesystem->isAbsolutePath($filePath)) {
  1038. $filePath = $cwd . '/' . $filePath;
  1039. $filePath = $filesystem->normalizePath($filePath);
  1040. } else {
  1041. $filePath = Preg::replace('{[\\\\/]{2,}}', '/', $filePath);
  1042. }
  1043. $realPath = realpath($filePath);
  1044. if (isset($scannedFiles[$realPath])) {
  1045. continue;
  1046. }
  1047. if ($excluded && Preg::isMatch($excluded, strtr($realPath, '\\', '/'))) {
  1048. continue;
  1049. }
  1050. if ($excluded && Preg::isMatch($excluded, strtr($filePath, '\\', '/'))) {
  1051. continue;
  1052. }
  1053. $classes = self::findClasses($filePath);
  1054. if (null !== $autoloadType) {
  1055. $classes = self::filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath, $io);
  1056. if ($classes) {
  1057. $scannedFiles[$realPath] = true;
  1058. }
  1059. } else {
  1060. $scannedFiles[$realPath] = true;
  1061. }
  1062. foreach ($classes as $class) {
  1063. if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
  1064. continue;
  1065. }
  1066. if (!isset($map[$class])) {
  1067. $map[$class] = $filePath;
  1068. } elseif ($io && $map[$class] !== $filePath && !Preg::isMatch('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  1069. $io->writeError(
  1070. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1071. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  1072. );
  1073. }
  1074. }
  1075. }
  1076. return $map;
  1077. }
  1078. private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io)
  1079. {
  1080. $validClasses = array();
  1081. $rejectedClasses = array();
  1082. $realSubPath = substr($filePath, strlen($basePath) + 1);
  1083. $realSubPath = substr($realSubPath, 0, strrpos($realSubPath, '.'));
  1084. foreach ($classes as $class) {
  1085. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  1086. continue;
  1087. }
  1088. if ('psr-0' === $namespaceType) {
  1089. $namespaceLength = strrpos($class, '\\');
  1090. if (false !== $namespaceLength) {
  1091. $namespace = substr($class, 0, $namespaceLength + 1);
  1092. $className = substr($class, $namespaceLength + 1);
  1093. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  1094. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  1095. } else {
  1096. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  1097. }
  1098. } elseif ('psr-4' === $namespaceType) {
  1099. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  1100. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  1101. } else {
  1102. throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");
  1103. }
  1104. if ($subPath === $realSubPath) {
  1105. $validClasses[] = $class;
  1106. } else {
  1107. $rejectedClasses[] = $class;
  1108. }
  1109. }
  1110. if (empty($validClasses)) {
  1111. foreach ($rejectedClasses as $class) {
  1112. if ($io) {
  1113. $io->writeError("<warning>Class $class located in ".Preg::replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
  1114. }
  1115. }
  1116. return array();
  1117. }
  1118. return $validClasses;
  1119. }
  1120. private static function findClasses($path)
  1121. {
  1122. $extraTypes = self::getExtraTypes();
  1123. $contents = @php_strip_whitespace($path);
  1124. if (!$contents) {
  1125. if (!file_exists($path)) {
  1126. $message = 'File at "%s" does not exist, check your classmap definitions';
  1127. } elseif (!Filesystem::isReadable($path)) {
  1128. $message = 'File at "%s" is not readable, check its permissions';
  1129. } elseif ('' === trim(file_get_contents($path))) {
  1130. return array();
  1131. } else {
  1132. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  1133. }
  1134. $error = error_get_last();
  1135. if (isset($error['message'])) {
  1136. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  1137. }
  1138. throw new \RuntimeException(sprintf($message, $path));
  1139. }
  1140. Preg::matchAll('{\b(?:class|interface'.$extraTypes.')\s}i', $contents, $matches);
  1141. if (!$matches) {
  1142. return array();
  1143. }
  1144. $p = new PhpFileCleaner($contents, count($matches[0]));
  1145. $contents = $p->clean();
  1146. unset($p);
  1147. Preg::matchAll('{
  1148. (?:
  1149. \b(?<![\$:>])(?P<type>class|interface'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  1150. | \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*+ [\{;]
  1151. )
  1152. }ix', $contents, $matches);
  1153. $classes = array();
  1154. $namespace = '';
  1155. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  1156. if (!empty($matches['ns'][$i])) {
  1157. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
  1158. } else {
  1159. $name = $matches['name'][$i];
  1160. if ($name === 'extends' || $name === 'implements') {
  1161. continue;
  1162. }
  1163. if ($name[0] === ':') {
  1164. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  1165. } elseif ($matches['type'][$i] === 'enum') {
  1166. $colonPos = strrpos($name, ':');
  1167. if (false !== $colonPos) {
  1168. $name = substr($name, 0, $colonPos);
  1169. }
  1170. }
  1171. $classes[] = ltrim($namespace . $name, '\\');
  1172. }
  1173. }
  1174. return $classes;
  1175. }
  1176. private static function getExtraTypes()
  1177. {
  1178. static $extraTypes = null;
  1179. if (null === $extraTypes) {
  1180. $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
  1181. if (PHP_VERSION_ID >= 80100 || (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>='))) {
  1182. $extraTypes .= '|enum';
  1183. }
  1184. PhpFileCleaner::setTypeConfig(array_merge(array('class', 'interface'), array_filter(explode('|', $extraTypes))));
  1185. }
  1186. return $extraTypes;
  1187. }
  1188. }
  1189. <?php
  1190. namespace Composer\Autoload;
  1191. use Composer\Pcre\Preg;
  1192. class PhpFileCleaner
  1193. {
  1194. private static $typeConfig;
  1195. private static $restPattern;
  1196. private $contents;
  1197. private $len;
  1198. private $maxMatches;
  1199. private $index = 0;
  1200. public static function setTypeConfig($types)
  1201. {
  1202. foreach ($types as $type) {
  1203. self::$typeConfig[$type[0]] = array(
  1204. 'name' => $type,
  1205. 'length' => \strlen($type),
  1206. 'pattern' => '{.\b(?<![\$:>])'.$type.'\s++[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+}Ais',
  1207. );
  1208. }
  1209. self::$restPattern = '{[^?"\'</'.implode('', array_keys(self::$typeConfig)).']+}A';
  1210. }
  1211. public function __construct($contents, $maxMatches)
  1212. {
  1213. $this->contents = $contents;
  1214. $this->len = \strlen($this->contents);
  1215. $this->maxMatches = $maxMatches;
  1216. }
  1217. public function clean()
  1218. {
  1219. $clean = '';
  1220. while ($this->index < $this->len) {
  1221. $this->skipToPhp();
  1222. $clean .= '<?';
  1223. while ($this->index < $this->len) {
  1224. $char = $this->contents[$this->index];
  1225. if ($char === '?' && $this->peek('>')) {
  1226. $clean .= '?>';
  1227. $this->index += 2;
  1228. continue 2;
  1229. }
  1230. if ($char === '"') {
  1231. $this->skipString('"');
  1232. $clean .= 'null';
  1233. continue;
  1234. }
  1235. if ($char === "'") {
  1236. $this->skipString("'");
  1237. $clean .= 'null';
  1238. continue;
  1239. }
  1240. if ($char === "<" && $this->peek('<') && $this->match('{<<<[ \t]*+([\'"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*+)\\1(?:\r\n|\n|\r)}A', $match)) {
  1241. $this->index += \strlen($match[0]);
  1242. $this->skipHeredoc($match[2]);
  1243. $clean .= 'null';
  1244. continue;
  1245. }
  1246. if ($char === '/') {
  1247. if ($this->peek('/')) {
  1248. $this->skipToNewline();
  1249. continue;
  1250. }
  1251. if ($this->peek('*')) {
  1252. $this->skipComment();
  1253. continue;
  1254. }
  1255. }
  1256. if ($this->maxMatches === 1 && isset(self::$typeConfig[$char])) {
  1257. $type = self::$typeConfig[$char];
  1258. if (
  1259. \substr($this->contents, $this->index, $type['length']) === $type['name']
  1260. && Preg::isMatch($type['pattern'], $this->contents, $match, 0, $this->index - 1)
  1261. ) {
  1262. $clean .= $match[0];
  1263. return $clean;
  1264. }
  1265. }
  1266. $this->index += 1;
  1267. if ($this->match(self::$restPattern, $match)) {
  1268. $clean .= $char . $match[0];
  1269. $this->index += \strlen($match[0]);
  1270. } else {
  1271. $clean .= $char;
  1272. }
  1273. }
  1274. }
  1275. return $clean;
  1276. }
  1277. private function skipToPhp()
  1278. {
  1279. while ($this->index < $this->len) {
  1280. if ($this->contents[$this->index] === '<' && $this->peek('?')) {
  1281. $this->index += 2;
  1282. break;
  1283. }
  1284. $this->index += 1;
  1285. }
  1286. }
  1287. private function skipString($delimiter)
  1288. {
  1289. $this->index += 1;
  1290. while ($this->index < $this->len) {
  1291. if ($this->contents[$this->index] === '\\' && ($this->peek('\\') || $this->peek($delimiter))) {
  1292. $this->index += 2;
  1293. continue;
  1294. }
  1295. if ($this->contents[$this->index] === $delimiter) {
  1296. $this->index += 1;
  1297. break;
  1298. }
  1299. $this->index += 1;
  1300. }
  1301. }
  1302. private function skipComment()
  1303. {
  1304. $this->index += 2;
  1305. while ($this->index < $this->len) {
  1306. if ($this->contents[$this->index] === '*' && $this->peek('/')) {
  1307. $this->index += 2;
  1308. break;
  1309. }
  1310. $this->index += 1;
  1311. }
  1312. }
  1313. private function skipToNewline()
  1314. {
  1315. while ($this->index < $this->len) {
  1316. if ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n") {
  1317. return;
  1318. }
  1319. $this->index += 1;
  1320. }
  1321. }
  1322. private function skipHeredoc($delimiter)
  1323. {
  1324. $firstDelimiterChar = $delimiter[0];
  1325. $delimiterLength = \strlen($delimiter);
  1326. $delimiterPattern = '{'.preg_quote($delimiter).'(?![a-zA-Z0-9_\x80-\xff])}A';
  1327. while ($this->index < $this->len) {
  1328. switch ($this->contents[$this->index]) {
  1329. case "\t":
  1330. case " ":
  1331. $this->index += 1;
  1332. continue 2;
  1333. case $firstDelimiterChar:
  1334. if (
  1335. \substr($this->contents, $this->index, $delimiterLength) === $delimiter
  1336. && $this->match($delimiterPattern)
  1337. ) {
  1338. $this->index += $delimiterLength;
  1339. return;
  1340. }
  1341. break;
  1342. }
  1343. while ($this->index < $this->len) {
  1344. $this->skipToNewline();
  1345. while ($this->index < $this->len && ($this->contents[$this->index] === "\r" || $this->contents[$this->index] === "\n")) {
  1346. $this->index += 1;
  1347. }
  1348. break;
  1349. }
  1350. }
  1351. }
  1352. private function peek($char)
  1353. {
  1354. return $this->index + 1 < $this->len && $this->contents[$this->index + 1] === $char;
  1355. }
  1356. private function match($regex, array &$match = null)
  1357. {
  1358. return Preg::isMatch($regex, $this->contents, $match, 0, $this->index);
  1359. }
  1360. }
  1361. <?php
  1362. namespace Composer;
  1363. use Composer\IO\IOInterface;
  1364. use Composer\Pcre\Preg;
  1365. use Composer\Util\Filesystem;
  1366. use Composer\Util\Platform;
  1367. use Composer\Util\Silencer;
  1368. use Symfony\Component\Finder\Finder;
  1369. class Cache
  1370. {
  1371. private static $cacheCollected = null;
  1372. private $io;
  1373. private $root;
  1374. private $enabled = null;
  1375. private $allowlist;
  1376. private $filesystem;
  1377. private $readOnly;
  1378. public function __construct(IOInterface $io, $cacheDir, $allowlist = 'a-z0-9.', Filesystem $filesystem = null, $readOnly = false)
  1379. {
  1380. $this->io = $io;
  1381. $this->root = rtrim($cacheDir, '/\\') . '/';
  1382. $this->allowlist = $allowlist;
  1383. $this->filesystem = $filesystem ?: new Filesystem();
  1384. $this->readOnly = (bool) $readOnly;
  1385. if (!self::isUsable($cacheDir)) {
  1386. $this->enabled = false;
  1387. }
  1388. }
  1389. public function setReadOnly($readOnly)
  1390. {
  1391. $this->readOnly = (bool) $readOnly;
  1392. }
  1393. public function isReadOnly()
  1394. {
  1395. return $this->readOnly;
  1396. }
  1397. public static function isUsable($path)
  1398. {
  1399. return !Preg::isMatch('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1400. }
  1401. public function isEnabled()
  1402. {
  1403. if ($this->enabled === null) {
  1404. $this->enabled = true;
  1405. if (
  1406. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1407. || !is_writable($this->root)
  1408. ) {
  1409. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  1410. $this->enabled = false;
  1411. }
  1412. }
  1413. return $this->enabled;
  1414. }
  1415. public function getRoot()
  1416. {
  1417. return $this->root;
  1418. }
  1419. public function read($file)
  1420. {
  1421. if ($this->isEnabled()) {
  1422. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1423. if (file_exists($this->root . $file)) {
  1424. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1425. return file_get_contents($this->root . $file);
  1426. }
  1427. }
  1428. return false;
  1429. }
  1430. public function write($file, $contents)
  1431. {
  1432. if ($this->isEnabled() && !$this->readOnly) {
  1433. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1434. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1435. $tempFileName = $this->root . $file . uniqid('.', true) . '.tmp';
  1436. try {
  1437. return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
  1438. } catch (\ErrorException $e) {
  1439. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1440. if (Preg::isMatch('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1441. unlink($tempFileName);
  1442. $message = sprintf(
  1443. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  1444. $tempFileName,
  1445. $m[1],
  1446. $m[2],
  1447. @disk_free_space(dirname($tempFileName))
  1448. );
  1449. $this->io->writeError($message);
  1450. return false;
  1451. }
  1452. throw $e;
  1453. }
  1454. }
  1455. return false;
  1456. }
  1457. public function copyFrom($file, $source)
  1458. {
  1459. if ($this->isEnabled() && !$this->readOnly) {
  1460. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1461. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1462. if (!file_exists($source)) {
  1463. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1464. } elseif ($this->io->isDebug()) {
  1465. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1466. }
  1467. return copy($source, $this->root . $file);
  1468. }
  1469. return false;
  1470. }
  1471. public function copyTo($file, $target)
  1472. {
  1473. if ($this->isEnabled()) {
  1474. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1475. if (file_exists($this->root . $file)) {
  1476. try {
  1477. touch($this->root . $file, filemtime($this->root . $file), time());
  1478. } catch (\ErrorException $e) {
  1479. Silencer::call('touch', $this->root . $file);
  1480. }
  1481. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1482. return copy($this->root . $file, $target);
  1483. }
  1484. }
  1485. return false;
  1486. }
  1487. public function gcIsNecessary()
  1488. {
  1489. if (self::$cacheCollected) {
  1490. return false;
  1491. }
  1492. self::$cacheCollected = true;
  1493. if (Platform::getEnv('COMPOSER_TEST_SUITE')) {
  1494. return false;
  1495. }
  1496. if (PHP_VERSION_ID > 70000) {
  1497. return !random_int(0, 50);
  1498. }
  1499. return !mt_rand(0, 50);
  1500. }
  1501. public function remove($file)
  1502. {
  1503. if ($this->isEnabled()) {
  1504. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1505. if (file_exists($this->root . $file)) {
  1506. return $this->filesystem->unlink($this->root . $file);
  1507. }
  1508. }
  1509. return false;
  1510. }
  1511. public function clear()
  1512. {
  1513. if ($this->isEnabled()) {
  1514. $this->filesystem->emptyDirectory($this->root);
  1515. return true;
  1516. }
  1517. return false;
  1518. }
  1519. public function getAge($file)
  1520. {
  1521. if ($this->isEnabled()) {
  1522. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1523. if (file_exists($this->root . $file) && ($mtime = filemtime($this->root . $file)) !== false) {
  1524. return abs(time() - $mtime);
  1525. }
  1526. }
  1527. return false;
  1528. }
  1529. public function gc($ttl, $maxSize)
  1530. {
  1531. if ($this->isEnabled()) {
  1532. $expire = new \DateTime();
  1533. $expire->modify('-'.$ttl.' seconds');
  1534. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1535. foreach ($finder as $file) {
  1536. $this->filesystem->unlink($file->getPathname());
  1537. }
  1538. $totalSize = $this->filesystem->size($this->root);
  1539. if ($totalSize > $maxSize) {
  1540. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1541. while ($totalSize > $maxSize && $iterator->valid()) {
  1542. $filepath = $iterator->current()->getPathname();
  1543. $totalSize -= $this->filesystem->size($filepath);
  1544. $this->filesystem->unlink($filepath);
  1545. $iterator->next();
  1546. }
  1547. }
  1548. self::$cacheCollected = true;
  1549. return true;
  1550. }
  1551. return false;
  1552. }
  1553. public function sha1($file)
  1554. {
  1555. if ($this->isEnabled()) {
  1556. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1557. if (file_exists($this->root . $file)) {
  1558. return sha1_file($this->root . $file);
  1559. }
  1560. }
  1561. return false;
  1562. }
  1563. public function sha256($file)
  1564. {
  1565. if ($this->isEnabled()) {
  1566. $file = Preg::replace('{[^'.$this->allowlist.']}i', '-', $file);
  1567. if (file_exists($this->root . $file)) {
  1568. return hash_file('sha256', $this->root . $file);
  1569. }
  1570. }
  1571. return false;
  1572. }
  1573. protected function getFinder()
  1574. {
  1575. return Finder::create()->in($this->root)->files();
  1576. }
  1577. }
  1578. <?php
  1579. namespace Composer\Command;
  1580. use Composer\Composer;
  1581. use Symfony\Component\Console\Input\InputInterface;
  1582. use Symfony\Component\Console\Output\OutputInterface;
  1583. class AboutCommand extends BaseCommand
  1584. {
  1585. protected function configure()
  1586. {
  1587. $this
  1588. ->setName('about')
  1589. ->setDescription('Shows a short information about Composer.')
  1590. ->setHelp(
  1591. <<<EOT
  1592. <info>php composer.phar about</info>
  1593. EOT
  1594. )
  1595. ;
  1596. }
  1597. protected function execute(InputInterface $input, OutputInterface $output)
  1598. {
  1599. $composerVersion = Composer::getVersion();
  1600. $this->getIO()->write(
  1601. <<<EOT
  1602. <info>Composer - Dependency Manager for PHP - version $composerVersion</info>
  1603. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1604. See https://getcomposer.org/ for more information.</comment>
  1605. EOT
  1606. );
  1607. return 0;
  1608. }
  1609. }
  1610. <?php
  1611. namespace Composer\Command;
  1612. use Composer\Factory;
  1613. use Composer\IO\IOInterface;
  1614. use Composer\Config;
  1615. use Composer\Composer;
  1616. use Composer\Package\BasePackage;
  1617. use Composer\Package\CompletePackageInterface;
  1618. use Composer\Repository\CompositeRepository;
  1619. use Composer\Repository\RepositoryFactory;
  1620. use Composer\Script\ScriptEvents;
  1621. use Composer\Plugin\CommandEvent;
  1622. use Composer\Plugin\PluginEvents;
  1623. use Composer\Util\Filesystem;
  1624. use Composer\Util\Loop;
  1625. use Composer\Util\ProcessExecutor;
  1626. use Symfony\Component\Console\Input\InputArgument;
  1627. use Symfony\Component\Console\Input\InputInterface;
  1628. use Symfony\Component\Console\Input\InputOption;
  1629. use Symfony\Component\Console\Output\OutputInterface;
  1630. class ArchiveCommand extends BaseCommand
  1631. {
  1632. protected function configure()
  1633. {
  1634. $this
  1635. ->setName('archive')
  1636. ->setDescription('Creates an archive of this composer package.')
  1637. ->setDefinition(array(
  1638. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1639. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1640. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar, tar.gz, tar.bz2 or zip (default tar)'),
  1641. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1642. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1643. .' Note that the format will be appended.'),
  1644. new InputOption('ignore-filters', null, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1645. ))
  1646. ->setHelp(
  1647. <<<EOT
  1648. The <info>archive</info> command creates an archive of the specified format
  1649. containing the files and directories of the Composer project or the specified
  1650. package in the specified version and writes it to the specified directory.
  1651. <info>php composer.phar archive [--format=zip] [--dir=/foo] [package [version]]</info>
  1652. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1653. EOT
  1654. )
  1655. ;
  1656. }
  1657. protected function execute(InputInterface $input, OutputInterface $output)
  1658. {
  1659. $composer = $this->getComposer(false);
  1660. $config = null;
  1661. if ($composer) {
  1662. $config = $composer->getConfig();
  1663. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1664. $eventDispatcher = $composer->getEventDispatcher();
  1665. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1666. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1667. }
  1668. if (!$config) {
  1669. $config = Factory::createConfig();
  1670. }
  1671. if (null === $input->getOption('format')) {
  1672. $input->setOption('format', $config->get('archive-format'));
  1673. }
  1674. if (null === $input->getOption('dir')) {
  1675. $input->setOption('dir', $config->get('archive-dir'));
  1676. }
  1677. $returnCode = $this->archive(
  1678. $this->getIO(),
  1679. $config,
  1680. $input->getArgument('package'),
  1681. $input->getArgument('version'),
  1682. $input->getOption('format'),
  1683. $input->getOption('dir'),
  1684. $input->getOption('file'),
  1685. $input->getOption('ignore-filters'),
  1686. $composer
  1687. );
  1688. if (0 === $returnCode && $composer) {
  1689. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1690. }
  1691. return $returnCode;
  1692. }
  1693. protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
  1694. {
  1695. if ($composer) {
  1696. $archiveManager = $composer->getArchiveManager();
  1697. } else {
  1698. $factory = new Factory;
  1699. $process = new ProcessExecutor();
  1700. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1701. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1702. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1703. }
  1704. if ($packageName) {
  1705. $package = $this->selectPackage($io, $packageName, $version);
  1706. if (!$package) {
  1707. return 1;
  1708. }
  1709. } else {
  1710. $package = $this->getComposer()->getPackage();
  1711. }
  1712. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1713. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1714. $fs = new Filesystem;
  1715. $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
  1716. $io->writeError('Created: ', false);
  1717. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1718. return 0;
  1719. }
  1720. protected function selectPackage(IOInterface $io, $packageName, $version = null)
  1721. {
  1722. $io->writeError('<info>Searching for the specified package.</info>');
  1723. if ($composer = $this->getComposer(false)) {
  1724. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1725. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1726. } else {
  1727. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1728. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1729. $repo = new CompositeRepository($defaultRepos);
  1730. }
  1731. $packages = $repo->findPackages($packageName, $version);
  1732. if (count($packages) > 1) {
  1733. $package = reset($packages);
  1734. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1735. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {
  1736. return $p->getPrettyString();
  1737. }, $packages)).'.');
  1738. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1739. } elseif ($packages) {
  1740. $package = reset($packages);
  1741. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1742. } else {
  1743. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1744. return false;
  1745. }
  1746. if (!$package instanceof CompletePackageInterface) {
  1747. throw new \LogicException('Expected a CompletePackageInterface instance but found '.get_class($package));
  1748. }
  1749. return $package;
  1750. }
  1751. }
  1752. <?php
  1753. namespace Composer\Command;
  1754. use Composer\Composer;
  1755. use Composer\Config;
  1756. use Composer\Console\Application;
  1757. use Composer\Factory;
  1758. use Composer\IO\IOInterface;
  1759. use Composer\IO\NullIO;
  1760. use Composer\Plugin\PreCommandRunEvent;
  1761. use Composer\Package\Version\VersionParser;
  1762. use Composer\Plugin\PluginEvents;
  1763. use Composer\Util\Platform;
  1764. use Symfony\Component\Console\Helper\Table;
  1765. use Symfony\Component\Console\Helper\TableSeparator;
  1766. use Symfony\Component\Console\Input\InputInterface;
  1767. use Symfony\Component\Console\Output\OutputInterface;
  1768. use Symfony\Component\Console\Command\Command;
  1769. use Symfony\Component\Console\Terminal;
  1770. abstract class BaseCommand extends Command
  1771. {
  1772. private $composer;
  1773. private $io;
  1774. public function getComposer($required = true, $disablePlugins = null, $disableScripts = null)
  1775. {
  1776. if (null === $this->composer) {
  1777. $application = $this->getApplication();
  1778. if ($application instanceof Application) {
  1779. $this->composer = $application->getComposer($required, $disablePlugins, $disableScripts);
  1780. } elseif ($required) {
  1781. throw new \RuntimeException(
  1782. 'Could not create a Composer\Composer instance, you must inject '.
  1783. 'one if this command is not used with a Composer\Console\Application instance'
  1784. );
  1785. }
  1786. }
  1787. return $this->composer;
  1788. }
  1789. public function setComposer(Composer $composer)
  1790. {
  1791. $this->composer = $composer;
  1792. }
  1793. public function resetComposer()
  1794. {
  1795. $this->composer = null;
  1796. $this->getApplication()->resetComposer();
  1797. }
  1798. public function isProxyCommand()
  1799. {
  1800. return false;
  1801. }
  1802. public function getIO()
  1803. {
  1804. if (null === $this->io) {
  1805. $application = $this->getApplication();
  1806. if ($application instanceof Application) {
  1807. $this->io = $application->getIO();
  1808. } else {
  1809. $this->io = new NullIO();
  1810. }
  1811. }
  1812. return $this->io;
  1813. }
  1814. public function setIO(IOInterface $io)
  1815. {
  1816. $this->io = $io;
  1817. }
  1818. protected function initialize(InputInterface $input, OutputInterface $output)
  1819. {
  1820. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1821. $disableScripts = $input->hasParameterOption('--no-scripts');
  1822. if ($this instanceof SelfUpdateCommand) {
  1823. $disablePlugins = true;
  1824. $disableScripts = true;
  1825. }
  1826. $composer = $this->getComposer(false, $disablePlugins, $disableScripts);
  1827. if (null === $composer) {
  1828. $composer = Factory::createGlobal($this->getIO(), $disablePlugins, $disableScripts);
  1829. }
  1830. if ($composer) {
  1831. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1832. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1833. }
  1834. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1835. $input->setOption('no-progress', true);
  1836. }
  1837. if (true == $input->hasOption('no-dev')) {
  1838. if (!$input->getOption('no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) {
  1839. $input->setOption('no-dev', true);
  1840. }
  1841. }
  1842. parent::initialize($input, $output);
  1843. }
  1844. protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
  1845. {
  1846. $preferSource = false;
  1847. $preferDist = false;
  1848. switch ($config->get('preferred-install')) {
  1849. case 'source':
  1850. $preferSource = true;
  1851. break;
  1852. case 'dist':
  1853. $preferDist = true;
  1854. break;
  1855. case 'auto':
  1856. default:
  1857. break;
  1858. }
  1859. if ($input->hasOption('prefer-install') && $input->getOption('prefer-install')) {
  1860. if ($input->getOption('prefer-source')) {
  1861. throw new \InvalidArgumentException('--prefer-source can not be used together with --prefer-install');
  1862. }
  1863. if ($input->getOption('prefer-dist')) {
  1864. throw new \InvalidArgumentException('--prefer-dist can not be used together with --prefer-install');
  1865. }
  1866. switch ($input->getOption('prefer-install')) {
  1867. case 'dist':
  1868. $input->setOption('prefer-dist', true);
  1869. break;
  1870. case 'source':
  1871. $input->setOption('prefer-source', true);
  1872. break;
  1873. case 'auto':
  1874. $preferDist = false;
  1875. $preferSource = false;
  1876. break;
  1877. default:
  1878. throw new \UnexpectedValueException('--prefer-install accepts one of "dist", "source" or "auto", got '.$input->getOption('prefer-install'));
  1879. }
  1880. }
  1881. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1882. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1883. $preferDist = (bool) $input->getOption('prefer-dist');
  1884. }
  1885. return array($preferSource, $preferDist);
  1886. }
  1887. protected function formatRequirements(array $requirements)
  1888. {
  1889. $requires = array();
  1890. $requirements = $this->normalizeRequirements($requirements);
  1891. foreach ($requirements as $requirement) {
  1892. if (!isset($requirement['version'])) {
  1893. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  1894. }
  1895. $requires[$requirement['name']] = $requirement['version'];
  1896. }
  1897. return $requires;
  1898. }
  1899. protected function normalizeRequirements(array $requirements)
  1900. {
  1901. $parser = new VersionParser();
  1902. return $parser->parseNameVersionPairs($requirements);
  1903. }
  1904. protected function renderTable(array $table, OutputInterface $output)
  1905. {
  1906. $renderer = new Table($output);
  1907. $renderer->setStyle('compact');
  1908. $rendererStyle = $renderer->getStyle();
  1909. if (method_exists($rendererStyle, 'setVerticalBorderChars')) {
  1910. $rendererStyle->setVerticalBorderChars('');
  1911. } else {
  1912. $rendererStyle->setVerticalBorderChar('');
  1913. }
  1914. $rendererStyle->setCellRowContentFormat('%s ');
  1915. $renderer->setRows($table)->render();
  1916. }
  1917. protected function getTerminalWidth()
  1918. {
  1919. if (class_exists('Symfony\Component\Console\Terminal')) {
  1920. $terminal = new Terminal();
  1921. $width = $terminal->getWidth();
  1922. } else {
  1923. list($width) = $this->getApplication()->getTerminalDimensions();
  1924. }
  1925. if (null === $width) {
  1926. $width = PHP_INT_MAX;
  1927. }
  1928. if (Platform::isWindows()) {
  1929. $width--;
  1930. } else {
  1931. $width = max(80, $width);
  1932. }
  1933. return $width;
  1934. }
  1935. }
  1936. <?php
  1937. namespace Composer\Command;
  1938. use Composer\Package\Link;
  1939. use Composer\Package\PackageInterface;
  1940. use Composer\Package\CompletePackageInterface;
  1941. use Composer\Package\RootPackage;
  1942. use Composer\Repository\InstalledArrayRepository;
  1943. use Composer\Repository\CompositeRepository;
  1944. use Composer\Repository\RootPackageRepository;
  1945. use Composer\Repository\InstalledRepository;
  1946. use Composer\Repository\PlatformRepository;
  1947. use Composer\Repository\RepositoryFactory;
  1948. use Composer\Plugin\CommandEvent;
  1949. use Composer\Plugin\PluginEvents;
  1950. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1951. use Composer\Package\Version\VersionParser;
  1952. use Symfony\Component\Console\Input\InputInterface;
  1953. use Symfony\Component\Console\Output\OutputInterface;
  1954. class BaseDependencyCommand extends BaseCommand
  1955. {
  1956. const ARGUMENT_PACKAGE = 'package';
  1957. const ARGUMENT_CONSTRAINT = 'version';
  1958. const OPTION_RECURSIVE = 'recursive';
  1959. const OPTION_TREE = 'tree';
  1960. protected $colors;
  1961. protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
  1962. {
  1963. $composer = $this->getComposer();
  1964. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1965. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1966. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1967. $installedRepo = new InstalledRepository(array(
  1968. new RootPackageRepository($composer->getPackage()),
  1969. $composer->getRepositoryManager()->getLocalRepository(),
  1970. new PlatformRepository(array(), $platformOverrides),
  1971. ));
  1972. list($needle, $textConstraint) = array_pad(
  1973. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1974. 2,
  1975. $input->hasArgument(self::ARGUMENT_CONSTRAINT) ? $input->getArgument(self::ARGUMENT_CONSTRAINT) : '*'
  1976. );
  1977. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  1978. if (empty($packages)) {
  1979. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1980. }
  1981. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  1982. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  1983. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  1984. $installedRepo->addRepository(new InstalledArrayRepository(array(clone $match)));
  1985. }
  1986. }
  1987. $needles = array($needle);
  1988. if ($inverted) {
  1989. foreach ($packages as $package) {
  1990. $needles = array_merge($needles, array_map(function (Link $link) {
  1991. return $link->getTarget();
  1992. }, $package->getReplaces()));
  1993. }
  1994. }
  1995. if ('*' !== $textConstraint) {
  1996. $versionParser = new VersionParser();
  1997. $constraint = $versionParser->parseConstraints($textConstraint);
  1998. } else {
  1999. $constraint = null;
  2000. }
  2001. $renderTree = $input->getOption(self::OPTION_TREE);
  2002. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  2003. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  2004. if (empty($results)) {
  2005. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  2006. $this->getIO()->writeError(sprintf(
  2007. '<info>There is no installed package depending on "%s"%s</info>',
  2008. $needle,
  2009. $extra
  2010. ));
  2011. } elseif ($renderTree) {
  2012. $this->initStyles($output);
  2013. $root = $packages[0];
  2014. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root instanceof CompletePackageInterface ? $root->getDescription() : ''));
  2015. $this->printTree($results);
  2016. } else {
  2017. $this->printTable($output, $results);
  2018. }
  2019. return 0;
  2020. }
  2021. protected function printTable(OutputInterface $output, $results)
  2022. {
  2023. $table = array();
  2024. $doubles = array();
  2025. do {
  2026. $queue = array();
  2027. $rows = array();
  2028. foreach ($results as $result) {
  2029. list($package, $link, $children) = $result;
  2030. $unique = (string) $link;
  2031. if (isset($doubles[$unique])) {
  2032. continue;
  2033. }
  2034. $doubles[$unique] = true;
  2035. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  2036. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  2037. if ($children) {
  2038. $queue = array_merge($queue, $children);
  2039. }
  2040. }
  2041. $results = $queue;
  2042. $table = array_merge($rows, $table);
  2043. } while (!empty($results));
  2044. $this->renderTable($table, $output);
  2045. }
  2046. protected function initStyles(OutputInterface $output)
  2047. {
  2048. $this->colors = array(
  2049. 'green',
  2050. 'yellow',
  2051. 'cyan',
  2052. 'magenta',
  2053. 'blue',
  2054. );
  2055. foreach ($this->colors as $color) {
  2056. $style = new OutputFormatterStyle($color);
  2057. $output->getFormatter()->setStyle($color, $style);
  2058. }
  2059. }
  2060. protected function printTree($results, $prefix = '', $level = 1)
  2061. {
  2062. $count = count($results);
  2063. $idx = 0;
  2064. foreach ($results as $result) {
  2065. list($package, $link, $children) = $result;
  2066. $color = $this->colors[$level % count($this->colors)];
  2067. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  2068. $isLast = (++$idx == $count);
  2069. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  2070. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  2071. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  2072. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  2073. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  2074. if ($children) {
  2075. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  2076. }
  2077. }
  2078. }
  2079. private function writeTreeLine($line)
  2080. {
  2081. $io = $this->getIO();
  2082. if (!$io->isDecorated()) {
  2083. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  2084. }
  2085. $io->write($line);
  2086. }
  2087. }
  2088. <?php
  2089. namespace Composer\Command;
  2090. use Composer\Package\Link;
  2091. use Composer\Semver\Constraint\Constraint;
  2092. use Symfony\Component\Console\Input\InputInterface;
  2093. use Symfony\Component\Console\Input\InputOption;
  2094. use Symfony\Component\Console\Output\OutputInterface;
  2095. use Composer\Repository\PlatformRepository;
  2096. use Composer\Repository\RootPackageRepository;
  2097. use Composer\Repository\InstalledRepository;
  2098. class CheckPlatformReqsCommand extends BaseCommand
  2099. {
  2100. protected function configure()
  2101. {
  2102. $this->setName('check-platform-reqs')
  2103. ->setDescription('Check that platform requirements are satisfied.')
  2104. ->setDefinition(array(
  2105. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  2106. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  2107. ))
  2108. ->setHelp(
  2109. <<<EOT
  2110. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  2111. 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.
  2112. <info>php composer.phar check-platform-reqs</info>
  2113. EOT
  2114. );
  2115. }
  2116. protected function execute(InputInterface $input, OutputInterface $output)
  2117. {
  2118. $composer = $this->getComposer();
  2119. $requires = array();
  2120. $removePackages = array();
  2121. if ($input->getOption('lock')) {
  2122. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  2123. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2124. } else {
  2125. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  2126. if (!$installedRepo->getPackages()) {
  2127. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  2128. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  2129. } else {
  2130. if ($input->getOption('no-dev')) {
  2131. $removePackages = $installedRepo->getDevPackageNames();
  2132. }
  2133. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  2134. }
  2135. }
  2136. if (!$input->getOption('no-dev')) {
  2137. $requires += $composer->getPackage()->getDevRequires();
  2138. }
  2139. foreach ($requires as $require => $link) {
  2140. $requires[$require] = array($link);
  2141. }
  2142. $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
  2143. foreach ($installedRepo->getPackages() as $package) {
  2144. if (in_array($package->getName(), $removePackages, true)) {
  2145. continue;
  2146. }
  2147. foreach ($package->getRequires() as $require => $link) {
  2148. $requires[$require][] = $link;
  2149. }
  2150. }
  2151. ksort($requires);
  2152. $installedRepo->addRepository(new PlatformRepository(array(), array()));
  2153. $results = array();
  2154. $exitCode = 0;
  2155. foreach ($requires as $require => $links) {
  2156. if (PlatformRepository::isPlatformPackage($require)) {
  2157. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  2158. if ($candidates) {
  2159. $reqResults = array();
  2160. foreach ($candidates as $candidate) {
  2161. $candidateConstraint = null;
  2162. if ($candidate->getName() === $require) {
  2163. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  2164. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  2165. } else {
  2166. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  2167. if ($link->getTarget() === $require) {
  2168. $candidateConstraint = $link->getConstraint();
  2169. break;
  2170. }
  2171. }
  2172. }
  2173. if (!$candidateConstraint) {
  2174. continue;
  2175. }
  2176. foreach ($links as $link) {
  2177. if (!$link->getConstraint()->matches($candidateConstraint)) {
  2178. $reqResults[] = array(
  2179. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2180. $candidateConstraint->getPrettyString(),
  2181. $link,
  2182. '<error>failed</error>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  2183. );
  2184. continue 2;
  2185. }
  2186. }
  2187. $results[] = array(
  2188. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  2189. $candidateConstraint->getPrettyString(),
  2190. null,
  2191. '<info>success</info>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  2192. );
  2193. continue 2;
  2194. }
  2195. $results = array_merge($results, $reqResults);
  2196. $exitCode = max($exitCode, 1);
  2197. continue;
  2198. }
  2199. $results[] = array(
  2200. $require,
  2201. 'n/a',
  2202. $links[0],
  2203. '<error>missing</error>',
  2204. );
  2205. $exitCode = max($exitCode, 2);
  2206. }
  2207. }
  2208. $this->printTable($output, $results);
  2209. return $exitCode;
  2210. }
  2211. protected function printTable(OutputInterface $output, $results)
  2212. {
  2213. $rows = array();
  2214. foreach ($results as $result) {
  2215. list($platformPackage, $version, $link, $status) = $result;
  2216. $rows[] = array(
  2217. $platformPackage,
  2218. $version,
  2219. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  2220. $status,
  2221. );
  2222. }
  2223. $this->renderTable($rows, $output);
  2224. }
  2225. }
  2226. <?php
  2227. namespace Composer\Command;
  2228. use Composer\Cache;
  2229. use Composer\Factory;
  2230. use Symfony\Component\Console\Input\InputInterface;
  2231. use Symfony\Component\Console\Output\OutputInterface;
  2232. class ClearCacheCommand extends BaseCommand
  2233. {
  2234. protected function configure()
  2235. {
  2236. $this
  2237. ->setName('clear-cache')
  2238. ->setAliases(array('clearcache', 'cc'))
  2239. ->setDescription('Clears composer\'s internal package cache.')
  2240. ->setHelp(
  2241. <<<EOT
  2242. The <info>clear-cache</info> deletes all cached packages from composer's
  2243. cache directory.
  2244. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  2245. EOT
  2246. )
  2247. ;
  2248. }
  2249. protected function execute(InputInterface $input, OutputInterface $output)
  2250. {
  2251. $config = Factory::createConfig();
  2252. $io = $this->getIO();
  2253. $cachePaths = array(
  2254. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  2255. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  2256. 'cache-files-dir' => $config->get('cache-files-dir'),
  2257. 'cache-dir' => $config->get('cache-dir'),
  2258. );
  2259. foreach ($cachePaths as $key => $cachePath) {
  2260. $cachePath = realpath($cachePath);
  2261. if (!$cachePath) {
  2262. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  2263. continue;
  2264. }
  2265. $cache = new Cache($io, $cachePath);
  2266. $cache->setReadOnly($config->get('cache-read-only'));
  2267. if (!$cache->isEnabled()) {
  2268. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  2269. continue;
  2270. }
  2271. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  2272. $cache->clear();
  2273. }
  2274. $io->writeError('<info>All caches cleared.</info>');
  2275. return 0;
  2276. }
  2277. }
  2278. <?php
  2279. namespace Composer\Command;
  2280. use Composer\Pcre\Preg;
  2281. use Composer\Util\Filesystem;
  2282. use Composer\Util\Platform;
  2283. use Composer\Util\Silencer;
  2284. use Symfony\Component\Console\Input\InputInterface;
  2285. use Symfony\Component\Console\Input\InputArgument;
  2286. use Symfony\Component\Console\Input\InputOption;
  2287. use Symfony\Component\Console\Output\OutputInterface;
  2288. use Composer\Config;
  2289. use Composer\Config\JsonConfigSource;
  2290. use Composer\Factory;
  2291. use Composer\IO\IOInterface;
  2292. use Composer\Json\JsonFile;
  2293. use Composer\Semver\VersionParser;
  2294. use Composer\Package\BasePackage;
  2295. class ConfigCommand extends BaseCommand
  2296. {
  2297. protected $config;
  2298. protected $configFile;
  2299. protected $configSource;
  2300. protected $authConfigFile;
  2301. protected $authConfigSource;
  2302. protected function configure()
  2303. {
  2304. $this
  2305. ->setName('config')
  2306. ->setDescription('Sets config options.')
  2307. ->setDefinition(array(
  2308. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  2309. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  2310. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  2311. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  2312. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  2313. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  2314. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  2315. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  2316. 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'),
  2317. 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)'),
  2318. new InputOption('source', null, InputOption::VALUE_NONE, 'Display where the config value is loaded from'),
  2319. new InputArgument('setting-key', null, 'Setting key'),
  2320. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  2321. ))
  2322. ->setHelp(
  2323. <<<EOT
  2324. This command allows you to edit composer config settings and repositories
  2325. in either the local composer.json file or the global config.json file.
  2326. Additionally it lets you edit most properties in the local composer.json.
  2327. To set a config setting:
  2328. <comment>%command.full_name% bin-dir bin/</comment>
  2329. To read a config setting:
  2330. <comment>%command.full_name% bin-dir</comment>
  2331. Outputs: <info>bin</info>
  2332. To edit the global config.json file:
  2333. <comment>%command.full_name% --global</comment>
  2334. To add a repository:
  2335. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  2336. To remove a repository (repo is a short alias for repositories):
  2337. <comment>%command.full_name% --unset repo.foo</comment>
  2338. To disable packagist:
  2339. <comment>%command.full_name% repo.packagist false</comment>
  2340. You can alter repositories in the global config.json file by passing in the
  2341. <info>--global</info> option.
  2342. To add or edit suggested packages you can use:
  2343. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  2344. To add or edit extra properties you can use:
  2345. <comment>%command.full_name% extra.property value</comment>
  2346. Or to add a complex value you can use json with:
  2347. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  2348. To edit the file in an external editor:
  2349. <comment>%command.full_name% --editor</comment>
  2350. To choose your editor you can set the "EDITOR" env variable.
  2351. To get a list of configuration values in the file:
  2352. <comment>%command.full_name% --list</comment>
  2353. You can always pass more than one option. As an example, if you want to edit the
  2354. global config.json file.
  2355. <comment>%command.full_name% --editor --global</comment>
  2356. Read more at https://getcomposer.org/doc/03-cli.md#config
  2357. EOT
  2358. )
  2359. ;
  2360. }
  2361. protected function initialize(InputInterface $input, OutputInterface $output)
  2362. {
  2363. parent::initialize($input, $output);
  2364. if ($input->getOption('global') && null !== $input->getOption('file')) {
  2365. throw new \RuntimeException('--file and --global can not be combined');
  2366. }
  2367. $io = $this->getIO();
  2368. $this->config = Factory::createConfig($io);
  2369. $configFile = $input->getOption('global')
  2370. ? ($this->config->get('home') . '/config.json')
  2371. : ($input->getOption('file') ?: Factory::getComposerFile());
  2372. if (
  2373. ($configFile === 'composer.json' || $configFile === './composer.json')
  2374. && !file_exists($configFile)
  2375. && realpath(getcwd()) === realpath($this->config->get('home'))
  2376. ) {
  2377. file_put_contents($configFile, "{\n}\n");
  2378. }
  2379. $this->configFile = new JsonFile($configFile, null, $io);
  2380. $this->configSource = new JsonConfigSource($this->configFile);
  2381. $authConfigFile = $input->getOption('global')
  2382. ? ($this->config->get('home') . '/auth.json')
  2383. : dirname(realpath($configFile)) . '/auth.json';
  2384. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  2385. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  2386. if ($input->getOption('global') && !$this->configFile->exists()) {
  2387. touch($this->configFile->getPath());
  2388. $this->configFile->write(array('config' => new \ArrayObject));
  2389. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  2390. }
  2391. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  2392. touch($this->authConfigFile->getPath());
  2393. $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));
  2394. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  2395. }
  2396. if (!$this->configFile->exists()) {
  2397. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  2398. }
  2399. }
  2400. protected function execute(InputInterface $input, OutputInterface $output)
  2401. {
  2402. if (true === $input->getOption('editor')) {
  2403. $editor = escapeshellcmd(Platform::getEnv('EDITOR'));
  2404. if (!$editor) {
  2405. if (Platform::isWindows()) {
  2406. $editor = 'notepad';
  2407. } else {
  2408. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  2409. if (exec('which '.$candidate)) {
  2410. $editor = $candidate;
  2411. break;
  2412. }
  2413. }
  2414. }
  2415. }
  2416. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  2417. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  2418. return 0;
  2419. }
  2420. if (false === $input->getOption('global')) {
  2421. $this->config->merge($this->configFile->read(), $this->configFile->getPath());
  2422. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()), $this->authConfigFile->getPath());
  2423. }
  2424. if (true === $input->getOption('list')) {
  2425. $this->listConfiguration($this->config->all(), $this->config->raw(), $output, null, (bool) $input->getOption('source'));
  2426. return 0;
  2427. }
  2428. $settingKey = $input->getArgument('setting-key');
  2429. if (!is_string($settingKey)) {
  2430. return 0;
  2431. }
  2432. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  2433. throw new \RuntimeException('You can not combine a setting value with --unset');
  2434. }
  2435. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  2436. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  2437. $rawData = $this->configFile->read();
  2438. $data = $this->config->all();
  2439. if (Preg::isMatch('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  2440. if (!isset($matches[1]) || $matches[1] === '') {
  2441. $value = isset($data['repositories']) ? $data['repositories'] : array();
  2442. } else {
  2443. if (!isset($data['repositories'][$matches[1]])) {
  2444. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  2445. }
  2446. $value = $data['repositories'][$matches[1]];
  2447. }
  2448. } elseif (strpos($settingKey, '.')) {
  2449. $bits = explode('.', $settingKey);
  2450. if ($bits[0] === 'extra') {
  2451. $data = $rawData;
  2452. } else {
  2453. $data = $data['config'];
  2454. }
  2455. $match = false;
  2456. foreach ($bits as $bit) {
  2457. $key = isset($key) ? $key.'.'.$bit : $bit;
  2458. $match = false;
  2459. if (isset($data[$key])) {
  2460. $match = true;
  2461. $data = $data[$key];
  2462. unset($key);
  2463. }
  2464. }
  2465. if (!$match) {
  2466. throw new \RuntimeException($settingKey.' is not defined.');
  2467. }
  2468. $value = $data;
  2469. } elseif (isset($data['config'][$settingKey])) {
  2470. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  2471. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  2472. $value = $rawData[$settingKey];
  2473. } else {
  2474. throw new \RuntimeException($settingKey.' is not defined');
  2475. }
  2476. if (is_array($value)) {
  2477. $value = json_encode($value);
  2478. }
  2479. $sourceOfConfigValue = '';
  2480. if ($input->getOption('source')) {
  2481. $sourceOfConfigValue = ' (' . $this->config->getSourceOfValue($settingKey) . ')';
  2482. }
  2483. $this->getIO()->write($value . $sourceOfConfigValue, true, IOInterface::QUIET);
  2484. return 0;
  2485. }
  2486. $values = $input->getArgument('setting-value');
  2487. $booleanValidator = function ($val) {
  2488. return in_array($val, array('true', 'false', '1', '0'), true);
  2489. };
  2490. $booleanNormalizer = function ($val) {
  2491. return $val !== 'false' && (bool) $val;
  2492. };
  2493. $uniqueConfigValues = array(
  2494. 'process-timeout' => array('is_numeric', 'intval'),
  2495. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  2496. 'use-github-api' => array($booleanValidator, $booleanNormalizer),
  2497. 'preferred-install' => array(
  2498. function ($val) {
  2499. return in_array($val, array('auto', 'source', 'dist'), true);
  2500. },
  2501. function ($val) {
  2502. return $val;
  2503. },
  2504. ),
  2505. 'gitlab-protocol' => array(
  2506. function ($val) {
  2507. return in_array($val, array('git', 'http', 'https'), true);
  2508. },
  2509. function ($val) {
  2510. return $val;
  2511. },
  2512. ),
  2513. 'store-auths' => array(
  2514. function ($val) {
  2515. return in_array($val, array('true', 'false', 'prompt'), true);
  2516. },
  2517. function ($val) {
  2518. if ('prompt' === $val) {
  2519. return 'prompt';
  2520. }
  2521. return $val !== 'false' && (bool) $val;
  2522. },
  2523. ),
  2524. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  2525. 'vendor-dir' => array('is_string', function ($val) {
  2526. return $val;
  2527. }),
  2528. 'bin-dir' => array('is_string', function ($val) {
  2529. return $val;
  2530. }),
  2531. 'archive-dir' => array('is_string', function ($val) {
  2532. return $val;
  2533. }),
  2534. 'archive-format' => array('is_string', function ($val) {
  2535. return $val;
  2536. }),
  2537. 'data-dir' => array('is_string', function ($val) {
  2538. return $val;
  2539. }),
  2540. 'cache-dir' => array('is_string', function ($val) {
  2541. return $val;
  2542. }),
  2543. 'cache-files-dir' => array('is_string', function ($val) {
  2544. return $val;
  2545. }),
  2546. 'cache-repo-dir' => array('is_string', function ($val) {
  2547. return $val;
  2548. }),
  2549. 'cache-vcs-dir' => array('is_string', function ($val) {
  2550. return $val;
  2551. }),
  2552. 'cache-ttl' => array('is_numeric', 'intval'),
  2553. 'cache-files-ttl' => array('is_numeric', 'intval'),
  2554. 'cache-files-maxsize' => array(
  2555. function ($val) {
  2556. return Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val);
  2557. },
  2558. function ($val) {
  2559. return $val;
  2560. },
  2561. ),
  2562. 'bin-compat' => array(
  2563. function ($val) {
  2564. return in_array($val, array('auto', 'full', 'symlink'));
  2565. },
  2566. function ($val) {
  2567. return $val;
  2568. },
  2569. ),
  2570. 'discard-changes' => array(
  2571. function ($val) {
  2572. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  2573. },
  2574. function ($val) {
  2575. if ('stash' === $val) {
  2576. return 'stash';
  2577. }
  2578. return $val !== 'false' && (bool) $val;
  2579. },
  2580. ),
  2581. 'autoloader-suffix' => array('is_string', function ($val) {
  2582. return $val === 'null' ? null : $val;
  2583. }),
  2584. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  2585. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  2586. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  2587. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  2588. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  2589. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  2590. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  2591. 'cafile' => array(
  2592. function ($val) {
  2593. return file_exists($val) && Filesystem::isReadable($val);
  2594. },
  2595. function ($val) {
  2596. return $val === 'null' ? null : $val;
  2597. },
  2598. ),
  2599. 'capath' => array(
  2600. function ($val) {
  2601. return is_dir($val) && Filesystem::isReadable($val);
  2602. },
  2603. function ($val) {
  2604. return $val === 'null' ? null : $val;
  2605. },
  2606. ),
  2607. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  2608. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  2609. 'lock' => array($booleanValidator, $booleanNormalizer),
  2610. 'allow-plugins' => array($booleanValidator, $booleanNormalizer),
  2611. 'platform-check' => array(
  2612. function ($val) {
  2613. return in_array($val, array('php-only', 'true', 'false', '1', '0'), true);
  2614. },
  2615. function ($val) {
  2616. if ('php-only' === $val) {
  2617. return 'php-only';
  2618. }
  2619. return $val !== 'false' && (bool)$val;
  2620. },
  2621. ),
  2622. 'use-parent-dir' => array(
  2623. function ($val) {
  2624. return in_array($val, array('true', 'false', 'prompt'), true);
  2625. },
  2626. function ($val) {
  2627. if ('prompt' === $val) {
  2628. return 'prompt';
  2629. }
  2630. return $val !== 'false' && (bool) $val;
  2631. },
  2632. ),
  2633. );
  2634. $multiConfigValues = array(
  2635. 'github-protocols' => array(
  2636. function ($vals) {
  2637. if (!is_array($vals)) {
  2638. return 'array expected';
  2639. }
  2640. foreach ($vals as $val) {
  2641. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2642. return 'valid protocols include: git, https, ssh';
  2643. }
  2644. }
  2645. return true;
  2646. },
  2647. function ($vals) {
  2648. return $vals;
  2649. },
  2650. ),
  2651. 'github-domains' => array(
  2652. function ($vals) {
  2653. if (!is_array($vals)) {
  2654. return 'array expected';
  2655. }
  2656. return true;
  2657. },
  2658. function ($vals) {
  2659. return $vals;
  2660. },
  2661. ),
  2662. 'gitlab-domains' => array(
  2663. function ($vals) {
  2664. if (!is_array($vals)) {
  2665. return 'array expected';
  2666. }
  2667. return true;
  2668. },
  2669. function ($vals) {
  2670. return $vals;
  2671. },
  2672. ),
  2673. );
  2674. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2675. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  2676. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2677. }
  2678. $this->configSource->removeConfigSetting($settingKey);
  2679. return 0;
  2680. }
  2681. if (isset($uniqueConfigValues[$settingKey])) {
  2682. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2683. return 0;
  2684. }
  2685. if (isset($multiConfigValues[$settingKey])) {
  2686. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2687. return 0;
  2688. }
  2689. if (Preg::isMatch('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  2690. if ($input->getOption('unset')) {
  2691. $this->configSource->removeConfigSetting($settingKey);
  2692. return 0;
  2693. }
  2694. list($validator) = $uniqueConfigValues['preferred-install'];
  2695. if (!$validator($values[0])) {
  2696. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  2697. }
  2698. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2699. return 0;
  2700. }
  2701. if (Preg::isMatch('{^allow-plugins\.([a-zA-Z0-9/*-]+)}', $settingKey, $matches)) {
  2702. if ($input->getOption('unset')) {
  2703. $this->configSource->removeConfigSetting($settingKey);
  2704. return 0;
  2705. }
  2706. if (true !== $booleanValidator($values[0])) {
  2707. throw new \RuntimeException(sprintf(
  2708. '"%s" is an invalid value',
  2709. $values[0]
  2710. ));
  2711. }
  2712. $normalizedValue = $booleanNormalizer($values[0]);
  2713. $this->configSource->addConfigSetting($settingKey, $normalizedValue);
  2714. return 0;
  2715. }
  2716. $uniqueProps = array(
  2717. 'name' => array('is_string', function ($val) {
  2718. return $val;
  2719. }),
  2720. 'type' => array('is_string', function ($val) {
  2721. return $val;
  2722. }),
  2723. 'description' => array('is_string', function ($val) {
  2724. return $val;
  2725. }),
  2726. 'homepage' => array('is_string', function ($val) {
  2727. return $val;
  2728. }),
  2729. 'version' => array('is_string', function ($val) {
  2730. return $val;
  2731. }),
  2732. 'minimum-stability' => array(
  2733. function ($val) {
  2734. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2735. },
  2736. function ($val) {
  2737. return VersionParser::normalizeStability($val);
  2738. },
  2739. ),
  2740. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2741. );
  2742. $multiProps = array(
  2743. 'keywords' => array(
  2744. function ($vals) {
  2745. if (!is_array($vals)) {
  2746. return 'array expected';
  2747. }
  2748. return true;
  2749. },
  2750. function ($vals) {
  2751. return $vals;
  2752. },
  2753. ),
  2754. 'license' => array(
  2755. function ($vals) {
  2756. if (!is_array($vals)) {
  2757. return 'array expected';
  2758. }
  2759. return true;
  2760. },
  2761. function ($vals) {
  2762. return $vals;
  2763. },
  2764. ),
  2765. );
  2766. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  2767. 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');
  2768. }
  2769. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2770. $this->configSource->removeProperty($settingKey);
  2771. return 0;
  2772. }
  2773. if (isset($uniqueProps[$settingKey])) {
  2774. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2775. return 0;
  2776. }
  2777. if (isset($multiProps[$settingKey])) {
  2778. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2779. return 0;
  2780. }
  2781. if (Preg::isMatch('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2782. if ($input->getOption('unset')) {
  2783. $this->configSource->removeRepository($matches[1]);
  2784. return 0;
  2785. }
  2786. if (2 === count($values)) {
  2787. $this->configSource->addRepository($matches[1], array(
  2788. 'type' => $values[0],
  2789. 'url' => $values[1],
  2790. ), $input->getOption('append'));
  2791. return 0;
  2792. }
  2793. if (1 === count($values)) {
  2794. $value = strtolower($values[0]);
  2795. if (true === $booleanValidator($value)) {
  2796. if (false === $booleanNormalizer($value)) {
  2797. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  2798. return 0;
  2799. }
  2800. } else {
  2801. $value = JsonFile::parseJson($values[0]);
  2802. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  2803. return 0;
  2804. }
  2805. }
  2806. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2807. }
  2808. if (Preg::isMatch('/^extra\.(.+)/', $settingKey, $matches)) {
  2809. if ($input->getOption('unset')) {
  2810. $this->configSource->removeProperty($settingKey);
  2811. return 0;
  2812. }
  2813. $value = $values[0];
  2814. if ($input->getOption('json')) {
  2815. $value = JsonFile::parseJson($value);
  2816. if ($input->getOption('merge')) {
  2817. $currentValue = $this->configFile->read();
  2818. $bits = explode('.', $settingKey);
  2819. foreach ($bits as $bit) {
  2820. $currentValue = isset($currentValue[$bit]) ? $currentValue[$bit] : null;
  2821. }
  2822. if (is_array($currentValue)) {
  2823. $value = array_merge($currentValue, $value);
  2824. }
  2825. }
  2826. }
  2827. $this->configSource->addProperty($settingKey, $value);
  2828. return 0;
  2829. }
  2830. if (Preg::isMatch('/^suggest\.(.+)/', $settingKey, $matches)) {
  2831. if ($input->getOption('unset')) {
  2832. $this->configSource->removeProperty($settingKey);
  2833. return 0;
  2834. }
  2835. $this->configSource->addProperty($settingKey, implode(' ', $values));
  2836. return 0;
  2837. }
  2838. if (in_array($settingKey, array('suggest', 'extra'), true) && $input->getOption('unset')) {
  2839. $this->configSource->removeProperty($settingKey);
  2840. return 0;
  2841. }
  2842. if (Preg::isMatch('/^platform\.(.+)/', $settingKey, $matches)) {
  2843. if ($input->getOption('unset')) {
  2844. $this->configSource->removeConfigSetting($settingKey);
  2845. return 0;
  2846. }
  2847. $this->configSource->addConfigSetting($settingKey, $values[0] === 'false' ? false : $values[0]);
  2848. return 0;
  2849. }
  2850. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2851. $this->configSource->removeConfigSetting($settingKey);
  2852. return 0;
  2853. }
  2854. if (Preg::isMatch('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  2855. if ($input->getOption('unset')) {
  2856. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2857. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2858. return 0;
  2859. }
  2860. if ($matches[1] === 'bitbucket-oauth') {
  2861. if (2 !== count($values)) {
  2862. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2863. }
  2864. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2865. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2866. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  2867. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2868. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'token' => $values[1]));
  2869. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
  2870. if (1 !== count($values)) {
  2871. throw new \RuntimeException('Too many arguments, expected only one token');
  2872. }
  2873. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2874. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2875. } elseif ($matches[1] === 'http-basic') {
  2876. if (2 !== count($values)) {
  2877. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2878. }
  2879. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2880. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2881. }
  2882. return 0;
  2883. }
  2884. if (Preg::isMatch('/^scripts\.(.+)/', $settingKey, $matches)) {
  2885. if ($input->getOption('unset')) {
  2886. $this->configSource->removeProperty($settingKey);
  2887. return 0;
  2888. }
  2889. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2890. return 0;
  2891. }
  2892. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2893. }
  2894. protected function handleSingleValue($key, array $callbacks, array $values, $method)
  2895. {
  2896. list($validator, $normalizer) = $callbacks;
  2897. if (1 !== count($values)) {
  2898. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2899. }
  2900. if (true !== $validation = $validator($values[0])) {
  2901. throw new \RuntimeException(sprintf(
  2902. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2903. $values[0]
  2904. ));
  2905. }
  2906. $normalizedValue = $normalizer($values[0]);
  2907. if ($key === 'disable-tls') {
  2908. if (!$normalizedValue && $this->config->get('disable-tls')) {
  2909. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2910. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  2911. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  2912. }
  2913. }
  2914. call_user_func(array($this->configSource, $method), $key, $normalizedValue);
  2915. }
  2916. protected function handleMultiValue($key, array $callbacks, array $values, $method)
  2917. {
  2918. list($validator, $normalizer) = $callbacks;
  2919. if (true !== $validation = $validator($values)) {
  2920. throw new \RuntimeException(sprintf(
  2921. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2922. json_encode($values)
  2923. ));
  2924. }
  2925. call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2926. }
  2927. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null, $showSource = false)
  2928. {
  2929. $origK = $k;
  2930. $io = $this->getIO();
  2931. foreach ($contents as $key => $value) {
  2932. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2933. continue;
  2934. }
  2935. $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
  2936. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2937. $k .= Preg::replace('{^config\.}', '', $key . '.');
  2938. $this->listConfiguration($value, $rawVal, $output, $k, $showSource);
  2939. $k = $origK;
  2940. continue;
  2941. }
  2942. if (is_array($value)) {
  2943. $value = array_map(function ($val) {
  2944. return is_array($val) ? json_encode($val) : $val;
  2945. }, $value);
  2946. $value = '['.implode(', ', $value).']';
  2947. }
  2948. if (is_bool($value)) {
  2949. $value = var_export($value, true);
  2950. }
  2951. $source = '';
  2952. if ($showSource) {
  2953. $source = ' (' . $this->config->getSourceOfValue($k . $key) . ')';
  2954. }
  2955. if (is_string($rawVal) && $rawVal != $value) {
  2956. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>' . $source, true, IOInterface::QUIET);
  2957. } else {
  2958. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>' . $source, true, IOInterface::QUIET);
  2959. }
  2960. }
  2961. }
  2962. }
  2963. <?php
  2964. namespace Composer\Command;
  2965. use Composer\Config;
  2966. use Composer\Factory;
  2967. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  2968. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  2969. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  2970. use Composer\Installer;
  2971. use Composer\Installer\ProjectInstaller;
  2972. use Composer\Installer\SuggestedPackagesReporter;
  2973. use Composer\IO\IOInterface;
  2974. use Composer\Package\BasePackage;
  2975. use Composer\DependencyResolver\Operation\InstallOperation;
  2976. use Composer\Package\Version\VersionSelector;
  2977. use Composer\Package\AliasPackage;
  2978. use Composer\Pcre\Preg;
  2979. use Composer\Repository\RepositoryFactory;
  2980. use Composer\Repository\CompositeRepository;
  2981. use Composer\Repository\PlatformRepository;
  2982. use Composer\Repository\InstalledArrayRepository;
  2983. use Composer\Repository\RepositorySet;
  2984. use Composer\Script\ScriptEvents;
  2985. use Composer\Util\Silencer;
  2986. use Symfony\Component\Console\Input\InputArgument;
  2987. use Symfony\Component\Console\Input\InputInterface;
  2988. use Symfony\Component\Console\Input\InputOption;
  2989. use Symfony\Component\Console\Output\OutputInterface;
  2990. use Symfony\Component\Finder\Finder;
  2991. use Composer\Json\JsonFile;
  2992. use Composer\Config\JsonConfigSource;
  2993. use Composer\Util\Filesystem;
  2994. use Composer\Util\Platform;
  2995. use Composer\Util\ProcessExecutor;
  2996. use Composer\Package\Version\VersionParser;
  2997. class CreateProjectCommand extends BaseCommand
  2998. {
  2999. protected $suggestedPackagesReporter;
  3000. protected function configure()
  3001. {
  3002. $this
  3003. ->setName('create-project')
  3004. ->setDescription('Creates new project from a package into given directory.')
  3005. ->setDefinition(array(
  3006. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  3007. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  3008. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  3009. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  3010. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  3011. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  3012. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  3013. 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'),
  3014. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  3015. 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.'),
  3016. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  3017. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  3018. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  3019. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  3020. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  3021. 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.'),
  3022. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  3023. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  3024. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  3025. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3026. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3027. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  3028. ))
  3029. ->setHelp(
  3030. <<<EOT
  3031. The <info>create-project</info> command creates a new project from a given
  3032. package into a new directory. If executed without params and in a directory
  3033. with a composer.json file it installs the packages for the current project.
  3034. You can use this command to bootstrap new projects or setup a clean
  3035. version-controlled installation for developers of your project.
  3036. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  3037. You can also specify the version with the package name using = or : as separator.
  3038. <info>php composer.phar create-project vendor/project:version target-directory</info>
  3039. To install unstable packages, either specify the version you want, or use the
  3040. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  3041. To setup a developer workable version you should create the project using the source
  3042. controlled code by appending the <info>'--prefer-source'</info> flag.
  3043. To install a package from another repository than the default one you
  3044. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  3045. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  3046. EOT
  3047. )
  3048. ;
  3049. }
  3050. protected function execute(InputInterface $input, OutputInterface $output)
  3051. {
  3052. $config = Factory::createConfig();
  3053. $io = $this->getIO();
  3054. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  3055. if ($input->getOption('dev')) {
  3056. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  3057. }
  3058. if ($input->getOption('no-custom-installers')) {
  3059. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  3060. $input->setOption('no-plugins', true);
  3061. }
  3062. if ($input->isInteractive() && $input->getOption('ask')) {
  3063. $parts = explode("/", strtolower($input->getArgument('package')), 2);
  3064. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  3065. }
  3066. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  3067. return $this->installProject(
  3068. $io,
  3069. $config,
  3070. $input,
  3071. $input->getArgument('package'),
  3072. $input->getArgument('directory'),
  3073. $input->getArgument('version'),
  3074. $input->getOption('stability'),
  3075. $preferSource,
  3076. $preferDist,
  3077. !$input->getOption('no-dev'),
  3078. $input->getOption('repository') ?: $input->getOption('repository-url'),
  3079. $input->getOption('no-plugins'),
  3080. $input->getOption('no-scripts'),
  3081. $input->getOption('no-progress'),
  3082. $input->getOption('no-install'),
  3083. PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs),
  3084. !$input->getOption('no-secure-http'),
  3085. $input->getOption('add-repository')
  3086. );
  3087. }
  3088. public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName = null, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $noInstall = false, PlatformRequirementFilterInterface $platformRequirementFilter = null, $secureHttp = true, $addRepository = false)
  3089. {
  3090. $oldCwd = getcwd();
  3091. if ($repositories !== null && !is_array($repositories)) {
  3092. $repositories = (array) $repositories;
  3093. }
  3094. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  3095. $io->loadConfiguration($config);
  3096. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  3097. if ($packageName !== null) {
  3098. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $platformRequirementFilter, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $disableScripts, $noProgress, $secureHttp);
  3099. } else {
  3100. $installedFromVcs = false;
  3101. }
  3102. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  3103. unlink('composer.lock');
  3104. }
  3105. $composer = Factory::create($io, null, $disablePlugins, $disableScripts);
  3106. if ($repositories !== null && $addRepository) {
  3107. foreach ($repositories as $index => $repo) {
  3108. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  3109. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  3110. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  3111. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  3112. if (
  3113. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  3114. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  3115. ) {
  3116. $configSource->addRepository('packagist.org', false);
  3117. } else {
  3118. $configSource->addRepository($name, $repoConfig, false);
  3119. }
  3120. $composer = Factory::create($io, null, $disablePlugins);
  3121. }
  3122. }
  3123. $process = new ProcessExecutor($io);
  3124. $fs = new Filesystem($process);
  3125. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  3126. $config = $composer->getConfig();
  3127. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  3128. if ($noInstall === false) {
  3129. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  3130. $installer = Installer::create($io, $composer);
  3131. $installer->setPreferSource($preferSource)
  3132. ->setPreferDist($preferDist)
  3133. ->setDevMode($installDevPackages)
  3134. ->setPlatformRequirementFilter($platformRequirementFilter)
  3135. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  3136. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  3137. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  3138. ->setApcuAutoloader($config->get('apcu-autoloader'));
  3139. if (!$composer->getLocker()->isLocked()) {
  3140. $installer->setUpdate(true);
  3141. }
  3142. if ($disablePlugins) {
  3143. $installer->disablePlugins();
  3144. }
  3145. $status = $installer->run();
  3146. if (0 !== $status) {
  3147. return $status;
  3148. }
  3149. }
  3150. $hasVcs = $installedFromVcs;
  3151. if (
  3152. !$input->getOption('keep-vcs')
  3153. && $installedFromVcs
  3154. && (
  3155. $input->getOption('remove-vcs')
  3156. || !$io->isInteractive()
  3157. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  3158. )
  3159. ) {
  3160. $finder = new Finder();
  3161. $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
  3162. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  3163. $finder->name($vcsName);
  3164. }
  3165. try {
  3166. $dirs = iterator_to_array($finder);
  3167. unset($finder);
  3168. foreach ($dirs as $dir) {
  3169. if (!$fs->removeDirectory($dir)) {
  3170. throw new \RuntimeException('Could not remove '.$dir);
  3171. }
  3172. }
  3173. } catch (\Exception $e) {
  3174. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  3175. }
  3176. $hasVcs = false;
  3177. }
  3178. if (!$hasVcs) {
  3179. $package = $composer->getPackage();
  3180. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  3181. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  3182. foreach ($package->{'get'.$meta['method']}() as $link) {
  3183. if ($link->getPrettyConstraint() === 'self.version') {
  3184. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  3185. }
  3186. }
  3187. }
  3188. }
  3189. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  3190. chdir($oldCwd);
  3191. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  3192. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  3193. Silencer::call('rmdir', $vendorComposerDir);
  3194. $vendorDir = $config->get('vendor-dir');
  3195. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  3196. Silencer::call('rmdir', $vendorDir);
  3197. }
  3198. }
  3199. return 0;
  3200. }
  3201. protected function installRootPackage(IOInterface $io, Config $config, $packageName, PlatformRequirementFilterInterface $platformRequirementFilter, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, array $repositories = null, $disablePlugins = false, $disableScripts = false, $noProgress = false, $secureHttp = true)
  3202. {
  3203. if (!$secureHttp) {
  3204. $config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);
  3205. }
  3206. $parser = new VersionParser();
  3207. $requirements = $parser->parseNameVersionPairs(array($packageName));
  3208. $name = strtolower($requirements[0]['name']);
  3209. if (!$packageVersion && isset($requirements[0]['version'])) {
  3210. $packageVersion = $requirements[0]['version'];
  3211. }
  3212. if (null === $directory) {
  3213. $parts = explode("/", $name, 2);
  3214. $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  3215. }
  3216. $process = new ProcessExecutor($io);
  3217. $fs = new Filesystem($process);
  3218. if (!$fs->isAbsolutePath($directory)) {
  3219. $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
  3220. }
  3221. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
  3222. if (file_exists($directory)) {
  3223. if (!is_dir($directory)) {
  3224. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  3225. }
  3226. if (!$fs->isDirEmpty($directory)) {
  3227. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  3228. }
  3229. }
  3230. if (null === $stability) {
  3231. if (null === $packageVersion) {
  3232. $stability = 'stable';
  3233. } elseif (Preg::isMatch('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  3234. $stability = $match[1];
  3235. } else {
  3236. $stability = VersionParser::parseStability($packageVersion);
  3237. }
  3238. }
  3239. $stability = VersionParser::normalizeStability($stability);
  3240. if (!isset(BasePackage::$stabilities[$stability])) {
  3241. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  3242. }
  3243. $composer = Factory::create($io, $config->all(), $disablePlugins);
  3244. $config = $composer->getConfig();
  3245. $rm = $composer->getRepositoryManager();
  3246. $repositorySet = new RepositorySet($stability);
  3247. if (null === $repositories) {
  3248. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  3249. } else {
  3250. foreach ($repositories as $repo) {
  3251. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  3252. if (
  3253. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  3254. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  3255. ) {
  3256. continue;
  3257. }
  3258. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  3259. }
  3260. }
  3261. $platformOverrides = $config->get('platform') ?: array();
  3262. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3263. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  3264. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $platformRequirementFilter);
  3265. if (!$package) {
  3266. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  3267. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && $versionSelector->findBestCandidate($name, $packageVersion, $stability, PlatformRequirementFilterFactory::ignoreAll())) {
  3268. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  3269. }
  3270. throw new \InvalidArgumentException($errorMessage .'.');
  3271. }
  3272. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  3273. @mkdir($directory, 0777, true);
  3274. if ($realDir = realpath($directory)) {
  3275. pcntl_async_signals(true);
  3276. pcntl_signal(SIGINT, function () use ($realDir) {
  3277. $fs = new Filesystem();
  3278. $fs->removeDirectory($realDir);
  3279. exit(130);
  3280. });
  3281. }
  3282. }
  3283. if (function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli') {
  3284. @mkdir($directory, 0777, true);
  3285. if ($realDir = realpath($directory)) {
  3286. sapi_windows_set_ctrl_handler(function () use ($realDir) {
  3287. $fs = new Filesystem();
  3288. $fs->removeDirectory($realDir);
  3289. exit(130);
  3290. });
  3291. }
  3292. }
  3293. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  3294. $package = $package->getAliasOf();
  3295. }
  3296. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  3297. if ($disablePlugins) {
  3298. $io->writeError('<info>Plugins have been disabled.</info>');
  3299. }
  3300. if ($package instanceof AliasPackage) {
  3301. $package = $package->getAliasOf();
  3302. }
  3303. $dm = $composer->getDownloadManager();
  3304. $dm->setPreferSource($preferSource)
  3305. ->setPreferDist($preferDist);
  3306. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  3307. $im = $composer->getInstallationManager();
  3308. $im->setOutputProgress(!$noProgress);
  3309. $im->addInstaller($projectInstaller);
  3310. $im->execute(new InstalledArrayRepository(), array(new InstallOperation($package)));
  3311. $im->notifyInstalls($io);
  3312. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  3313. $installedFromVcs = 'source' === $package->getInstallationSource();
  3314. $io->writeError('<info>Created project in ' . $directory . '</info>');
  3315. chdir($directory);
  3316. Platform::putEnv('COMPOSER_ROOT_VERSION', $package->getPrettyVersion());
  3317. return $installedFromVcs;
  3318. }
  3319. }
  3320. <?php
  3321. namespace Composer\Command;
  3322. use Symfony\Component\Console\Input\InputInterface;
  3323. use Symfony\Component\Console\Output\OutputInterface;
  3324. use Symfony\Component\Console\Input\InputArgument;
  3325. use Symfony\Component\Console\Input\InputOption;
  3326. class DependsCommand extends BaseDependencyCommand
  3327. {
  3328. protected function configure()
  3329. {
  3330. $this
  3331. ->setName('depends')
  3332. ->setAliases(array('why'))
  3333. ->setDescription('Shows which packages cause the given package to be installed.')
  3334. ->setDefinition(array(
  3335. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  3336. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  3337. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  3338. ))
  3339. ->setHelp(
  3340. <<<EOT
  3341. Displays detailed information about where a package is referenced.
  3342. <info>php composer.phar depends composer/composer</info>
  3343. Read more at https://getcomposer.org/doc/03-cli.md#depends-why-
  3344. EOT
  3345. )
  3346. ;
  3347. }
  3348. protected function execute(InputInterface $input, OutputInterface $output)
  3349. {
  3350. return parent::doExecute($input, $output);
  3351. }
  3352. }
  3353. <?php
  3354. namespace Composer\Command;
  3355. use Composer\Composer;
  3356. use Composer\Factory;
  3357. use Composer\Config;
  3358. use Composer\Downloader\TransportException;
  3359. use Composer\Pcre\Preg;
  3360. use Composer\Repository\PlatformRepository;
  3361. use Composer\Plugin\CommandEvent;
  3362. use Composer\Plugin\PluginEvents;
  3363. use Composer\Util\ConfigValidator;
  3364. use Composer\Util\IniHelper;
  3365. use Composer\Util\ProcessExecutor;
  3366. use Composer\Util\HttpDownloader;
  3367. use Composer\Util\StreamContextFactory;
  3368. use Composer\Util\Platform;
  3369. use Composer\SelfUpdate\Keys;
  3370. use Composer\SelfUpdate\Versions;
  3371. use Composer\IO\NullIO;
  3372. use Composer\Package\CompletePackageInterface;
  3373. use Composer\XdebugHandler\XdebugHandler;
  3374. use Symfony\Component\Console\Input\InputInterface;
  3375. use Symfony\Component\Console\Output\OutputInterface;
  3376. use Symfony\Component\Process\ExecutableFinder;
  3377. class DiagnoseCommand extends BaseCommand
  3378. {
  3379. protected $httpDownloader;
  3380. protected $process;
  3381. protected $exitCode = 0;
  3382. protected function configure()
  3383. {
  3384. $this
  3385. ->setName('diagnose')
  3386. ->setDescription('Diagnoses the system to identify common errors.')
  3387. ->setHelp(
  3388. <<<EOT
  3389. The <info>diagnose</info> command checks common errors to help debugging problems.
  3390. The process exit code will be 1 in case of warnings and 2 for errors.
  3391. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  3392. EOT
  3393. )
  3394. ;
  3395. }
  3396. protected function execute(InputInterface $input, OutputInterface $output)
  3397. {
  3398. $composer = $this->getComposer(false);
  3399. $io = $this->getIO();
  3400. if ($composer) {
  3401. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  3402. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3403. $io->write('Checking composer.json: ', false);
  3404. $this->outputResult($this->checkComposerSchema());
  3405. }
  3406. if ($composer) {
  3407. $config = $composer->getConfig();
  3408. } else {
  3409. $config = Factory::createConfig();
  3410. }
  3411. $config->merge(array('config' => array('secure-http' => false)), Config::SOURCE_COMMAND);
  3412. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  3413. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  3414. $this->process = new ProcessExecutor($io);
  3415. $io->write('Checking platform settings: ', false);
  3416. $this->outputResult($this->checkPlatform());
  3417. $io->write('Checking git settings: ', false);
  3418. $this->outputResult($this->checkGit());
  3419. $io->write('Checking http connectivity to packagist: ', false);
  3420. $this->outputResult($this->checkHttp('http', $config));
  3421. $io->write('Checking https connectivity to packagist: ', false);
  3422. $this->outputResult($this->checkHttp('https', $config));
  3423. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  3424. if (!empty($opts['http']['proxy'])) {
  3425. $io->write('Checking HTTP proxy: ', false);
  3426. $this->outputResult($this->checkHttpProxy());
  3427. }
  3428. if ($oauth = $config->get('github-oauth')) {
  3429. foreach ($oauth as $domain => $token) {
  3430. $io->write('Checking '.$domain.' oauth access: ', false);
  3431. $this->outputResult($this->checkGithubOauth($domain, $token));
  3432. }
  3433. } else {
  3434. $io->write('Checking github.com rate limit: ', false);
  3435. try {
  3436. $rate = $this->getGithubRateLimit('github.com');
  3437. if (!is_array($rate)) {
  3438. $this->outputResult($rate);
  3439. } elseif (10 > $rate['remaining']) {
  3440. $io->write('<warning>WARNING</warning>');
  3441. $io->write(sprintf(
  3442. '<comment>Github has a rate limit on their API. '
  3443. . 'You currently have <options=bold>%u</options=bold> '
  3444. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  3445. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  3446. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  3447. $rate['remaining'],
  3448. $rate['limit']
  3449. ));
  3450. } else {
  3451. $this->outputResult(true);
  3452. }
  3453. } catch (\Exception $e) {
  3454. if ($e instanceof TransportException && $e->getCode() === 401) {
  3455. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  3456. } else {
  3457. $this->outputResult($e);
  3458. }
  3459. }
  3460. }
  3461. $io->write('Checking disk free space: ', false);
  3462. $this->outputResult($this->checkDiskSpace($config));
  3463. if (strpos(__FILE__, 'phar:') === 0) {
  3464. $io->write('Checking pubkeys: ', false);
  3465. $this->outputResult($this->checkPubKeys($config));
  3466. $io->write('Checking composer version: ', false);
  3467. $this->outputResult($this->checkVersion($config));
  3468. }
  3469. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  3470. $platformOverrides = $config->get('platform') ?: array();
  3471. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3472. $phpPkg = $platformRepo->findPackage('php', '*');
  3473. $phpVersion = $phpPkg->getPrettyVersion();
  3474. if ($phpPkg instanceof CompletePackageInterface && false !== strpos($phpPkg->getDescription(), 'overridden')) {
  3475. $phpVersion .= ' - ' . $phpPkg->getDescription();
  3476. }
  3477. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  3478. if (defined('PHP_BINARY')) {
  3479. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  3480. }
  3481. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  3482. $io->write('cURL version: ' . $this->getCurlVersion());
  3483. $finder = new ExecutableFinder;
  3484. $hasSystemUnzip = (bool) $finder->find('unzip');
  3485. $bin7zip = '';
  3486. if ($hasSystem7zip = (bool) $finder->find('7z', null, array('C:\Program Files\7-Zip'))) {
  3487. $bin7zip = '7z';
  3488. }
  3489. if (!Platform::isWindows() && !$hasSystem7zip && $hasSystem7zip = (bool) $finder->find('7zz')) {
  3490. $bin7zip = '7zz';
  3491. }
  3492. $io->write(
  3493. 'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
  3494. . ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
  3495. . ', ' . ($hasSystem7zip ? '<comment>7-Zip present ('.$bin7zip.')</comment>' : '<comment>7-Zip not available</comment>')
  3496. . (($hasSystem7zip || $hasSystemUnzip) && !function_exists('proc_open') ? ', <warning>proc_open is disabled or not present, unzip/7-z will not be usable</warning>' : '')
  3497. );
  3498. return $this->exitCode;
  3499. }
  3500. private function checkComposerSchema()
  3501. {
  3502. $validator = new ConfigValidator($this->getIO());
  3503. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  3504. if ($errors || $warnings) {
  3505. $messages = array(
  3506. 'error' => $errors,
  3507. 'warning' => $warnings,
  3508. );
  3509. $output = '';
  3510. foreach ($messages as $style => $msgs) {
  3511. foreach ($msgs as $msg) {
  3512. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  3513. }
  3514. }
  3515. return rtrim($output);
  3516. }
  3517. return true;
  3518. }
  3519. private function checkGit()
  3520. {
  3521. if (!function_exists('proc_open')) {
  3522. return '<comment>proc_open is not available, git cannot be used</comment>';
  3523. }
  3524. $this->process->execute('git config color.ui', $output);
  3525. if (strtolower(trim($output)) === 'always') {
  3526. 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>';
  3527. }
  3528. return true;
  3529. }
  3530. private function checkHttp($proto, Config $config)
  3531. {
  3532. $result = $this->checkConnectivity();
  3533. if ($result !== true) {
  3534. return $result;
  3535. }
  3536. $result = array();
  3537. if ($proto === 'https' && $config->get('disable-tls') === true) {
  3538. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  3539. }
  3540. try {
  3541. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  3542. } catch (TransportException $e) {
  3543. if ($hints = HttpDownloader::getExceptionHints($e)) {
  3544. foreach ($hints as $hint) {
  3545. $result[] = $hint;
  3546. }
  3547. }
  3548. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  3549. }
  3550. if (isset($tlsWarning)) {
  3551. $result[] = $tlsWarning;
  3552. }
  3553. if (count($result) > 0) {
  3554. return $result;
  3555. }
  3556. return true;
  3557. }
  3558. private function checkHttpProxy()
  3559. {
  3560. $result = $this->checkConnectivity();
  3561. if ($result !== true) {
  3562. return $result;
  3563. }
  3564. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  3565. try {
  3566. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  3567. $hash = reset($json['provider-includes']);
  3568. $hash = $hash['sha256'];
  3569. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  3570. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  3571. if (hash('sha256', $provider) !== $hash) {
  3572. return 'It seems that your proxy is modifying http traffic on the fly';
  3573. }
  3574. } catch (\Exception $e) {
  3575. return $e;
  3576. }
  3577. return true;
  3578. }
  3579. private function checkGithubOauth($domain, $token)
  3580. {
  3581. $result = $this->checkConnectivity();
  3582. if ($result !== true) {
  3583. return $result;
  3584. }
  3585. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3586. try {
  3587. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  3588. $this->httpDownloader->get($url, array(
  3589. 'retry-auth-failure' => false,
  3590. ));
  3591. return true;
  3592. } catch (\Exception $e) {
  3593. if ($e instanceof TransportException && $e->getCode() === 401) {
  3594. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  3595. }
  3596. return $e;
  3597. }
  3598. }
  3599. private function getGithubRateLimit($domain, $token = null)
  3600. {
  3601. $result = $this->checkConnectivity();
  3602. if ($result !== true) {
  3603. return $result;
  3604. }
  3605. if ($token) {
  3606. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3607. }
  3608. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  3609. $data = $this->httpDownloader->get($url, array('retry-auth-failure' => false))->decodeJson();
  3610. return $data['resources']['core'];
  3611. }
  3612. private function checkDiskSpace(Config $config)
  3613. {
  3614. $minSpaceFree = 1024 * 1024;
  3615. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  3616. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  3617. ) {
  3618. return '<error>The disk hosting '.$dir.' is full</error>';
  3619. }
  3620. return true;
  3621. }
  3622. private function checkPubKeys(Config $config)
  3623. {
  3624. $home = $config->get('home');
  3625. $errors = array();
  3626. $io = $this->getIO();
  3627. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  3628. $io->write('');
  3629. }
  3630. if (file_exists($home.'/keys.tags.pub')) {
  3631. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  3632. } else {
  3633. $errors[] = '<error>Missing pubkey for tags verification</error>';
  3634. }
  3635. if (file_exists($home.'/keys.dev.pub')) {
  3636. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  3637. } else {
  3638. $errors[] = '<error>Missing pubkey for dev verification</error>';
  3639. }
  3640. if ($errors) {
  3641. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  3642. }
  3643. return $errors ?: true;
  3644. }
  3645. private function checkVersion(Config $config)
  3646. {
  3647. $result = $this->checkConnectivity();
  3648. if ($result !== true) {
  3649. return $result;
  3650. }
  3651. $versionsUtil = new Versions($config, $this->httpDownloader);
  3652. try {
  3653. $latest = $versionsUtil->getLatest();
  3654. } catch (\Exception $e) {
  3655. return $e;
  3656. }
  3657. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  3658. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  3659. }
  3660. return true;
  3661. }
  3662. private function getCurlVersion()
  3663. {
  3664. if (extension_loaded('curl')) {
  3665. if (!HttpDownloader::isCurlEnabled()) {
  3666. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  3667. }
  3668. $version = curl_version();
  3669. return '<comment>'.$version['version'].'</comment> '.
  3670. 'libz <comment>'.(!empty($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  3671. 'ssl <comment>'.(isset($version['ssl_version']) ? $version['ssl_version'] : 'missing').'</comment>';
  3672. }
  3673. return '<error>missing, using php streams fallback, which reduces performance</error>';
  3674. }
  3675. private function outputResult($result)
  3676. {
  3677. $io = $this->getIO();
  3678. if (true === $result) {
  3679. $io->write('<info>OK</info>');
  3680. return;
  3681. }
  3682. $hadError = false;
  3683. $hadWarning = false;
  3684. if ($result instanceof \Exception) {
  3685. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  3686. }
  3687. if (!$result) {
  3688. $hadError = true;
  3689. } else {
  3690. if (!is_array($result)) {
  3691. $result = array($result);
  3692. }
  3693. foreach ($result as $message) {
  3694. if (false !== strpos($message, '<error>')) {
  3695. $hadError = true;
  3696. } elseif (false !== strpos($message, '<warning>')) {
  3697. $hadWarning = true;
  3698. }
  3699. }
  3700. }
  3701. if ($hadError) {
  3702. $io->write('<error>FAIL</error>');
  3703. $this->exitCode = max($this->exitCode, 2);
  3704. } elseif ($hadWarning) {
  3705. $io->write('<warning>WARNING</warning>');
  3706. $this->exitCode = max($this->exitCode, 1);
  3707. }
  3708. if ($result) {
  3709. foreach ($result as $message) {
  3710. $io->write($message);
  3711. }
  3712. }
  3713. }
  3714. private function checkPlatform()
  3715. {
  3716. $output = '';
  3717. $out = function ($msg, $style) use (&$output) {
  3718. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  3719. };
  3720. $errors = array();
  3721. $warnings = array();
  3722. $displayIniMessage = false;
  3723. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  3724. $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.';
  3725. if (!function_exists('json_decode')) {
  3726. $errors['json'] = true;
  3727. }
  3728. if (!extension_loaded('Phar')) {
  3729. $errors['phar'] = true;
  3730. }
  3731. if (!extension_loaded('filter')) {
  3732. $errors['filter'] = true;
  3733. }
  3734. if (!extension_loaded('hash')) {
  3735. $errors['hash'] = true;
  3736. }
  3737. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  3738. $errors['iconv_mbstring'] = true;
  3739. }
  3740. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  3741. $errors['allow_url_fopen'] = true;
  3742. }
  3743. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  3744. $errors['ioncube'] = ioncube_loader_version();
  3745. }
  3746. if (PHP_VERSION_ID < 50302) {
  3747. $errors['php'] = PHP_VERSION;
  3748. }
  3749. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  3750. $warnings['php'] = PHP_VERSION;
  3751. }
  3752. if (!extension_loaded('openssl')) {
  3753. $errors['openssl'] = true;
  3754. }
  3755. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  3756. $warnings['openssl_version'] = true;
  3757. }
  3758. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  3759. $warnings['apc_cli'] = true;
  3760. }
  3761. if (!extension_loaded('zlib')) {
  3762. $warnings['zlib'] = true;
  3763. }
  3764. ob_start();
  3765. phpinfo(INFO_GENERAL);
  3766. $phpinfo = ob_get_clean();
  3767. if (Preg::isMatch('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  3768. $configure = $match[1];
  3769. if (false !== strpos($configure, '--enable-sigchild')) {
  3770. $warnings['sigchild'] = true;
  3771. }
  3772. if (false !== strpos($configure, '--with-curlwrappers')) {
  3773. $warnings['curlwrappers'] = true;
  3774. }
  3775. }
  3776. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  3777. $warnings['xdebug_profile'] = true;
  3778. } elseif (XdebugHandler::isXdebugActive()) {
  3779. $warnings['xdebug_loaded'] = true;
  3780. }
  3781. if (defined('PHP_WINDOWS_VERSION_BUILD')
  3782. && (version_compare(PHP_VERSION, '7.2.23', '<')
  3783. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  3784. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  3785. $warnings['onedrive'] = PHP_VERSION;
  3786. }
  3787. if (!empty($errors)) {
  3788. foreach ($errors as $error => $current) {
  3789. switch ($error) {
  3790. case 'json':
  3791. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  3792. $text .= "Install it or recompile php without --disable-json";
  3793. break;
  3794. case 'phar':
  3795. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3796. $text .= "Install it or recompile php without --disable-phar";
  3797. break;
  3798. case 'filter':
  3799. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3800. $text .= "Install it or recompile php without --disable-filter";
  3801. break;
  3802. case 'hash':
  3803. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3804. $text .= "Install it or recompile php without --disable-hash";
  3805. break;
  3806. case 'iconv_mbstring':
  3807. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3808. $text .= "Install either of them or recompile php without --disable-iconv";
  3809. break;
  3810. case 'php':
  3811. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  3812. break;
  3813. case 'allow_url_fopen':
  3814. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3815. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3816. $text .= " allow_url_fopen = On";
  3817. $displayIniMessage = true;
  3818. break;
  3819. case 'ioncube':
  3820. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3821. $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;
  3822. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3823. $displayIniMessage = true;
  3824. break;
  3825. case 'openssl':
  3826. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3827. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3828. break;
  3829. default:
  3830. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  3831. }
  3832. $out($text, 'error');
  3833. }
  3834. $output .= PHP_EOL;
  3835. }
  3836. if (!empty($warnings)) {
  3837. foreach ($warnings as $warning => $current) {
  3838. switch ($warning) {
  3839. case 'apc_cli':
  3840. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3841. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3842. $text .= " apc.enable_cli = Off";
  3843. $displayIniMessage = true;
  3844. break;
  3845. case 'zlib':
  3846. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3847. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3848. $displayIniMessage = true;
  3849. break;
  3850. case 'sigchild':
  3851. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3852. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3853. $text .= " https://bugs.php.net/bug.php?id=22999";
  3854. break;
  3855. case 'curlwrappers':
  3856. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3857. $text .= " Recompile it without this flag if possible";
  3858. break;
  3859. case 'php':
  3860. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  3861. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  3862. break;
  3863. case 'openssl_version':
  3864. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3865. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3866. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3867. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3868. break;
  3869. case 'xdebug_loaded':
  3870. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3871. $text .= " Disabling it when using Composer is recommended.";
  3872. break;
  3873. case 'xdebug_profile':
  3874. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3875. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3876. $text .= " xdebug.profiler_enabled = 0";
  3877. $displayIniMessage = true;
  3878. break;
  3879. case 'onedrive':
  3880. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  3881. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  3882. break;
  3883. default:
  3884. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  3885. }
  3886. $out($text, 'comment');
  3887. }
  3888. }
  3889. if ($displayIniMessage) {
  3890. $out($iniMessage, 'comment');
  3891. }
  3892. return !$warnings && !$errors ? true : $output;
  3893. }
  3894. private function checkConnectivity()
  3895. {
  3896. if (!ini_get('allow_url_fopen')) {
  3897. return '<info>Skipped because allow_url_fopen is missing.</info>';
  3898. }
  3899. return true;
  3900. }
  3901. }
  3902. <?php
  3903. namespace Composer\Command;
  3904. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  3905. use Composer\Plugin\CommandEvent;
  3906. use Composer\Plugin\PluginEvents;
  3907. use Symfony\Component\Console\Input\InputInterface;
  3908. use Symfony\Component\Console\Input\InputOption;
  3909. use Symfony\Component\Console\Output\OutputInterface;
  3910. class DumpAutoloadCommand extends BaseCommand
  3911. {
  3912. protected function configure()
  3913. {
  3914. $this
  3915. ->setName('dump-autoload')
  3916. ->setAliases(array('dumpautoload'))
  3917. ->setDescription('Dumps the autoloader.')
  3918. ->setDefinition(array(
  3919. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3920. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3921. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3922. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  3923. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
  3924. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules. Composer will by default infer this automatically according to the last install or update --no-dev state.'),
  3925. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3926. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3927. ))
  3928. ->setHelp(
  3929. <<<EOT
  3930. <info>php composer.phar dump-autoload</info>
  3931. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
  3932. EOT
  3933. )
  3934. ;
  3935. }
  3936. protected function execute(InputInterface $input, OutputInterface $output)
  3937. {
  3938. $composer = $this->getComposer();
  3939. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3940. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3941. $installationManager = $composer->getInstallationManager();
  3942. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3943. $package = $composer->getPackage();
  3944. $config = $composer->getConfig();
  3945. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3946. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3947. $apcuPrefix = $input->getOption('apcu-prefix');
  3948. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  3949. if ($authoritative) {
  3950. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  3951. } elseif ($optimize) {
  3952. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  3953. } else {
  3954. $this->getIO()->write('<info>Generating autoload files</info>');
  3955. }
  3956. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  3957. $generator = $composer->getAutoloadGenerator();
  3958. if ($input->getOption('no-dev')) {
  3959. $generator->setDevMode(false);
  3960. }
  3961. if ($input->getOption('dev')) {
  3962. if ($input->getOption('no-dev')) {
  3963. throw new \InvalidArgumentException('You can not use both --no-dev and --dev as they conflict with each other.');
  3964. }
  3965. $generator->setDevMode(true);
  3966. }
  3967. $generator->setClassMapAuthoritative($authoritative);
  3968. $generator->setRunScripts(true);
  3969. $generator->setApcu($apcu, $apcuPrefix);
  3970. $generator->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  3971. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3972. if ($authoritative) {
  3973. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3974. } elseif ($optimize) {
  3975. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3976. } else {
  3977. $this->getIO()->write('<info>Generated autoload files</info>');
  3978. }
  3979. return 0;
  3980. }
  3981. }
  3982. <?php
  3983. namespace Composer\Command;
  3984. use Symfony\Component\Console\Input\InputInterface;
  3985. use Symfony\Component\Console\Input\InputOption;
  3986. use Symfony\Component\Console\Output\OutputInterface;
  3987. use Symfony\Component\Console\Input\InputArgument;
  3988. class ExecCommand extends BaseCommand
  3989. {
  3990. protected function configure()
  3991. {
  3992. $this
  3993. ->setName('exec')
  3994. ->setDescription('Executes a vendored binary/script.')
  3995. ->setDefinition(array(
  3996. new InputOption('list', 'l', InputOption::VALUE_NONE),
  3997. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  3998. new InputArgument(
  3999. 'args',
  4000. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  4001. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  4002. ),
  4003. ))
  4004. ->setHelp(
  4005. <<<EOT
  4006. Executes a vendored binary/script.
  4007. Read more at https://getcomposer.org/doc/03-cli.md#exec
  4008. EOT
  4009. )
  4010. ;
  4011. }
  4012. protected function execute(InputInterface $input, OutputInterface $output)
  4013. {
  4014. $composer = $this->getComposer();
  4015. $binDir = $composer->getConfig()->get('bin-dir');
  4016. if ($input->getOption('list') || !$input->getArgument('binary')) {
  4017. $bins = glob($binDir . '/*');
  4018. $bins = array_merge($bins, array_map(function ($e) {
  4019. return "$e (local)";
  4020. }, $composer->getPackage()->getBinaries()));
  4021. if (!$bins) {
  4022. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  4023. }
  4024. $this->getIO()->write(
  4025. <<<EOT
  4026. <comment>Available binaries:</comment>
  4027. EOT
  4028. );
  4029. foreach ($bins as $bin) {
  4030. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  4031. continue;
  4032. }
  4033. $previousBin = $bin;
  4034. $bin = basename($bin);
  4035. $this->getIO()->write(
  4036. <<<EOT
  4037. <info>- $bin</info>
  4038. EOT
  4039. );
  4040. }
  4041. return 0;
  4042. }
  4043. $binary = $input->getArgument('binary');
  4044. $dispatcher = $composer->getEventDispatcher();
  4045. $dispatcher->addListener('__exec_command', $binary);
  4046. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {
  4047. try {
  4048. chdir($this->getApplication()->getInitialWorkingDirectory());
  4049. } catch (\Exception $e) {
  4050. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  4051. }
  4052. }
  4053. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  4054. }
  4055. }
  4056. <?php
  4057. namespace Composer\Command;
  4058. use Composer\Json\JsonFile;
  4059. use Composer\Package\AliasPackage;
  4060. use Composer\Package\BasePackage;
  4061. use Composer\Package\CompletePackageInterface;
  4062. use Composer\Pcre\Preg;
  4063. use Composer\Repository\CompositeRepository;
  4064. use Composer\Semver\Constraint\MatchAllConstraint;
  4065. use Symfony\Component\Console\Input\InputInterface;
  4066. use Symfony\Component\Console\Input\InputOption;
  4067. use Symfony\Component\Console\Output\OutputInterface;
  4068. class FundCommand extends BaseCommand
  4069. {
  4070. protected function configure()
  4071. {
  4072. $this->setName('fund')
  4073. ->setDescription('Discover how to help fund the maintenance of your dependencies.')
  4074. ->setDefinition(array(
  4075. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4076. ))
  4077. ;
  4078. }
  4079. protected function execute(InputInterface $input, OutputInterface $output)
  4080. {
  4081. $composer = $this->getComposer();
  4082. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4083. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  4084. $fundings = array();
  4085. $packagesToLoad = array();
  4086. foreach ($repo->getPackages() as $package) {
  4087. if ($package instanceof AliasPackage) {
  4088. continue;
  4089. }
  4090. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  4091. }
  4092. $result = $remoteRepos->loadPackages($packagesToLoad, array('dev' => BasePackage::STABILITY_DEV), array());
  4093. foreach ($result['packages'] as $package) {
  4094. if (
  4095. !$package instanceof AliasPackage
  4096. && $package instanceof CompletePackageInterface
  4097. && $package->isDefaultBranch()
  4098. && $package->getFunding()
  4099. && isset($packagesToLoad[$package->getName()])
  4100. ) {
  4101. $fundings = $this->insertFundingData($fundings, $package);
  4102. unset($packagesToLoad[$package->getName()]);
  4103. }
  4104. }
  4105. foreach ($repo->getPackages() as $package) {
  4106. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  4107. continue;
  4108. }
  4109. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  4110. $fundings = $this->insertFundingData($fundings, $package);
  4111. }
  4112. }
  4113. ksort($fundings);
  4114. $io = $this->getIO();
  4115. $format = $input->getOption('format');
  4116. if (!in_array($format, array('text', 'json'))) {
  4117. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4118. return 1;
  4119. }
  4120. if ($fundings && $format === 'text') {
  4121. $prev = null;
  4122. $io->write('The following packages were found in your dependencies which publish funding information:');
  4123. foreach ($fundings as $vendor => $links) {
  4124. $io->write('');
  4125. $io->write(sprintf("<comment>%s</comment>", $vendor));
  4126. foreach ($links as $url => $packages) {
  4127. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  4128. if ($prev !== $line) {
  4129. $io->write($line);
  4130. $prev = $line;
  4131. }
  4132. $io->write(sprintf(' %s', $url));
  4133. }
  4134. }
  4135. $io->write("");
  4136. $io->write("Please consider following these links and sponsoring the work of package authors!");
  4137. $io->write("Thank you!");
  4138. } elseif ($format === 'json') {
  4139. $io->write(JsonFile::encode($fundings));
  4140. } else {
  4141. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  4142. }
  4143. return 0;
  4144. }
  4145. private function insertFundingData(array $fundings, CompletePackageInterface $package)
  4146. {
  4147. foreach ($package->getFunding() as $fundingOption) {
  4148. list($vendor, $packageName) = explode('/', $package->getPrettyName());
  4149. if (empty($fundingOption['url'])) {
  4150. continue;
  4151. }
  4152. $url = $fundingOption['url'];
  4153. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && Preg::isMatch('{^https://github.com/([^/]+)$}', $url, $match)) {
  4154. $url = 'https://github.com/sponsors/'.$match[1];
  4155. }
  4156. $fundings[$vendor][$url][] = $packageName;
  4157. }
  4158. return $fundings;
  4159. }
  4160. }
  4161. <?php
  4162. namespace Composer\Command;
  4163. use Composer\Factory;
  4164. use Composer\Pcre\Preg;
  4165. use Composer\Util\Filesystem;
  4166. use Composer\Util\Platform;
  4167. use Symfony\Component\Console\Input\InputInterface;
  4168. use Symfony\Component\Console\Input\InputArgument;
  4169. use Symfony\Component\Console\Input\StringInput;
  4170. use Symfony\Component\Console\Output\OutputInterface;
  4171. class GlobalCommand extends BaseCommand
  4172. {
  4173. protected function configure()
  4174. {
  4175. $this
  4176. ->setName('global')
  4177. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  4178. ->setDefinition(array(
  4179. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  4180. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  4181. ))
  4182. ->setHelp(
  4183. <<<EOT
  4184. Use this command as a wrapper to run other Composer commands
  4185. within the global context of COMPOSER_HOME.
  4186. You can use this to install CLI utilities globally, all you need
  4187. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  4188. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  4189. and /home/<user>/.composer on unix systems.
  4190. If your system uses freedesktop.org standards, then it will first check
  4191. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  4192. Note: This path may vary depending on customizations to bin-dir in
  4193. composer.json or the environmental variable COMPOSER_BIN_DIR.
  4194. Read more at https://getcomposer.org/doc/03-cli.md#global
  4195. EOT
  4196. )
  4197. ;
  4198. }
  4199. public function run(InputInterface $input, OutputInterface $output)
  4200. {
  4201. if (!method_exists($input, '__toString')) {
  4202. throw new \LogicException('Expected an Input instance that is stringable, got '.get_class($input));
  4203. }
  4204. $tokens = Preg::split('{\s+}', $input->__toString());
  4205. $args = array();
  4206. foreach ($tokens as $token) {
  4207. if ($token && $token[0] !== '-') {
  4208. $args[] = $token;
  4209. if (count($args) >= 2) {
  4210. break;
  4211. }
  4212. }
  4213. }
  4214. if (count($args) < 2) {
  4215. return parent::run($input, $output);
  4216. }
  4217. if (Platform::getEnv('COMPOSER')) {
  4218. Platform::clearEnv('COMPOSER');
  4219. }
  4220. $config = Factory::createConfig();
  4221. $home = $config->get('home');
  4222. if (!is_dir($home)) {
  4223. $fs = new Filesystem();
  4224. $fs->ensureDirectoryExists($home);
  4225. if (!is_dir($home)) {
  4226. throw new \RuntimeException('Could not create home directory');
  4227. }
  4228. }
  4229. try {
  4230. chdir($home);
  4231. } catch (\Exception $e) {
  4232. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  4233. }
  4234. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  4235. $input = new StringInput(Preg::replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  4236. $this->getApplication()->resetComposer();
  4237. return $this->getApplication()->run($input, $output);
  4238. }
  4239. public function isProxyCommand()
  4240. {
  4241. return true;
  4242. }
  4243. }
  4244. <?php
  4245. namespace Composer\Command;
  4246. use Composer\Package\CompletePackageInterface;
  4247. use Composer\Repository\RepositoryInterface;
  4248. use Composer\Repository\RootPackageRepository;
  4249. use Composer\Repository\RepositoryFactory;
  4250. use Composer\Util\Platform;
  4251. use Composer\Util\ProcessExecutor;
  4252. use Symfony\Component\Console\Input\InputArgument;
  4253. use Symfony\Component\Console\Input\InputOption;
  4254. use Symfony\Component\Console\Input\InputInterface;
  4255. use Symfony\Component\Console\Output\OutputInterface;
  4256. class HomeCommand extends BaseCommand
  4257. {
  4258. protected function configure()
  4259. {
  4260. $this
  4261. ->setName('browse')
  4262. ->setAliases(array('home'))
  4263. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  4264. ->setDefinition(array(
  4265. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  4266. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  4267. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  4268. ))
  4269. ->setHelp(
  4270. <<<EOT
  4271. The home command opens or shows a package's repository URL or
  4272. homepage in your default browser.
  4273. To open the homepage by default, use -H or --homepage.
  4274. To show instead of open the repository or homepage URL, use -s or --show.
  4275. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  4276. EOT
  4277. );
  4278. }
  4279. protected function execute(InputInterface $input, OutputInterface $output)
  4280. {
  4281. $repos = $this->initializeRepos();
  4282. $io = $this->getIO();
  4283. $return = 0;
  4284. $packages = $input->getArgument('packages');
  4285. if (!$packages) {
  4286. $io->writeError('No package specified, opening homepage for the root package');
  4287. $packages = array($this->getComposer()->getPackage()->getName());
  4288. }
  4289. foreach ($packages as $packageName) {
  4290. $handled = false;
  4291. $packageExists = false;
  4292. foreach ($repos as $repo) {
  4293. foreach ($repo->findPackages($packageName) as $package) {
  4294. $packageExists = true;
  4295. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  4296. $handled = true;
  4297. break 2;
  4298. }
  4299. }
  4300. }
  4301. if (!$packageExists) {
  4302. $return = 1;
  4303. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  4304. }
  4305. if (!$handled) {
  4306. $return = 1;
  4307. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  4308. }
  4309. }
  4310. return $return;
  4311. }
  4312. private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
  4313. {
  4314. $support = $package->getSupport();
  4315. $url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
  4316. if (!$url || $showHomepage) {
  4317. $url = $package->getHomepage();
  4318. }
  4319. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  4320. return false;
  4321. }
  4322. if ($showOnly) {
  4323. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  4324. } else {
  4325. $this->openBrowser($url);
  4326. }
  4327. return true;
  4328. }
  4329. private function openBrowser($url)
  4330. {
  4331. $url = ProcessExecutor::escape($url);
  4332. $process = new ProcessExecutor($this->getIO());
  4333. if (Platform::isWindows()) {
  4334. $process->execute('start "web" explorer ' . $url, $output);
  4335. return;
  4336. }
  4337. $linux = $process->execute('which xdg-open', $output);
  4338. $osx = $process->execute('which open', $output);
  4339. if (0 === $linux) {
  4340. $process->execute('xdg-open ' . $url, $output);
  4341. } elseif (0 === $osx) {
  4342. $process->execute('open ' . $url, $output);
  4343. } else {
  4344. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  4345. }
  4346. }
  4347. private function initializeRepos()
  4348. {
  4349. $composer = $this->getComposer(false);
  4350. if ($composer) {
  4351. return array_merge(
  4352. array(new RootPackageRepository($composer->getPackage())),
  4353. array($composer->getRepositoryManager()->getLocalRepository()),
  4354. $composer->getRepositoryManager()->getRepositories()
  4355. );
  4356. }
  4357. return RepositoryFactory::defaultRepos($this->getIO());
  4358. }
  4359. }
  4360. <?php
  4361. namespace Composer\Command;
  4362. use Composer\Factory;
  4363. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  4364. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  4365. use Composer\Json\JsonFile;
  4366. use Composer\Json\JsonValidationException;
  4367. use Composer\Package\BasePackage;
  4368. use Composer\Package\CompletePackageInterface;
  4369. use Composer\Package\Package;
  4370. use Composer\Package\PackageInterface;
  4371. use Composer\Package\Version\VersionParser;
  4372. use Composer\Package\Version\VersionSelector;
  4373. use Composer\Pcre\Preg;
  4374. use Composer\Repository\CompositeRepository;
  4375. use Composer\Repository\PlatformRepository;
  4376. use Composer\Repository\RepositoryFactory;
  4377. use Composer\Repository\RepositorySet;
  4378. use Composer\Util\Filesystem;
  4379. use Composer\Util\ProcessExecutor;
  4380. use Composer\Semver\Constraint\Constraint;
  4381. use Composer\Util\Silencer;
  4382. use Symfony\Component\Console\Input\ArrayInput;
  4383. use Symfony\Component\Console\Input\InputInterface;
  4384. use Symfony\Component\Console\Input\InputOption;
  4385. use Symfony\Component\Console\Output\OutputInterface;
  4386. use Symfony\Component\Process\ExecutableFinder;
  4387. use Symfony\Component\Process\Process;
  4388. use Symfony\Component\Console\Helper\FormatterHelper;
  4389. class InitCommand extends BaseCommand
  4390. {
  4391. protected $repos;
  4392. private $gitConfig;
  4393. private $repositorySets;
  4394. protected function configure()
  4395. {
  4396. $this
  4397. ->setName('init')
  4398. ->setDescription('Creates a basic composer.json file in current directory.')
  4399. ->setDefinition(array(
  4400. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  4401. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  4402. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  4403. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  4404. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  4405. 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"'),
  4406. 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"'),
  4407. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  4408. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  4409. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  4410. new InputOption('autoload', 'a', InputOption::VALUE_REQUIRED, 'Add PSR-4 autoload mapping. Maps your package\'s namespace to the provided directory. (Expects a relative path, e.g. src/)'),
  4411. ))
  4412. ->setHelp(
  4413. <<<EOT
  4414. The <info>init</info> command creates a basic composer.json file
  4415. in the current directory.
  4416. <info>php composer.phar init</info>
  4417. Read more at https://getcomposer.org/doc/03-cli.md#init
  4418. EOT
  4419. )
  4420. ;
  4421. }
  4422. protected function execute(InputInterface $input, OutputInterface $output)
  4423. {
  4424. $io = $this->getIO();
  4425. $allowlist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license', 'autoload');
  4426. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  4427. if (isset($options['name']) && !Preg::isMatch('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $options['name'])) {
  4428. throw new \InvalidArgumentException(
  4429. 'The package name '.$options['name'].' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
  4430. );
  4431. }
  4432. if (isset($options['author'])) {
  4433. $options['authors'] = $this->formatAuthors($options['author']);
  4434. unset($options['author']);
  4435. }
  4436. $repositories = $input->getOption('repository');
  4437. if ($repositories) {
  4438. $config = Factory::createConfig($io);
  4439. foreach ($repositories as $repo) {
  4440. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  4441. }
  4442. }
  4443. if (isset($options['stability'])) {
  4444. $options['minimum-stability'] = $options['stability'];
  4445. unset($options['stability']);
  4446. }
  4447. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  4448. if (array() === $options['require']) {
  4449. $options['require'] = new \stdClass;
  4450. }
  4451. if (isset($options['require-dev'])) {
  4452. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  4453. if (array() === $options['require-dev']) {
  4454. $options['require-dev'] = new \stdClass;
  4455. }
  4456. }
  4457. $autoloadPath = null;
  4458. if (isset($options['autoload'])) {
  4459. $autoloadPath = $options['autoload'];
  4460. $namespace = $this->namespaceFromPackageName($input->getOption('name'));
  4461. $options['autoload'] = (object) array(
  4462. 'psr-4' => array(
  4463. $namespace . '\\' => $autoloadPath,
  4464. ),
  4465. );
  4466. }
  4467. $file = new JsonFile(Factory::getComposerFile());
  4468. $json = JsonFile::encode($options);
  4469. if ($input->isInteractive()) {
  4470. $io->writeError(array('', $json, ''));
  4471. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  4472. $io->writeError('<error>Command aborted</error>');
  4473. return 1;
  4474. }
  4475. } else {
  4476. if (json_encode($options) === '{"require":{}}') {
  4477. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  4478. }
  4479. $io->writeError('Writing '.$file->getPath());
  4480. }
  4481. $file->write($options);
  4482. try {
  4483. $file->validateSchema(JsonFile::LAX_SCHEMA);
  4484. } catch (JsonValidationException $e) {
  4485. $io->writeError('<error>Schema validation error, aborting</error>');
  4486. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  4487. $io->writeError($e->getMessage() . ':' . PHP_EOL . $errors);
  4488. Silencer::call('unlink', $file->getPath());
  4489. return 1;
  4490. }
  4491. if ($autoloadPath) {
  4492. $filesystem = new Filesystem();
  4493. $filesystem->ensureDirectoryExists($autoloadPath);
  4494. if (!$this->hasDependencies($options)) {
  4495. $this->runDumpAutoloadCommand($output);
  4496. }
  4497. }
  4498. if ($input->isInteractive() && is_dir('.git')) {
  4499. $ignoreFile = realpath('.gitignore');
  4500. if (false === $ignoreFile) {
  4501. $ignoreFile = realpath('.') . '/.gitignore';
  4502. }
  4503. if (!$this->hasVendorIgnore($ignoreFile)) {
  4504. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  4505. if ($io->askConfirmation($question)) {
  4506. $this->addVendorIgnore($ignoreFile);
  4507. }
  4508. }
  4509. }
  4510. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  4511. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  4512. $this->updateDependencies($output);
  4513. }
  4514. if ($autoloadPath) {
  4515. $namespace = $this->namespaceFromPackageName($input->getOption('name'));
  4516. $io->writeError('PSR-4 autoloading configured. Use "<comment>namespace '.$namespace.';</comment>" in '.$autoloadPath);
  4517. $io->writeError('Include the Composer autoloader with: <comment>require \'vendor/autoload.php\';</comment>');
  4518. }
  4519. return 0;
  4520. }
  4521. protected function interact(InputInterface $input, OutputInterface $output)
  4522. {
  4523. $git = $this->getGitConfig();
  4524. $io = $this->getIO();
  4525. $formatter = $this->getHelperSet()->get('formatter');
  4526. $repositories = $input->getOption('repository');
  4527. if ($repositories) {
  4528. $config = Factory::createConfig($io);
  4529. $repos = array(new PlatformRepository);
  4530. $createDefaultPackagistRepo = true;
  4531. foreach ($repositories as $repo) {
  4532. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4533. if (
  4534. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  4535. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  4536. ) {
  4537. $createDefaultPackagistRepo = false;
  4538. continue;
  4539. }
  4540. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig);
  4541. }
  4542. if ($createDefaultPackagistRepo) {
  4543. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  4544. 'type' => 'composer',
  4545. 'url' => 'https://repo.packagist.org',
  4546. ));
  4547. }
  4548. $this->repos = new CompositeRepository($repos);
  4549. unset($repos, $config, $repositories);
  4550. }
  4551. $io->writeError(array(
  4552. '',
  4553. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  4554. '',
  4555. ));
  4556. $io->writeError(array(
  4557. '',
  4558. 'This command will guide you through creating your composer.json config.',
  4559. '',
  4560. ));
  4561. $cwd = realpath(".");
  4562. if (!$name = $input->getOption('name')) {
  4563. $name = basename($cwd);
  4564. $name = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  4565. $name = strtolower($name);
  4566. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  4567. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  4568. } elseif (isset($git['github.user'])) {
  4569. $name = $git['github.user'] . '/' . $name;
  4570. } elseif (!empty($_SERVER['USERNAME'])) {
  4571. $name = $_SERVER['USERNAME'] . '/' . $name;
  4572. } elseif (!empty($_SERVER['USER'])) {
  4573. $name = $_SERVER['USER'] . '/' . $name;
  4574. } elseif (get_current_user()) {
  4575. $name = get_current_user() . '/' . $name;
  4576. } else {
  4577. $name .= '/' . $name;
  4578. }
  4579. $name = strtolower($name);
  4580. }
  4581. $name = $io->askAndValidate(
  4582. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  4583. function ($value) use ($name) {
  4584. if (null === $value) {
  4585. return $name;
  4586. }
  4587. if (!Preg::isMatch('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  4588. throw new \InvalidArgumentException(
  4589. '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_.-]+'
  4590. );
  4591. }
  4592. return $value;
  4593. },
  4594. null,
  4595. $name
  4596. );
  4597. $input->setOption('name', $name);
  4598. $description = $input->getOption('description') ?: false;
  4599. $description = $io->ask(
  4600. 'Description [<comment>'.$description.'</comment>]: ',
  4601. $description
  4602. );
  4603. $input->setOption('description', $description);
  4604. if (null === $author = $input->getOption('author')) {
  4605. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  4606. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  4607. } elseif (isset($git['user.name'])) {
  4608. $author_name = $git['user.name'];
  4609. }
  4610. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  4611. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  4612. } elseif (isset($git['user.email'])) {
  4613. $author_email = $git['user.email'];
  4614. }
  4615. if (isset($author_name, $author_email)) {
  4616. $author = sprintf('%s <%s>', $author_name, $author_email);
  4617. }
  4618. }
  4619. $self = $this;
  4620. $author = $io->askAndValidate(
  4621. 'Author [<comment>'.$author.'</comment>, n to skip]: ',
  4622. function ($value) use ($self, $author) {
  4623. if ($value === 'n' || $value === 'no') {
  4624. return;
  4625. }
  4626. $value = $value ?: $author;
  4627. $author = $self->parseAuthorString($value);
  4628. return sprintf('%s <%s>', $author['name'], $author['email']);
  4629. },
  4630. null,
  4631. $author
  4632. );
  4633. $input->setOption('author', $author);
  4634. $minimumStability = $input->getOption('stability') ?: null;
  4635. $minimumStability = $io->askAndValidate(
  4636. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  4637. function ($value) use ($minimumStability) {
  4638. if (null === $value) {
  4639. return $minimumStability;
  4640. }
  4641. if (!isset(BasePackage::$stabilities[$value])) {
  4642. throw new \InvalidArgumentException(
  4643. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  4644. implode(', ', array_keys(BasePackage::$stabilities))
  4645. );
  4646. }
  4647. return $value;
  4648. },
  4649. null,
  4650. $minimumStability
  4651. );
  4652. $input->setOption('stability', $minimumStability);
  4653. $type = $input->getOption('type') ?: false;
  4654. $type = $io->ask(
  4655. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  4656. $type
  4657. );
  4658. $input->setOption('type', $type);
  4659. if (null === $license = $input->getOption('license')) {
  4660. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  4661. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  4662. }
  4663. }
  4664. $license = $io->ask(
  4665. 'License [<comment>'.$license.'</comment>]: ',
  4666. $license
  4667. );
  4668. $input->setOption('license', $license);
  4669. $io->writeError(array('', 'Define your dependencies.', ''));
  4670. $repos = $this->getRepos();
  4671. $preferredStability = $minimumStability ?: 'stable';
  4672. $platformRepo = null;
  4673. if ($repos instanceof CompositeRepository) {
  4674. foreach ($repos->getRepositories() as $candidateRepo) {
  4675. if ($candidateRepo instanceof PlatformRepository) {
  4676. $platformRepo = $candidateRepo;
  4677. break;
  4678. }
  4679. }
  4680. }
  4681. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  4682. $require = $input->getOption('require');
  4683. $requirements = array();
  4684. if ($require || $io->askConfirmation($question)) {
  4685. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  4686. }
  4687. $input->setOption('require', $requirements);
  4688. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  4689. $requireDev = $input->getOption('require-dev');
  4690. $devRequirements = array();
  4691. if ($requireDev || $io->askConfirmation($question)) {
  4692. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  4693. }
  4694. $input->setOption('require-dev', $devRequirements);
  4695. $autoload = $input->getOption('autoload') ?: 'src/';
  4696. $namespace = $this->namespaceFromPackageName($input->getOption('name'));
  4697. $autoload = $io->askAndValidate(
  4698. 'Add PSR-4 autoload mapping? Maps namespace "'.$namespace.'" to the entered relative path. [<comment>'.$autoload.'</comment>, n to skip]: ',
  4699. function ($value) use ($autoload) {
  4700. if (null === $value) {
  4701. return $autoload;
  4702. }
  4703. if ($value === 'n' || $value === 'no') {
  4704. return;
  4705. }
  4706. $value = $value ?: $autoload;
  4707. if (!Preg::isMatch('{^[^/][A-Za-z0-9\-_/]+/$}', $value)) {
  4708. throw new \InvalidArgumentException(sprintf(
  4709. 'The src folder name "%s" is invalid. Please add a relative path with tailing forward slash. [A-Za-z0-9_-/]+/',
  4710. $value
  4711. ));
  4712. }
  4713. return $value;
  4714. },
  4715. null,
  4716. $autoload
  4717. );
  4718. $input->setOption('autoload', $autoload);
  4719. }
  4720. public function parseAuthorString($author)
  4721. {
  4722. if (Preg::isMatch('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
  4723. if ($this->isValidEmail($match['email'])) {
  4724. return array(
  4725. 'name' => trim($match['name']),
  4726. 'email' => $match['email'],
  4727. );
  4728. }
  4729. }
  4730. throw new \InvalidArgumentException(
  4731. 'Invalid author string. Must be in the format: '.
  4732. 'John Smith <john@example.com>'
  4733. );
  4734. }
  4735. protected function getRepos()
  4736. {
  4737. if (!$this->repos) {
  4738. $this->repos = new CompositeRepository(array_merge(
  4739. array(new PlatformRepository),
  4740. RepositoryFactory::defaultRepos($this->getIO())
  4741. ));
  4742. }
  4743. return $this->repos;
  4744. }
  4745. final protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), PlatformRepository $platformRepo = null, $preferredStability = 'stable', $checkProvidedVersions = true, $fixed = false)
  4746. {
  4747. if ($requires) {
  4748. $requires = $this->normalizeRequirements($requires);
  4749. $result = array();
  4750. $io = $this->getIO();
  4751. foreach ($requires as $requirement) {
  4752. if (!isset($requirement['version'])) {
  4753. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);
  4754. $requirement['version'] = $version;
  4755. $requirement['name'] = $name;
  4756. $io->writeError(sprintf(
  4757. 'Using version <info>%s</info> for <info>%s</info>',
  4758. $requirement['version'],
  4759. $requirement['name']
  4760. ));
  4761. } else {
  4762. list($name) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed);
  4763. $requirement['name'] = $name;
  4764. }
  4765. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  4766. }
  4767. return $result;
  4768. }
  4769. $versionParser = new VersionParser();
  4770. $composer = $this->getComposer(false);
  4771. $installedRepo = $composer ? $composer->getRepositoryManager()->getLocalRepository() : null;
  4772. $existingPackages = array();
  4773. if ($installedRepo) {
  4774. foreach ($installedRepo->getPackages() as $package) {
  4775. $existingPackages[] = $package->getName();
  4776. }
  4777. }
  4778. unset($composer, $installedRepo);
  4779. $io = $this->getIO();
  4780. while (null !== $package = $io->ask('Search for a package: ')) {
  4781. $matches = $this->getRepos()->search($package);
  4782. if (count($matches)) {
  4783. foreach ($matches as $position => $foundPackage) {
  4784. if (in_array($foundPackage['name'], $existingPackages, true)) {
  4785. unset($matches[$position]);
  4786. }
  4787. }
  4788. $matches = array_values($matches);
  4789. $exactMatch = null;
  4790. $choices = array();
  4791. foreach ($matches as $position => $foundPackage) {
  4792. $abandoned = '';
  4793. if (isset($foundPackage['abandoned'])) {
  4794. if (is_string($foundPackage['abandoned'])) {
  4795. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  4796. } else {
  4797. $replacement = 'No replacement was suggested';
  4798. }
  4799. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  4800. }
  4801. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  4802. if ($foundPackage['name'] === $package) {
  4803. $exactMatch = true;
  4804. break;
  4805. }
  4806. }
  4807. if (!$exactMatch) {
  4808. $io->writeError(array(
  4809. '',
  4810. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  4811. '',
  4812. ));
  4813. $io->writeError($choices);
  4814. $io->writeError('');
  4815. $validator = function ($selection) use ($matches, $versionParser) {
  4816. if ('' === $selection) {
  4817. return false;
  4818. }
  4819. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  4820. $package = $matches[(int) $selection];
  4821. return $package['name'];
  4822. }
  4823. if (Preg::isMatch('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  4824. if (isset($packageMatches['version'])) {
  4825. $versionParser->parseConstraints($packageMatches['version']);
  4826. return $packageMatches['name'].' '.$packageMatches['version'];
  4827. }
  4828. return $packageMatches['name'];
  4829. }
  4830. throw new \Exception('Not a valid selection');
  4831. };
  4832. $package = $io->askAndValidate(
  4833. 'Enter package # to add, or the complete package name if it is not listed: ',
  4834. $validator,
  4835. 3,
  4836. false
  4837. );
  4838. }
  4839. if (false !== $package && false === strpos($package, ' ')) {
  4840. $validator = function ($input) {
  4841. $input = trim($input);
  4842. return $input ?: false;
  4843. };
  4844. $constraint = $io->askAndValidate(
  4845. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  4846. $validator,
  4847. 3,
  4848. false
  4849. );
  4850. if (false === $constraint) {
  4851. list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
  4852. $io->writeError(sprintf(
  4853. 'Using version <info>%s</info> for <info>%s</info>',
  4854. $constraint,
  4855. $package
  4856. ));
  4857. }
  4858. $package .= ' '.$constraint;
  4859. }
  4860. if (false !== $package) {
  4861. $requires[] = $package;
  4862. $existingPackages[] = substr($package, 0, strpos($package, ' '));
  4863. }
  4864. }
  4865. }
  4866. return $requires;
  4867. }
  4868. protected function formatAuthors($author)
  4869. {
  4870. return array($this->parseAuthorString($author));
  4871. }
  4872. public function namespaceFromPackageName($packageName)
  4873. {
  4874. if (!$packageName || strpos($packageName, '/') === false) {
  4875. return null;
  4876. }
  4877. $namespace = array_map(
  4878. function ($part) {
  4879. $part = Preg::replace('/[^a-z0-9]/i', ' ', $part);
  4880. $part = ucwords($part);
  4881. return str_replace(' ', '', $part);
  4882. },
  4883. explode('/', $packageName)
  4884. );
  4885. return join('\\', $namespace);
  4886. }
  4887. protected function getGitConfig()
  4888. {
  4889. if (null !== $this->gitConfig) {
  4890. return $this->gitConfig;
  4891. }
  4892. $finder = new ExecutableFinder();
  4893. $gitBin = $finder->find('git');
  4894. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  4895. $cmd = new Process(array($gitBin, 'config', '-l'));
  4896. } else {
  4897. $cmd = new Process(sprintf('%s config -l', ProcessExecutor::escape($gitBin)));
  4898. }
  4899. $cmd->run();
  4900. if ($cmd->isSuccessful()) {
  4901. $this->gitConfig = array();
  4902. Preg::matchAll('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches);
  4903. foreach ($matches[1] as $key => $match) {
  4904. $this->gitConfig[$match] = $matches[2][$key];
  4905. }
  4906. return $this->gitConfig;
  4907. }
  4908. return $this->gitConfig = array();
  4909. }
  4910. protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
  4911. {
  4912. if (!file_exists($ignoreFile)) {
  4913. return false;
  4914. }
  4915. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  4916. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  4917. foreach ($lines as $line) {
  4918. if (Preg::isMatch($pattern, $line)) {
  4919. return true;
  4920. }
  4921. }
  4922. return false;
  4923. }
  4924. protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
  4925. {
  4926. $contents = "";
  4927. if (file_exists($ignoreFile)) {
  4928. $contents = file_get_contents($ignoreFile);
  4929. if (strpos($contents, "\n") !== 0) {
  4930. $contents .= "\n";
  4931. }
  4932. }
  4933. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  4934. }
  4935. protected function isValidEmail($email)
  4936. {
  4937. if (!function_exists('filter_var')) {
  4938. return true;
  4939. }
  4940. if (PHP_VERSION_ID < 50303) {
  4941. return true;
  4942. }
  4943. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  4944. }
  4945. private function getRepositorySet(InputInterface $input, $minimumStability = null)
  4946. {
  4947. $key = $minimumStability ?: 'default';
  4948. if (!isset($this->repositorySets[$key])) {
  4949. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?: $this->getMinimumStability($input));
  4950. $repositorySet->addRepository($this->getRepos());
  4951. }
  4952. return $this->repositorySets[$key];
  4953. }
  4954. private function getMinimumStability(InputInterface $input)
  4955. {
  4956. if ($input->hasOption('stability')) {
  4957. return VersionParser::normalizeStability($input->getOption('stability') ?: 'stable');
  4958. }
  4959. $file = Factory::getComposerFile();
  4960. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  4961. if (!empty($composer['minimum-stability'])) {
  4962. return VersionParser::normalizeStability($composer['minimum-stability']);
  4963. }
  4964. }
  4965. return 'stable';
  4966. }
  4967. private function findBestVersionAndNameForPackage(InputInterface $input, $name, PlatformRepository $platformRepo = null, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null, $fixed = null)
  4968. {
  4969. $ignorePlatformReqs = false;
  4970. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  4971. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4972. }
  4973. $platformRequirementFilter = PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs);
  4974. $versionSelector = new VersionSelector($this->getRepositorySet($input, $minimumStability), $platformRepo);
  4975. $effectiveMinimumStability = $minimumStability ?: $this->getMinimumStability($input);
  4976. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $platformRequirementFilter);
  4977. if (!$package) {
  4978. if ($platformRequirementFilter->isIgnored($name)) {
  4979. return array($name, $requiredVersion ?: '*');
  4980. }
  4981. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && ($candidate = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, PlatformRequirementFilterFactory::ignoreAll()))) {
  4982. throw new \InvalidArgumentException(sprintf(
  4983. 'Package %s%s has requirements incompatible with your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo),
  4984. $name,
  4985. $requiredVersion ? ' at version '.$requiredVersion : ''
  4986. ));
  4987. }
  4988. if ($package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  4989. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $platformRequirementFilter, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4990. throw new \InvalidArgumentException(
  4991. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages from the higher priority repository do not match your minimum-stability and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.'
  4992. );
  4993. }
  4994. throw new \InvalidArgumentException(sprintf(
  4995. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  4996. $name,
  4997. $effectiveMinimumStability
  4998. ));
  4999. }
  5000. if ($requiredVersion && $package = $versionSelector->findBestCandidate($name, null, $preferredStability, $platformRequirementFilter)) {
  5001. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, PlatformRequirementFilterFactory::ignoreNothing(), RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  5002. throw new \InvalidArgumentException(
  5003. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages from the higher priority repository do not match your constraint and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.'
  5004. );
  5005. }
  5006. throw new \InvalidArgumentException(sprintf(
  5007. 'Could not find package %s in a version matching "%s" and a stability matching "'.$effectiveMinimumStability.'".',
  5008. $name,
  5009. $requiredVersion
  5010. ));
  5011. }
  5012. if (!($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter) && ($candidate = $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll(), RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES))) {
  5013. $additional = '';
  5014. if (false === $versionSelector->findBestCandidate($name, null, $preferredStability, PlatformRequirementFilterFactory::ignoreAll())) {
  5015. $additional = PHP_EOL.PHP_EOL.'Additionally, the package was only found with a stability of "'.$candidate->getStability().'" while your minimum stability is "'.$effectiveMinimumStability.'".';
  5016. }
  5017. throw new \InvalidArgumentException(sprintf(
  5018. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version' . $this->getPlatformExceptionDetails($candidate, $platformRepo) . '%s',
  5019. $name,
  5020. $additional
  5021. ));
  5022. }
  5023. $similar = $this->findSimilar($name);
  5024. if ($similar) {
  5025. if (in_array($name, $similar, true)) {
  5026. throw new \InvalidArgumentException(sprintf(
  5027. "Could not find package %s. It was however found via repository search, which indicates a consistency issue with the repository.",
  5028. $name
  5029. ));
  5030. }
  5031. throw new \InvalidArgumentException(sprintf(
  5032. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  5033. $name,
  5034. implode("\n ", $similar)
  5035. ));
  5036. }
  5037. throw new \InvalidArgumentException(sprintf(
  5038. '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).',
  5039. $name,
  5040. $effectiveMinimumStability
  5041. ));
  5042. }
  5043. return array(
  5044. $package->getPrettyName(),
  5045. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  5046. );
  5047. }
  5048. private function getPlatformExceptionDetails(PackageInterface $candidate, PlatformRepository $platformRepo = null)
  5049. {
  5050. $details = array();
  5051. if (!$platformRepo) {
  5052. return '';
  5053. }
  5054. foreach ($candidate->getRequires() as $link) {
  5055. if (!PlatformRepository::isPlatformPackage($link->getTarget())) {
  5056. continue;
  5057. }
  5058. $platformPkg = $platformRepo->findPackage($link->getTarget(), '*');
  5059. if (!$platformPkg) {
  5060. if ($platformRepo->isPlatformPackageDisabled($link->getTarget())) {
  5061. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' but it is disabled by your platform config. Enable it again with "composer config platform.'.$link->getTarget().' --unset".';
  5062. } else {
  5063. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' but it is not present.';
  5064. }
  5065. continue;
  5066. }
  5067. if (!$link->getConstraint()->matches(new Constraint('==', $platformPkg->getVersion()))) {
  5068. $platformPkgVersion = $platformPkg->getPrettyVersion();
  5069. $platformExtra = $platformPkg->getExtra();
  5070. if (isset($platformExtra['config.platform']) && $platformPkg instanceof CompletePackageInterface) {
  5071. $platformPkgVersion .= ' ('.$platformPkg->getDescription().')';
  5072. }
  5073. $details[] = $candidate->getPrettyName().' '.$candidate->getPrettyVersion().' requires '.$link->getTarget().' '.$link->getPrettyConstraint().' which does not match your installed version '.$platformPkgVersion.'.';
  5074. }
  5075. }
  5076. if (!$details) {
  5077. return '';
  5078. }
  5079. return ':'.PHP_EOL.' - ' . implode(PHP_EOL.' - ', $details);
  5080. }
  5081. private function findSimilar($package)
  5082. {
  5083. try {
  5084. $results = $this->repos->search($package);
  5085. } catch (\Exception $e) {
  5086. return array();
  5087. }
  5088. $similarPackages = array();
  5089. $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
  5090. foreach ($results as $result) {
  5091. if ($installedRepo->findPackage($result['name'], '*')) {
  5092. continue;
  5093. }
  5094. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  5095. }
  5096. asort($similarPackages);
  5097. return array_keys(array_slice($similarPackages, 0, 5));
  5098. }
  5099. private function updateDependencies(OutputInterface $output)
  5100. {
  5101. try {
  5102. $updateCommand = $this->getApplication()->find('update');
  5103. $this->getApplication()->resetComposer();
  5104. $updateCommand->run(new ArrayInput(array()), $output);
  5105. } catch (\Exception $e) {
  5106. $this->getIO()->writeError('Could not update dependencies. Run `composer update` to see more information.');
  5107. }
  5108. }
  5109. private function runDumpAutoloadCommand(OutputInterface $output)
  5110. {
  5111. try {
  5112. $command = $this->getApplication()->find('dump-autoload');
  5113. $this->getApplication()->resetComposer();
  5114. $command->run(new ArrayInput(array()), $output);
  5115. } catch (\Exception $e) {
  5116. $this->getIO()->writeError('Could not run dump-autoload.');
  5117. }
  5118. }
  5119. private function hasDependencies($options)
  5120. {
  5121. $requires = (array) $options['require'];
  5122. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  5123. return !empty($requires) || !empty($devRequires);
  5124. }
  5125. }
  5126. <?php
  5127. namespace Composer\Command;
  5128. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  5129. use Composer\Installer;
  5130. use Composer\Plugin\CommandEvent;
  5131. use Composer\Plugin\PluginEvents;
  5132. use Composer\Util\HttpDownloader;
  5133. use Symfony\Component\Console\Input\InputInterface;
  5134. use Symfony\Component\Console\Input\InputOption;
  5135. use Symfony\Component\Console\Input\InputArgument;
  5136. use Symfony\Component\Console\Output\OutputInterface;
  5137. class InstallCommand extends BaseCommand
  5138. {
  5139. protected function configure()
  5140. {
  5141. $this
  5142. ->setName('install')
  5143. ->setAliases(array('i'))
  5144. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  5145. ->setDefinition(array(
  5146. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5147. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5148. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5149. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5150. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  5151. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5152. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  5153. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  5154. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5155. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  5156. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  5157. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5158. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5159. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5160. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5161. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5162. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5163. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  5164. ))
  5165. ->setHelp(
  5166. <<<EOT
  5167. The <info>install</info> command reads the composer.lock file from
  5168. the current directory, processes it, and downloads and installs all the
  5169. libraries and dependencies outlined in that file. If the file does not
  5170. exist it will look for composer.json and do the same.
  5171. <info>php composer.phar install</info>
  5172. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  5173. EOT
  5174. )
  5175. ;
  5176. }
  5177. protected function execute(InputInterface $input, OutputInterface $output)
  5178. {
  5179. $io = $this->getIO();
  5180. if ($input->getOption('dev')) {
  5181. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  5182. }
  5183. if ($input->getOption('no-suggest')) {
  5184. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5185. }
  5186. if ($args = $input->getArgument('packages')) {
  5187. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  5188. return 1;
  5189. }
  5190. if ($input->getOption('no-install')) {
  5191. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  5192. return 1;
  5193. }
  5194. $composer = $this->getComposer(true, $input->getOption('no-plugins'), $input->getOption('no-scripts'));
  5195. if ((!$composer->getLocker() || !$composer->getLocker()->isLocked()) && !HttpDownloader::isCurlEnabled()) {
  5196. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  5197. }
  5198. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  5199. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5200. $install = Installer::create($io, $composer);
  5201. $config = $composer->getConfig();
  5202. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  5203. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  5204. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  5205. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5206. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  5207. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5208. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5209. $install
  5210. ->setDryRun($input->getOption('dry-run'))
  5211. ->setVerbose($input->getOption('verbose'))
  5212. ->setPreferSource($preferSource)
  5213. ->setPreferDist($preferDist)
  5214. ->setDevMode(!$input->getOption('no-dev'))
  5215. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  5216. ->setOptimizeAutoloader($optimize)
  5217. ->setClassMapAuthoritative($authoritative)
  5218. ->setApcuAutoloader($apcu, $apcuPrefix)
  5219. ->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs))
  5220. ;
  5221. if ($input->getOption('no-plugins')) {
  5222. $install->disablePlugins();
  5223. }
  5224. return $install->run();
  5225. }
  5226. }
  5227. <?php
  5228. namespace Composer\Command;
  5229. use Composer\Json\JsonFile;
  5230. use Composer\Package\CompletePackageInterface;
  5231. use Composer\Plugin\CommandEvent;
  5232. use Composer\Plugin\PluginEvents;
  5233. use Composer\Package\PackageInterface;
  5234. use Composer\Repository\RepositoryInterface;
  5235. use Symfony\Component\Console\Helper\Table;
  5236. use Symfony\Component\Console\Input\InputInterface;
  5237. use Symfony\Component\Console\Input\InputOption;
  5238. use Symfony\Component\Console\Output\OutputInterface;
  5239. use Symfony\Component\Console\Style\SymfonyStyle;
  5240. class LicensesCommand extends BaseCommand
  5241. {
  5242. protected function configure()
  5243. {
  5244. $this
  5245. ->setName('licenses')
  5246. ->setDescription('Shows information about licenses of dependencies.')
  5247. ->setDefinition(array(
  5248. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  5249. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  5250. ))
  5251. ->setHelp(
  5252. <<<EOT
  5253. The license command displays detailed information about the licenses of
  5254. the installed dependencies.
  5255. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  5256. EOT
  5257. )
  5258. ;
  5259. }
  5260. protected function execute(InputInterface $input, OutputInterface $output)
  5261. {
  5262. $composer = $this->getComposer();
  5263. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  5264. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5265. $root = $composer->getPackage();
  5266. $repo = $composer->getRepositoryManager()->getLocalRepository();
  5267. if ($input->getOption('no-dev')) {
  5268. $packages = $this->filterRequiredPackages($repo, $root);
  5269. } else {
  5270. $packages = $this->appendPackages($repo->getPackages(), array());
  5271. }
  5272. ksort($packages);
  5273. $io = $this->getIO();
  5274. switch ($format = $input->getOption('format')) {
  5275. case 'text':
  5276. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  5277. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  5278. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  5279. $io->write('Dependencies:');
  5280. $io->write('');
  5281. $table = new Table($output);
  5282. $table->setStyle('compact');
  5283. $tableStyle = $table->getStyle();
  5284. if (method_exists($tableStyle, 'setVerticalBorderChars')) {
  5285. $tableStyle->setVerticalBorderChars('');
  5286. } else {
  5287. $tableStyle->setVerticalBorderChar('');
  5288. }
  5289. $tableStyle->setCellRowContentFormat('%s ');
  5290. $table->setHeaders(array('Name', 'Version', 'License'));
  5291. foreach ($packages as $package) {
  5292. $table->addRow(array(
  5293. $package->getPrettyName(),
  5294. $package->getFullPrettyVersion(),
  5295. implode(', ', $package instanceof CompletePackageInterface ? $package->getLicense() : array()) ?: 'none',
  5296. ));
  5297. }
  5298. $table->render();
  5299. break;
  5300. case 'json':
  5301. $dependencies = array();
  5302. foreach ($packages as $package) {
  5303. $dependencies[$package->getPrettyName()] = array(
  5304. 'version' => $package->getFullPrettyVersion(),
  5305. 'license' => $package instanceof CompletePackageInterface ? $package->getLicense() : array(),
  5306. );
  5307. }
  5308. $io->write(JsonFile::encode(array(
  5309. 'name' => $root->getPrettyName(),
  5310. 'version' => $root->getFullPrettyVersion(),
  5311. 'license' => $root->getLicense(),
  5312. 'dependencies' => $dependencies,
  5313. )));
  5314. break;
  5315. case 'summary':
  5316. $usedLicenses = array();
  5317. foreach ($packages as $package) {
  5318. $license = $package instanceof CompletePackageInterface ? $package->getLicense() : array();
  5319. $licenseName = $license[0];
  5320. if (!isset($usedLicenses[$licenseName])) {
  5321. $usedLicenses[$licenseName] = 0;
  5322. }
  5323. $usedLicenses[$licenseName]++;
  5324. }
  5325. arsort($usedLicenses, SORT_NUMERIC);
  5326. $rows = array();
  5327. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  5328. $rows[] = array($usedLicense, $numberOfDependencies);
  5329. }
  5330. $symfonyIo = new SymfonyStyle($input, $output);
  5331. $symfonyIo->table(
  5332. array('License', 'Number of dependencies'),
  5333. $rows
  5334. );
  5335. break;
  5336. default:
  5337. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  5338. }
  5339. return 0;
  5340. }
  5341. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  5342. {
  5343. $requires = array_keys($package->getRequires());
  5344. $packageListNames = array_keys($bucket);
  5345. $packages = array_filter(
  5346. $repo->getPackages(),
  5347. function ($package) use ($requires, $packageListNames) {
  5348. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  5349. }
  5350. );
  5351. $bucket = $this->appendPackages($packages, $bucket);
  5352. foreach ($packages as $package) {
  5353. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  5354. }
  5355. return $bucket;
  5356. }
  5357. public function appendPackages(array $packages, array $bucket)
  5358. {
  5359. foreach ($packages as $package) {
  5360. $bucket[$package->getName()] = $package;
  5361. }
  5362. return $bucket;
  5363. }
  5364. }
  5365. <?php
  5366. namespace Composer\Command;
  5367. use Symfony\Component\Console\Input\InputInterface;
  5368. use Symfony\Component\Console\Input\InputArgument;
  5369. use Symfony\Component\Console\Input\ArrayInput;
  5370. use Symfony\Component\Console\Input\InputOption;
  5371. use Symfony\Component\Console\Output\OutputInterface;
  5372. class OutdatedCommand extends ShowCommand
  5373. {
  5374. protected function configure()
  5375. {
  5376. $this
  5377. ->setName('outdated')
  5378. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  5379. ->setDefinition(array(
  5380. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  5381. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  5382. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  5383. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  5384. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  5385. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  5386. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  5387. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  5388. 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.'),
  5389. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  5390. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option'),
  5391. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  5392. ))
  5393. ->setHelp(
  5394. <<<EOT
  5395. The outdated command is just a proxy for `composer show -l`
  5396. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  5397. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  5398. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  5399. compatibility breaks according to semver, so upgrade when you can but it
  5400. may involve work.
  5401. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  5402. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  5403. EOT
  5404. )
  5405. ;
  5406. }
  5407. protected function execute(InputInterface $input, OutputInterface $output)
  5408. {
  5409. $args = array(
  5410. 'command' => 'show',
  5411. '--latest' => true,
  5412. );
  5413. if (!$input->getOption('all')) {
  5414. $args['--outdated'] = true;
  5415. }
  5416. if ($input->getOption('direct')) {
  5417. $args['--direct'] = true;
  5418. }
  5419. if ($input->getArgument('package')) {
  5420. $args['package'] = $input->getArgument('package');
  5421. }
  5422. if ($input->getOption('strict')) {
  5423. $args['--strict'] = true;
  5424. }
  5425. if ($input->getOption('minor-only')) {
  5426. $args['--minor-only'] = true;
  5427. }
  5428. if ($input->getOption('locked')) {
  5429. $args['--locked'] = true;
  5430. }
  5431. if ($input->getOption('no-dev')) {
  5432. $args['--no-dev'] = true;
  5433. }
  5434. if ($input->getOption('ignore-platform-req')) {
  5435. $args['--ignore-platform-req'] = $input->getOption('ignore-platform-req');
  5436. }
  5437. if ($input->getOption('ignore-platform-reqs')) {
  5438. $args['--ignore-platform-reqs'] = true;
  5439. }
  5440. $args['--format'] = $input->getOption('format');
  5441. $args['--ignore'] = $input->getOption('ignore');
  5442. $input = new ArrayInput($args);
  5443. return $this->getApplication()->run($input, $output);
  5444. }
  5445. public function isProxyCommand()
  5446. {
  5447. return true;
  5448. }
  5449. }
  5450. <?php
  5451. namespace Composer\Command;
  5452. use Symfony\Component\Console\Input\InputInterface;
  5453. use Symfony\Component\Console\Output\OutputInterface;
  5454. use Symfony\Component\Console\Input\InputArgument;
  5455. use Symfony\Component\Console\Input\InputOption;
  5456. class ProhibitsCommand extends BaseDependencyCommand
  5457. {
  5458. protected function configure()
  5459. {
  5460. $this
  5461. ->setName('prohibits')
  5462. ->setAliases(array('why-not'))
  5463. ->setDescription('Shows which packages prevent the given package from being installed.')
  5464. ->setDefinition(array(
  5465. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  5466. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::REQUIRED, 'Version constraint, which version you expected to be installed'),
  5467. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  5468. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  5469. ))
  5470. ->setHelp(
  5471. <<<EOT
  5472. Displays detailed information about why a package cannot be installed.
  5473. <info>php composer.phar prohibits composer/composer</info>
  5474. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  5475. EOT
  5476. )
  5477. ;
  5478. }
  5479. protected function execute(InputInterface $input, OutputInterface $output)
  5480. {
  5481. return parent::doExecute($input, $output, true);
  5482. }
  5483. }
  5484. <?php
  5485. namespace Composer\Command;
  5486. use Composer\DependencyResolver\Operation\InstallOperation;
  5487. use Composer\DependencyResolver\Operation\UninstallOperation;
  5488. use Composer\DependencyResolver\Transaction;
  5489. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  5490. use Composer\Package\AliasPackage;
  5491. use Composer\Package\BasePackage;
  5492. use Composer\Pcre\Preg;
  5493. use Composer\Plugin\CommandEvent;
  5494. use Composer\Plugin\PluginEvents;
  5495. use Composer\Script\ScriptEvents;
  5496. use Composer\Util\Platform;
  5497. use Symfony\Component\Console\Input\InputInterface;
  5498. use Symfony\Component\Console\Input\InputOption;
  5499. use Symfony\Component\Console\Input\InputArgument;
  5500. use Symfony\Component\Console\Output\OutputInterface;
  5501. class ReinstallCommand extends BaseCommand
  5502. {
  5503. protected function configure()
  5504. {
  5505. $this
  5506. ->setName('reinstall')
  5507. ->setDescription('Uninstalls and reinstalls the given package names')
  5508. ->setDefinition(array(
  5509. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5510. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5511. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5512. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  5513. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5514. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5515. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5516. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5517. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5518. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5519. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5520. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'List of package names to reinstall, can include a wildcard (*) to match any substring.'),
  5521. ))
  5522. ->setHelp(
  5523. <<<EOT
  5524. The <info>reinstall</info> command looks up installed packages by name,
  5525. uninstalls them and reinstalls them. This lets you do a clean install
  5526. of a package if you messed with its files, or if you wish to change
  5527. the installation type using --prefer-install.
  5528. <info>php composer.phar reinstall acme/foo "acme/bar-*"</info>
  5529. Read more at https://getcomposer.org/doc/03-cli.md#reinstall
  5530. EOT
  5531. )
  5532. ;
  5533. }
  5534. protected function execute(InputInterface $input, OutputInterface $output)
  5535. {
  5536. $io = $this->getIO();
  5537. $composer = $this->getComposer(true, $input->getOption('no-plugins'), $input->getOption('no-scripts'));
  5538. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5539. $packagesToReinstall = array();
  5540. $packageNamesToReinstall = array();
  5541. foreach ($input->getArgument('packages') as $pattern) {
  5542. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  5543. $matched = false;
  5544. foreach ($localRepo->getCanonicalPackages() as $package) {
  5545. if (Preg::isMatch($patternRegexp, $package->getName())) {
  5546. $matched = true;
  5547. $packagesToReinstall[] = $package;
  5548. $packageNamesToReinstall[] = $package->getName();
  5549. }
  5550. }
  5551. if (!$matched) {
  5552. $io->writeError('<warning>Pattern "' . $pattern . '" does not match any currently installed packages.</warning>');
  5553. }
  5554. }
  5555. if (!$packagesToReinstall) {
  5556. $io->writeError('<warning>Found no packages to reinstall, aborting.</warning>');
  5557. return 1;
  5558. }
  5559. $uninstallOperations = array();
  5560. foreach ($packagesToReinstall as $package) {
  5561. $uninstallOperations[] = new UninstallOperation($package);
  5562. }
  5563. $presentPackages = $localRepo->getPackages();
  5564. $resultPackages = $presentPackages;
  5565. foreach ($presentPackages as $index => $package) {
  5566. if (in_array($package->getName(), $packageNamesToReinstall, true)) {
  5567. unset($presentPackages[$index]);
  5568. }
  5569. }
  5570. $transaction = new Transaction($presentPackages, $resultPackages);
  5571. $installOperations = $transaction->getOperations();
  5572. $installOrder = array();
  5573. foreach ($installOperations as $index => $op) {
  5574. if ($op instanceof InstallOperation && !$op->getPackage() instanceof AliasPackage) {
  5575. $installOrder[$op->getPackage()->getName()] = $index;
  5576. }
  5577. }
  5578. usort($uninstallOperations, function ($a, $b) use ($installOrder) {
  5579. return $installOrder[$b->getPackage()->getName()] - $installOrder[$a->getPackage()->getName()];
  5580. });
  5581. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'reinstall', $input, $output);
  5582. $eventDispatcher = $composer->getEventDispatcher();
  5583. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  5584. $config = $composer->getConfig();
  5585. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  5586. $installationManager = $composer->getInstallationManager();
  5587. $downloadManager = $composer->getDownloadManager();
  5588. $package = $composer->getPackage();
  5589. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5590. $installationManager->setOutputProgress(!$input->getOption('no-progress'));
  5591. if ($input->getOption('no-plugins')) {
  5592. $installationManager->disablePlugins();
  5593. }
  5594. $downloadManager->setPreferSource($preferSource);
  5595. $downloadManager->setPreferDist($preferDist);
  5596. $devMode = $localRepo->getDevMode() !== null ? $localRepo->getDevMode() : true;
  5597. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  5598. $eventDispatcher->dispatchScript(ScriptEvents::PRE_INSTALL_CMD, $devMode);
  5599. $installationManager->execute($localRepo, $uninstallOperations, $devMode);
  5600. $installationManager->execute($localRepo, $installOperations, $devMode);
  5601. if (!$input->getOption('no-autoloader')) {
  5602. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  5603. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  5604. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5605. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  5606. $generator = $composer->getAutoloadGenerator();
  5607. $generator->setClassMapAuthoritative($authoritative);
  5608. $generator->setApcu($apcu, $apcuPrefix);
  5609. $generator->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  5610. $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  5611. }
  5612. $eventDispatcher->dispatchScript(ScriptEvents::POST_INSTALL_CMD, $devMode);
  5613. return 0;
  5614. }
  5615. }
  5616. <?php
  5617. namespace Composer\Command;
  5618. use Composer\Config\JsonConfigSource;
  5619. use Composer\DependencyResolver\Request;
  5620. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  5621. use Composer\Installer;
  5622. use Composer\Pcre\Preg;
  5623. use Composer\Plugin\CommandEvent;
  5624. use Composer\Plugin\PluginEvents;
  5625. use Composer\Json\JsonFile;
  5626. use Composer\Factory;
  5627. use Symfony\Component\Console\Input\InputInterface;
  5628. use Symfony\Component\Console\Input\InputOption;
  5629. use Symfony\Component\Console\Input\InputArgument;
  5630. use Symfony\Component\Console\Output\OutputInterface;
  5631. use Composer\Package\BasePackage;
  5632. class RemoveCommand extends BaseCommand
  5633. {
  5634. protected function configure()
  5635. {
  5636. $this
  5637. ->setName('remove')
  5638. ->setDescription('Removes a package from the require or require-dev.')
  5639. ->setDefinition(array(
  5640. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  5641. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  5642. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5643. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5644. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5645. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5646. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5647. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  5648. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5649. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5650. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  5651. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  5652. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5653. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5654. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5655. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5656. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5657. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5658. ))
  5659. ->setHelp(
  5660. <<<EOT
  5661. The <info>remove</info> command removes a package from the current
  5662. list of installed packages
  5663. <info>php composer.phar remove</info>
  5664. Read more at https://getcomposer.org/doc/03-cli.md#remove
  5665. EOT
  5666. )
  5667. ;
  5668. }
  5669. protected function interact(InputInterface $input, OutputInterface $output)
  5670. {
  5671. if ($input->getOption('unused')) {
  5672. $composer = $this->getComposer();
  5673. $locker = $composer->getLocker();
  5674. if (!$locker->isLocked()) {
  5675. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  5676. }
  5677. $lockedPackages = $locker->getLockedRepository()->getPackages();
  5678. $required = array();
  5679. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  5680. $required[$link->getTarget()] = true;
  5681. }
  5682. do {
  5683. $found = false;
  5684. foreach ($lockedPackages as $index => $package) {
  5685. foreach ($package->getNames() as $name) {
  5686. if (isset($required[$name])) {
  5687. foreach ($package->getRequires() as $link) {
  5688. $required[$link->getTarget()] = true;
  5689. }
  5690. $found = true;
  5691. unset($lockedPackages[$index]);
  5692. break;
  5693. }
  5694. }
  5695. }
  5696. } while ($found);
  5697. $unused = array();
  5698. foreach ($lockedPackages as $package) {
  5699. $unused[] = $package->getName();
  5700. }
  5701. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  5702. if (!$input->getArgument('packages')) {
  5703. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  5704. $this->setCode(function () {
  5705. return 0;
  5706. });
  5707. }
  5708. }
  5709. }
  5710. protected function execute(InputInterface $input, OutputInterface $output)
  5711. {
  5712. $packages = $input->getArgument('packages');
  5713. $packages = array_map('strtolower', $packages);
  5714. $file = Factory::getComposerFile();
  5715. $jsonFile = new JsonFile($file);
  5716. $composer = $jsonFile->read();
  5717. $composerBackup = file_get_contents($jsonFile->getPath());
  5718. $json = new JsonConfigSource($jsonFile);
  5719. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5720. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5721. $io = $this->getIO();
  5722. if ($input->getOption('update-with-dependencies')) {
  5723. $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>');
  5724. }
  5725. foreach (array('require', 'require-dev') as $linkType) {
  5726. if (isset($composer[$linkType])) {
  5727. foreach ($composer[$linkType] as $name => $version) {
  5728. $composer[$linkType][strtolower($name)] = $name;
  5729. }
  5730. }
  5731. }
  5732. $dryRun = $input->getOption('dry-run');
  5733. $toRemove = array();
  5734. foreach ($packages as $package) {
  5735. if (isset($composer[$type][$package])) {
  5736. if ($dryRun) {
  5737. $toRemove[$type][] = $composer[$type][$package];
  5738. } else {
  5739. $json->removeLink($type, $composer[$type][$package]);
  5740. }
  5741. } elseif (isset($composer[$altType][$package])) {
  5742. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5743. if ($io->isInteractive()) {
  5744. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5745. if ($dryRun) {
  5746. $toRemove[$altType][] = $composer[$altType][$package];
  5747. } else {
  5748. $json->removeLink($altType, $composer[$altType][$package]);
  5749. }
  5750. }
  5751. }
  5752. } elseif (isset($composer[$type]) && $matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  5753. foreach ($matches as $matchedPackage) {
  5754. if ($dryRun) {
  5755. $toRemove[$type][] = $matchedPackage;
  5756. } else {
  5757. $json->removeLink($type, $matchedPackage);
  5758. }
  5759. }
  5760. } elseif (isset($composer[$altType]) && $matches = Preg::grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  5761. foreach ($matches as $matchedPackage) {
  5762. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5763. if ($io->isInteractive()) {
  5764. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5765. if ($dryRun) {
  5766. $toRemove[$altType][] = $matchedPackage;
  5767. } else {
  5768. $json->removeLink($altType, $matchedPackage);
  5769. }
  5770. }
  5771. }
  5772. }
  5773. } else {
  5774. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5775. }
  5776. }
  5777. $io->writeError('<info>'.$file.' has been updated</info>');
  5778. if ($input->getOption('no-update')) {
  5779. return 0;
  5780. }
  5781. if ($composer = $this->getComposer(false)) {
  5782. $composer->getPluginManager()->deactivateInstalledPlugins();
  5783. }
  5784. $this->resetComposer();
  5785. $composer = $this->getComposer(true, $input->getOption('no-plugins'), $input->getOption('no-scripts'));
  5786. if ($dryRun) {
  5787. $rootPackage = $composer->getPackage();
  5788. $links = array(
  5789. 'require' => $rootPackage->getRequires(),
  5790. 'require-dev' => $rootPackage->getDevRequires(),
  5791. );
  5792. foreach ($toRemove as $type => $names) {
  5793. foreach ($names as $name) {
  5794. unset($links[$type][$name]);
  5795. }
  5796. }
  5797. $rootPackage->setRequires($links['require']);
  5798. $rootPackage->setDevRequires($links['require-dev']);
  5799. }
  5800. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5801. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5802. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5803. $install = Installer::create($io, $composer);
  5804. $updateDevMode = !$input->getOption('update-no-dev');
  5805. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5806. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5807. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5808. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5809. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5810. $flags = '';
  5811. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5812. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5813. $flags .= ' --with-all-dependencies';
  5814. } elseif ($input->getOption('no-update-with-dependencies')) {
  5815. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5816. $flags .= ' --with-dependencies';
  5817. }
  5818. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5819. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5820. $install
  5821. ->setVerbose($input->getOption('verbose'))
  5822. ->setDevMode($updateDevMode)
  5823. ->setOptimizeAutoloader($optimize)
  5824. ->setClassMapAuthoritative($authoritative)
  5825. ->setApcuAutoloader($apcu, $apcuPrefix)
  5826. ->setUpdate(true)
  5827. ->setInstall(!$input->getOption('no-install'))
  5828. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5829. ->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs))
  5830. ->setDryRun($dryRun)
  5831. ;
  5832. if ($composer->getLocker()->isLocked()) {
  5833. $install->setUpdateAllowList($packages);
  5834. }
  5835. $status = $install->run();
  5836. if ($status !== 0) {
  5837. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5838. file_put_contents($jsonFile->getPath(), $composerBackup);
  5839. }
  5840. if (!$dryRun) {
  5841. foreach ($packages as $package) {
  5842. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5843. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5844. return 2;
  5845. }
  5846. }
  5847. }
  5848. return $status;
  5849. }
  5850. }
  5851. <?php
  5852. namespace Composer\Command;
  5853. use Composer\DependencyResolver\Request;
  5854. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  5855. use Composer\Util\Filesystem;
  5856. use Symfony\Component\Console\Input\InputInterface;
  5857. use Symfony\Component\Console\Input\InputArgument;
  5858. use Symfony\Component\Console\Input\InputOption;
  5859. use Symfony\Component\Console\Output\OutputInterface;
  5860. use Composer\Factory;
  5861. use Composer\Installer;
  5862. use Composer\Installer\InstallerEvents;
  5863. use Composer\Json\JsonFile;
  5864. use Composer\Json\JsonManipulator;
  5865. use Composer\Package\Version\VersionParser;
  5866. use Composer\Package\Loader\ArrayLoader;
  5867. use Composer\Package\BasePackage;
  5868. use Composer\Plugin\CommandEvent;
  5869. use Composer\Plugin\PluginEvents;
  5870. use Composer\Repository\CompositeRepository;
  5871. use Composer\Repository\PlatformRepository;
  5872. use Composer\IO\IOInterface;
  5873. use Composer\Util\Silencer;
  5874. class RequireCommand extends InitCommand
  5875. {
  5876. private $newlyCreated;
  5877. private $firstRequire;
  5878. private $json;
  5879. private $file;
  5880. private $composerBackup;
  5881. private $lock;
  5882. private $lockBackup;
  5883. private $dependencyResolutionCompleted = false;
  5884. protected function configure()
  5885. {
  5886. $this
  5887. ->setName('require')
  5888. ->setDescription('Adds required packages to your composer.json and installs them.')
  5889. ->setDefinition(array(
  5890. 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"'),
  5891. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5892. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5893. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5894. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  5895. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  5896. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5897. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5898. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5899. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5900. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5901. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5902. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5903. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5904. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5905. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5906. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5907. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5908. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5909. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5910. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5911. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5912. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5913. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5914. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5915. ))
  5916. ->setHelp(
  5917. <<<EOT
  5918. The require command adds required packages to your composer.json and installs them.
  5919. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5920. matches to require.
  5921. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5922. If you do not want to install the new dependencies immediately you can call it with --no-update
  5923. Read more at https://getcomposer.org/doc/03-cli.md#require
  5924. EOT
  5925. )
  5926. ;
  5927. }
  5928. protected function execute(InputInterface $input, OutputInterface $output)
  5929. {
  5930. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  5931. pcntl_async_signals(true);
  5932. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  5933. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  5934. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  5935. }
  5936. $this->file = Factory::getComposerFile();
  5937. $io = $this->getIO();
  5938. if ($input->getOption('no-suggest')) {
  5939. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5940. }
  5941. $this->newlyCreated = !file_exists($this->file);
  5942. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  5943. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  5944. return 1;
  5945. }
  5946. if (!Filesystem::isReadable($this->file)) {
  5947. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  5948. return 1;
  5949. }
  5950. if (filesize($this->file) === 0) {
  5951. file_put_contents($this->file, "{\n}\n");
  5952. }
  5953. $this->json = new JsonFile($this->file);
  5954. $this->lock = Factory::getLockFile($this->file);
  5955. $this->composerBackup = file_get_contents($this->json->getPath());
  5956. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  5957. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  5958. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  5959. return 1;
  5960. }
  5961. if ($input->getOption('fixed') === true) {
  5962. $config = $this->json->read();
  5963. $packageType = empty($config['type']) ? 'library' : $config['type'];
  5964. if ($packageType !== 'project') {
  5965. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  5966. if (empty($config['type'])) {
  5967. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  5968. }
  5969. return 1;
  5970. }
  5971. }
  5972. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5973. $repos = $composer->getRepositoryManager()->getRepositories();
  5974. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5975. $this->repos = new CompositeRepository(array_merge(
  5976. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  5977. $repos
  5978. ));
  5979. if ($composer->getPackage()->getPreferStable()) {
  5980. $preferredStability = 'stable';
  5981. } else {
  5982. $preferredStability = $composer->getPackage()->getMinimumStability();
  5983. }
  5984. try {
  5985. $requirements = $this->determineRequirements(
  5986. $input,
  5987. $output,
  5988. $input->getArgument('packages'),
  5989. $platformRepo,
  5990. $preferredStability,
  5991. !$input->getOption('no-update'),
  5992. $input->getOption('fixed')
  5993. );
  5994. } catch (\Exception $e) {
  5995. if ($this->newlyCreated) {
  5996. $this->revertComposerFile(false);
  5997. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  5998. }
  5999. throw $e;
  6000. }
  6001. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  6002. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  6003. $requirements = $this->formatRequirements($requirements);
  6004. $versionParser = new VersionParser();
  6005. foreach ($requirements as $package => $constraint) {
  6006. if (strtolower($package) === $composer->getPackage()->getName()) {
  6007. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  6008. return 1;
  6009. }
  6010. $versionParser->parseConstraints($constraint);
  6011. }
  6012. $inconsistentRequireKeys = $this->getInconsistentRequireKeys($requirements, $requireKey);
  6013. if (count($inconsistentRequireKeys) > 0) {
  6014. foreach ($inconsistentRequireKeys as $package) {
  6015. $io->warning(sprintf(
  6016. '%s is currently present in the %s key and you ran the command %s the --dev flag, which would move it to the %s key.',
  6017. $package,
  6018. $removeKey,
  6019. $input->getOption('dev') ? 'with' : 'without',
  6020. $requireKey
  6021. ));
  6022. }
  6023. if ($io->isInteractive()) {
  6024. if (!$io->askConfirmation(sprintf('<info>Do you want to move %s?</info> [<comment>no</comment>]? ', count($inconsistentRequireKeys) > 1 ? 'these requirements' : 'this requirement'), false)) {
  6025. if (!$io->askConfirmation(sprintf('<info>Do you want to re-run the command %s --dev?</info> [<comment>yes</comment>]? ', $input->getOption('dev') ? 'without' : 'with'), true)) {
  6026. return 0;
  6027. }
  6028. list($requireKey, $removeKey) = array($removeKey, $requireKey);
  6029. }
  6030. }
  6031. }
  6032. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  6033. $this->firstRequire = $this->newlyCreated;
  6034. if (!$this->firstRequire) {
  6035. $composerDefinition = $this->json->read();
  6036. if (empty($composerDefinition['require']) && empty($composerDefinition['require-dev'])) {
  6037. $this->firstRequire = true;
  6038. }
  6039. }
  6040. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  6041. $composerDefinition = $this->json->read();
  6042. foreach ($requirements as $package => $version) {
  6043. $composerDefinition[$requireKey][$package] = $version;
  6044. unset($composerDefinition[$removeKey][$package]);
  6045. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  6046. unset($composerDefinition[$removeKey]);
  6047. }
  6048. }
  6049. $this->json->write($composerDefinition);
  6050. }
  6051. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  6052. if ($input->getOption('no-update')) {
  6053. return 0;
  6054. }
  6055. $composer->getPluginManager()->deactivateInstalledPlugins();
  6056. try {
  6057. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  6058. } catch (\Exception $e) {
  6059. if (!$this->dependencyResolutionCompleted) {
  6060. $this->revertComposerFile(false);
  6061. }
  6062. throw $e;
  6063. }
  6064. }
  6065. private function getInconsistentRequireKeys(array $newRequirements, $requireKey)
  6066. {
  6067. $requireKeys = $this->getPackagesByRequireKey();
  6068. $inconsistentRequirements = array();
  6069. foreach ($requireKeys as $package => $packageRequireKey) {
  6070. if (!isset($newRequirements[$package])) {
  6071. continue;
  6072. }
  6073. if ($requireKey !== $packageRequireKey) {
  6074. $inconsistentRequirements[] = $package;
  6075. }
  6076. }
  6077. return $inconsistentRequirements;
  6078. }
  6079. private function getPackagesByRequireKey()
  6080. {
  6081. $composerDefinition = $this->json->read();
  6082. $require = array();
  6083. $requireDev = array();
  6084. if (isset($composerDefinition['require'])) {
  6085. $require = $composerDefinition['require'];
  6086. }
  6087. if (isset($composerDefinition['require-dev'])) {
  6088. $requireDev = $composerDefinition['require-dev'];
  6089. }
  6090. return array_merge(
  6091. array_fill_keys(array_keys($require), 'require'),
  6092. array_fill_keys(array_keys($requireDev), 'require-dev')
  6093. );
  6094. }
  6095. public function markSolverComplete()
  6096. {
  6097. $this->dependencyResolutionCompleted = true;
  6098. }
  6099. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
  6100. {
  6101. $this->resetComposer();
  6102. $composer = $this->getComposer(true, $input->getOption('no-plugins'), $input->getOption('no-scripts'));
  6103. $this->dependencyResolutionCompleted = false;
  6104. $composer->getEventDispatcher()->addListener(InstallerEvents::PRE_OPERATIONS_EXEC, array($this, 'markSolverComplete'), 10000);
  6105. if ($input->getOption('dry-run')) {
  6106. $rootPackage = $composer->getPackage();
  6107. $links = array(
  6108. 'require' => $rootPackage->getRequires(),
  6109. 'require-dev' => $rootPackage->getDevRequires(),
  6110. );
  6111. $loader = new ArrayLoader();
  6112. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['method'], $requirements);
  6113. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  6114. foreach ($requirements as $package => $constraint) {
  6115. unset($links[$removeKey][$package]);
  6116. }
  6117. $rootPackage->setRequires($links['require']);
  6118. $rootPackage->setDevRequires($links['require-dev']);
  6119. }
  6120. $updateDevMode = !$input->getOption('update-no-dev');
  6121. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  6122. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  6123. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  6124. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  6125. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  6126. $flags = '';
  6127. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  6128. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  6129. $flags .= ' --with-all-dependencies';
  6130. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  6131. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  6132. $flags .= ' --with-dependencies';
  6133. }
  6134. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  6135. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  6136. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6137. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  6138. $install = Installer::create($io, $composer);
  6139. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  6140. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($composer->getConfig(), $input);
  6141. $install
  6142. ->setDryRun($input->getOption('dry-run'))
  6143. ->setVerbose($input->getOption('verbose'))
  6144. ->setPreferSource($preferSource)
  6145. ->setPreferDist($preferDist)
  6146. ->setDevMode($updateDevMode)
  6147. ->setOptimizeAutoloader($optimize)
  6148. ->setClassMapAuthoritative($authoritative)
  6149. ->setApcuAutoloader($apcu, $apcuPrefix)
  6150. ->setUpdate(true)
  6151. ->setInstall(!$input->getOption('no-install'))
  6152. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  6153. ->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs))
  6154. ->setPreferStable($input->getOption('prefer-stable'))
  6155. ->setPreferLowest($input->getOption('prefer-lowest'))
  6156. ;
  6157. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  6158. $install->setUpdateAllowList(array_keys($requirements));
  6159. }
  6160. $status = $install->run();
  6161. if ($status !== 0) {
  6162. if ($status === Installer::ERROR_DEPENDENCY_RESOLUTION_FAILED) {
  6163. foreach ($this->normalizeRequirements($input->getArgument('packages')) as $req) {
  6164. if (!isset($req['version'])) {
  6165. $io->writeError('You can also try re-running composer require with an explicit version constraint, e.g. "composer require '.$req['name'].':*" to figure out if any version is installable, or "composer require '.$req['name'].':^2.1" if you know which you need.');
  6166. break;
  6167. }
  6168. }
  6169. }
  6170. $this->revertComposerFile(false);
  6171. }
  6172. return $status;
  6173. }
  6174. private function updateFileCleanly(JsonFile $json, array $new, $requireKey, $removeKey, $sortPackages)
  6175. {
  6176. $contents = file_get_contents($json->getPath());
  6177. $manipulator = new JsonManipulator($contents);
  6178. foreach ($new as $package => $constraint) {
  6179. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  6180. return false;
  6181. }
  6182. if (!$manipulator->removeSubNode($removeKey, $package)) {
  6183. return false;
  6184. }
  6185. }
  6186. $manipulator->removeMainKeyIfEmpty($removeKey);
  6187. file_put_contents($json->getPath(), $manipulator->getContents());
  6188. return true;
  6189. }
  6190. protected function interact(InputInterface $input, OutputInterface $output)
  6191. {
  6192. return;
  6193. }
  6194. public function revertComposerFile($hardExit = true)
  6195. {
  6196. $io = $this->getIO();
  6197. if ($this->newlyCreated) {
  6198. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  6199. unlink($this->json->getPath());
  6200. if (file_exists($this->lock)) {
  6201. unlink($this->lock);
  6202. }
  6203. } else {
  6204. $msg = ' to its ';
  6205. if ($this->lockBackup) {
  6206. $msg = ' and '.$this->lock.' to their ';
  6207. }
  6208. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  6209. file_put_contents($this->json->getPath(), $this->composerBackup);
  6210. if ($this->lockBackup) {
  6211. file_put_contents($this->lock, $this->lockBackup);
  6212. }
  6213. }
  6214. if ($hardExit) {
  6215. exit(1);
  6216. }
  6217. }
  6218. }
  6219. <?php
  6220. namespace Composer\Command;
  6221. use Composer\Script\Event as ScriptEvent;
  6222. use Composer\Script\ScriptEvents;
  6223. use Composer\Util\ProcessExecutor;
  6224. use Composer\Util\Platform;
  6225. use Symfony\Component\Console\Input\InputInterface;
  6226. use Symfony\Component\Console\Input\InputOption;
  6227. use Symfony\Component\Console\Input\InputArgument;
  6228. use Symfony\Component\Console\Output\OutputInterface;
  6229. class RunScriptCommand extends BaseCommand
  6230. {
  6231. protected $scriptEvents = array(
  6232. ScriptEvents::PRE_INSTALL_CMD,
  6233. ScriptEvents::POST_INSTALL_CMD,
  6234. ScriptEvents::PRE_UPDATE_CMD,
  6235. ScriptEvents::POST_UPDATE_CMD,
  6236. ScriptEvents::PRE_STATUS_CMD,
  6237. ScriptEvents::POST_STATUS_CMD,
  6238. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  6239. ScriptEvents::POST_CREATE_PROJECT_CMD,
  6240. ScriptEvents::PRE_ARCHIVE_CMD,
  6241. ScriptEvents::POST_ARCHIVE_CMD,
  6242. ScriptEvents::PRE_AUTOLOAD_DUMP,
  6243. ScriptEvents::POST_AUTOLOAD_DUMP,
  6244. );
  6245. protected function configure()
  6246. {
  6247. $this
  6248. ->setName('run-script')
  6249. ->setAliases(array('run'))
  6250. ->setDescription('Runs the scripts defined in composer.json.')
  6251. ->setDefinition(array(
  6252. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  6253. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  6254. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  6255. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  6256. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  6257. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  6258. ))
  6259. ->setHelp(
  6260. <<<EOT
  6261. The <info>run-script</info> command runs scripts defined in composer.json:
  6262. <info>php composer.phar run-script post-update-cmd</info>
  6263. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  6264. EOT
  6265. )
  6266. ;
  6267. }
  6268. protected function execute(InputInterface $input, OutputInterface $output)
  6269. {
  6270. if ($input->getOption('list')) {
  6271. return $this->listScripts($output);
  6272. }
  6273. if (!$input->getArgument('script')) {
  6274. throw new \RuntimeException('Missing required argument "script"');
  6275. }
  6276. $script = $input->getArgument('script');
  6277. if (!in_array($script, $this->scriptEvents)) {
  6278. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  6279. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  6280. }
  6281. }
  6282. $composer = $this->getComposer();
  6283. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  6284. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  6285. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  6286. if (!$hasListeners) {
  6287. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  6288. }
  6289. $args = $input->getArgument('args');
  6290. if (null !== $timeout = $input->getOption('timeout')) {
  6291. if (!ctype_digit($timeout)) {
  6292. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  6293. }
  6294. ProcessExecutor::setTimeout((int) $timeout);
  6295. }
  6296. Platform::putEnv('COMPOSER_DEV_MODE', $devMode ? '1' : '0');
  6297. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  6298. }
  6299. protected function listScripts(OutputInterface $output)
  6300. {
  6301. $scripts = $this->getComposer()->getPackage()->getScripts();
  6302. if (!count($scripts)) {
  6303. return 0;
  6304. }
  6305. $io = $this->getIO();
  6306. $io->writeError('<info>scripts:</info>');
  6307. $table = array();
  6308. foreach ($scripts as $name => $script) {
  6309. $description = '';
  6310. try {
  6311. $cmd = $this->getApplication()->find($name);
  6312. if ($cmd instanceof ScriptAliasCommand) {
  6313. $description = $cmd->getDescription();
  6314. }
  6315. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  6316. }
  6317. $table[] = array(' '.$name, $description);
  6318. }
  6319. $this->renderTable($table, $output);
  6320. return 0;
  6321. }
  6322. }
  6323. <?php
  6324. namespace Composer\Command;
  6325. use Symfony\Component\Console\Input\InputInterface;
  6326. use Symfony\Component\Console\Input\InputOption;
  6327. use Symfony\Component\Console\Input\InputArgument;
  6328. use Symfony\Component\Console\Output\OutputInterface;
  6329. class ScriptAliasCommand extends BaseCommand
  6330. {
  6331. private $script;
  6332. private $description;
  6333. public function __construct($script, $description)
  6334. {
  6335. $this->script = $script;
  6336. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  6337. parent::__construct();
  6338. }
  6339. protected function configure()
  6340. {
  6341. $this
  6342. ->setName($this->script)
  6343. ->setDescription($this->description)
  6344. ->setDefinition(array(
  6345. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  6346. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  6347. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  6348. ))
  6349. ->setHelp(
  6350. <<<EOT
  6351. The <info>run-script</info> command runs scripts defined in composer.json:
  6352. <info>php composer.phar run-script post-update-cmd</info>
  6353. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  6354. EOT
  6355. )
  6356. ;
  6357. }
  6358. protected function execute(InputInterface $input, OutputInterface $output)
  6359. {
  6360. $composer = $this->getComposer();
  6361. $args = $input->getArguments();
  6362. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  6363. }
  6364. }
  6365. <?php
  6366. namespace Composer\Command;
  6367. use Composer\Factory;
  6368. use Composer\Json\JsonFile;
  6369. use Symfony\Component\Console\Input\InputInterface;
  6370. use Symfony\Component\Console\Input\InputArgument;
  6371. use Symfony\Component\Console\Input\InputOption;
  6372. use Symfony\Component\Console\Output\OutputInterface;
  6373. use Composer\Repository\CompositeRepository;
  6374. use Composer\Repository\PlatformRepository;
  6375. use Composer\Repository\RepositoryInterface;
  6376. use Composer\Plugin\CommandEvent;
  6377. use Composer\Plugin\PluginEvents;
  6378. class SearchCommand extends BaseCommand
  6379. {
  6380. protected function configure()
  6381. {
  6382. $this
  6383. ->setName('search')
  6384. ->setDescription('Searches for packages.')
  6385. ->setDefinition(array(
  6386. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in package names'),
  6387. new InputOption('only-vendor', 'O', InputOption::VALUE_NONE, 'Search only for vendor / organization names, returns only "vendor" as result'),
  6388. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  6389. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6390. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  6391. ))
  6392. ->setHelp(
  6393. <<<EOT
  6394. The search command searches for packages by its name
  6395. <info>php composer.phar search symfony composer</info>
  6396. Read more at https://getcomposer.org/doc/03-cli.md#search
  6397. EOT
  6398. )
  6399. ;
  6400. }
  6401. protected function execute(InputInterface $input, OutputInterface $output)
  6402. {
  6403. $platformRepo = new PlatformRepository;
  6404. $io = $this->getIO();
  6405. $format = $input->getOption('format');
  6406. if (!in_array($format, array('text', 'json'))) {
  6407. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6408. return 1;
  6409. }
  6410. if (!($composer = $this->getComposer(false))) {
  6411. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  6412. }
  6413. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6414. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  6415. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6416. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  6417. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6418. $mode = RepositoryInterface::SEARCH_FULLTEXT;
  6419. if ($input->getOption('only-name') === true) {
  6420. if ($input->getOption('only-vendor') === true) {
  6421. throw new \InvalidArgumentException('--only-name and --only-vendor cannot be used together');
  6422. }
  6423. $mode = RepositoryInterface::SEARCH_NAME;
  6424. } elseif ($input->getOption('only-vendor') === true) {
  6425. $mode = RepositoryInterface::SEARCH_VENDOR;
  6426. }
  6427. $type = $input->getOption('type');
  6428. $query = implode(' ', $input->getArgument('tokens'));
  6429. if ($mode !== RepositoryInterface::SEARCH_FULLTEXT) {
  6430. $query = preg_quote($query);
  6431. }
  6432. $results = $repos->search($query, $mode, $type);
  6433. if ($results && $format === 'text') {
  6434. $width = $this->getTerminalWidth();
  6435. $nameLength = 0;
  6436. foreach ($results as $result) {
  6437. $nameLength = max(strlen($result['name']), $nameLength);
  6438. }
  6439. $nameLength += 1;
  6440. foreach ($results as $result) {
  6441. $description = isset($result['description']) ? $result['description'] : '';
  6442. $warning = !empty($result['abandoned']) ? '<warning>! Abandoned !</warning> ' : '';
  6443. $remaining = $width - $nameLength - strlen($warning) - 2;
  6444. if (strlen($description) > $remaining) {
  6445. $description = substr($description, 0, $remaining - 3) . '...';
  6446. }
  6447. $io->write(str_pad($result['name'], $nameLength, ' ') . $warning . $description);
  6448. }
  6449. } elseif ($format === 'json') {
  6450. $io->write(JsonFile::encode($results));
  6451. }
  6452. return 0;
  6453. }
  6454. }
  6455. <?php
  6456. namespace Composer\Command;
  6457. use Composer\Composer;
  6458. use Composer\Factory;
  6459. use Composer\Config;
  6460. use Composer\Pcre\Preg;
  6461. use Composer\Util\Filesystem;
  6462. use Composer\Util\Platform;
  6463. use Composer\SelfUpdate\Keys;
  6464. use Composer\SelfUpdate\Versions;
  6465. use Composer\IO\IOInterface;
  6466. use Composer\Downloader\FilesystemException;
  6467. use Composer\Downloader\TransportException;
  6468. use Symfony\Component\Console\Input\InputInterface;
  6469. use Symfony\Component\Console\Input\InputOption;
  6470. use Symfony\Component\Console\Input\InputArgument;
  6471. use Symfony\Component\Console\Output\OutputInterface;
  6472. use Symfony\Component\Finder\Finder;
  6473. class SelfUpdateCommand extends BaseCommand
  6474. {
  6475. const HOMEPAGE = 'getcomposer.org';
  6476. const OLD_INSTALL_EXT = '-old.phar';
  6477. protected function configure()
  6478. {
  6479. $this
  6480. ->setName('self-update')
  6481. ->setAliases(array('selfupdate'))
  6482. ->setDescription('Updates composer.phar to the latest version.')
  6483. ->setDefinition(array(
  6484. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  6485. 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'),
  6486. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  6487. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6488. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  6489. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  6490. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  6491. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  6492. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  6493. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  6494. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  6495. ))
  6496. ->setHelp(
  6497. <<<EOT
  6498. The <info>self-update</info> command checks getcomposer.org for newer
  6499. versions of composer and if found, installs the latest.
  6500. <info>php composer.phar self-update</info>
  6501. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  6502. EOT
  6503. )
  6504. ;
  6505. }
  6506. protected function execute(InputInterface $input, OutputInterface $output)
  6507. {
  6508. class_exists('Composer\Util\Platform');
  6509. class_exists('Composer\Downloader\FilesystemException');
  6510. $config = Factory::createConfig();
  6511. if ($config->get('disable-tls') === true) {
  6512. $baseUrl = 'http://' . self::HOMEPAGE;
  6513. } else {
  6514. $baseUrl = 'https://' . self::HOMEPAGE;
  6515. }
  6516. $io = $this->getIO();
  6517. $httpDownloader = Factory::createHttpDownloader($io, $config);
  6518. $versionsUtil = new Versions($config, $httpDownloader);
  6519. $requestedChannel = null;
  6520. foreach (Versions::$channels as $channel) {
  6521. if ($input->getOption($channel)) {
  6522. $requestedChannel = $channel;
  6523. $versionsUtil->setChannel($channel);
  6524. break;
  6525. }
  6526. }
  6527. if ($input->getOption('set-channel-only')) {
  6528. return 0;
  6529. }
  6530. $cacheDir = $config->get('cache-dir');
  6531. $rollbackDir = $config->get('data-dir');
  6532. $home = $config->get('home');
  6533. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  6534. if ($input->getOption('update-keys')) {
  6535. $this->fetchKeys($io, $config);
  6536. return 0;
  6537. }
  6538. if (!file_exists($localFilename)) {
  6539. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  6540. }
  6541. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  6542. if (!is_writable($tmpDir)) {
  6543. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  6544. }
  6545. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  6546. $composeUser = posix_getpwuid(posix_geteuid());
  6547. $homeOwner = posix_getpwuid(fileowner($home));
  6548. if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  6549. $io->writeError('<warning>You are running Composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  6550. }
  6551. }
  6552. if ($input->getOption('rollback')) {
  6553. return $this->rollback($output, $rollbackDir, $localFilename);
  6554. }
  6555. $latest = $versionsUtil->getLatest();
  6556. $latestStable = $versionsUtil->getLatest('stable');
  6557. try {
  6558. $latestPreview = $versionsUtil->getLatest('preview');
  6559. } catch (\UnexpectedValueException $e) {
  6560. $latestPreview = $latestStable;
  6561. }
  6562. $latestVersion = $latest['version'];
  6563. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  6564. $currentMajorVersion = Preg::replace('{^(\d+).*}', '$1', Composer::getVersion());
  6565. $updateMajorVersion = Preg::replace('{^(\d+).*}', '$1', $updateVersion);
  6566. $previewMajorVersion = Preg::replace('{^(\d+).*}', '$1', $latestPreview['version']);
  6567. if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
  6568. if ($currentMajorVersion < $updateMajorVersion) {
  6569. $skippedVersion = $updateVersion;
  6570. $versionsUtil->setChannel($currentMajorVersion);
  6571. $latest = $versionsUtil->getLatest();
  6572. $latestStable = $versionsUtil->getLatest('stable');
  6573. $latestVersion = $latest['version'];
  6574. $updateVersion = $latestVersion;
  6575. $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>');
  6576. } elseif ($currentMajorVersion < $previewMajorVersion) {
  6577. $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>');
  6578. }
  6579. }
  6580. if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
  6581. $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>');
  6582. }
  6583. if (Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  6584. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  6585. return 1;
  6586. }
  6587. $channelString = $versionsUtil->getChannel();
  6588. if (is_numeric($channelString)) {
  6589. $channelString .= '.x';
  6590. }
  6591. if (Composer::VERSION === $updateVersion) {
  6592. $io->writeError(
  6593. sprintf(
  6594. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  6595. $updateVersion,
  6596. $channelString
  6597. )
  6598. );
  6599. if ($input->getOption('clean-backups')) {
  6600. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  6601. }
  6602. return 0;
  6603. }
  6604. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp'.rand(0, 10000000).'.phar';
  6605. $backupFile = sprintf(
  6606. '%s/%s-%s%s',
  6607. $rollbackDir,
  6608. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  6609. Preg::replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  6610. self::OLD_INSTALL_EXT
  6611. );
  6612. $updatingToTag = !Preg::isMatch('{^[0-9a-f]{40}$}', $updateVersion);
  6613. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  6614. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  6615. try {
  6616. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  6617. } catch (TransportException $e) {
  6618. if ($e->getStatusCode() === 404) {
  6619. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  6620. }
  6621. throw $e;
  6622. }
  6623. $io->writeError(' ', false);
  6624. $httpDownloader->copy($remoteFilename, $tempFilename);
  6625. $io->writeError('');
  6626. if (!file_exists($tempFilename) || !$signature) {
  6627. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  6628. return 1;
  6629. }
  6630. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  6631. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  6632. } else {
  6633. if (!extension_loaded('openssl')) {
  6634. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  6635. . '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.');
  6636. }
  6637. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  6638. if (!file_exists($sigFile)) {
  6639. file_put_contents(
  6640. $home.'/keys.dev.pub',
  6641. <<<DEVPUBKEY
  6642. -----BEGIN PUBLIC KEY-----
  6643. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  6644. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  6645. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  6646. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  6647. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  6648. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  6649. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  6650. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  6651. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  6652. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  6653. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  6654. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  6655. -----END PUBLIC KEY-----
  6656. DEVPUBKEY
  6657. );
  6658. file_put_contents(
  6659. $home.'/keys.tags.pub',
  6660. <<<TAGSPUBKEY
  6661. -----BEGIN PUBLIC KEY-----
  6662. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  6663. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  6664. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  6665. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  6666. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  6667. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  6668. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  6669. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  6670. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  6671. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  6672. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  6673. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  6674. -----END PUBLIC KEY-----
  6675. TAGSPUBKEY
  6676. );
  6677. }
  6678. $pubkeyid = openssl_pkey_get_public($sigFile);
  6679. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  6680. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  6681. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  6682. }
  6683. $signature = json_decode($signature, true);
  6684. $signature = base64_decode($signature['sha384']);
  6685. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  6686. if (PHP_VERSION_ID < 80000) {
  6687. openssl_free_key($pubkeyid);
  6688. }
  6689. if (!$verified) {
  6690. 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');
  6691. }
  6692. }
  6693. if ($input->getOption('clean-backups')) {
  6694. $this->cleanBackups($rollbackDir);
  6695. }
  6696. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  6697. @unlink($tempFilename);
  6698. return 1;
  6699. }
  6700. if (file_exists($backupFile)) {
  6701. $io->writeError(sprintf(
  6702. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  6703. Composer::VERSION
  6704. ));
  6705. } else {
  6706. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  6707. }
  6708. return 0;
  6709. }
  6710. protected function fetchKeys(IOInterface $io, Config $config)
  6711. {
  6712. if (!$io->isInteractive()) {
  6713. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  6714. }
  6715. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  6716. $validator = function ($value) {
  6717. if (!Preg::isMatch('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  6718. throw new \UnexpectedValueException('Invalid input');
  6719. }
  6720. return trim($value)."\n";
  6721. };
  6722. $devKey = '';
  6723. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  6724. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  6725. while ($line = $io->ask('')) {
  6726. $devKey .= trim($line)."\n";
  6727. if (trim($line) === '-----END PUBLIC KEY-----') {
  6728. break;
  6729. }
  6730. }
  6731. }
  6732. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  6733. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  6734. $tagsKey = '';
  6735. while (!Preg::isMatch('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  6736. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  6737. while ($line = $io->ask('')) {
  6738. $tagsKey .= trim($line)."\n";
  6739. if (trim($line) === '-----END PUBLIC KEY-----') {
  6740. break;
  6741. }
  6742. }
  6743. }
  6744. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  6745. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  6746. $io->write('Public keys stored in '.$config->get('home'));
  6747. }
  6748. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  6749. {
  6750. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  6751. if (!$rollbackVersion) {
  6752. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  6753. }
  6754. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  6755. if (!is_file($oldFile)) {
  6756. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  6757. }
  6758. if (!Filesystem::isReadable($oldFile)) {
  6759. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  6760. }
  6761. $io = $this->getIO();
  6762. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  6763. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  6764. return 1;
  6765. }
  6766. return 0;
  6767. }
  6768. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  6769. {
  6770. $io = $this->getIO();
  6771. @chmod($newFilename, fileperms($localFilename));
  6772. if (!$this->validatePhar($newFilename, $error)) {
  6773. $io->writeError('<error>The '.($backupTarget ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  6774. if ($backupTarget) {
  6775. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  6776. }
  6777. return false;
  6778. }
  6779. if ($backupTarget) {
  6780. @copy($localFilename, $backupTarget);
  6781. }
  6782. try {
  6783. if (Platform::isWindows()) {
  6784. copy($newFilename, $localFilename);
  6785. @unlink($newFilename);
  6786. } else {
  6787. rename($newFilename, $localFilename);
  6788. }
  6789. return true;
  6790. } catch (\Exception $e) {
  6791. if (!is_writable(dirname($localFilename))
  6792. && $io->isInteractive()
  6793. && $this->isWindowsNonAdminUser()) {
  6794. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  6795. }
  6796. @unlink($newFilename);
  6797. $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
  6798. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  6799. }
  6800. }
  6801. protected function cleanBackups($rollbackDir, $except = null)
  6802. {
  6803. $finder = $this->getOldInstallationFinder($rollbackDir);
  6804. $io = $this->getIO();
  6805. $fs = new Filesystem;
  6806. foreach ($finder as $file) {
  6807. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  6808. continue;
  6809. }
  6810. $file = (string) $file;
  6811. $io->writeError('<info>Removing: '.$file.'</info>');
  6812. $fs->remove($file);
  6813. }
  6814. }
  6815. protected function getLastBackupVersion($rollbackDir)
  6816. {
  6817. $finder = $this->getOldInstallationFinder($rollbackDir);
  6818. $finder->sortByName();
  6819. $files = iterator_to_array($finder);
  6820. if (count($files)) {
  6821. return basename(end($files), self::OLD_INSTALL_EXT);
  6822. }
  6823. return false;
  6824. }
  6825. protected function getOldInstallationFinder($rollbackDir)
  6826. {
  6827. return Finder::create()
  6828. ->depth(0)
  6829. ->files()
  6830. ->name('*' . self::OLD_INSTALL_EXT)
  6831. ->in($rollbackDir);
  6832. }
  6833. protected function validatePhar($pharFile, &$error)
  6834. {
  6835. if (ini_get('phar.readonly')) {
  6836. return true;
  6837. }
  6838. try {
  6839. $phar = new \Phar($pharFile);
  6840. unset($phar);
  6841. $result = true;
  6842. } catch (\Exception $e) {
  6843. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  6844. throw $e;
  6845. }
  6846. $error = $e->getMessage();
  6847. $result = false;
  6848. }
  6849. return $result;
  6850. }
  6851. protected function isWindowsNonAdminUser()
  6852. {
  6853. if (!Platform::isWindows()) {
  6854. return false;
  6855. }
  6856. exec('fltmc.exe filters', $output, $exitCode);
  6857. return $exitCode !== 0;
  6858. }
  6859. protected function tryAsWindowsAdmin($localFilename, $newFilename)
  6860. {
  6861. $io = $this->getIO();
  6862. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6863. $helpMessage = 'Please run the self-update command as an Administrator.';
  6864. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6865. if (!$io->askConfirmation($question, false)) {
  6866. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6867. return false;
  6868. }
  6869. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6870. $script = $tmpFile.'.vbs';
  6871. rename($tmpFile, $script);
  6872. $checksum = hash_file('sha256', $newFilename);
  6873. $source = str_replace('/', '\\', $newFilename);
  6874. $destination = str_replace('/', '\\', $localFilename);
  6875. $vbs = <<<EOT
  6876. Set UAC = CreateObject("Shell.Application")
  6877. UAC.ShellExecute "cmd.exe", "/c copy /b /y ""$source"" ""$destination""", "", "runas", 0
  6878. Wscript.Sleep(300)
  6879. EOT;
  6880. file_put_contents($script, $vbs);
  6881. exec('"'.$script.'"');
  6882. @unlink($script);
  6883. if ($result = Filesystem::isReadable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
  6884. $io->writeError('<info>Operation succeeded.</info>');
  6885. @unlink($newFilename);
  6886. } else {
  6887. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  6888. }
  6889. return $result;
  6890. }
  6891. }
  6892. <?php
  6893. namespace Composer\Command;
  6894. use Composer\Composer;
  6895. use Composer\DependencyResolver\DefaultPolicy;
  6896. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  6897. use Composer\Json\JsonFile;
  6898. use Composer\Package\BasePackage;
  6899. use Composer\Package\CompletePackageInterface;
  6900. use Composer\Package\Link;
  6901. use Composer\Package\AliasPackage;
  6902. use Composer\Package\Package;
  6903. use Composer\Package\PackageInterface;
  6904. use Composer\Package\Version\VersionParser;
  6905. use Composer\Package\Version\VersionSelector;
  6906. use Composer\Pcre\Preg;
  6907. use Composer\Plugin\CommandEvent;
  6908. use Composer\Plugin\PluginEvents;
  6909. use Composer\Repository\InstalledArrayRepository;
  6910. use Composer\Repository\ComposerRepository;
  6911. use Composer\Repository\CompositeRepository;
  6912. use Composer\Repository\FilterRepository;
  6913. use Composer\Repository\PlatformRepository;
  6914. use Composer\Repository\RepositoryFactory;
  6915. use Composer\Repository\InstalledRepository;
  6916. use Composer\Repository\RepositoryInterface;
  6917. use Composer\Repository\RepositorySet;
  6918. use Composer\Repository\RootPackageRepository;
  6919. use Composer\Semver\Constraint\ConstraintInterface;
  6920. use Composer\Semver\Semver;
  6921. use Composer\Spdx\SpdxLicenses;
  6922. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  6923. use Symfony\Component\Console\Input\InputArgument;
  6924. use Symfony\Component\Console\Input\InputInterface;
  6925. use Symfony\Component\Console\Input\InputOption;
  6926. use Symfony\Component\Console\Output\OutputInterface;
  6927. class ShowCommand extends BaseCommand
  6928. {
  6929. protected $versionParser;
  6930. protected $colors;
  6931. private $repositorySet;
  6932. protected function configure()
  6933. {
  6934. $this
  6935. ->setName('show')
  6936. ->setAliases(array('info'))
  6937. ->setDescription('Shows information about packages.')
  6938. ->setDefinition(array(
  6939. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  6940. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  6941. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  6942. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  6943. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  6944. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  6945. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  6946. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  6947. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  6948. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  6949. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  6950. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  6951. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  6952. 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.'),
  6953. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  6954. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6955. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6956. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6957. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6958. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option'),
  6959. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages). Use with the --outdated option'),
  6960. ))
  6961. ->setHelp(
  6962. <<<EOT
  6963. The show command displays detailed information about a package, or
  6964. lists all packages available.
  6965. Read more at https://getcomposer.org/doc/03-cli.md#show
  6966. EOT
  6967. )
  6968. ;
  6969. }
  6970. protected function execute(InputInterface $input, OutputInterface $output)
  6971. {
  6972. $this->versionParser = new VersionParser;
  6973. if ($input->getOption('tree')) {
  6974. $this->initStyles($output);
  6975. }
  6976. $composer = $this->getComposer(false);
  6977. $io = $this->getIO();
  6978. if ($input->getOption('installed')) {
  6979. $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>');
  6980. }
  6981. if ($input->getOption('outdated')) {
  6982. $input->setOption('latest', true);
  6983. } elseif ($input->getOption('ignore')) {
  6984. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  6985. }
  6986. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  6987. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  6988. return 1;
  6989. }
  6990. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  6991. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  6992. return 1;
  6993. }
  6994. if ($input->getOption('tree') && $input->getOption('latest')) {
  6995. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  6996. return 1;
  6997. }
  6998. if ($input->getOption('tree') && $input->getOption('path')) {
  6999. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  7000. return 1;
  7001. }
  7002. $format = $input->getOption('format');
  7003. if (!in_array($format, array('text', 'json'))) {
  7004. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  7005. return 1;
  7006. }
  7007. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  7008. $platformOverrides = array();
  7009. if ($composer) {
  7010. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  7011. }
  7012. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  7013. $lockedRepo = null;
  7014. if ($input->getOption('self')) {
  7015. $package = $this->getComposer()->getPackage();
  7016. if ($input->getOption('name-only')) {
  7017. $io->write($package->getName());
  7018. return 0;
  7019. }
  7020. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  7021. } elseif ($input->getOption('platform')) {
  7022. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  7023. } elseif ($input->getOption('available')) {
  7024. $installedRepo = new InstalledRepository(array($platformRepo));
  7025. if ($composer) {
  7026. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  7027. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  7028. } else {
  7029. $defaultRepos = RepositoryFactory::defaultRepos($io);
  7030. $repos = new CompositeRepository($defaultRepos);
  7031. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  7032. }
  7033. } elseif ($input->getOption('all') && $composer) {
  7034. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7035. $locker = $composer->getLocker();
  7036. if ($locker->isLocked()) {
  7037. $lockedRepo = $locker->getLockedRepository(true);
  7038. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  7039. } else {
  7040. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  7041. }
  7042. $repos = new CompositeRepository(array_merge(array(new FilterRepository($installedRepo, array('canonical' => false))), $composer->getRepositoryManager()->getRepositories()));
  7043. } elseif ($input->getOption('all')) {
  7044. $defaultRepos = RepositoryFactory::defaultRepos($io);
  7045. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  7046. $installedRepo = new InstalledRepository(array($platformRepo));
  7047. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  7048. } elseif ($input->getOption('locked')) {
  7049. if (!$composer || !$composer->getLocker()->isLocked()) {
  7050. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  7051. }
  7052. $locker = $composer->getLocker();
  7053. $lockedRepo = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7054. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  7055. } else {
  7056. if (!$composer) {
  7057. $composer = $this->getComposer();
  7058. }
  7059. $rootPkg = $composer->getPackage();
  7060. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  7061. if ($input->getOption('no-dev')) {
  7062. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  7063. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) {
  7064. return clone $pkg;
  7065. }, $packages))));
  7066. }
  7067. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  7068. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  7069. }
  7070. }
  7071. if ($composer) {
  7072. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  7073. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7074. }
  7075. if ($input->getOption('latest') && null === $composer) {
  7076. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  7077. $input->setOption('latest', false);
  7078. }
  7079. $packageFilter = $input->getArgument('package');
  7080. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  7081. if (empty($package)) {
  7082. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  7083. if (empty($package)) {
  7084. $options = $input->getOptions();
  7085. $hint = '';
  7086. if ($input->getOption('locked')) {
  7087. $hint .= ' in lock file';
  7088. }
  7089. if (isset($options['working-dir'])) {
  7090. $hint .= ' in ' . $options['working-dir'] . '/composer.json';
  7091. }
  7092. if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
  7093. $hint .= ', try using --platform (-p) to show platform packages';
  7094. }
  7095. if (!$input->getOption('all')) {
  7096. $hint .= ', try using --all (-a) to show all available packages';
  7097. }
  7098. throw new \InvalidArgumentException('Package "' . $packageFilter . '" not found'.$hint.'.');
  7099. }
  7100. } else {
  7101. $versions = array($package->getPrettyVersion() => $package->getVersion());
  7102. }
  7103. $exitCode = 0;
  7104. if ($input->getOption('tree')) {
  7105. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  7106. if ('json' === $format) {
  7107. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  7108. } else {
  7109. $this->displayPackageTree(array($arrayTree));
  7110. }
  7111. } else {
  7112. $latestPackage = null;
  7113. if ($input->getOption('latest')) {
  7114. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'), $ignorePlatformReqs);
  7115. }
  7116. if (
  7117. $input->getOption('outdated')
  7118. && $input->getOption('strict')
  7119. && $latestPackage
  7120. && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion()
  7121. && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned())
  7122. ) {
  7123. $exitCode = 1;
  7124. }
  7125. if ($input->getOption('path')) {
  7126. $io->write($package->getName(), false);
  7127. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  7128. return $exitCode;
  7129. }
  7130. if ('json' === $format) {
  7131. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  7132. } else {
  7133. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  7134. }
  7135. }
  7136. return $exitCode;
  7137. }
  7138. if ($input->getOption('tree')) {
  7139. $rootRequires = $this->getRootRequires();
  7140. $packages = $installedRepo->getPackages();
  7141. usort($packages, function (BasePackage $a, BasePackage $b) {
  7142. return strcmp((string) $a, (string) $b);
  7143. });
  7144. $arrayTree = array();
  7145. foreach ($packages as $package) {
  7146. if (in_array($package->getName(), $rootRequires, true)) {
  7147. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  7148. }
  7149. }
  7150. if ('json' === $format) {
  7151. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  7152. } else {
  7153. $this->displayPackageTree($arrayTree);
  7154. }
  7155. return 0;
  7156. }
  7157. $packages = array();
  7158. $packageFilterRegex = null;
  7159. if (null !== $packageFilter) {
  7160. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  7161. }
  7162. $packageListFilter = array();
  7163. if ($input->getOption('direct')) {
  7164. $packageListFilter = $this->getRootRequires();
  7165. }
  7166. if ($input->getOption('path') && null === $composer) {
  7167. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  7168. $input->setOption('path', false);
  7169. }
  7170. foreach ($repos->getRepositories() as $repo) {
  7171. if ($repo === $platformRepo) {
  7172. $type = 'platform';
  7173. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  7174. $type = 'locked';
  7175. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  7176. $type = 'installed';
  7177. } else {
  7178. $type = 'available';
  7179. }
  7180. if ($repo instanceof ComposerRepository) {
  7181. foreach ($repo->getPackageNames($packageFilter) as $name) {
  7182. $packages[$type][$name] = $name;
  7183. }
  7184. } else {
  7185. foreach ($repo->getPackages() as $package) {
  7186. if (!isset($packages[$type][$package->getName()])
  7187. || !is_object($packages[$type][$package->getName()])
  7188. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  7189. ) {
  7190. while ($package instanceof AliasPackage) {
  7191. $package = $package->getAliasOf();
  7192. }
  7193. if (!$packageFilterRegex || Preg::isMatch($packageFilterRegex, $package->getName())) {
  7194. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  7195. $packages[$type][$package->getName()] = $package;
  7196. }
  7197. }
  7198. }
  7199. }
  7200. if ($repo === $platformRepo) {
  7201. foreach ($platformRepo->getDisabledPackages() as $name => $package) {
  7202. $packages[$type][$name] = $package;
  7203. }
  7204. }
  7205. }
  7206. }
  7207. $showAllTypes = $input->getOption('all');
  7208. $showLatest = $input->getOption('latest');
  7209. $showMinorOnly = $input->getOption('minor-only');
  7210. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  7211. $indent = $showAllTypes ? ' ' : '';
  7212. $latestPackages = array();
  7213. $exitCode = 0;
  7214. $viewData = array();
  7215. $viewMetaData = array();
  7216. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  7217. if (isset($packages[$type])) {
  7218. ksort($packages[$type]);
  7219. $nameLength = $versionLength = $latestLength = 0;
  7220. if ($showLatest && $showVersion) {
  7221. foreach ($packages[$type] as $package) {
  7222. if (is_object($package)) {
  7223. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly, $ignorePlatformReqs);
  7224. if ($latestPackage === false) {
  7225. continue;
  7226. }
  7227. $latestPackages[$package->getPrettyName()] = $latestPackage;
  7228. }
  7229. }
  7230. }
  7231. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  7232. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  7233. $writeLatest = $writeVersion && $showLatest;
  7234. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  7235. $hasOutdatedPackages = false;
  7236. $viewData[$type] = array();
  7237. foreach ($packages[$type] as $package) {
  7238. $packageViewData = array();
  7239. if (is_object($package)) {
  7240. $latestPackage = null;
  7241. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  7242. $latestPackage = $latestPackages[$package->getPrettyName()];
  7243. }
  7244. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && (!$latestPackage instanceof CompletePackageInterface || !$latestPackage->isAbandoned());
  7245. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  7246. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  7247. continue;
  7248. }
  7249. if ($input->getOption('outdated') || $input->getOption('strict')) {
  7250. $hasOutdatedPackages = true;
  7251. }
  7252. $packageViewData['name'] = $package->getPrettyName();
  7253. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  7254. if ($writeVersion) {
  7255. $packageViewData['version'] = $package->getFullPrettyVersion();
  7256. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  7257. }
  7258. if ($writeLatest && $latestPackage) {
  7259. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  7260. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  7261. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  7262. }
  7263. if ($writeDescription && $package instanceof CompletePackageInterface) {
  7264. $packageViewData['description'] = $package->getDescription();
  7265. }
  7266. if ($writePath) {
  7267. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  7268. }
  7269. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7270. $replacement = is_string($latestPackage->getReplacementPackage())
  7271. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  7272. : 'No replacement was suggested';
  7273. $packageWarning = sprintf(
  7274. 'Package %s is abandoned, you should avoid using it. %s.',
  7275. $package->getPrettyName(),
  7276. $replacement
  7277. );
  7278. $packageViewData['warning'] = $packageWarning;
  7279. }
  7280. } else {
  7281. $packageViewData['name'] = $package;
  7282. $nameLength = max($nameLength, strlen($package));
  7283. }
  7284. $viewData[$type][] = $packageViewData;
  7285. }
  7286. $viewMetaData[$type] = array(
  7287. 'nameLength' => $nameLength,
  7288. 'versionLength' => $versionLength,
  7289. 'latestLength' => $latestLength,
  7290. );
  7291. if ($input->getOption('strict') && $hasOutdatedPackages) {
  7292. $exitCode = 1;
  7293. break;
  7294. }
  7295. }
  7296. }
  7297. if ('json' === $format) {
  7298. $io->write(JsonFile::encode($viewData));
  7299. } else {
  7300. if ($input->getOption('latest') && array_filter($viewData)) {
  7301. if (!$io->isDecorated()) {
  7302. $io->writeError('Legend:');
  7303. $io->writeError('! patch or minor release available - update recommended');
  7304. $io->writeError('~ major release available - update possible');
  7305. if (!$input->getOption('outdated')) {
  7306. $io->writeError('= up to date version');
  7307. }
  7308. } else {
  7309. $io->writeError('<info>Color legend:</info>');
  7310. $io->writeError('- <highlight>patch or minor</highlight> release available - update recommended');
  7311. $io->writeError('- <comment>major</comment> release available - update possible');
  7312. if (!$input->getOption('outdated')) {
  7313. $io->writeError('- <info>up to date</info> version');
  7314. }
  7315. }
  7316. }
  7317. $width = $this->getTerminalWidth();
  7318. foreach ($viewData as $type => $packages) {
  7319. $nameLength = $viewMetaData[$type]['nameLength'];
  7320. $versionLength = $viewMetaData[$type]['versionLength'];
  7321. $latestLength = $viewMetaData[$type]['latestLength'];
  7322. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  7323. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  7324. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  7325. if ($writeLatest && !$io->isDecorated()) {
  7326. $latestLength += 2;
  7327. }
  7328. if ($showAllTypes) {
  7329. if ('available' === $type) {
  7330. $io->write('<comment>' . $type . '</comment>:');
  7331. } else {
  7332. $io->write('<info>' . $type . '</info>:');
  7333. }
  7334. }
  7335. foreach ($packages as $package) {
  7336. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  7337. if (isset($package['version']) && $writeVersion) {
  7338. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  7339. }
  7340. if (isset($package['latest']) && $writeLatest) {
  7341. $latestVersion = $package['latest'];
  7342. $updateStatus = $package['latest-status'];
  7343. $style = $this->updateStatusToVersionStyle($updateStatus);
  7344. if (!$io->isDecorated()) {
  7345. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  7346. }
  7347. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  7348. }
  7349. if (isset($package['description']) && $writeDescription) {
  7350. $description = strtok($package['description'], "\r\n");
  7351. $remaining = $width - $nameLength - $versionLength - 4;
  7352. if ($writeLatest) {
  7353. $remaining -= $latestLength;
  7354. }
  7355. if (strlen($description) > $remaining) {
  7356. $description = substr($description, 0, $remaining - 3) . '...';
  7357. }
  7358. $io->write(' ' . $description, false);
  7359. }
  7360. if (isset($package['path'])) {
  7361. $io->write(' ' . $package['path'], false);
  7362. }
  7363. $io->write('');
  7364. if (isset($package['warning'])) {
  7365. $io->write('<warning>' . $package['warning'] . '</warning>');
  7366. }
  7367. }
  7368. if ($showAllTypes) {
  7369. $io->write('');
  7370. }
  7371. }
  7372. }
  7373. return $exitCode;
  7374. }
  7375. protected function getRootRequires()
  7376. {
  7377. $rootPackage = $this->getComposer()->getPackage();
  7378. return array_map(
  7379. 'strtolower',
  7380. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  7381. );
  7382. }
  7383. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  7384. {
  7385. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  7386. }
  7387. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
  7388. {
  7389. $name = strtolower($name);
  7390. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  7391. $policy = new DefaultPolicy();
  7392. $repositorySet = new RepositorySet('dev');
  7393. $repositorySet->allowInstalledRepositories();
  7394. $repositorySet->addRepository($repos);
  7395. $matchedPackage = null;
  7396. $versions = array();
  7397. if (PlatformRepository::isPlatformPackage($name)) {
  7398. $pool = $repositorySet->createPoolWithAllPackages();
  7399. } else {
  7400. $pool = $repositorySet->createPoolForPackage($name);
  7401. }
  7402. $matches = $pool->whatProvides($name, $constraint);
  7403. foreach ($matches as $index => $package) {
  7404. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  7405. $package = $package->getAliasOf();
  7406. }
  7407. if (null === $version && $installedRepo->hasPackage($package)) {
  7408. $matchedPackage = $package;
  7409. }
  7410. $versions[$package->getPrettyVersion()] = $package->getVersion();
  7411. $matches[$index] = $package->getId();
  7412. }
  7413. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  7414. $matchedPackage = $pool->literalToPackage($preferred[0]);
  7415. }
  7416. return array($matchedPackage, $versions);
  7417. }
  7418. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  7419. {
  7420. $io = $this->getIO();
  7421. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  7422. $this->printLinks($package, Link::TYPE_REQUIRE);
  7423. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  7424. if ($package->getSuggests()) {
  7425. $io->write("\n<info>suggests</info>");
  7426. foreach ($package->getSuggests() as $suggested => $reason) {
  7427. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  7428. }
  7429. }
  7430. $this->printLinks($package, Link::TYPE_PROVIDE);
  7431. $this->printLinks($package, Link::TYPE_CONFLICT);
  7432. $this->printLinks($package, Link::TYPE_REPLACE);
  7433. }
  7434. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  7435. {
  7436. $io = $this->getIO();
  7437. $io->write('<info>name</info> : ' . $package->getPrettyName());
  7438. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  7439. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  7440. $this->printVersions($package, $versions, $installedRepo);
  7441. if ($latestPackage) {
  7442. $style = $this->getVersionStyle($latestPackage, $package);
  7443. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  7444. } else {
  7445. $latestPackage = $package;
  7446. }
  7447. $io->write('<info>type</info> : ' . $package->getType());
  7448. $this->printLicenses($package);
  7449. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  7450. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  7451. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  7452. if ($installedRepo->hasPackage($package)) {
  7453. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  7454. }
  7455. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  7456. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7457. $replacement = ($latestPackage->getReplacementPackage() !== null)
  7458. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  7459. : null;
  7460. $io->writeError(
  7461. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  7462. );
  7463. }
  7464. if ($package->getSupport()) {
  7465. $io->write("\n<info>support</info>");
  7466. foreach ($package->getSupport() as $type => $value) {
  7467. $io->write('<comment>' . $type . '</comment> : '.$value);
  7468. }
  7469. }
  7470. if ($package->getAutoload()) {
  7471. $io->write("\n<info>autoload</info>");
  7472. $autoloadConfig = $package->getAutoload();
  7473. foreach ($autoloadConfig as $type => $autoloads) {
  7474. $io->write('<comment>' . $type . '</comment>');
  7475. if ($type === 'psr-0' || $type === 'psr-4') {
  7476. foreach ($autoloads as $name => $path) {
  7477. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  7478. }
  7479. } elseif ($type === 'classmap') {
  7480. $io->write(implode(', ', $autoloadConfig[$type]));
  7481. }
  7482. }
  7483. if ($package->getIncludePaths()) {
  7484. $io->write('<comment>include-path</comment>');
  7485. $io->write(implode(', ', $package->getIncludePaths()));
  7486. }
  7487. }
  7488. }
  7489. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
  7490. {
  7491. $versions = array_keys($versions);
  7492. $versions = Semver::rsort($versions);
  7493. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  7494. foreach ($installedPackages as $installedPackage) {
  7495. $installedVersion = $installedPackage->getPrettyVersion();
  7496. $key = array_search($installedVersion, $versions);
  7497. if (false !== $key) {
  7498. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  7499. }
  7500. }
  7501. }
  7502. $versions = implode(', ', $versions);
  7503. $this->getIO()->write('<info>versions</info> : ' . $versions);
  7504. }
  7505. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  7506. {
  7507. $title = $title ?: $linkType;
  7508. $io = $this->getIO();
  7509. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  7510. $io->write("\n<info>" . $title . "</info>");
  7511. foreach ($links as $link) {
  7512. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  7513. }
  7514. }
  7515. }
  7516. protected function printLicenses(CompletePackageInterface $package)
  7517. {
  7518. $spdxLicenses = new SpdxLicenses();
  7519. $licenses = $package->getLicense();
  7520. $io = $this->getIO();
  7521. foreach ($licenses as $licenseId) {
  7522. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  7523. if (!$license) {
  7524. $out = $licenseId;
  7525. } else {
  7526. if ($license[1] === true) {
  7527. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  7528. } else {
  7529. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  7530. }
  7531. }
  7532. $io->write('<info>license</info> : ' . $out);
  7533. }
  7534. }
  7535. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  7536. {
  7537. $json = array(
  7538. 'name' => $package->getPrettyName(),
  7539. 'description' => $package->getDescription(),
  7540. 'keywords' => $package->getKeywords() ?: array(),
  7541. 'type' => $package->getType(),
  7542. 'homepage' => $package->getHomepage(),
  7543. 'names' => $package->getNames(),
  7544. );
  7545. $json = $this->appendVersions($json, $versions);
  7546. $json = $this->appendLicenses($json, $package);
  7547. if ($latestPackage) {
  7548. $json['latest'] = $latestPackage->getPrettyVersion();
  7549. } else {
  7550. $latestPackage = $package;
  7551. }
  7552. if ($package->getSourceType()) {
  7553. $json['source'] = array(
  7554. 'type' => $package->getSourceType(),
  7555. 'url' => $package->getSourceUrl(),
  7556. 'reference' => $package->getSourceReference(),
  7557. );
  7558. }
  7559. if ($package->getDistType()) {
  7560. $json['dist'] = array(
  7561. 'type' => $package->getDistType(),
  7562. 'url' => $package->getDistUrl(),
  7563. 'reference' => $package->getDistReference(),
  7564. );
  7565. }
  7566. if ($installedRepo->hasPackage($package)) {
  7567. $json['path'] = realpath($this->getComposer()->getInstallationManager()->getInstallPath($package));
  7568. if ($json['path'] === false) {
  7569. unset($json['path']);
  7570. }
  7571. }
  7572. if ($latestPackage instanceof CompletePackageInterface && $latestPackage->isAbandoned()) {
  7573. $json['replacement'] = $latestPackage->getReplacementPackage();
  7574. }
  7575. if ($package->getSuggests()) {
  7576. $json['suggests'] = $package->getSuggests();
  7577. }
  7578. if ($package->getSupport()) {
  7579. $json['support'] = $package->getSupport();
  7580. }
  7581. $json = $this->appendAutoload($json, $package);
  7582. if ($package->getIncludePaths()) {
  7583. $json['include_path'] = $package->getIncludePaths();
  7584. }
  7585. $json = $this->appendLinks($json, $package);
  7586. $this->getIO()->write(JsonFile::encode($json));
  7587. }
  7588. private function appendVersions($json, array $versions)
  7589. {
  7590. uasort($versions, 'version_compare');
  7591. $versions = array_keys(array_reverse($versions));
  7592. $json['versions'] = $versions;
  7593. return $json;
  7594. }
  7595. private function appendLicenses($json, CompletePackageInterface $package)
  7596. {
  7597. if ($licenses = $package->getLicense()) {
  7598. $spdxLicenses = new SpdxLicenses();
  7599. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  7600. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  7601. if (!$license) {
  7602. return $licenseId;
  7603. }
  7604. return array(
  7605. 'name' => $license[0],
  7606. 'osi' => $licenseId,
  7607. 'url' => $license[2],
  7608. );
  7609. }, $licenses);
  7610. }
  7611. return $json;
  7612. }
  7613. private function appendAutoload($json, CompletePackageInterface $package)
  7614. {
  7615. if ($package->getAutoload()) {
  7616. $autoload = array();
  7617. foreach ($package->getAutoload() as $type => $autoloads) {
  7618. if ($type === 'psr-0' || $type === 'psr-4') {
  7619. $psr = array();
  7620. foreach ($autoloads as $name => $path) {
  7621. if (!$path) {
  7622. $path = '.';
  7623. }
  7624. $psr[$name ?: '*'] = $path;
  7625. }
  7626. $autoload[$type] = $psr;
  7627. } elseif ($type === 'classmap') {
  7628. $autoload['classmap'] = $autoloads;
  7629. }
  7630. }
  7631. $json['autoload'] = $autoload;
  7632. }
  7633. return $json;
  7634. }
  7635. private function appendLinks($json, CompletePackageInterface $package)
  7636. {
  7637. foreach (Link::$TYPES as $linkType) {
  7638. $json = $this->appendLink($json, $package, $linkType);
  7639. }
  7640. return $json;
  7641. }
  7642. private function appendLink($json, CompletePackageInterface $package, $linkType)
  7643. {
  7644. $links = $package->{'get' . ucfirst($linkType)}();
  7645. if ($links) {
  7646. $json[$linkType] = array();
  7647. foreach ($links as $link) {
  7648. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  7649. }
  7650. }
  7651. return $json;
  7652. }
  7653. protected function initStyles(OutputInterface $output)
  7654. {
  7655. $this->colors = array(
  7656. 'green',
  7657. 'yellow',
  7658. 'cyan',
  7659. 'magenta',
  7660. 'blue',
  7661. );
  7662. foreach ($this->colors as $color) {
  7663. $style = new OutputFormatterStyle($color);
  7664. $output->getFormatter()->setStyle($color, $style);
  7665. }
  7666. }
  7667. protected function displayPackageTree(array $arrayTree)
  7668. {
  7669. $io = $this->getIO();
  7670. foreach ($arrayTree as $package) {
  7671. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  7672. $io->write(' ' . $package['version'], false);
  7673. $io->write(' ' . strtok($package['description'], "\r\n"));
  7674. if (isset($package['requires'])) {
  7675. $requires = $package['requires'];
  7676. $treeBar = '├';
  7677. $j = 0;
  7678. $total = count($requires);
  7679. foreach ($requires as $require) {
  7680. $requireName = $require['name'];
  7681. $j++;
  7682. if ($j === $total) {
  7683. $treeBar = 'â””';
  7684. }
  7685. $level = 1;
  7686. $color = $this->colors[$level];
  7687. $info = sprintf(
  7688. '%s──<%s>%s</%s> %s',
  7689. $treeBar,
  7690. $color,
  7691. $requireName,
  7692. $color,
  7693. $require['version']
  7694. );
  7695. $this->writeTreeLine($info);
  7696. $treeBar = str_replace('â””', ' ', $treeBar);
  7697. $packagesInTree = array($package['name'], $requireName);
  7698. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  7699. }
  7700. }
  7701. }
  7702. }
  7703. protected function generatePackageTree(
  7704. PackageInterface $package,
  7705. InstalledRepository $installedRepo,
  7706. RepositoryInterface $remoteRepos
  7707. ) {
  7708. $requires = $package->getRequires();
  7709. ksort($requires);
  7710. $children = array();
  7711. foreach ($requires as $requireName => $require) {
  7712. $packagesInTree = array($package->getName(), $requireName);
  7713. $treeChildDesc = array(
  7714. 'name' => $requireName,
  7715. 'version' => $require->getPrettyConstraint(),
  7716. );
  7717. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  7718. if ($deepChildren) {
  7719. $treeChildDesc['requires'] = $deepChildren;
  7720. }
  7721. $children[] = $treeChildDesc;
  7722. }
  7723. $tree = array(
  7724. 'name' => $package->getPrettyName(),
  7725. 'version' => $package->getPrettyVersion(),
  7726. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : '',
  7727. );
  7728. if ($children) {
  7729. $tree['requires'] = $children;
  7730. }
  7731. return $tree;
  7732. }
  7733. protected function displayTree(
  7734. $package,
  7735. array $packagesInTree,
  7736. $previousTreeBar = '├',
  7737. $level = 1
  7738. ) {
  7739. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  7740. if (is_array($package) && isset($package['requires'])) {
  7741. $requires = $package['requires'];
  7742. $treeBar = $previousTreeBar . ' ├';
  7743. $i = 0;
  7744. $total = count($requires);
  7745. foreach ($requires as $require) {
  7746. $currentTree = $packagesInTree;
  7747. $i++;
  7748. if ($i === $total) {
  7749. $treeBar = $previousTreeBar . ' â””';
  7750. }
  7751. $colorIdent = $level % count($this->colors);
  7752. $color = $this->colors[$colorIdent];
  7753. $circularWarn = in_array(
  7754. $require['name'],
  7755. $currentTree,
  7756. true
  7757. ) ? '(circular dependency aborted here)' : '';
  7758. $info = rtrim(sprintf(
  7759. '%s──<%s>%s</%s> %s %s',
  7760. $treeBar,
  7761. $color,
  7762. $require['name'],
  7763. $color,
  7764. $require['version'],
  7765. $circularWarn
  7766. ));
  7767. $this->writeTreeLine($info);
  7768. $treeBar = str_replace('â””', ' ', $treeBar);
  7769. $currentTree[] = $require['name'];
  7770. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  7771. }
  7772. }
  7773. }
  7774. protected function addTree(
  7775. $name,
  7776. Link $link,
  7777. InstalledRepository $installedRepo,
  7778. RepositoryInterface $remoteRepos,
  7779. array $packagesInTree
  7780. ) {
  7781. $children = array();
  7782. list($package) = $this->getPackage(
  7783. $installedRepo,
  7784. $remoteRepos,
  7785. $name,
  7786. $link->getPrettyConstraint() === 'self.version' ? $link->getConstraint() : $link->getPrettyConstraint()
  7787. );
  7788. if (is_object($package)) {
  7789. $requires = $package->getRequires();
  7790. ksort($requires);
  7791. foreach ($requires as $requireName => $require) {
  7792. $currentTree = $packagesInTree;
  7793. $treeChildDesc = array(
  7794. 'name' => $requireName,
  7795. 'version' => $require->getPrettyConstraint(),
  7796. );
  7797. if (!in_array($requireName, $currentTree, true)) {
  7798. $currentTree[] = $requireName;
  7799. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  7800. if ($deepChildren) {
  7801. $treeChildDesc['requires'] = $deepChildren;
  7802. }
  7803. }
  7804. $children[] = $treeChildDesc;
  7805. }
  7806. }
  7807. return $children;
  7808. }
  7809. private function updateStatusToVersionStyle($updateStatus)
  7810. {
  7811. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  7812. }
  7813. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  7814. {
  7815. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  7816. return 'up-to-date';
  7817. }
  7818. $constraint = $package->getVersion();
  7819. if (0 !== strpos($constraint, 'dev-')) {
  7820. $constraint = '^'.$constraint;
  7821. }
  7822. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  7823. return 'semver-safe-update';
  7824. }
  7825. return 'update-possible';
  7826. }
  7827. private function writeTreeLine($line)
  7828. {
  7829. $io = $this->getIO();
  7830. if (!$io->isDecorated()) {
  7831. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  7832. }
  7833. $io->write($line);
  7834. }
  7835. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, $minorOnly = false, $ignorePlatformReqs = false)
  7836. {
  7837. $name = $package->getName();
  7838. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  7839. $stability = $composer->getPackage()->getMinimumStability();
  7840. $flags = $composer->getPackage()->getStabilityFlags();
  7841. if (isset($flags[$name])) {
  7842. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  7843. }
  7844. $bestStability = $stability;
  7845. if ($composer->getPackage()->getPreferStable()) {
  7846. $bestStability = $package->getStability();
  7847. }
  7848. $targetVersion = null;
  7849. if (0 === strpos($package->getVersion(), 'dev-')) {
  7850. $targetVersion = $package->getVersion();
  7851. }
  7852. if ($targetVersion === null && $minorOnly) {
  7853. $targetVersion = '^' . $package->getVersion();
  7854. }
  7855. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability, PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  7856. while ($candidate instanceof AliasPackage) {
  7857. $candidate = $candidate->getAliasOf();
  7858. }
  7859. return $candidate;
  7860. }
  7861. private function getRepositorySet(Composer $composer)
  7862. {
  7863. if (!$this->repositorySet) {
  7864. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  7865. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  7866. }
  7867. return $this->repositorySet;
  7868. }
  7869. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  7870. {
  7871. $requires = $package->getRequires();
  7872. foreach ($repo->getPackages() as $candidate) {
  7873. foreach ($candidate->getNames() as $name) {
  7874. if (isset($requires[$name])) {
  7875. if (!in_array($candidate, $bucket, true)) {
  7876. $bucket[] = $candidate;
  7877. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  7878. }
  7879. break;
  7880. }
  7881. }
  7882. }
  7883. return $bucket;
  7884. }
  7885. }
  7886. <?php
  7887. namespace Composer\Command;
  7888. use Symfony\Component\Console\Input\InputInterface;
  7889. use Symfony\Component\Console\Input\InputOption;
  7890. use Symfony\Component\Console\Output\OutputInterface;
  7891. use Composer\Downloader\ChangeReportInterface;
  7892. use Composer\Downloader\DvcsDownloaderInterface;
  7893. use Composer\Downloader\VcsCapableDownloaderInterface;
  7894. use Composer\Package\Dumper\ArrayDumper;
  7895. use Composer\Package\Version\VersionGuesser;
  7896. use Composer\Package\Version\VersionParser;
  7897. use Composer\Plugin\CommandEvent;
  7898. use Composer\Plugin\PluginEvents;
  7899. use Composer\Script\ScriptEvents;
  7900. use Composer\Util\ProcessExecutor;
  7901. class StatusCommand extends BaseCommand
  7902. {
  7903. const EXIT_CODE_ERRORS = 1;
  7904. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  7905. const EXIT_CODE_VERSION_CHANGES = 4;
  7906. protected function configure()
  7907. {
  7908. $this
  7909. ->setName('status')
  7910. ->setDescription('Shows a list of locally modified packages.')
  7911. ->setDefinition(array(
  7912. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  7913. ))
  7914. ->setHelp(
  7915. <<<EOT
  7916. The status command displays a list of dependencies that have
  7917. been modified locally.
  7918. Read more at https://getcomposer.org/doc/03-cli.md#status
  7919. EOT
  7920. )
  7921. ;
  7922. }
  7923. protected function execute(InputInterface $input, OutputInterface $output)
  7924. {
  7925. $composer = $this->getComposer();
  7926. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  7927. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7928. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  7929. $exitCode = $this->doExecute($input);
  7930. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  7931. return $exitCode;
  7932. }
  7933. private function doExecute(InputInterface $input)
  7934. {
  7935. $composer = $this->getComposer();
  7936. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  7937. $dm = $composer->getDownloadManager();
  7938. $im = $composer->getInstallationManager();
  7939. $errors = array();
  7940. $io = $this->getIO();
  7941. $unpushedChanges = array();
  7942. $vcsVersionChanges = array();
  7943. $parser = new VersionParser;
  7944. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  7945. $dumper = new ArrayDumper;
  7946. foreach ($installedRepo->getCanonicalPackages() as $package) {
  7947. $downloader = $dm->getDownloaderForPackage($package);
  7948. $targetDir = $im->getInstallPath($package);
  7949. if ($downloader instanceof ChangeReportInterface) {
  7950. if (is_link($targetDir)) {
  7951. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  7952. }
  7953. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  7954. $errors[$targetDir] = $changes;
  7955. }
  7956. }
  7957. if ($downloader instanceof VcsCapableDownloaderInterface) {
  7958. if ($downloader->getVcsReference($package, $targetDir)) {
  7959. switch ($package->getInstallationSource()) {
  7960. case 'source':
  7961. $previousRef = $package->getSourceReference();
  7962. break;
  7963. case 'dist':
  7964. $previousRef = $package->getDistReference();
  7965. break;
  7966. default:
  7967. $previousRef = null;
  7968. }
  7969. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  7970. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  7971. $vcsVersionChanges[$targetDir] = array(
  7972. 'previous' => array(
  7973. 'version' => $package->getPrettyVersion(),
  7974. 'ref' => $previousRef,
  7975. ),
  7976. 'current' => array(
  7977. 'version' => $currentVersion['pretty_version'],
  7978. 'ref' => $currentVersion['commit'],
  7979. ),
  7980. );
  7981. }
  7982. }
  7983. }
  7984. if ($downloader instanceof DvcsDownloaderInterface) {
  7985. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  7986. $unpushedChanges[$targetDir] = $unpushed;
  7987. }
  7988. }
  7989. }
  7990. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  7991. $io->writeError('<info>No local changes</info>');
  7992. return 0;
  7993. }
  7994. if ($errors) {
  7995. $io->writeError('<error>You have changes in the following dependencies:</error>');
  7996. foreach ($errors as $path => $changes) {
  7997. if ($input->getOption('verbose')) {
  7998. $indentedChanges = implode("\n", array_map(function ($line) {
  7999. return ' ' . ltrim($line);
  8000. }, explode("\n", $changes)));
  8001. $io->write('<info>'.$path.'</info>:');
  8002. $io->write($indentedChanges);
  8003. } else {
  8004. $io->write($path);
  8005. }
  8006. }
  8007. }
  8008. if ($unpushedChanges) {
  8009. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  8010. foreach ($unpushedChanges as $path => $changes) {
  8011. if ($input->getOption('verbose')) {
  8012. $indentedChanges = implode("\n", array_map(function ($line) {
  8013. return ' ' . ltrim($line);
  8014. }, explode("\n", $changes)));
  8015. $io->write('<info>'.$path.'</info>:');
  8016. $io->write($indentedChanges);
  8017. } else {
  8018. $io->write($path);
  8019. }
  8020. }
  8021. }
  8022. if ($vcsVersionChanges) {
  8023. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  8024. foreach ($vcsVersionChanges as $path => $changes) {
  8025. if ($input->getOption('verbose')) {
  8026. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  8027. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  8028. if ($io->isVeryVerbose()) {
  8029. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  8030. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  8031. }
  8032. $io->write('<info>'.$path.'</info>:');
  8033. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  8034. } else {
  8035. $io->write($path);
  8036. }
  8037. }
  8038. }
  8039. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  8040. $io->writeError('Use --verbose (-v) to see a list of files');
  8041. }
  8042. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  8043. }
  8044. }
  8045. <?php
  8046. namespace Composer\Command;
  8047. use Composer\Repository\PlatformRepository;
  8048. use Composer\Repository\RootPackageRepository;
  8049. use Composer\Repository\InstalledRepository;
  8050. use Composer\Installer\SuggestedPackagesReporter;
  8051. use Symfony\Component\Console\Input\InputArgument;
  8052. use Symfony\Component\Console\Input\InputInterface;
  8053. use Symfony\Component\Console\Input\InputOption;
  8054. use Symfony\Component\Console\Output\OutputInterface;
  8055. class SuggestsCommand extends BaseCommand
  8056. {
  8057. protected function configure()
  8058. {
  8059. $this
  8060. ->setName('suggests')
  8061. ->setDescription('Shows package suggestions.')
  8062. ->setDefinition(array(
  8063. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  8064. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  8065. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  8066. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  8067. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  8068. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  8069. ))
  8070. ->setHelp(
  8071. <<<EOT
  8072. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  8073. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  8074. EOT
  8075. )
  8076. ;
  8077. }
  8078. protected function execute(InputInterface $input, OutputInterface $output)
  8079. {
  8080. $composer = $this->getComposer();
  8081. $installedRepos = array(
  8082. new RootPackageRepository(clone $composer->getPackage()),
  8083. );
  8084. $locker = $composer->getLocker();
  8085. if ($locker->isLocked()) {
  8086. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  8087. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  8088. } else {
  8089. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  8090. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  8091. }
  8092. $installedRepo = new InstalledRepository($installedRepos);
  8093. $reporter = new SuggestedPackagesReporter($this->getIO());
  8094. $filter = $input->getArgument('packages');
  8095. $packages = $installedRepo->getPackages();
  8096. $packages[] = $composer->getPackage();
  8097. foreach ($packages as $package) {
  8098. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  8099. continue;
  8100. }
  8101. $reporter->addSuggestionsFromPackage($package);
  8102. }
  8103. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  8104. if ($input->getOption('by-suggestion')) {
  8105. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  8106. }
  8107. if ($input->getOption('by-package')) {
  8108. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  8109. }
  8110. if ($input->getOption('list')) {
  8111. $mode = SuggestedPackagesReporter::MODE_LIST;
  8112. }
  8113. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  8114. return 0;
  8115. }
  8116. }
  8117. <?php
  8118. namespace Composer\Command;
  8119. use Composer\Composer;
  8120. use Composer\DependencyResolver\Request;
  8121. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  8122. use Composer\Installer;
  8123. use Composer\IO\IOInterface;
  8124. use Composer\Package\Loader\RootPackageLoader;
  8125. use Composer\Pcre\Preg;
  8126. use Composer\Plugin\CommandEvent;
  8127. use Composer\Plugin\PluginEvents;
  8128. use Composer\Package\Version\VersionParser;
  8129. use Composer\Util\HttpDownloader;
  8130. use Composer\Semver\Constraint\MultiConstraint;
  8131. use Composer\Package\Link;
  8132. use Symfony\Component\Console\Helper\Table;
  8133. use Symfony\Component\Console\Input\InputInterface;
  8134. use Symfony\Component\Console\Input\InputOption;
  8135. use Symfony\Component\Console\Input\InputArgument;
  8136. use Symfony\Component\Console\Output\OutputInterface;
  8137. use Symfony\Component\Console\Question\Question;
  8138. class UpdateCommand extends BaseCommand
  8139. {
  8140. protected function configure()
  8141. {
  8142. $this
  8143. ->setName('update')
  8144. ->setAliases(array('u', 'upgrade'))
  8145. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  8146. ->setDefinition(array(
  8147. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  8148. 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'),
  8149. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  8150. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
  8151. new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).'),
  8152. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  8153. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  8154. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  8155. 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.'),
  8156. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  8157. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  8158. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  8159. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  8160. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  8161. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  8162. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  8163. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  8164. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  8165. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  8166. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  8167. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  8168. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  8169. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  8170. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  8171. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  8172. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  8173. ))
  8174. ->setHelp(
  8175. <<<EOT
  8176. The <info>update</info> command reads the composer.json file from the
  8177. current directory, processes it, and updates, removes or installs all the
  8178. dependencies.
  8179. <info>php composer.phar update</info>
  8180. To limit the update operation to a few packages, you can list the package(s)
  8181. you want to update as such:
  8182. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  8183. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  8184. from a specific vendor:
  8185. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  8186. To run an update with more restrictive constraints you can use:
  8187. <info>php composer.phar update --with vendor/package:1.0.*</info>
  8188. To run a partial update with more restrictive constraints you can use the shorthand:
  8189. <info>php composer.phar update vendor/package:1.0.*</info>
  8190. To select packages names interactively with auto-completion use <info>-i</info>.
  8191. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  8192. EOT
  8193. )
  8194. ;
  8195. }
  8196. protected function execute(InputInterface $input, OutputInterface $output)
  8197. {
  8198. $io = $this->getIO();
  8199. if ($input->getOption('dev')) {
  8200. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  8201. }
  8202. if ($input->getOption('no-suggest')) {
  8203. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  8204. }
  8205. $composer = $this->getComposer(true, $input->getOption('no-plugins'), $input->getOption('no-scripts'));
  8206. if (!HttpDownloader::isCurlEnabled()) {
  8207. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  8208. }
  8209. $packages = $input->getArgument('packages');
  8210. $reqs = $this->formatRequirements($input->getOption('with'));
  8211. if ($packages) {
  8212. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg) {
  8213. return Preg::isMatch('{\S+[ =:]\S+}', $pkg);
  8214. });
  8215. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  8216. $reqs[$package] = $constraint;
  8217. }
  8218. foreach ($allowlistPackagesWithRequirements as $package) {
  8219. $packageName = Preg::replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  8220. $index = array_search($package, $packages);
  8221. $packages[$index] = $packageName;
  8222. }
  8223. }
  8224. $rootPackage = $composer->getPackage();
  8225. $rootRequires = $rootPackage->getRequires();
  8226. $rootDevRequires = $rootPackage->getDevRequires();
  8227. foreach ($reqs as $package => $constraint) {
  8228. if (isset($rootRequires[$package])) {
  8229. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  8230. } elseif (isset($rootDevRequires[$package])) {
  8231. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  8232. } else {
  8233. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  8234. }
  8235. }
  8236. $rootPackage->setRequires($rootRequires);
  8237. $rootPackage->setDevRequires($rootDevRequires);
  8238. $rootPackage->setReferences(RootPackageLoader::extractReferences($reqs, $rootPackage->getReferences()));
  8239. $rootPackage->setStabilityFlags(RootPackageLoader::extractStabilityFlags($reqs, $rootPackage->getMinimumStability(), $rootPackage->getStabilityFlags()));
  8240. if ($input->getOption('interactive')) {
  8241. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  8242. }
  8243. if ($input->getOption('root-reqs')) {
  8244. $requires = array_keys($rootRequires);
  8245. if (!$input->getOption('no-dev')) {
  8246. $requires = array_merge($requires, array_keys($rootDevRequires));
  8247. }
  8248. if (!empty($packages)) {
  8249. $packages = array_intersect($packages, $requires);
  8250. } else {
  8251. $packages = $requires;
  8252. }
  8253. }
  8254. $filteredPackages = array_filter($packages, function ($package) {
  8255. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  8256. });
  8257. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  8258. $packages = $filteredPackages;
  8259. if ($updateMirrors && !empty($packages)) {
  8260. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  8261. return -1;
  8262. }
  8263. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  8264. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8265. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  8266. $install = Installer::create($io, $composer);
  8267. $config = $composer->getConfig();
  8268. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  8269. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  8270. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  8271. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  8272. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  8273. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  8274. if ($input->getOption('with-all-dependencies')) {
  8275. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  8276. } elseif ($input->getOption('with-dependencies')) {
  8277. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  8278. }
  8279. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  8280. $install
  8281. ->setDryRun($input->getOption('dry-run'))
  8282. ->setVerbose($input->getOption('verbose'))
  8283. ->setPreferSource($preferSource)
  8284. ->setPreferDist($preferDist)
  8285. ->setDevMode(!$input->getOption('no-dev'))
  8286. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  8287. ->setOptimizeAutoloader($optimize)
  8288. ->setClassMapAuthoritative($authoritative)
  8289. ->setApcuAutoloader($apcu, $apcuPrefix)
  8290. ->setUpdate(true)
  8291. ->setInstall(!$input->getOption('no-install'))
  8292. ->setUpdateMirrors($updateMirrors)
  8293. ->setUpdateAllowList($packages)
  8294. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  8295. ->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs))
  8296. ->setPreferStable($input->getOption('prefer-stable'))
  8297. ->setPreferLowest($input->getOption('prefer-lowest'))
  8298. ;
  8299. if ($input->getOption('no-plugins')) {
  8300. $install->disablePlugins();
  8301. }
  8302. return $install->run();
  8303. }
  8304. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  8305. {
  8306. if (!$input->isInteractive()) {
  8307. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  8308. }
  8309. $requires = array_merge(
  8310. $composer->getPackage()->getRequires(),
  8311. $composer->getPackage()->getDevRequires()
  8312. );
  8313. $autocompleterValues = array();
  8314. foreach ($requires as $require) {
  8315. $target = $require->getTarget();
  8316. $autocompleterValues[strtolower($target)] = $target;
  8317. }
  8318. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  8319. foreach ($installedPackages as $package) {
  8320. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  8321. }
  8322. $helper = $this->getHelper('question');
  8323. $question = new Question('<comment>Enter package name: </comment>', null);
  8324. $io->writeError('<info>Press enter without value to end submission</info>');
  8325. do {
  8326. $autocompleterValues = array_diff($autocompleterValues, $packages);
  8327. $question->setAutocompleterValues($autocompleterValues);
  8328. $addedPackage = $helper->ask($input, $output, $question);
  8329. if (!is_string($addedPackage) || empty($addedPackage)) {
  8330. break;
  8331. }
  8332. $addedPackage = strtolower($addedPackage);
  8333. if (!in_array($addedPackage, $packages)) {
  8334. $packages[] = $addedPackage;
  8335. }
  8336. } while (true);
  8337. $packages = array_filter($packages);
  8338. if (!$packages) {
  8339. throw new \InvalidArgumentException('You must enter minimum one package.');
  8340. }
  8341. $table = new Table($output);
  8342. $table->setHeaders(array('Selected packages'));
  8343. foreach ($packages as $package) {
  8344. $table->addRow(array($package));
  8345. }
  8346. $table->render();
  8347. if ($io->askConfirmation(sprintf(
  8348. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  8349. 1 === count($packages) ? '' : 's'
  8350. ))) {
  8351. return $packages;
  8352. }
  8353. throw new \RuntimeException('Installation aborted.');
  8354. }
  8355. private function appendConstraintToLink(Link $link, $constraint)
  8356. {
  8357. $parser = new VersionParser;
  8358. $oldPrettyString = $link->getConstraint()->getPrettyString();
  8359. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  8360. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  8361. return new Link(
  8362. $link->getSource(),
  8363. $link->getTarget(),
  8364. $newConstraint,
  8365. $link->getDescription(),
  8366. $link->getPrettyConstraint() . ', ' . $constraint
  8367. );
  8368. }
  8369. }
  8370. <?php
  8371. namespace Composer\Command;
  8372. use Composer\Factory;
  8373. use Composer\IO\IOInterface;
  8374. use Composer\Package\Loader\ValidatingArrayLoader;
  8375. use Composer\Plugin\CommandEvent;
  8376. use Composer\Plugin\PluginEvents;
  8377. use Composer\Repository\InstalledRepository;
  8378. use Composer\Repository\PlatformRepository;
  8379. use Composer\Util\ConfigValidator;
  8380. use Composer\Util\Filesystem;
  8381. use Symfony\Component\Console\Input\InputArgument;
  8382. use Symfony\Component\Console\Input\InputInterface;
  8383. use Symfony\Component\Console\Input\InputOption;
  8384. use Symfony\Component\Console\Output\OutputInterface;
  8385. class ValidateCommand extends BaseCommand
  8386. {
  8387. protected function configure()
  8388. {
  8389. $this
  8390. ->setName('validate')
  8391. ->setDescription('Validates a composer.json and composer.lock.')
  8392. ->setDefinition(array(
  8393. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  8394. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  8395. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  8396. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  8397. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  8398. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  8399. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  8400. ))
  8401. ->setHelp(
  8402. <<<EOT
  8403. The validate command validates a given composer.json and composer.lock
  8404. Exit codes in case of errors are:
  8405. 1 validation warning(s), only when --strict is given
  8406. 2 validation error(s)
  8407. 3 file unreadable or missing
  8408. Read more at https://getcomposer.org/doc/03-cli.md#validate
  8409. EOT
  8410. );
  8411. }
  8412. protected function execute(InputInterface $input, OutputInterface $output)
  8413. {
  8414. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  8415. $io = $this->getIO();
  8416. if (!file_exists($file)) {
  8417. $io->writeError('<error>' . $file . ' not found.</error>');
  8418. return 3;
  8419. }
  8420. if (!Filesystem::isReadable($file)) {
  8421. $io->writeError('<error>' . $file . ' is not readable.</error>');
  8422. return 3;
  8423. }
  8424. $validator = new ConfigValidator($io);
  8425. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  8426. $checkPublish = !$input->getOption('no-check-publish');
  8427. $checkLock = !$input->getOption('no-check-lock');
  8428. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  8429. $isStrict = $input->getOption('strict');
  8430. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  8431. $lockErrors = array();
  8432. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  8433. $locker = $composer->getLocker();
  8434. if ($locker->isLocked() && !$locker->isFresh()) {
  8435. $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>`.';
  8436. }
  8437. if ($locker->isLocked()) {
  8438. $missingRequirements = false;
  8439. $sets = array(
  8440. array('repo' => $locker->getLockedRepository(false), 'method' => 'getRequires', 'description' => 'Required'),
  8441. array('repo' => $locker->getLockedRepository(true), 'method' => 'getDevRequires', 'description' => 'Required (in require-dev)'),
  8442. );
  8443. foreach ($sets as $set) {
  8444. $installedRepo = new InstalledRepository(array($set['repo']));
  8445. foreach (call_user_func(array($composer->getPackage(), $set['method'])) as $link) {
  8446. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  8447. continue;
  8448. }
  8449. if (!$installedRepo->findPackagesWithReplacersAndProviders($link->getTarget(), $link->getConstraint())) {
  8450. if ($results = $installedRepo->findPackagesWithReplacersAndProviders($link->getTarget())) {
  8451. $provider = reset($results);
  8452. $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is in the lock file as "'.$provider->getPrettyVersion().'" but that does not satisfy your constraint "'.$link->getPrettyConstraint().'".';
  8453. } else {
  8454. $lockErrors[] = '- ' . $set['description'].' package "' . $link->getTarget() . '" is not present in the lock file.';
  8455. }
  8456. $missingRequirements = true;
  8457. }
  8458. }
  8459. }
  8460. if ($missingRequirements) {
  8461. $lockErrors[] = 'This usually happens when composer files are incorrectly merged or the composer.json file is manually edited.';
  8462. $lockErrors[] = 'Read more about correctly resolving merge conflicts https://getcomposer.org/doc/articles/resolving-merge-conflicts.md';
  8463. $lockErrors[] = 'and prefer using the "require" command over editing the composer.json file directly https://getcomposer.org/doc/03-cli.md#require';
  8464. }
  8465. }
  8466. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  8467. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  8468. if ($input->getOption('with-dependencies')) {
  8469. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  8470. foreach ($localRepo->getPackages() as $package) {
  8471. $path = $composer->getInstallationManager()->getInstallPath($package);
  8472. $file = $path . '/composer.json';
  8473. if (is_dir($path) && file_exists($file)) {
  8474. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  8475. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  8476. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  8477. $exitCode = max($depCode, $exitCode);
  8478. }
  8479. }
  8480. }
  8481. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  8482. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  8483. return max($eventCode, $exitCode);
  8484. }
  8485. private function outputResult(IOInterface $io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false)
  8486. {
  8487. $doPrintSchemaUrl = false;
  8488. if ($errors) {
  8489. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  8490. } elseif ($publishErrors) {
  8491. $io->writeError('<info>' . $name . ' is valid for simple usage with Composer but has</info>');
  8492. $io->writeError('<info>strict errors that make it unable to be published as a package</info>');
  8493. $doPrintSchemaUrl = $printSchemaUrl;
  8494. } elseif ($warnings) {
  8495. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  8496. $doPrintSchemaUrl = $printSchemaUrl;
  8497. } elseif ($lockErrors) {
  8498. $io->write('<info>' . $name . ' is valid but your composer.lock has some '.($checkLock ? 'errors' : 'warnings').'</info>');
  8499. } else {
  8500. $io->write('<info>' . $name . ' is valid</info>');
  8501. }
  8502. if ($doPrintSchemaUrl) {
  8503. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  8504. }
  8505. if ($errors) {
  8506. $errors = array_map(function ($err) {
  8507. return '- ' . $err;
  8508. }, $errors);
  8509. array_unshift($errors, '# General errors');
  8510. }
  8511. if ($warnings) {
  8512. $warnings = array_map(function ($err) {
  8513. return '- ' . $err;
  8514. }, $warnings);
  8515. array_unshift($warnings, '# General warnings');
  8516. }
  8517. $extraWarnings = array();
  8518. if ($publishErrors) {
  8519. $publishErrors = array_map(function ($err) {
  8520. return '- ' . $err;
  8521. }, $publishErrors);
  8522. if ($checkPublish) {
  8523. array_unshift($publishErrors, '# Publish errors');
  8524. $errors = array_merge($errors, $publishErrors);
  8525. } else {
  8526. array_unshift($publishErrors, '# Publish warnings');
  8527. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  8528. }
  8529. }
  8530. if ($lockErrors) {
  8531. if ($checkLock) {
  8532. array_unshift($lockErrors, '# Lock file errors');
  8533. $errors = array_merge($errors, $lockErrors);
  8534. } else {
  8535. array_unshift($lockErrors, '# Lock file warnings');
  8536. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  8537. }
  8538. }
  8539. $messages = array(
  8540. 'error' => $errors,
  8541. 'warning' => array_merge($warnings, $extraWarnings),
  8542. );
  8543. foreach ($messages as $style => $msgs) {
  8544. foreach ($msgs as $msg) {
  8545. if (strpos($msg, '#') === 0) {
  8546. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  8547. } else {
  8548. $io->writeError($msg);
  8549. }
  8550. }
  8551. }
  8552. }
  8553. }
  8554. <?php
  8555. namespace Composer;
  8556. use Composer\Package\RootPackageInterface;
  8557. use Composer\Package\Locker;
  8558. use Composer\Pcre\Preg;
  8559. use Composer\Util\Loop;
  8560. use Composer\Repository\RepositoryManager;
  8561. use Composer\Installer\InstallationManager;
  8562. use Composer\Plugin\PluginManager;
  8563. use Composer\Downloader\DownloadManager;
  8564. use Composer\EventDispatcher\EventDispatcher;
  8565. use Composer\Autoload\AutoloadGenerator;
  8566. use Composer\Package\Archiver\ArchiveManager;
  8567. class Composer
  8568. {
  8569. const VERSION = '2.2.6';
  8570. const BRANCH_ALIAS_VERSION = '';
  8571. const RELEASE_DATE = '2022-02-04 17:00:38';
  8572. const SOURCE_VERSION = '';
  8573. const RUNTIME_API_VERSION = '2.2.2';
  8574. public static function getVersion()
  8575. {
  8576. if (self::VERSION === '@package_version'.'@') {
  8577. return self::SOURCE_VERSION;
  8578. }
  8579. if (self::BRANCH_ALIAS_VERSION !== '' && Preg::isMatch('{^[a-f0-9]{40}$}', self::VERSION)) {
  8580. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  8581. }
  8582. return self::VERSION;
  8583. }
  8584. private $package;
  8585. private $locker = null;
  8586. private $loop;
  8587. private $repositoryManager;
  8588. private $downloadManager;
  8589. private $installationManager;
  8590. private $pluginManager;
  8591. private $config;
  8592. private $eventDispatcher;
  8593. private $autoloadGenerator;
  8594. private $archiveManager;
  8595. public function setPackage(RootPackageInterface $package)
  8596. {
  8597. $this->package = $package;
  8598. }
  8599. public function getPackage()
  8600. {
  8601. return $this->package;
  8602. }
  8603. public function setConfig(Config $config)
  8604. {
  8605. $this->config = $config;
  8606. }
  8607. public function getConfig()
  8608. {
  8609. return $this->config;
  8610. }
  8611. public function setLocker(Locker $locker)
  8612. {
  8613. $this->locker = $locker;
  8614. }
  8615. public function getLocker()
  8616. {
  8617. return $this->locker;
  8618. }
  8619. public function setLoop(Loop $loop)
  8620. {
  8621. $this->loop = $loop;
  8622. }
  8623. public function getLoop()
  8624. {
  8625. return $this->loop;
  8626. }
  8627. public function setRepositoryManager(RepositoryManager $manager)
  8628. {
  8629. $this->repositoryManager = $manager;
  8630. }
  8631. public function getRepositoryManager()
  8632. {
  8633. return $this->repositoryManager;
  8634. }
  8635. public function setDownloadManager(DownloadManager $manager)
  8636. {
  8637. $this->downloadManager = $manager;
  8638. }
  8639. public function getDownloadManager()
  8640. {
  8641. return $this->downloadManager;
  8642. }
  8643. public function setArchiveManager(ArchiveManager $manager)
  8644. {
  8645. $this->archiveManager = $manager;
  8646. }
  8647. public function getArchiveManager()
  8648. {
  8649. return $this->archiveManager;
  8650. }
  8651. public function setInstallationManager(InstallationManager $manager)
  8652. {
  8653. $this->installationManager = $manager;
  8654. }
  8655. public function getInstallationManager()
  8656. {
  8657. return $this->installationManager;
  8658. }
  8659. public function setPluginManager(PluginManager $manager)
  8660. {
  8661. $this->pluginManager = $manager;
  8662. }
  8663. public function getPluginManager()
  8664. {
  8665. return $this->pluginManager;
  8666. }
  8667. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  8668. {
  8669. $this->eventDispatcher = $eventDispatcher;
  8670. }
  8671. public function getEventDispatcher()
  8672. {
  8673. return $this->eventDispatcher;
  8674. }
  8675. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  8676. {
  8677. $this->autoloadGenerator = $autoloadGenerator;
  8678. }
  8679. public function getAutoloadGenerator()
  8680. {
  8681. return $this->autoloadGenerator;
  8682. }
  8683. }
  8684. <?php
  8685. namespace Composer;
  8686. use Composer\Config\ConfigSourceInterface;
  8687. use Composer\Downloader\TransportException;
  8688. use Composer\IO\IOInterface;
  8689. use Composer\Pcre\Preg;
  8690. use Composer\Util\Platform;
  8691. use Composer\Util\ProcessExecutor;
  8692. class Config
  8693. {
  8694. const SOURCE_DEFAULT = 'default';
  8695. const SOURCE_COMMAND = 'command';
  8696. const SOURCE_UNKNOWN = 'unknown';
  8697. const RELATIVE_PATHS = 1;
  8698. public static $defaultConfig = array(
  8699. 'process-timeout' => 300,
  8700. 'use-include-path' => false,
  8701. 'allow-plugins' => null,
  8702. 'use-parent-dir' => 'prompt',
  8703. 'preferred-install' => 'dist',
  8704. 'notify-on-install' => true,
  8705. 'github-protocols' => array('https', 'ssh', 'git'),
  8706. 'gitlab-protocol' => null,
  8707. 'vendor-dir' => 'vendor',
  8708. 'bin-dir' => '{$vendor-dir}/bin',
  8709. 'cache-dir' => '{$home}/cache',
  8710. 'data-dir' => '{$home}',
  8711. 'cache-files-dir' => '{$cache-dir}/files',
  8712. 'cache-repo-dir' => '{$cache-dir}/repo',
  8713. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  8714. 'cache-ttl' => 15552000,
  8715. 'cache-files-ttl' => null,
  8716. 'cache-files-maxsize' => '300MiB',
  8717. 'cache-read-only' => false,
  8718. 'bin-compat' => 'auto',
  8719. 'discard-changes' => false,
  8720. 'autoloader-suffix' => null,
  8721. 'sort-packages' => false,
  8722. 'optimize-autoloader' => false,
  8723. 'classmap-authoritative' => false,
  8724. 'apcu-autoloader' => false,
  8725. 'prepend-autoloader' => true,
  8726. 'github-domains' => array('github.com'),
  8727. 'bitbucket-expose-hostname' => true,
  8728. 'disable-tls' => false,
  8729. 'secure-http' => true,
  8730. 'secure-svn-domains' => array(),
  8731. 'cafile' => null,
  8732. 'capath' => null,
  8733. 'github-expose-hostname' => true,
  8734. 'gitlab-domains' => array('gitlab.com'),
  8735. 'store-auths' => 'prompt',
  8736. 'platform' => array(),
  8737. 'archive-format' => 'tar',
  8738. 'archive-dir' => '.',
  8739. 'htaccess-protect' => true,
  8740. 'use-github-api' => true,
  8741. 'lock' => true,
  8742. 'platform-check' => 'php-only',
  8743. );
  8744. public static $defaultRepositories = array(
  8745. 'packagist.org' => array(
  8746. 'type' => 'composer',
  8747. 'url' => 'https://repo.packagist.org',
  8748. ),
  8749. );
  8750. private $config;
  8751. private $baseDir;
  8752. private $repositories;
  8753. private $configSource;
  8754. private $authConfigSource;
  8755. private $useEnvironment;
  8756. private $warnedHosts = array();
  8757. private $sourceOfConfigValue = array();
  8758. public function __construct($useEnvironment = true, $baseDir = null)
  8759. {
  8760. $this->config = static::$defaultConfig;
  8761. if (strtotime('2022-07-01') < time()) {
  8762. $this->config['allow-plugins'] = array();
  8763. }
  8764. $this->repositories = static::$defaultRepositories;
  8765. $this->useEnvironment = (bool) $useEnvironment;
  8766. $this->baseDir = $baseDir;
  8767. foreach ($this->config as $configKey => $configValue) {
  8768. $this->setSourceOfConfigValue($configValue, $configKey, self::SOURCE_DEFAULT);
  8769. }
  8770. foreach ($this->repositories as $configKey => $configValue) {
  8771. $this->setSourceOfConfigValue($configValue, 'repositories.' . $configKey, self::SOURCE_DEFAULT);
  8772. }
  8773. }
  8774. public function setConfigSource(ConfigSourceInterface $source)
  8775. {
  8776. $this->configSource = $source;
  8777. }
  8778. public function getConfigSource()
  8779. {
  8780. return $this->configSource;
  8781. }
  8782. public function setAuthConfigSource(ConfigSourceInterface $source)
  8783. {
  8784. $this->authConfigSource = $source;
  8785. }
  8786. public function getAuthConfigSource()
  8787. {
  8788. return $this->authConfigSource;
  8789. }
  8790. public function merge($config, $source = self::SOURCE_UNKNOWN)
  8791. {
  8792. if (!empty($config['config']) && is_array($config['config'])) {
  8793. foreach ($config['config'] as $key => $val) {
  8794. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer'), true) && isset($this->config[$key])) {
  8795. $this->config[$key] = array_merge($this->config[$key], $val);
  8796. $this->setSourceOfConfigValue($val, $key, $source);
  8797. } elseif (in_array($key, array('allow-plugins'), true) && isset($this->config[$key]) && is_array($this->config[$key])) {
  8798. $this->config[$key] = array_merge($val, $this->config[$key], $val);
  8799. $this->setSourceOfConfigValue($val, $key, $source);
  8800. } elseif (in_array($key, array('gitlab-domains', 'github-domains'), true) && isset($this->config[$key])) {
  8801. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  8802. $this->setSourceOfConfigValue($val, $key, $source);
  8803. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  8804. if (is_array($val) || is_array($this->config[$key])) {
  8805. if (is_string($val)) {
  8806. $val = array('*' => $val);
  8807. }
  8808. if (is_string($this->config[$key])) {
  8809. $this->config[$key] = array('*' => $this->config[$key]);
  8810. $this->sourceOfConfigValue[$key . '*'] = $source;
  8811. }
  8812. $this->config[$key] = array_merge($this->config[$key], $val);
  8813. $this->setSourceOfConfigValue($val, $key, $source);
  8814. if (isset($this->config[$key]['*'])) {
  8815. $wildcard = $this->config[$key]['*'];
  8816. unset($this->config[$key]['*']);
  8817. $this->config[$key]['*'] = $wildcard;
  8818. }
  8819. } else {
  8820. $this->config[$key] = $val;
  8821. $this->setSourceOfConfigValue($val, $key, $source);
  8822. }
  8823. } else {
  8824. $this->config[$key] = $val;
  8825. $this->setSourceOfConfigValue($val, $key, $source);
  8826. }
  8827. }
  8828. }
  8829. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  8830. $this->repositories = array_reverse($this->repositories, true);
  8831. $newRepos = array_reverse($config['repositories'], true);
  8832. foreach ($newRepos as $name => $repository) {
  8833. if (false === $repository) {
  8834. $this->disableRepoByName((string) $name);
  8835. continue;
  8836. }
  8837. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  8838. $this->disableRepoByName((string) key($repository));
  8839. continue;
  8840. }
  8841. if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && Preg::isMatch('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
  8842. $this->disableRepoByName('packagist.org');
  8843. }
  8844. if (is_int($name)) {
  8845. $this->repositories[] = $repository;
  8846. $this->setSourceOfConfigValue($repository, 'repositories.' . array_search($repository, $this->repositories, true), $source);
  8847. } else {
  8848. if ($name === 'packagist') {
  8849. $this->repositories[$name . '.org'] = $repository;
  8850. $this->setSourceOfConfigValue($repository, 'repositories.' . $name . '.org', $source);
  8851. } else {
  8852. $this->repositories[$name] = $repository;
  8853. $this->setSourceOfConfigValue($repository, 'repositories.' . $name, $source);
  8854. }
  8855. }
  8856. }
  8857. $this->repositories = array_reverse($this->repositories, true);
  8858. }
  8859. }
  8860. public function getRepositories()
  8861. {
  8862. return $this->repositories;
  8863. }
  8864. public function get($key, $flags = 0)
  8865. {
  8866. switch ($key) {
  8867. case 'vendor-dir':
  8868. case 'bin-dir':
  8869. case 'process-timeout':
  8870. case 'data-dir':
  8871. case 'cache-dir':
  8872. case 'cache-files-dir':
  8873. case 'cache-repo-dir':
  8874. case 'cache-vcs-dir':
  8875. case 'cafile':
  8876. case 'capath':
  8877. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  8878. $val = $this->getComposerEnv($env);
  8879. if ($val !== false) {
  8880. $this->setSourceOfConfigValue($val, $key, $env);
  8881. }
  8882. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  8883. $val = Platform::expandPath($val);
  8884. if (substr($key, -4) !== '-dir') {
  8885. return $val;
  8886. }
  8887. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  8888. case 'cache-read-only':
  8889. case 'htaccess-protect':
  8890. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  8891. $val = $this->getComposerEnv($env);
  8892. if (false === $val) {
  8893. $val = $this->config[$key];
  8894. } else {
  8895. $this->setSourceOfConfigValue($val, $key, $env);
  8896. }
  8897. return $val !== 'false' && (bool) $val;
  8898. case 'disable-tls':
  8899. case 'secure-http':
  8900. case 'use-github-api':
  8901. case 'lock':
  8902. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  8903. return false;
  8904. }
  8905. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  8906. case 'cache-ttl':
  8907. return (int) $this->config[$key];
  8908. case 'cache-files-maxsize':
  8909. if (!Preg::isMatch('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  8910. throw new \RuntimeException(
  8911. "Could not parse the value of '$key': {$this->config[$key]}"
  8912. );
  8913. }
  8914. $size = $matches[1];
  8915. if (isset($matches[2])) {
  8916. switch (strtolower($matches[2])) {
  8917. case 'g':
  8918. $size *= 1024;
  8919. case 'm':
  8920. $size *= 1024;
  8921. case 'k':
  8922. $size *= 1024;
  8923. break;
  8924. }
  8925. }
  8926. return $size;
  8927. case 'cache-files-ttl':
  8928. if (isset($this->config[$key])) {
  8929. return (int) $this->config[$key];
  8930. }
  8931. return (int) $this->config['cache-ttl'];
  8932. case 'home':
  8933. $val = Preg::replace('#^(\$HOME|~)(/|$)#', rtrim(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  8934. return rtrim($this->process($val, $flags), '/\\');
  8935. case 'bin-compat':
  8936. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  8937. if (!in_array($value, array('auto', 'full', 'proxy', 'symlink'))) {
  8938. throw new \RuntimeException(
  8939. "Invalid value for 'bin-compat': {$value}. Expected auto, full or proxy"
  8940. );
  8941. }
  8942. if ($value === 'symlink') {
  8943. trigger_error('config.bin-compat "symlink" is deprecated since Composer 2.2, use auto, full (for Windows compatibility) or proxy instead.', E_USER_DEPRECATED);
  8944. }
  8945. return $value;
  8946. case 'discard-changes':
  8947. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  8948. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  8949. throw new \RuntimeException(
  8950. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  8951. );
  8952. }
  8953. if ('stash' === $env) {
  8954. return 'stash';
  8955. }
  8956. return $env !== 'false' && (bool) $env;
  8957. }
  8958. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  8959. throw new \RuntimeException(
  8960. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  8961. );
  8962. }
  8963. return $this->config[$key];
  8964. case 'github-protocols':
  8965. $protos = $this->config['github-protocols'];
  8966. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  8967. unset($protos[$index]);
  8968. }
  8969. if (reset($protos) === 'http') {
  8970. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  8971. }
  8972. return $protos;
  8973. default:
  8974. if (!isset($this->config[$key])) {
  8975. return null;
  8976. }
  8977. return $this->process($this->config[$key], $flags);
  8978. }
  8979. }
  8980. public function all($flags = 0)
  8981. {
  8982. $all = array(
  8983. 'repositories' => $this->getRepositories(),
  8984. );
  8985. foreach (array_keys($this->config) as $key) {
  8986. $all['config'][$key] = $this->get($key, $flags);
  8987. }
  8988. return $all;
  8989. }
  8990. public function getSourceOfValue($key)
  8991. {
  8992. $this->get($key);
  8993. return isset($this->sourceOfConfigValue[$key]) ? $this->sourceOfConfigValue[$key] : self::SOURCE_UNKNOWN;
  8994. }
  8995. private function setSourceOfConfigValue($configValue, $path, $source)
  8996. {
  8997. $this->sourceOfConfigValue[$path] = $source;
  8998. if (is_array($configValue)) {
  8999. foreach ($configValue as $key => $value) {
  9000. $this->setSourceOfConfigValue($value, $path . '.' . $key, $source);
  9001. }
  9002. }
  9003. }
  9004. public function raw()
  9005. {
  9006. return array(
  9007. 'repositories' => $this->getRepositories(),
  9008. 'config' => $this->config,
  9009. );
  9010. }
  9011. public function has($key)
  9012. {
  9013. return array_key_exists($key, $this->config);
  9014. }
  9015. private function process($value, $flags)
  9016. {
  9017. $config = $this;
  9018. if (!is_string($value)) {
  9019. return $value;
  9020. }
  9021. return Preg::replaceCallback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  9022. return $config->get($match[1], $flags);
  9023. }, $value);
  9024. }
  9025. private function realpath($path)
  9026. {
  9027. if (Preg::isMatch('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  9028. return $path;
  9029. }
  9030. return $this->baseDir ? $this->baseDir . '/' . $path : $path;
  9031. }
  9032. private function getComposerEnv($var)
  9033. {
  9034. if ($this->useEnvironment) {
  9035. return Platform::getEnv($var);
  9036. }
  9037. return false;
  9038. }
  9039. private function disableRepoByName($name)
  9040. {
  9041. if (isset($this->repositories[$name])) {
  9042. unset($this->repositories[$name]);
  9043. } elseif ($name === 'packagist') {
  9044. unset($this->repositories['packagist.org']);
  9045. }
  9046. }
  9047. public function prohibitUrlByConfig($url, IOInterface $io = null)
  9048. {
  9049. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  9050. return;
  9051. }
  9052. $scheme = parse_url($url, PHP_URL_SCHEME);
  9053. $hostname = parse_url($url, PHP_URL_HOST);
  9054. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  9055. if ($this->get('secure-http')) {
  9056. if ($scheme === 'svn') {
  9057. if (in_array($hostname, $this->get('secure-svn-domains'), true)) {
  9058. return;
  9059. }
  9060. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-svn-domains for details.");
  9061. }
  9062. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  9063. }
  9064. if ($io) {
  9065. $host = parse_url($url, PHP_URL_HOST);
  9066. if (is_string($host)) {
  9067. if (!isset($this->warnedHosts[$host])) {
  9068. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  9069. }
  9070. $this->warnedHosts[$host] = true;
  9071. }
  9072. }
  9073. }
  9074. }
  9075. public static function disableProcessTimeout()
  9076. {
  9077. ProcessExecutor::setTimeout(0);
  9078. }
  9079. }
  9080. <?php
  9081. namespace Composer\Config;
  9082. interface ConfigSourceInterface
  9083. {
  9084. public function addRepository($name, $config, $append = true);
  9085. public function removeRepository($name);
  9086. public function addConfigSetting($name, $value);
  9087. public function removeConfigSetting($name);
  9088. public function addProperty($name, $value);
  9089. public function removeProperty($name);
  9090. public function addLink($type, $name, $value);
  9091. public function removeLink($type, $name);
  9092. public function getName();
  9093. }
  9094. <?php
  9095. namespace Composer\Config;
  9096. use Composer\Json\JsonFile;
  9097. use Composer\Json\JsonManipulator;
  9098. use Composer\Json\JsonValidationException;
  9099. use Composer\Pcre\Preg;
  9100. use Composer\Util\Filesystem;
  9101. use Composer\Util\Silencer;
  9102. class JsonConfigSource implements ConfigSourceInterface
  9103. {
  9104. private $file;
  9105. private $authConfig;
  9106. public function __construct(JsonFile $file, $authConfig = false)
  9107. {
  9108. $this->file = $file;
  9109. $this->authConfig = $authConfig;
  9110. }
  9111. public function getName()
  9112. {
  9113. return $this->file->getPath();
  9114. }
  9115. public function addRepository($name, $config, $append = true)
  9116. {
  9117. $this->manipulateJson('addRepository', $name, $config, $append, function (&$config, $repo, $repoConfig) use ($append) {
  9118. if (isset($config['repositories'])) {
  9119. foreach ($config['repositories'] as $index => $val) {
  9120. if ($index === $repo) {
  9121. continue;
  9122. }
  9123. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  9124. unset($config['repositories'][$index]);
  9125. $config['repositories']['packagist.org'] = false;
  9126. break;
  9127. }
  9128. }
  9129. }
  9130. if ($append) {
  9131. $config['repositories'][$repo] = $repoConfig;
  9132. } else {
  9133. $config['repositories'] = array($repo => $repoConfig) + $config['repositories'];
  9134. }
  9135. });
  9136. }
  9137. public function removeRepository($name)
  9138. {
  9139. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  9140. unset($config['repositories'][$repo]);
  9141. });
  9142. }
  9143. public function addConfigSetting($name, $value)
  9144. {
  9145. $authConfig = $this->authConfig;
  9146. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  9147. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  9148. list($key, $host) = explode('.', $key, 2);
  9149. if ($authConfig) {
  9150. $config[$key][$host] = $val;
  9151. } else {
  9152. $config['config'][$key][$host] = $val;
  9153. }
  9154. } else {
  9155. $config['config'][$key] = $val;
  9156. }
  9157. });
  9158. }
  9159. public function removeConfigSetting($name)
  9160. {
  9161. $authConfig = $this->authConfig;
  9162. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  9163. if (Preg::isMatch('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  9164. list($key, $host) = explode('.', $key, 2);
  9165. if ($authConfig) {
  9166. unset($config[$key][$host]);
  9167. } else {
  9168. unset($config['config'][$key][$host]);
  9169. }
  9170. } else {
  9171. unset($config['config'][$key]);
  9172. }
  9173. });
  9174. }
  9175. public function addProperty($name, $value)
  9176. {
  9177. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  9178. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  9179. $bits = explode('.', $key);
  9180. $last = array_pop($bits);
  9181. $arr = &$config[reset($bits)];
  9182. foreach ($bits as $bit) {
  9183. if (!isset($arr[$bit])) {
  9184. $arr[$bit] = array();
  9185. }
  9186. $arr = &$arr[$bit];
  9187. }
  9188. $arr[$last] = $val;
  9189. } else {
  9190. $config[$key] = $val;
  9191. }
  9192. });
  9193. }
  9194. public function removeProperty($name)
  9195. {
  9196. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  9197. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  9198. $bits = explode('.', $key);
  9199. $last = array_pop($bits);
  9200. $arr = &$config[reset($bits)];
  9201. foreach ($bits as $bit) {
  9202. if (!isset($arr[$bit])) {
  9203. return;
  9204. }
  9205. $arr = &$arr[$bit];
  9206. }
  9207. unset($arr[$last]);
  9208. } else {
  9209. unset($config[$key]);
  9210. }
  9211. });
  9212. }
  9213. public function addLink($type, $name, $value)
  9214. {
  9215. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  9216. $config[$type][$name] = $value;
  9217. });
  9218. }
  9219. public function removeLink($type, $name)
  9220. {
  9221. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  9222. unset($config[$type][$name]);
  9223. });
  9224. $this->manipulateJson('removeMainKeyIfEmpty', $type, function (&$config, $type) {
  9225. if (0 === count($config[$type])) {
  9226. unset($config[$type]);
  9227. }
  9228. });
  9229. }
  9230. protected function manipulateJson($method, $args, $fallback)
  9231. {
  9232. $args = func_get_args();
  9233. array_shift($args);
  9234. $fallback = array_pop($args);
  9235. if ($this->file->exists()) {
  9236. if (!is_writable($this->file->getPath())) {
  9237. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  9238. }
  9239. if (!Filesystem::isReadable($this->file->getPath())) {
  9240. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  9241. }
  9242. $contents = file_get_contents($this->file->getPath());
  9243. } elseif ($this->authConfig) {
  9244. $contents = "{\n}\n";
  9245. } else {
  9246. $contents = "{\n \"config\": {\n }\n}\n";
  9247. }
  9248. $manipulator = new JsonManipulator($contents);
  9249. $newFile = !$this->file->exists();
  9250. if ($this->authConfig && $method === 'addConfigSetting') {
  9251. $method = 'addSubNode';
  9252. list($mainNode, $name) = explode('.', $args[0], 2);
  9253. $args = array($mainNode, $name, $args[1]);
  9254. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  9255. $method = 'removeSubNode';
  9256. list($mainNode, $name) = explode('.', $args[0], 2);
  9257. $args = array($mainNode, $name);
  9258. }
  9259. if (call_user_func_array(array($manipulator, $method), $args)) {
  9260. file_put_contents($this->file->getPath(), $manipulator->getContents());
  9261. } else {
  9262. $config = $this->file->read();
  9263. $this->arrayUnshiftRef($args, $config);
  9264. call_user_func_array($fallback, $args);
  9265. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support') as $prop) {
  9266. if (isset($config[$prop]) && $config[$prop] === array()) {
  9267. $config[$prop] = new \stdClass;
  9268. }
  9269. }
  9270. foreach (array('psr-0', 'psr-4') as $prop) {
  9271. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === array()) {
  9272. $config['autoload'][$prop] = new \stdClass;
  9273. }
  9274. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === array()) {
  9275. $config['autoload-dev'][$prop] = new \stdClass;
  9276. }
  9277. }
  9278. foreach (array('platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install') as $prop) {
  9279. if (isset($config['config'][$prop]) && $config['config'][$prop] === array()) {
  9280. $config['config'][$prop] = new \stdClass;
  9281. }
  9282. }
  9283. $this->file->write($config);
  9284. }
  9285. try {
  9286. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  9287. } catch (JsonValidationException $e) {
  9288. file_put_contents($this->file->getPath(), $contents);
  9289. 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). '.PHP_EOL.implode(PHP_EOL, $e->getErrors()), 0, $e);
  9290. }
  9291. if ($newFile) {
  9292. Silencer::call('chmod', $this->file->getPath(), 0600);
  9293. }
  9294. }
  9295. private function arrayUnshiftRef(&$array, &$value)
  9296. {
  9297. $return = array_unshift($array, '');
  9298. $array[0] = &$value;
  9299. return $return;
  9300. }
  9301. }
  9302. <?php
  9303. namespace Composer\Console;
  9304. use Composer\IO\NullIO;
  9305. use Composer\Util\Filesystem;
  9306. use Composer\Util\Platform;
  9307. use Composer\Util\Silencer;
  9308. use Symfony\Component\Console\Application as BaseApplication;
  9309. use Symfony\Component\Console\Exception\CommandNotFoundException;
  9310. use Symfony\Component\Console\Helper\HelperSet;
  9311. use Symfony\Component\Console\Helper\QuestionHelper;
  9312. use Symfony\Component\Console\Input\InputDefinition;
  9313. use Symfony\Component\Console\Input\InputInterface;
  9314. use Symfony\Component\Console\Input\InputOption;
  9315. use Symfony\Component\Console\Output\OutputInterface;
  9316. use Seld\JsonLint\ParsingException;
  9317. use Composer\Command;
  9318. use Composer\Composer;
  9319. use Composer\Factory;
  9320. use Composer\IO\IOInterface;
  9321. use Composer\IO\ConsoleIO;
  9322. use Composer\Json\JsonValidationException;
  9323. use Composer\Util\ErrorHandler;
  9324. use Composer\Util\HttpDownloader;
  9325. use Composer\EventDispatcher\ScriptExecutionException;
  9326. use Composer\Exception\NoSslException;
  9327. use Composer\XdebugHandler\XdebugHandler;
  9328. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  9329. class Application extends BaseApplication
  9330. {
  9331. protected $composer;
  9332. protected $io;
  9333. private static $logo = ' ______
  9334. / ____/___ ____ ___ ____ ____ ________ _____
  9335. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  9336. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  9337. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  9338. /_/
  9339. ';
  9340. private $hasPluginCommands = false;
  9341. private $disablePluginsByDefault = false;
  9342. private $disableScriptsByDefault = false;
  9343. private $initialWorkingDirectory;
  9344. public function __construct()
  9345. {
  9346. static $shutdownRegistered = false;
  9347. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  9348. ini_set('xdebug.show_exception_trace', '0');
  9349. ini_set('xdebug.scream', '0');
  9350. }
  9351. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  9352. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  9353. }
  9354. if (!$shutdownRegistered) {
  9355. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  9356. pcntl_async_signals(true);
  9357. pcntl_signal(SIGINT, function ($sig) {
  9358. exit(130);
  9359. });
  9360. }
  9361. $shutdownRegistered = true;
  9362. register_shutdown_function(function () {
  9363. $lastError = error_get_last();
  9364. if ($lastError && $lastError['message'] &&
  9365. (strpos($lastError['message'], 'Allowed memory') !== false ||
  9366. strpos($lastError['message'], 'exceeded memory') !== false )) {
  9367. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  9368. }
  9369. });
  9370. }
  9371. $this->io = new NullIO();
  9372. $this->initialWorkingDirectory = getcwd();
  9373. parent::__construct('Composer', Composer::getVersion());
  9374. }
  9375. public function run(InputInterface $input = null, OutputInterface $output = null)
  9376. {
  9377. if (null === $output) {
  9378. $output = Factory::createOutput();
  9379. }
  9380. return parent::run($input, $output);
  9381. }
  9382. public function doRun(InputInterface $input, OutputInterface $output)
  9383. {
  9384. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  9385. $this->disableScriptsByDefault = $input->hasParameterOption('--no-scripts');
  9386. if (Platform::getEnv('COMPOSER_NO_INTERACTION') || !Platform::isTty(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'))) {
  9387. $input->setInteractive(false);
  9388. }
  9389. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  9390. new QuestionHelper(),
  9391. )));
  9392. ErrorHandler::register($io);
  9393. if ($input->hasParameterOption('--no-cache')) {
  9394. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  9395. Platform::putEnv('COMPOSER_CACHE_DIR', Platform::isWindows() ? 'nul' : '/dev/null');
  9396. }
  9397. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  9398. $oldWorkingDir = getcwd();
  9399. chdir($newWorkDir);
  9400. $this->initialWorkingDirectory = $newWorkDir;
  9401. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  9402. }
  9403. $commandName = '';
  9404. if ($name = $this->getCommandName($input)) {
  9405. try {
  9406. $commandName = $this->find($name)->getName();
  9407. } catch (CommandNotFoundException $e) {
  9408. $commandName = false;
  9409. } catch (\InvalidArgumentException $e) {
  9410. }
  9411. }
  9412. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile()) && ($useParentDirIfNoJsonAvailable = $this->getUseParentDirConfigValue()) !== false) {
  9413. $dir = dirname(getcwd());
  9414. $home = realpath(Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE') ?: '/');
  9415. while (dirname($dir) !== $dir && $dir !== $home) {
  9416. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  9417. if ($useParentDirIfNoJsonAvailable === true || $io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  9418. if ($useParentDirIfNoJsonAvailable === true) {
  9419. $io->writeError('<info>No composer.json in current directory, changing working directory to '.$dir.'</info>');
  9420. } else {
  9421. $io->writeError('<info>Always want to use the parent dir? Use "composer config --global use-parent-dir true" to change the default.</info>');
  9422. }
  9423. $oldWorkingDir = getcwd();
  9424. chdir($dir);
  9425. }
  9426. break;
  9427. }
  9428. $dir = dirname($dir);
  9429. }
  9430. }
  9431. $mayNeedPluginCommand = false === $input->hasParameterOption(array('--version', '-V'))
  9432. && (
  9433. false === $commandName
  9434. || in_array($commandName, array('', 'list', 'help'), true)
  9435. );
  9436. if ($mayNeedPluginCommand && !$this->disablePluginsByDefault && !$this->hasPluginCommands) {
  9437. try {
  9438. foreach ($this->getPluginCommands() as $command) {
  9439. if ($this->has($command->getName())) {
  9440. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  9441. } else {
  9442. $this->add($command);
  9443. }
  9444. }
  9445. } catch (NoSslException $e) {
  9446. } catch (ParsingException $e) {
  9447. $details = $e->getDetails();
  9448. $file = realpath(Factory::getComposerFile());
  9449. $line = null;
  9450. if ($details && isset($details['line'])) {
  9451. $line = $details['line'];
  9452. }
  9453. $ghe = new GithubActionError($this->io);
  9454. $ghe->emit($e->getMessage(), $file, $line);
  9455. throw $e;
  9456. }
  9457. $this->hasPluginCommands = true;
  9458. }
  9459. $isProxyCommand = false;
  9460. if ($name = $this->getCommandName($input)) {
  9461. try {
  9462. $command = $this->find($name);
  9463. $commandName = $command->getName();
  9464. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  9465. } catch (\InvalidArgumentException $e) {
  9466. }
  9467. }
  9468. if (!$isProxyCommand) {
  9469. $io->writeError(sprintf(
  9470. 'Running %s (%s) with %s on %s',
  9471. Composer::getVersion(),
  9472. Composer::RELEASE_DATE,
  9473. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  9474. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  9475. ), true, IOInterface::DEBUG);
  9476. if (PHP_VERSION_ID < 50302) {
  9477. $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>');
  9478. }
  9479. if (XdebugHandler::isXdebugActive() && !Platform::getEnv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  9480. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  9481. }
  9482. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  9483. $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']));
  9484. }
  9485. if (
  9486. !Platform::isWindows()
  9487. && function_exists('exec')
  9488. && !Platform::getEnv('COMPOSER_ALLOW_SUPERUSER')
  9489. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  9490. ) {
  9491. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  9492. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  9493. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  9494. if ($io->isInteractive()) {
  9495. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  9496. return 1;
  9497. }
  9498. }
  9499. }
  9500. if ($uid = (int) Platform::getEnv('SUDO_UID')) {
  9501. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  9502. }
  9503. }
  9504. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  9505. }
  9506. Silencer::call(function () use ($io) {
  9507. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  9508. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  9509. $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()));
  9510. }
  9511. });
  9512. $file = Factory::getComposerFile();
  9513. if (is_file($file) && Filesystem::isReadable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  9514. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  9515. foreach ($composer['scripts'] as $script => $dummy) {
  9516. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  9517. if ($this->has($script)) {
  9518. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  9519. } else {
  9520. $description = null;
  9521. if (isset($composer['scripts-descriptions'][$script])) {
  9522. $description = $composer['scripts-descriptions'][$script];
  9523. }
  9524. $this->add(new Command\ScriptAliasCommand($script, $description));
  9525. }
  9526. }
  9527. }
  9528. }
  9529. }
  9530. }
  9531. try {
  9532. if ($input->hasParameterOption('--profile')) {
  9533. $startTime = microtime(true);
  9534. $this->io->enableDebugging($startTime);
  9535. }
  9536. $result = parent::doRun($input, $output);
  9537. if (isset($oldWorkingDir)) {
  9538. Silencer::call('chdir', $oldWorkingDir);
  9539. }
  9540. if (isset($startTime)) {
  9541. $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');
  9542. }
  9543. restore_error_handler();
  9544. return $result;
  9545. } catch (ScriptExecutionException $e) {
  9546. return $e->getCode();
  9547. } catch (\Exception $e) {
  9548. $ghe = new GithubActionError($this->io);
  9549. $ghe->emit($e->getMessage());
  9550. $this->hintCommonErrors($e);
  9551. restore_error_handler();
  9552. throw $e;
  9553. }
  9554. }
  9555. private function getNewWorkingDir(InputInterface $input)
  9556. {
  9557. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  9558. if (false !== $workingDir && !is_dir($workingDir)) {
  9559. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  9560. }
  9561. return $workingDir;
  9562. }
  9563. private function hintCommonErrors(\Exception $exception)
  9564. {
  9565. $io = $this->getIO();
  9566. Silencer::suppress();
  9567. try {
  9568. $composer = $this->getComposer(false, true);
  9569. if ($composer) {
  9570. $config = $composer->getConfig();
  9571. $minSpaceFree = 1024 * 1024;
  9572. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  9573. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  9574. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  9575. ) {
  9576. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  9577. }
  9578. }
  9579. } catch (\Exception $e) {
  9580. }
  9581. Silencer::restore();
  9582. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  9583. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  9584. $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);
  9585. }
  9586. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  9587. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  9588. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  9589. }
  9590. if ($exception instanceof ProcessTimedOutException) {
  9591. $io->writeError('<error>The following exception is caused by a process timeout</error>', true, IOInterface::QUIET);
  9592. $io->writeError('<error>Check https://getcomposer.org/doc/06-config.md#process-timeout for details</error>', true, IOInterface::QUIET);
  9593. }
  9594. if ($hints = HttpDownloader::getExceptionHints($exception)) {
  9595. foreach ($hints as $hint) {
  9596. $io->writeError($hint, true, IOInterface::QUIET);
  9597. }
  9598. }
  9599. }
  9600. public function getComposer($required = true, $disablePlugins = null, $disableScripts = null)
  9601. {
  9602. if (null === $disablePlugins) {
  9603. $disablePlugins = $this->disablePluginsByDefault;
  9604. }
  9605. if (null === $disableScripts) {
  9606. $disableScripts = $this->disableScriptsByDefault;
  9607. }
  9608. if (null === $this->composer) {
  9609. try {
  9610. $this->composer = Factory::create($this->io, null, $disablePlugins, $disableScripts);
  9611. } catch (\InvalidArgumentException $e) {
  9612. if ($required) {
  9613. $this->io->writeError($e->getMessage());
  9614. if (!method_exists($this, 'areExceptionsCaught') || $this->areExceptionsCaught()) {
  9615. exit(1);
  9616. }
  9617. throw $e;
  9618. }
  9619. } catch (JsonValidationException $e) {
  9620. if ($required) {
  9621. throw $e;
  9622. }
  9623. }
  9624. }
  9625. return $this->composer;
  9626. }
  9627. public function resetComposer()
  9628. {
  9629. $this->composer = null;
  9630. if (method_exists($this->getIO(), 'resetAuthentications')) {
  9631. $this->getIO()->resetAuthentications();
  9632. }
  9633. }
  9634. public function getIO()
  9635. {
  9636. return $this->io;
  9637. }
  9638. public function getHelp()
  9639. {
  9640. return self::$logo . parent::getHelp();
  9641. }
  9642. protected function getDefaultCommands()
  9643. {
  9644. $commands = array_merge(parent::getDefaultCommands(), array(
  9645. new Command\AboutCommand(),
  9646. new Command\ConfigCommand(),
  9647. new Command\DependsCommand(),
  9648. new Command\ProhibitsCommand(),
  9649. new Command\InitCommand(),
  9650. new Command\InstallCommand(),
  9651. new Command\CreateProjectCommand(),
  9652. new Command\UpdateCommand(),
  9653. new Command\SearchCommand(),
  9654. new Command\ValidateCommand(),
  9655. new Command\ShowCommand(),
  9656. new Command\SuggestsCommand(),
  9657. new Command\RequireCommand(),
  9658. new Command\DumpAutoloadCommand(),
  9659. new Command\StatusCommand(),
  9660. new Command\ArchiveCommand(),
  9661. new Command\DiagnoseCommand(),
  9662. new Command\RunScriptCommand(),
  9663. new Command\LicensesCommand(),
  9664. new Command\GlobalCommand(),
  9665. new Command\ClearCacheCommand(),
  9666. new Command\RemoveCommand(),
  9667. new Command\HomeCommand(),
  9668. new Command\ExecCommand(),
  9669. new Command\OutdatedCommand(),
  9670. new Command\CheckPlatformReqsCommand(),
  9671. new Command\FundCommand(),
  9672. new Command\ReinstallCommand(),
  9673. ));
  9674. if (strpos(__FILE__, 'phar:') === 0) {
  9675. $commands[] = new Command\SelfUpdateCommand();
  9676. }
  9677. return $commands;
  9678. }
  9679. public function getLongVersion()
  9680. {
  9681. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  9682. return sprintf(
  9683. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  9684. $this->getName(),
  9685. Composer::BRANCH_ALIAS_VERSION,
  9686. $this->getVersion(),
  9687. Composer::RELEASE_DATE
  9688. );
  9689. }
  9690. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  9691. }
  9692. protected function getDefaultInputDefinition()
  9693. {
  9694. $definition = parent::getDefaultInputDefinition();
  9695. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  9696. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  9697. $definition->addOption(new InputOption('--no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'));
  9698. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  9699. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  9700. return $definition;
  9701. }
  9702. private function getPluginCommands()
  9703. {
  9704. $commands = array();
  9705. $composer = $this->getComposer(false, false);
  9706. if (null === $composer) {
  9707. $composer = Factory::createGlobal($this->io);
  9708. }
  9709. if (null !== $composer) {
  9710. $pm = $composer->getPluginManager();
  9711. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  9712. $newCommands = $capability->getCommands();
  9713. if (!is_array($newCommands)) {
  9714. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  9715. }
  9716. foreach ($newCommands as $command) {
  9717. if (!$command instanceof Command\BaseCommand) {
  9718. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  9719. }
  9720. }
  9721. $commands = array_merge($commands, $newCommands);
  9722. }
  9723. }
  9724. return $commands;
  9725. }
  9726. public function getInitialWorkingDirectory()
  9727. {
  9728. return $this->initialWorkingDirectory;
  9729. }
  9730. private function getUseParentDirConfigValue()
  9731. {
  9732. $config = Factory::createConfig($this->io);
  9733. return $config->get('use-parent-dir');
  9734. }
  9735. }
  9736. <?php
  9737. namespace Composer\Console;
  9738. use Composer\IO\IOInterface;
  9739. use Composer\Util\Platform;
  9740. final class GithubActionError
  9741. {
  9742. protected $io;
  9743. public function __construct(IOInterface $io)
  9744. {
  9745. $this->io = $io;
  9746. }
  9747. public function emit($message, $file = null, $line = null)
  9748. {
  9749. if (Platform::getEnv('GITHUB_ACTIONS') && !Platform::getEnv('COMPOSER_TESTS_ARE_RUNNING')) {
  9750. $message = $this->escapeData($message);
  9751. if ($file && $line) {
  9752. $file = $this->escapeProperty($file);
  9753. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  9754. } elseif ($file) {
  9755. $file = $this->escapeProperty($file);
  9756. $this->io->write("::error file=". $file ."::". $message);
  9757. } else {
  9758. $this->io->write("::error ::". $message);
  9759. }
  9760. }
  9761. }
  9762. private function escapeData($data) {
  9763. $data = str_replace("%", '%25', $data);
  9764. $data = str_replace("\r", '%0D', $data);
  9765. $data = str_replace("\n", '%0A', $data);
  9766. return $data;
  9767. }
  9768. private function escapeProperty($property) {
  9769. $property = str_replace("%", '%25', $property);
  9770. $property = str_replace("\r", '%0D', $property);
  9771. $property = str_replace("\n", '%0A', $property);
  9772. $property = str_replace(":", '%3A', $property);
  9773. $property = str_replace(",", '%2C', $property);
  9774. return $property;
  9775. }
  9776. }
  9777. <?php
  9778. namespace Composer\Console;
  9779. use Composer\Pcre\Preg;
  9780. use Symfony\Component\Console\Formatter\OutputFormatter;
  9781. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  9782. class HtmlOutputFormatter extends OutputFormatter
  9783. {
  9784. private static $availableForegroundColors = array(
  9785. 30 => 'black',
  9786. 31 => 'red',
  9787. 32 => 'green',
  9788. 33 => 'yellow',
  9789. 34 => 'blue',
  9790. 35 => 'magenta',
  9791. 36 => 'cyan',
  9792. 37 => 'white',
  9793. );
  9794. private static $availableBackgroundColors = array(
  9795. 40 => 'black',
  9796. 41 => 'red',
  9797. 42 => 'green',
  9798. 43 => 'yellow',
  9799. 44 => 'blue',
  9800. 45 => 'magenta',
  9801. 46 => 'cyan',
  9802. 47 => 'white',
  9803. );
  9804. private static $availableOptions = array(
  9805. 1 => 'bold',
  9806. 4 => 'underscore',
  9807. );
  9808. public function __construct(array $styles = array())
  9809. {
  9810. parent::__construct(true, $styles);
  9811. }
  9812. public function format($message)
  9813. {
  9814. $formatted = parent::format($message);
  9815. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  9816. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  9817. }
  9818. private function formatHtml($matches)
  9819. {
  9820. $out = '<span style="';
  9821. foreach (explode(';', $matches[1]) as $code) {
  9822. if (isset(self::$availableForegroundColors[(int) $code])) {
  9823. $out .= 'color:'.self::$availableForegroundColors[(int) $code].';';
  9824. } elseif (isset(self::$availableBackgroundColors[(int) $code])) {
  9825. $out .= 'background-color:'.self::$availableBackgroundColors[(int) $code].';';
  9826. } elseif (isset(self::$availableOptions[(int) $code])) {
  9827. switch (self::$availableOptions[(int) $code]) {
  9828. case 'bold':
  9829. $out .= 'font-weight:bold;';
  9830. break;
  9831. case 'underscore':
  9832. $out .= 'text-decoration:underline;';
  9833. break;
  9834. }
  9835. }
  9836. }
  9837. return $out.'">'.$matches[2].'</span>';
  9838. }
  9839. }
  9840. <?php
  9841. namespace Composer\DependencyResolver;
  9842. class Decisions implements \Iterator, \Countable
  9843. {
  9844. const DECISION_LITERAL = 0;
  9845. const DECISION_REASON = 1;
  9846. protected $pool;
  9847. protected $decisionMap;
  9848. protected $decisionQueue = array();
  9849. public function __construct(Pool $pool)
  9850. {
  9851. $this->pool = $pool;
  9852. $this->decisionMap = array();
  9853. }
  9854. public function decide($literal, $level, Rule $why)
  9855. {
  9856. $this->addDecision($literal, $level);
  9857. $this->decisionQueue[] = array(
  9858. self::DECISION_LITERAL => $literal,
  9859. self::DECISION_REASON => $why,
  9860. );
  9861. }
  9862. public function satisfy($literal)
  9863. {
  9864. $packageId = abs($literal);
  9865. return (
  9866. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  9867. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  9868. );
  9869. }
  9870. public function conflict($literal)
  9871. {
  9872. $packageId = abs($literal);
  9873. return (
  9874. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  9875. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  9876. );
  9877. }
  9878. public function decided($literalOrPackageId)
  9879. {
  9880. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  9881. }
  9882. public function undecided($literalOrPackageId)
  9883. {
  9884. return empty($this->decisionMap[abs($literalOrPackageId)]);
  9885. }
  9886. public function decidedInstall($literalOrPackageId)
  9887. {
  9888. $packageId = abs($literalOrPackageId);
  9889. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  9890. }
  9891. public function decisionLevel($literalOrPackageId)
  9892. {
  9893. $packageId = abs($literalOrPackageId);
  9894. if (isset($this->decisionMap[$packageId])) {
  9895. return abs($this->decisionMap[$packageId]);
  9896. }
  9897. return 0;
  9898. }
  9899. public function decisionRule($literalOrPackageId)
  9900. {
  9901. $packageId = abs($literalOrPackageId);
  9902. foreach ($this->decisionQueue as $decision) {
  9903. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  9904. return $decision[self::DECISION_REASON];
  9905. }
  9906. }
  9907. return null;
  9908. }
  9909. public function atOffset($queueOffset)
  9910. {
  9911. return $this->decisionQueue[$queueOffset];
  9912. }
  9913. public function validOffset($queueOffset)
  9914. {
  9915. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  9916. }
  9917. public function lastReason()
  9918. {
  9919. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  9920. }
  9921. public function lastLiteral()
  9922. {
  9923. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  9924. }
  9925. public function reset()
  9926. {
  9927. while ($decision = array_pop($this->decisionQueue)) {
  9928. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  9929. }
  9930. }
  9931. public function resetToOffset($offset)
  9932. {
  9933. while (\count($this->decisionQueue) > $offset + 1) {
  9934. $decision = array_pop($this->decisionQueue);
  9935. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  9936. }
  9937. }
  9938. public function revertLast()
  9939. {
  9940. $this->decisionMap[abs($this->lastLiteral())] = 0;
  9941. array_pop($this->decisionQueue);
  9942. }
  9943. #[\ReturnTypeWillChange]
  9944. public function count()
  9945. {
  9946. return \count($this->decisionQueue);
  9947. }
  9948. #[\ReturnTypeWillChange]
  9949. public function rewind()
  9950. {
  9951. end($this->decisionQueue);
  9952. }
  9953. #[\ReturnTypeWillChange]
  9954. public function current()
  9955. {
  9956. return current($this->decisionQueue);
  9957. }
  9958. #[\ReturnTypeWillChange]
  9959. public function key()
  9960. {
  9961. return key($this->decisionQueue);
  9962. }
  9963. #[\ReturnTypeWillChange]
  9964. public function next()
  9965. {
  9966. prev($this->decisionQueue);
  9967. }
  9968. #[\ReturnTypeWillChange]
  9969. public function valid()
  9970. {
  9971. return false !== current($this->decisionQueue);
  9972. }
  9973. public function isEmpty()
  9974. {
  9975. return \count($this->decisionQueue) === 0;
  9976. }
  9977. protected function addDecision($literal, $level)
  9978. {
  9979. $packageId = abs($literal);
  9980. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  9981. if ($previousDecision != 0) {
  9982. $literalString = $this->pool->literalToPrettyString($literal, array());
  9983. $package = $this->pool->literalToPackage($literal);
  9984. throw new SolverBugException(
  9985. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  9986. );
  9987. }
  9988. if ($literal > 0) {
  9989. $this->decisionMap[$packageId] = $level;
  9990. } else {
  9991. $this->decisionMap[$packageId] = -$level;
  9992. }
  9993. }
  9994. public function toString(Pool $pool = null)
  9995. {
  9996. $decisionMap = $this->decisionMap;
  9997. ksort($decisionMap);
  9998. $str = '[';
  9999. foreach ($decisionMap as $packageId => $level) {
  10000. $str .= (($pool) ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  10001. }
  10002. $str .= ']';
  10003. return $str;
  10004. }
  10005. public function __toString()
  10006. {
  10007. return $this->toString();
  10008. }
  10009. }
  10010. <?php
  10011. namespace Composer\DependencyResolver;
  10012. use Composer\Package\AliasPackage;
  10013. use Composer\Package\BasePackage;
  10014. use Composer\Package\PackageInterface;
  10015. use Composer\Semver\Constraint\Constraint;
  10016. class DefaultPolicy implements PolicyInterface
  10017. {
  10018. private $preferStable;
  10019. private $preferLowest;
  10020. public function __construct($preferStable = false, $preferLowest = false)
  10021. {
  10022. $this->preferStable = $preferStable;
  10023. $this->preferLowest = $preferLowest;
  10024. }
  10025. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  10026. {
  10027. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  10028. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  10029. }
  10030. $constraint = new Constraint($operator, $b->getVersion());
  10031. $version = new Constraint('==', $a->getVersion());
  10032. return $constraint->matchSpecific($version, true);
  10033. }
  10034. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
  10035. {
  10036. $packages = $this->groupLiteralsByName($pool, $literals);
  10037. $policy = $this;
  10038. foreach ($packages as &$nameLiterals) {
  10039. usort($nameLiterals, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  10040. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  10041. });
  10042. }
  10043. foreach ($packages as &$sortedLiterals) {
  10044. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  10045. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  10046. }
  10047. $selected = \call_user_func_array('array_merge', array_values($packages));
  10048. usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  10049. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  10050. });
  10051. return $selected;
  10052. }
  10053. protected function groupLiteralsByName(Pool $pool, $literals)
  10054. {
  10055. $packages = array();
  10056. foreach ($literals as $literal) {
  10057. $packageName = $pool->literalToPackage($literal)->getName();
  10058. if (!isset($packages[$packageName])) {
  10059. $packages[$packageName] = array();
  10060. }
  10061. $packages[$packageName][] = $literal;
  10062. }
  10063. return $packages;
  10064. }
  10065. public function compareByPriority(Pool $pool, BasePackage $a, BasePackage $b, $requiredPackage = null, $ignoreReplace = false)
  10066. {
  10067. if ($a->getName() === $b->getName()) {
  10068. $aAliased = $a instanceof AliasPackage;
  10069. $bAliased = $b instanceof AliasPackage;
  10070. if ($aAliased && !$bAliased) {
  10071. return -1;
  10072. }
  10073. if (!$aAliased && $bAliased) {
  10074. return 1;
  10075. }
  10076. }
  10077. if (!$ignoreReplace) {
  10078. if ($this->replaces($a, $b)) {
  10079. return 1;
  10080. }
  10081. if ($this->replaces($b, $a)) {
  10082. return -1;
  10083. }
  10084. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  10085. $requiredVendor = substr($requiredPackage, 0, $pos);
  10086. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  10087. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  10088. if ($bIsSameVendor !== $aIsSameVendor) {
  10089. return $aIsSameVendor ? -1 : 1;
  10090. }
  10091. }
  10092. }
  10093. if ($a->id === $b->id) {
  10094. return 0;
  10095. }
  10096. return ($a->id < $b->id) ? -1 : 1;
  10097. }
  10098. protected function replaces(BasePackage $source, BasePackage $target)
  10099. {
  10100. foreach ($source->getReplaces() as $link) {
  10101. if ($link->getTarget() === $target->getName()
  10102. ) {
  10103. return true;
  10104. }
  10105. }
  10106. return false;
  10107. }
  10108. protected function pruneToBestVersion(Pool $pool, $literals)
  10109. {
  10110. $operator = $this->preferLowest ? '<' : '>';
  10111. $bestLiterals = array($literals[0]);
  10112. $bestPackage = $pool->literalToPackage($literals[0]);
  10113. foreach ($literals as $i => $literal) {
  10114. if (0 === $i) {
  10115. continue;
  10116. }
  10117. $package = $pool->literalToPackage($literal);
  10118. if ($this->versionCompare($package, $bestPackage, $operator)) {
  10119. $bestPackage = $package;
  10120. $bestLiterals = array($literal);
  10121. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  10122. $bestLiterals[] = $literal;
  10123. }
  10124. }
  10125. return $bestLiterals;
  10126. }
  10127. protected function pruneRemoteAliases(Pool $pool, array $literals)
  10128. {
  10129. $hasLocalAlias = false;
  10130. foreach ($literals as $literal) {
  10131. $package = $pool->literalToPackage($literal);
  10132. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  10133. $hasLocalAlias = true;
  10134. break;
  10135. }
  10136. }
  10137. if (!$hasLocalAlias) {
  10138. return $literals;
  10139. }
  10140. $selected = array();
  10141. foreach ($literals as $literal) {
  10142. $package = $pool->literalToPackage($literal);
  10143. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  10144. $selected[] = $literal;
  10145. }
  10146. }
  10147. return $selected;
  10148. }
  10149. }
  10150. <?php
  10151. namespace Composer\DependencyResolver;
  10152. class GenericRule extends Rule
  10153. {
  10154. protected $literals;
  10155. public function __construct(array $literals, $reason, $reasonData)
  10156. {
  10157. parent::__construct($reason, $reasonData);
  10158. sort($literals);
  10159. $this->literals = $literals;
  10160. }
  10161. public function getLiterals()
  10162. {
  10163. return $this->literals;
  10164. }
  10165. public function getHash()
  10166. {
  10167. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  10168. return $data['hash'];
  10169. }
  10170. public function equals(Rule $rule)
  10171. {
  10172. return $this->literals === $rule->getLiterals();
  10173. }
  10174. public function isAssertion()
  10175. {
  10176. return 1 === \count($this->literals);
  10177. }
  10178. public function __toString()
  10179. {
  10180. $result = $this->isDisabled() ? 'disabled(' : '(';
  10181. foreach ($this->literals as $i => $literal) {
  10182. if ($i != 0) {
  10183. $result .= '|';
  10184. }
  10185. $result .= $literal;
  10186. }
  10187. $result .= ')';
  10188. return $result;
  10189. }
  10190. }
  10191. <?php
  10192. namespace Composer\DependencyResolver;
  10193. use Composer\Repository\InstalledRepositoryInterface;
  10194. use Composer\Repository\RepositoryInterface;
  10195. class LocalRepoTransaction extends Transaction
  10196. {
  10197. public function __construct(RepositoryInterface $lockedRepository, InstalledRepositoryInterface $localRepository)
  10198. {
  10199. parent::__construct(
  10200. $localRepository->getPackages(),
  10201. $lockedRepository->getPackages()
  10202. );
  10203. }
  10204. }
  10205. <?php
  10206. namespace Composer\DependencyResolver;
  10207. use Composer\Package\AliasPackage;
  10208. use Composer\Package\BasePackage;
  10209. use Composer\Package\Package;
  10210. class LockTransaction extends Transaction
  10211. {
  10212. protected $presentMap;
  10213. protected $unlockableMap;
  10214. protected $resultPackages;
  10215. public function __construct(Pool $pool, array $presentMap, array $unlockableMap, Decisions $decisions)
  10216. {
  10217. $this->presentMap = $presentMap;
  10218. $this->unlockableMap = $unlockableMap;
  10219. $this->setResultPackages($pool, $decisions);
  10220. parent::__construct($this->presentMap, $this->resultPackages['all']);
  10221. }
  10222. public function setResultPackages(Pool $pool, Decisions $decisions)
  10223. {
  10224. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  10225. foreach ($decisions as $i => $decision) {
  10226. $literal = $decision[Decisions::DECISION_LITERAL];
  10227. if ($literal > 0) {
  10228. $package = $pool->literalToPackage($literal);
  10229. $this->resultPackages['all'][] = $package;
  10230. if (!isset($this->unlockableMap[$package->id])) {
  10231. $this->resultPackages['non-dev'][] = $package;
  10232. }
  10233. }
  10234. }
  10235. }
  10236. public function setNonDevPackages(LockTransaction $extractionResult)
  10237. {
  10238. $packages = $extractionResult->getNewLockPackages(false);
  10239. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  10240. $this->resultPackages['non-dev'] = array();
  10241. foreach ($packages as $package) {
  10242. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  10243. if ($package->getName() == $resultPackage->getName()) {
  10244. $this->resultPackages['non-dev'][] = $resultPackage;
  10245. unset($this->resultPackages['dev'][$i]);
  10246. }
  10247. }
  10248. }
  10249. }
  10250. public function getNewLockPackages($devMode, $updateMirrors = false)
  10251. {
  10252. $packages = array();
  10253. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  10254. if (!$package instanceof AliasPackage) {
  10255. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  10256. foreach ($this->presentMap as $presentPackage) {
  10257. if ($package->getName() == $presentPackage->getName() && $package->getVersion() == $presentPackage->getVersion()) {
  10258. if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
  10259. $package->setSourceDistReferences($presentPackage->getSourceReference());
  10260. }
  10261. if ($presentPackage->getReleaseDate() && $package instanceof Package) {
  10262. $package->setReleaseDate($presentPackage->getReleaseDate());
  10263. }
  10264. }
  10265. }
  10266. }
  10267. $packages[] = $package;
  10268. }
  10269. }
  10270. return $packages;
  10271. }
  10272. public function getAliases($aliases)
  10273. {
  10274. $usedAliases = array();
  10275. foreach ($this->resultPackages['all'] as $package) {
  10276. if ($package instanceof AliasPackage) {
  10277. foreach ($aliases as $index => $alias) {
  10278. if ($alias['package'] === $package->getName()) {
  10279. $usedAliases[] = $alias;
  10280. unset($aliases[$index]);
  10281. }
  10282. }
  10283. }
  10284. }
  10285. usort($usedAliases, function ($a, $b) {
  10286. return strcmp($a['package'], $b['package']);
  10287. });
  10288. return $usedAliases;
  10289. }
  10290. }
  10291. <?php
  10292. namespace Composer\DependencyResolver;
  10293. class MultiConflictRule extends Rule
  10294. {
  10295. protected $literals;
  10296. public function __construct(array $literals, $reason, $reasonData)
  10297. {
  10298. parent::__construct($reason, $reasonData);
  10299. if (\count($literals) < 3) {
  10300. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  10301. }
  10302. sort($literals);
  10303. $this->literals = $literals;
  10304. }
  10305. public function getLiterals()
  10306. {
  10307. return $this->literals;
  10308. }
  10309. public function getHash()
  10310. {
  10311. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  10312. return $data['hash'];
  10313. }
  10314. public function equals(Rule $rule)
  10315. {
  10316. if ($rule instanceof MultiConflictRule) {
  10317. return $this->literals === $rule->getLiterals();
  10318. }
  10319. return false;
  10320. }
  10321. public function isAssertion()
  10322. {
  10323. return false;
  10324. }
  10325. public function disable()
  10326. {
  10327. 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.");
  10328. }
  10329. public function __toString()
  10330. {
  10331. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  10332. foreach ($this->literals as $i => $literal) {
  10333. if ($i != 0) {
  10334. $result .= '|';
  10335. }
  10336. $result .= $literal;
  10337. }
  10338. $result .= '))';
  10339. return $result;
  10340. }
  10341. }
  10342. <?php
  10343. namespace Composer\DependencyResolver\Operation;
  10344. use Composer\Package\PackageInterface;
  10345. class InstallOperation extends SolverOperation implements OperationInterface
  10346. {
  10347. const TYPE = 'install';
  10348. protected $package;
  10349. public function __construct(PackageInterface $package)
  10350. {
  10351. $this->package = $package;
  10352. }
  10353. public function getPackage()
  10354. {
  10355. return $this->package;
  10356. }
  10357. public function show($lock)
  10358. {
  10359. return self::format($this->package, $lock);
  10360. }
  10361. public static function format(PackageInterface $package, $lock = false)
  10362. {
  10363. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  10364. }
  10365. }
  10366. <?php
  10367. namespace Composer\DependencyResolver\Operation;
  10368. use Composer\Package\AliasPackage;
  10369. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  10370. {
  10371. const TYPE = 'markAliasInstalled';
  10372. protected $package;
  10373. public function __construct(AliasPackage $package)
  10374. {
  10375. $this->package = $package;
  10376. }
  10377. public function getPackage()
  10378. {
  10379. return $this->package;
  10380. }
  10381. public function show($lock)
  10382. {
  10383. 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>)';
  10384. }
  10385. }
  10386. <?php
  10387. namespace Composer\DependencyResolver\Operation;
  10388. use Composer\Package\AliasPackage;
  10389. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  10390. {
  10391. const TYPE = 'markAliasUninstalled';
  10392. protected $package;
  10393. public function __construct(AliasPackage $package)
  10394. {
  10395. $this->package = $package;
  10396. }
  10397. public function getPackage()
  10398. {
  10399. return $this->package;
  10400. }
  10401. public function show($lock)
  10402. {
  10403. 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>)';
  10404. }
  10405. }
  10406. <?php
  10407. namespace Composer\DependencyResolver\Operation;
  10408. interface OperationInterface
  10409. {
  10410. public function getOperationType();
  10411. public function show($lock);
  10412. public function __toString();
  10413. }
  10414. <?php
  10415. namespace Composer\DependencyResolver\Operation;
  10416. abstract class SolverOperation implements OperationInterface
  10417. {
  10418. const TYPE = null;
  10419. public function getOperationType()
  10420. {
  10421. return static::TYPE;
  10422. }
  10423. public function __toString()
  10424. {
  10425. return $this->show(false);
  10426. }
  10427. }
  10428. <?php
  10429. namespace Composer\DependencyResolver\Operation;
  10430. use Composer\Package\PackageInterface;
  10431. class UninstallOperation extends SolverOperation implements OperationInterface
  10432. {
  10433. const TYPE = 'uninstall';
  10434. protected $package;
  10435. public function __construct(PackageInterface $package)
  10436. {
  10437. $this->package = $package;
  10438. }
  10439. public function getPackage()
  10440. {
  10441. return $this->package;
  10442. }
  10443. public function show($lock)
  10444. {
  10445. return self::format($this->package, $lock);
  10446. }
  10447. public static function format(PackageInterface $package, $lock = false)
  10448. {
  10449. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  10450. }
  10451. }
  10452. <?php
  10453. namespace Composer\DependencyResolver\Operation;
  10454. use Composer\Package\PackageInterface;
  10455. use Composer\Package\Version\VersionParser;
  10456. class UpdateOperation extends SolverOperation implements OperationInterface
  10457. {
  10458. const TYPE = 'update';
  10459. protected $initialPackage;
  10460. protected $targetPackage;
  10461. public function __construct(PackageInterface $initial, PackageInterface $target)
  10462. {
  10463. $this->initialPackage = $initial;
  10464. $this->targetPackage = $target;
  10465. }
  10466. public function getInitialPackage()
  10467. {
  10468. return $this->initialPackage;
  10469. }
  10470. public function getTargetPackage()
  10471. {
  10472. return $this->targetPackage;
  10473. }
  10474. public function show($lock)
  10475. {
  10476. return self::format($this->initialPackage, $this->targetPackage, $lock);
  10477. }
  10478. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
  10479. {
  10480. $fromVersion = $initialPackage->getFullPrettyVersion();
  10481. $toVersion = $targetPackage->getFullPrettyVersion();
  10482. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  10483. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  10484. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  10485. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  10486. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  10487. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  10488. }
  10489. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  10490. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  10491. }
  10492. }
  10493. <?php
  10494. namespace Composer\DependencyResolver;
  10495. use Composer\Package\PackageInterface;
  10496. use Composer\Semver\Constraint\Constraint;
  10497. interface PolicyInterface
  10498. {
  10499. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  10500. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
  10501. }
  10502. <?php
  10503. namespace Composer\DependencyResolver;
  10504. use Composer\Package\BasePackage;
  10505. use Composer\Package\Version\VersionParser;
  10506. use Composer\Semver\CompilingMatcher;
  10507. use Composer\Semver\Constraint\ConstraintInterface;
  10508. use Composer\Semver\Constraint\Constraint;
  10509. class Pool implements \Countable
  10510. {
  10511. protected $packages = array();
  10512. protected $packageByName = array();
  10513. protected $versionParser;
  10514. protected $providerCache = array();
  10515. protected $unacceptableFixedOrLockedPackages;
  10516. protected $removedVersions = array();
  10517. protected $removedVersionsByPackage = array();
  10518. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array(), array $removedVersions = array(), array $removedVersionsByPackage = array())
  10519. {
  10520. $this->versionParser = new VersionParser;
  10521. $this->setPackages($packages);
  10522. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  10523. $this->removedVersions = $removedVersions;
  10524. $this->removedVersionsByPackage = $removedVersionsByPackage;
  10525. }
  10526. public function getRemovedVersions($name, ConstraintInterface $constraint)
  10527. {
  10528. if (!isset($this->removedVersions[$name])) {
  10529. return array();
  10530. }
  10531. $result = array();
  10532. foreach ($this->removedVersions[$name] as $version => $prettyVersion) {
  10533. if ($constraint->matches(new Constraint('==', $version))) {
  10534. $result[$version] = $prettyVersion;
  10535. }
  10536. }
  10537. return $result;
  10538. }
  10539. public function getRemovedVersionsByPackage($objectHash)
  10540. {
  10541. if (!isset($this->removedVersionsByPackage[$objectHash])) {
  10542. return array();
  10543. }
  10544. return $this->removedVersionsByPackage[$objectHash];
  10545. }
  10546. private function setPackages(array $packages)
  10547. {
  10548. $id = 1;
  10549. foreach ($packages as $package) {
  10550. $this->packages[] = $package;
  10551. $package->id = $id++;
  10552. foreach ($package->getNames() as $provided) {
  10553. $this->packageByName[$provided][] = $package;
  10554. }
  10555. }
  10556. }
  10557. public function getPackages()
  10558. {
  10559. return $this->packages;
  10560. }
  10561. public function packageById($id)
  10562. {
  10563. return $this->packages[$id - 1];
  10564. }
  10565. #[\ReturnTypeWillChange]
  10566. public function count()
  10567. {
  10568. return \count($this->packages);
  10569. }
  10570. public function whatProvides($name, ConstraintInterface $constraint = null)
  10571. {
  10572. $key = (string) $constraint;
  10573. if (isset($this->providerCache[$name][$key])) {
  10574. return $this->providerCache[$name][$key];
  10575. }
  10576. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  10577. }
  10578. private function computeWhatProvides($name, ConstraintInterface $constraint = null)
  10579. {
  10580. if (!isset($this->packageByName[$name])) {
  10581. return array();
  10582. }
  10583. $matches = array();
  10584. foreach ($this->packageByName[$name] as $candidate) {
  10585. if ($this->match($candidate, $name, $constraint)) {
  10586. $matches[] = $candidate;
  10587. }
  10588. }
  10589. return $matches;
  10590. }
  10591. public function literalToPackage($literal)
  10592. {
  10593. $packageId = abs($literal);
  10594. return $this->packageById($packageId);
  10595. }
  10596. public function literalToPrettyString($literal, $installedMap)
  10597. {
  10598. $package = $this->literalToPackage($literal);
  10599. if (isset($installedMap[$package->id])) {
  10600. $prefix = ($literal > 0 ? 'keep' : 'remove');
  10601. } else {
  10602. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  10603. }
  10604. return $prefix.' '.$package->getPrettyString();
  10605. }
  10606. public function match(BasePackage $candidate, $name, ConstraintInterface $constraint = null)
  10607. {
  10608. $candidateName = $candidate->getName();
  10609. $candidateVersion = $candidate->getVersion();
  10610. if ($candidateName === $name) {
  10611. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  10612. }
  10613. $provides = $candidate->getProvides();
  10614. $replaces = $candidate->getReplaces();
  10615. if (isset($replaces[0]) || isset($provides[0])) {
  10616. foreach ($provides as $link) {
  10617. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  10618. return true;
  10619. }
  10620. }
  10621. foreach ($replaces as $link) {
  10622. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  10623. return true;
  10624. }
  10625. }
  10626. return false;
  10627. }
  10628. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  10629. return true;
  10630. }
  10631. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  10632. return true;
  10633. }
  10634. return false;
  10635. }
  10636. public function isUnacceptableFixedOrLockedPackage(BasePackage $package)
  10637. {
  10638. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  10639. }
  10640. public function getUnacceptableFixedOrLockedPackages()
  10641. {
  10642. return $this->unacceptableFixedOrLockedPackages;
  10643. }
  10644. public function __toString()
  10645. {
  10646. $str = "Pool:\n";
  10647. foreach ($this->packages as $package) {
  10648. $str .= '- '.str_pad((string) $package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  10649. }
  10650. return $str;
  10651. }
  10652. }
  10653. <?php
  10654. namespace Composer\DependencyResolver;
  10655. use Composer\EventDispatcher\EventDispatcher;
  10656. use Composer\IO\IOInterface;
  10657. use Composer\Package\AliasPackage;
  10658. use Composer\Package\BasePackage;
  10659. use Composer\Package\CompleteAliasPackage;
  10660. use Composer\Package\CompletePackage;
  10661. use Composer\Package\PackageInterface;
  10662. use Composer\Package\Version\StabilityFilter;
  10663. use Composer\Pcre\Preg;
  10664. use Composer\Plugin\PluginEvents;
  10665. use Composer\Plugin\PrePoolCreateEvent;
  10666. use Composer\Repository\PlatformRepository;
  10667. use Composer\Repository\RepositoryInterface;
  10668. use Composer\Repository\RootPackageRepository;
  10669. use Composer\Semver\CompilingMatcher;
  10670. use Composer\Semver\Constraint\Constraint;
  10671. use Composer\Semver\Constraint\ConstraintInterface;
  10672. use Composer\Semver\Constraint\MatchAllConstraint;
  10673. use Composer\Semver\Constraint\MultiConstraint;
  10674. use Composer\Semver\Intervals;
  10675. class PoolBuilder
  10676. {
  10677. private $acceptableStabilities;
  10678. private $stabilityFlags;
  10679. private $rootAliases;
  10680. private $rootReferences;
  10681. private $eventDispatcher;
  10682. private $poolOptimizer;
  10683. private $io;
  10684. private $aliasMap = array();
  10685. private $packagesToLoad = array();
  10686. private $loadedPackages = array();
  10687. private $loadedPerRepo = array();
  10688. private $packages = array();
  10689. private $unacceptableFixedOrLockedPackages = array();
  10690. private $updateAllowList = array();
  10691. private $skippedLoad = array();
  10692. private $pathRepoUnlocked = array();
  10693. private $maxExtendedReqs = array();
  10694. private $updateAllowWarned = array();
  10695. private $indexCounter = 0;
  10696. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null, PoolOptimizer $poolOptimizer = null)
  10697. {
  10698. $this->acceptableStabilities = $acceptableStabilities;
  10699. $this->stabilityFlags = $stabilityFlags;
  10700. $this->rootAliases = $rootAliases;
  10701. $this->rootReferences = $rootReferences;
  10702. $this->eventDispatcher = $eventDispatcher;
  10703. $this->poolOptimizer = $poolOptimizer;
  10704. $this->io = $io;
  10705. }
  10706. public function buildPool(array $repositories, Request $request)
  10707. {
  10708. if ($request->getUpdateAllowList()) {
  10709. $this->updateAllowList = $request->getUpdateAllowList();
  10710. $this->warnAboutNonMatchingUpdateAllowList($request);
  10711. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  10712. if (!$this->isUpdateAllowed($lockedPackage)) {
  10713. $this->skippedLoad[$lockedPackage->getName()][] = $lockedPackage;
  10714. foreach ($lockedPackage->getReplaces() as $link) {
  10715. $this->skippedLoad[$link->getTarget()][] = $lockedPackage;
  10716. }
  10717. if ($lockedPackage->getDistType() === 'path') {
  10718. $transportOptions = $lockedPackage->getTransportOptions();
  10719. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  10720. $this->pathRepoUnlocked[$lockedPackage->getName()] = true;
  10721. continue;
  10722. }
  10723. }
  10724. $request->lockPackage($lockedPackage);
  10725. }
  10726. }
  10727. }
  10728. foreach ($request->getFixedOrLockedPackages() as $package) {
  10729. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  10730. foreach ($package->getReplaces() as $link) {
  10731. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  10732. }
  10733. if (
  10734. $package->getRepository() instanceof RootPackageRepository
  10735. || $package->getRepository() instanceof PlatformRepository
  10736. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  10737. ) {
  10738. $this->loadPackage($request, $repositories, $package, false);
  10739. } else {
  10740. $this->unacceptableFixedOrLockedPackages[] = $package;
  10741. }
  10742. }
  10743. foreach ($request->getRequires() as $packageName => $constraint) {
  10744. if (isset($this->loadedPackages[$packageName])) {
  10745. continue;
  10746. }
  10747. $this->packagesToLoad[$packageName] = $constraint;
  10748. $this->maxExtendedReqs[$packageName] = true;
  10749. }
  10750. foreach ($this->packagesToLoad as $name => $constraint) {
  10751. if (isset($this->loadedPackages[$name])) {
  10752. unset($this->packagesToLoad[$name]);
  10753. }
  10754. }
  10755. while (!empty($this->packagesToLoad)) {
  10756. $this->loadPackagesMarkedForLoading($request, $repositories);
  10757. }
  10758. foreach ($this->packages as $i => $package) {
  10759. if (!$package instanceof AliasPackage) {
  10760. $constraint = new Constraint('==', $package->getVersion());
  10761. $aliasedPackages = array($i => $package);
  10762. if (isset($this->aliasMap[spl_object_hash($package)])) {
  10763. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  10764. }
  10765. $found = false;
  10766. foreach ($aliasedPackages as $packageOrAlias) {
  10767. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  10768. $found = true;
  10769. }
  10770. }
  10771. if (!$found) {
  10772. foreach ($aliasedPackages as $index => $packageOrAlias) {
  10773. unset($this->packages[$index]);
  10774. }
  10775. }
  10776. }
  10777. }
  10778. if ($this->eventDispatcher) {
  10779. $prePoolCreateEvent = new PrePoolCreateEvent(
  10780. PluginEvents::PRE_POOL_CREATE,
  10781. $repositories,
  10782. $request,
  10783. $this->acceptableStabilities,
  10784. $this->stabilityFlags,
  10785. $this->rootAliases,
  10786. $this->rootReferences,
  10787. $this->packages,
  10788. $this->unacceptableFixedOrLockedPackages
  10789. );
  10790. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  10791. $this->packages = $prePoolCreateEvent->getPackages();
  10792. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  10793. }
  10794. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  10795. $this->aliasMap = array();
  10796. $this->packagesToLoad = array();
  10797. $this->loadedPackages = array();
  10798. $this->loadedPerRepo = array();
  10799. $this->packages = array();
  10800. $this->unacceptableFixedOrLockedPackages = array();
  10801. $this->maxExtendedReqs = array();
  10802. $this->skippedLoad = array();
  10803. $this->indexCounter = 0;
  10804. $pool = $this->runOptimizer($request, $pool);
  10805. Intervals::clear();
  10806. return $pool;
  10807. }
  10808. private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
  10809. {
  10810. if (PlatformRepository::isPlatformPackage($name)) {
  10811. return;
  10812. }
  10813. if (isset($this->maxExtendedReqs[$name])) {
  10814. return;
  10815. }
  10816. $rootRequires = $request->getRequires();
  10817. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  10818. $constraint = $rootRequires[$name];
  10819. }
  10820. if (!isset($this->loadedPackages[$name])) {
  10821. if (isset($this->packagesToLoad[$name])) {
  10822. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  10823. return;
  10824. }
  10825. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  10826. }
  10827. $this->packagesToLoad[$name] = $constraint;
  10828. return;
  10829. }
  10830. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  10831. return;
  10832. }
  10833. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  10834. unset($this->loadedPackages[$name]);
  10835. }
  10836. private function loadPackagesMarkedForLoading(Request $request, array $repositories)
  10837. {
  10838. foreach ($this->packagesToLoad as $name => $constraint) {
  10839. $this->loadedPackages[$name] = $constraint;
  10840. }
  10841. $packageBatch = $this->packagesToLoad;
  10842. $this->packagesToLoad = array();
  10843. foreach ($repositories as $repoIndex => $repository) {
  10844. if (empty($packageBatch)) {
  10845. break;
  10846. }
  10847. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  10848. continue;
  10849. }
  10850. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
  10851. foreach ($result['namesFound'] as $name) {
  10852. unset($packageBatch[$name]);
  10853. }
  10854. foreach ($result['packages'] as $package) {
  10855. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  10856. $this->loadPackage($request, $repositories, $package, !isset($this->pathRepoUnlocked[$package->getName()]));
  10857. }
  10858. }
  10859. }
  10860. private function loadPackage(Request $request, array $repositories, BasePackage $package, $propagateUpdate)
  10861. {
  10862. $index = $this->indexCounter++;
  10863. $this->packages[$index] = $package;
  10864. if ($package instanceof AliasPackage) {
  10865. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  10866. }
  10867. $name = $package->getName();
  10868. if (isset($this->rootReferences[$name])) {
  10869. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  10870. $package->setSourceDistReferences($this->rootReferences[$name]);
  10871. }
  10872. }
  10873. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  10874. $alias = $this->rootAliases[$name][$package->getVersion()];
  10875. if ($package instanceof AliasPackage) {
  10876. $basePackage = $package->getAliasOf();
  10877. } else {
  10878. $basePackage = $package;
  10879. }
  10880. if ($basePackage instanceof CompletePackage) {
  10881. $aliasPackage = new CompleteAliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  10882. } else {
  10883. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  10884. }
  10885. $aliasPackage->setRootPackageAlias(true);
  10886. $newIndex = $this->indexCounter++;
  10887. $this->packages[$newIndex] = $aliasPackage;
  10888. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  10889. }
  10890. foreach ($package->getRequires() as $link) {
  10891. $require = $link->getTarget();
  10892. $linkConstraint = $link->getConstraint();
  10893. if (isset($this->skippedLoad[$require])) {
  10894. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  10895. $skippedRootRequires = $this->getSkippedRootRequires($request, $require);
  10896. if ($request->getUpdateAllowTransitiveRootDependencies() || !$skippedRootRequires) {
  10897. $this->unlockPackage($request, $repositories, $require);
  10898. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  10899. } else {
  10900. foreach ($skippedRootRequires as $rootRequire) {
  10901. if (!isset($this->updateAllowWarned[$rootRequire])) {
  10902. $this->updateAllowWarned[$rootRequire] = true;
  10903. $this->io->writeError('<warning>Dependency '.$rootRequire.' 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>');
  10904. }
  10905. }
  10906. }
  10907. } elseif (isset($this->pathRepoUnlocked[$require]) && !isset($this->loadedPackages[$require])) {
  10908. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  10909. }
  10910. } else {
  10911. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  10912. }
  10913. }
  10914. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  10915. foreach ($package->getReplaces() as $link) {
  10916. $replace = $link->getTarget();
  10917. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  10918. $skippedRootRequires = $this->getSkippedRootRequires($request, $replace);
  10919. if ($request->getUpdateAllowTransitiveRootDependencies() || !$skippedRootRequires) {
  10920. $this->unlockPackage($request, $repositories, $replace);
  10921. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  10922. } else {
  10923. foreach ($skippedRootRequires as $rootRequire) {
  10924. if (!isset($this->updateAllowWarned[$rootRequire])) {
  10925. $this->updateAllowWarned[$rootRequire] = true;
  10926. $this->io->writeError('<warning>Dependency '.$rootRequire.' 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>');
  10927. }
  10928. }
  10929. }
  10930. }
  10931. }
  10932. }
  10933. }
  10934. private function isRootRequire(Request $request, $name)
  10935. {
  10936. $rootRequires = $request->getRequires();
  10937. return isset($rootRequires[$name]);
  10938. }
  10939. private function getSkippedRootRequires(Request $request, $name)
  10940. {
  10941. if (!isset($this->skippedLoad[$name])) {
  10942. return array();
  10943. }
  10944. $rootRequires = $request->getRequires();
  10945. $matches = array();
  10946. if (isset($rootRequires[$name])) {
  10947. return array_map(function (PackageInterface $package) use ($name) {
  10948. if ($name !== $package->getName()) {
  10949. return $package->getName() .' (via replace of '.$name.')';
  10950. }
  10951. return $package->getName();
  10952. }, $this->skippedLoad[$name]);
  10953. }
  10954. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  10955. if (isset($rootRequires[$packageOrReplacer->getName()])) {
  10956. $matches[] = $packageOrReplacer->getName();
  10957. }
  10958. foreach ($packageOrReplacer->getReplaces() as $link) {
  10959. if (isset($rootRequires[$link->getTarget()])) {
  10960. if ($name !== $packageOrReplacer->getName()) {
  10961. $matches[] = $packageOrReplacer->getName() .' (via replace of '.$name.')';
  10962. } else {
  10963. $matches[] = $packageOrReplacer->getName();
  10964. }
  10965. break;
  10966. }
  10967. }
  10968. }
  10969. return $matches;
  10970. }
  10971. private function isUpdateAllowed(BasePackage $package)
  10972. {
  10973. foreach ($this->updateAllowList as $pattern => $void) {
  10974. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  10975. if (Preg::isMatch($patternRegexp, $package->getName())) {
  10976. return true;
  10977. }
  10978. }
  10979. return false;
  10980. }
  10981. private function warnAboutNonMatchingUpdateAllowList(Request $request)
  10982. {
  10983. foreach ($this->updateAllowList as $pattern => $void) {
  10984. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  10985. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10986. if (Preg::isMatch($patternRegexp, $package->getName())) {
  10987. continue 2;
  10988. }
  10989. }
  10990. foreach ($request->getRequires() as $packageName => $constraint) {
  10991. if (Preg::isMatch($patternRegexp, $packageName)) {
  10992. continue 2;
  10993. }
  10994. }
  10995. if (strpos($pattern, '*') !== false) {
  10996. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  10997. } else {
  10998. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  10999. }
  11000. }
  11001. }
  11002. private function unlockPackage(Request $request, array $repositories, $name)
  11003. {
  11004. foreach ($this->skippedLoad[$name] as $packageOrReplacer) {
  11005. if ($packageOrReplacer->getName() !== $name && isset($this->skippedLoad[$packageOrReplacer->getName()])) {
  11006. $replacerName = $packageOrReplacer->getName();
  11007. if ($request->getUpdateAllowTransitiveRootDependencies() || (!$this->isRootRequire($request, $name) && !$this->isRootRequire($request, $replacerName))) {
  11008. $this->unlockPackage($request, $repositories, $replacerName);
  11009. if ($this->isRootRequire($request, $replacerName)) {
  11010. $this->markPackageNameForLoading($request, $replacerName, new MatchAllConstraint);
  11011. } else {
  11012. foreach ($this->packages as $loadedPackage) {
  11013. $requires = $loadedPackage->getRequires();
  11014. if (isset($requires[$replacerName])) {
  11015. $this->markPackageNameForLoading($request, $replacerName, $requires[$replacerName]->getConstraint());
  11016. }
  11017. }
  11018. }
  11019. }
  11020. }
  11021. }
  11022. if (isset($this->pathRepoUnlocked[$name])) {
  11023. foreach ($this->packages as $index => $package) {
  11024. if ($package->getName() === $name) {
  11025. $this->removeLoadedPackage($request, $repositories, $package, $index);
  11026. }
  11027. }
  11028. }
  11029. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name], $this->pathRepoUnlocked[$name]);
  11030. foreach ($request->getLockedPackages() as $lockedPackage) {
  11031. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  11032. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  11033. $request->unlockPackage($lockedPackage);
  11034. $this->removeLoadedPackage($request, $repositories, $lockedPackage, $index);
  11035. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  11036. if ($fixedOrLockedPackage === $lockedPackage) {
  11037. continue;
  11038. }
  11039. if (isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  11040. $requires = $fixedOrLockedPackage->getRequires();
  11041. if (isset($requires[$lockedPackage->getName()])) {
  11042. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requires[$lockedPackage->getName()]->getConstraint());
  11043. }
  11044. }
  11045. }
  11046. }
  11047. }
  11048. }
  11049. }
  11050. private function removeLoadedPackage(Request $request, array $repositories, BasePackage $package, $index)
  11051. {
  11052. $repoIndex = array_search($package->getRepository(), $repositories, true);
  11053. unset($this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()]);
  11054. unset($this->packages[$index]);
  11055. if (isset($this->aliasMap[spl_object_hash($package)])) {
  11056. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  11057. unset($this->loadedPerRepo[$repoIndex][$aliasPackage->getName()][$aliasPackage->getVersion()]);
  11058. unset($this->packages[$aliasIndex]);
  11059. }
  11060. unset($this->aliasMap[spl_object_hash($package)]);
  11061. }
  11062. }
  11063. private function runOptimizer(Request $request, Pool $pool)
  11064. {
  11065. if (null === $this->poolOptimizer) {
  11066. return $pool;
  11067. }
  11068. $total = \count($pool->getPackages());
  11069. $pool = $this->poolOptimizer->optimize($request, $pool);
  11070. $filtered = $total - \count($pool->getPackages());
  11071. if (0 === $filtered) {
  11072. return $pool;
  11073. }
  11074. $this->io->write(sprintf(
  11075. '<info>Found %s package versions referenced in your dependency graph. %s (%d%%) were optimized away.</info>',
  11076. number_format($total),
  11077. number_format($filtered),
  11078. round(100/$total*$filtered)
  11079. ), true, IOInterface::VERY_VERBOSE);
  11080. return $pool;
  11081. }
  11082. }
  11083. <?php
  11084. namespace Composer\DependencyResolver;
  11085. use Composer\Package\AliasPackage;
  11086. use Composer\Package\BasePackage;
  11087. use Composer\Package\Version\VersionParser;
  11088. use Composer\Semver\CompilingMatcher;
  11089. use Composer\Semver\Constraint\ConstraintInterface;
  11090. use Composer\Semver\Constraint\Constraint;
  11091. use Composer\Semver\Constraint\MultiConstraint;
  11092. use Composer\Semver\Intervals;
  11093. class PoolOptimizer
  11094. {
  11095. private $policy;
  11096. private $irremovablePackages = array();
  11097. private $requireConstraintsPerPackage = array();
  11098. private $conflictConstraintsPerPackage = array();
  11099. private $packagesToRemove = array();
  11100. private $aliasesPerPackage = array();
  11101. private $removedVersionsByPackage = array();
  11102. public function __construct(PolicyInterface $policy)
  11103. {
  11104. $this->policy = $policy;
  11105. }
  11106. public function optimize(Request $request, Pool $pool)
  11107. {
  11108. $this->prepare($request, $pool);
  11109. $this->optimizeByIdenticalDependencies($request, $pool);
  11110. $this->optimizeImpossiblePackagesAway($request, $pool);
  11111. $optimizedPool = $this->applyRemovalsToPool($pool);
  11112. $this->irremovablePackages = array();
  11113. $this->requireConstraintsPerPackage = array();
  11114. $this->conflictConstraintsPerPackage = array();
  11115. $this->packagesToRemove = array();
  11116. $this->aliasesPerPackage = array();
  11117. $this->removedVersionsByPackage = array();
  11118. return $optimizedPool;
  11119. }
  11120. private function prepare(Request $request, Pool $pool)
  11121. {
  11122. $irremovablePackageConstraintGroups = array();
  11123. foreach ($request->getFixedOrLockedPackages() as $package) {
  11124. $irremovablePackageConstraintGroups[$package->getName()][] = new Constraint('==', $package->getVersion());
  11125. }
  11126. foreach ($request->getRequires() as $require => $constraint) {
  11127. $constraint = Intervals::compactConstraint($constraint);
  11128. $this->requireConstraintsPerPackage[$require][(string) $constraint] = $constraint;
  11129. }
  11130. foreach ($pool->getPackages() as $package) {
  11131. foreach ($package->getRequires() as $link) {
  11132. $constraint = Intervals::compactConstraint($link->getConstraint());
  11133. $this->requireConstraintsPerPackage[$link->getTarget()][(string) $constraint] = $constraint;
  11134. }
  11135. foreach ($package->getConflicts() as $link) {
  11136. $constraint = Intervals::compactConstraint($link->getConstraint());
  11137. $this->conflictConstraintsPerPackage[$link->getTarget()][(string) $constraint] = $constraint;
  11138. }
  11139. if ($package instanceof AliasPackage) {
  11140. $this->aliasesPerPackage[$package->getAliasOf()->id][] = $package;
  11141. }
  11142. }
  11143. $irremovablePackageConstraints = array();
  11144. foreach ($irremovablePackageConstraintGroups as $packageName => $constraints) {
  11145. $irremovablePackageConstraints[$packageName] = 1 === \count($constraints) ? $constraints[0] : new MultiConstraint($constraints, false);
  11146. }
  11147. unset($irremovablePackageConstraintGroups);
  11148. foreach ($pool->getPackages() as $package) {
  11149. if (!isset($irremovablePackageConstraints[$package->getName()])) {
  11150. continue;
  11151. }
  11152. if (CompilingMatcher::match($irremovablePackageConstraints[$package->getName()], Constraint::OP_EQ, $package->getVersion())) {
  11153. $this->markPackageIrremovable($package);
  11154. }
  11155. }
  11156. }
  11157. private function markPackageIrremovable(BasePackage $package)
  11158. {
  11159. $this->irremovablePackages[$package->id] = true;
  11160. if ($package instanceof AliasPackage) {
  11161. $this->markPackageIrremovable($package->getAliasOf());
  11162. }
  11163. if (isset($this->aliasesPerPackage[$package->id])) {
  11164. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  11165. $this->irremovablePackages[$aliasPackage->id] = true;
  11166. }
  11167. }
  11168. }
  11169. private function applyRemovalsToPool(Pool $pool)
  11170. {
  11171. $packages = array();
  11172. $removedVersions = array();
  11173. foreach ($pool->getPackages() as $package) {
  11174. if (!isset($this->packagesToRemove[$package->id])) {
  11175. $packages[] = $package;
  11176. } else {
  11177. $removedVersions[$package->getName()][$package->getVersion()] = $package->getPrettyVersion();
  11178. }
  11179. }
  11180. $optimizedPool = new Pool($packages, $pool->getUnacceptableFixedOrLockedPackages(), $removedVersions, $this->removedVersionsByPackage);
  11181. return $optimizedPool;
  11182. }
  11183. private function optimizeByIdenticalDependencies(Request $request, Pool $pool)
  11184. {
  11185. $identicalDefinitionsPerPackage = array();
  11186. $packageIdenticalDefinitionLookup = array();
  11187. foreach ($pool->getPackages() as $package) {
  11188. if (isset($this->irremovablePackages[$package->id])) {
  11189. continue;
  11190. }
  11191. $this->markPackageForRemoval($package->id);
  11192. $dependencyHash = $this->calculateDependencyHash($package);
  11193. foreach ($package->getNames(false) as $packageName) {
  11194. if (!isset($this->requireConstraintsPerPackage[$packageName])) {
  11195. continue;
  11196. }
  11197. foreach ($this->requireConstraintsPerPackage[$packageName] as $requireConstraint) {
  11198. $groupHashParts = array();
  11199. if (CompilingMatcher::match($requireConstraint, Constraint::OP_EQ, $package->getVersion())) {
  11200. $groupHashParts[] = 'require:' . (string) $requireConstraint;
  11201. }
  11202. if ($package->getReplaces()) {
  11203. foreach ($package->getReplaces() as $link) {
  11204. if (CompilingMatcher::match($link->getConstraint(), Constraint::OP_EQ, $package->getVersion())) {
  11205. $groupHashParts[] = 'require:' . (string) $link->getConstraint();
  11206. }
  11207. }
  11208. }
  11209. if (isset($this->conflictConstraintsPerPackage[$packageName])) {
  11210. foreach ($this->conflictConstraintsPerPackage[$packageName] as $conflictConstraint) {
  11211. if (CompilingMatcher::match($conflictConstraint, Constraint::OP_EQ, $package->getVersion())) {
  11212. $groupHashParts[] = 'conflict:' . (string) $conflictConstraint;
  11213. }
  11214. }
  11215. }
  11216. if (!$groupHashParts) {
  11217. continue;
  11218. }
  11219. $groupHash = implode('', $groupHashParts);
  11220. $identicalDefinitionsPerPackage[$packageName][$groupHash][$dependencyHash][] = $package;
  11221. $packageIdenticalDefinitionLookup[$package->id][$packageName] = array('groupHash' => $groupHash, 'dependencyHash' => $dependencyHash);
  11222. }
  11223. }
  11224. }
  11225. foreach ($identicalDefinitionsPerPackage as $constraintGroups) {
  11226. foreach ($constraintGroups as $constraintGroup) {
  11227. foreach ($constraintGroup as $packages) {
  11228. if (1 === \count($packages)) {
  11229. $this->keepPackage($packages[0], $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  11230. continue;
  11231. }
  11232. $literals = array();
  11233. foreach ($packages as $package) {
  11234. $literals[] = $package->id;
  11235. }
  11236. foreach ($this->policy->selectPreferredPackages($pool, $literals) as $preferredLiteral) {
  11237. $this->keepPackage($pool->literalToPackage($preferredLiteral), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  11238. }
  11239. }
  11240. }
  11241. }
  11242. }
  11243. private function calculateDependencyHash(BasePackage $package)
  11244. {
  11245. $hash = '';
  11246. $hashRelevantLinks = array(
  11247. 'requires' => $package->getRequires(),
  11248. 'conflicts' => $package->getConflicts(),
  11249. 'replaces' => $package->getReplaces(),
  11250. 'provides' => $package->getProvides()
  11251. );
  11252. foreach ($hashRelevantLinks as $key => $links) {
  11253. if (0 === \count($links)) {
  11254. continue;
  11255. }
  11256. $hash .= $key . ':';
  11257. $subhash = array();
  11258. foreach ($links as $link) {
  11259. $subhash[$link->getTarget()] = (string) $link->getConstraint();
  11260. }
  11261. ksort($subhash);
  11262. foreach ($subhash as $target => $constraint) {
  11263. $hash .= $target . '@' . $constraint;
  11264. }
  11265. }
  11266. return $hash;
  11267. }
  11268. private function markPackageForRemoval($id)
  11269. {
  11270. if (isset($this->irremovablePackages[$id])) {
  11271. throw new \LogicException('Attempted removing a package which was previously marked irremovable');
  11272. }
  11273. $this->packagesToRemove[$id] = true;
  11274. }
  11275. private function keepPackage(BasePackage $package, $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup)
  11276. {
  11277. unset($this->packagesToRemove[$package->id]);
  11278. if ($package instanceof AliasPackage) {
  11279. $this->keepPackage($package->getAliasOf(), $identicalDefinitionsPerPackage, $packageIdenticalDefinitionLookup);
  11280. }
  11281. foreach ($package->getNames(false) as $name) {
  11282. if (isset($packageIdenticalDefinitionLookup[$package->id][$name])) {
  11283. $packageGroupPointers = $packageIdenticalDefinitionLookup[$package->id][$name];
  11284. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  11285. foreach ($packageGroup as $pkg) {
  11286. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  11287. $pkg = $pkg->getAliasOf();
  11288. }
  11289. $this->removedVersionsByPackage[spl_object_hash($package)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  11290. }
  11291. }
  11292. }
  11293. if (isset($this->aliasesPerPackage[$package->id])) {
  11294. foreach ($this->aliasesPerPackage[$package->id] as $aliasPackage) {
  11295. unset($this->packagesToRemove[$aliasPackage->id]);
  11296. foreach ($aliasPackage->getNames(false) as $name) {
  11297. if (isset($packageIdenticalDefinitionLookup[$aliasPackage->id][$name])) {
  11298. $packageGroupPointers = $packageIdenticalDefinitionLookup[$aliasPackage->id][$name];
  11299. $packageGroup = $identicalDefinitionsPerPackage[$name][$packageGroupPointers['groupHash']][$packageGroupPointers['dependencyHash']];
  11300. foreach ($packageGroup as $pkg) {
  11301. if ($pkg instanceof AliasPackage && $pkg->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  11302. $pkg = $pkg->getAliasOf();
  11303. }
  11304. $this->removedVersionsByPackage[spl_object_hash($aliasPackage)][$pkg->getVersion()] = $pkg->getPrettyVersion();
  11305. }
  11306. }
  11307. }
  11308. }
  11309. }
  11310. }
  11311. private function optimizeImpossiblePackagesAway(Request $request, Pool $pool)
  11312. {
  11313. if (count($request->getLockedPackages()) === 0) {
  11314. return;
  11315. }
  11316. $packageIndex = array();
  11317. foreach ($pool->getPackages() as $package) {
  11318. $id = $package->id;
  11319. if (isset($this->irremovablePackages[$id])) {
  11320. continue;
  11321. }
  11322. if (isset($this->aliasesPerPackage[$id]) || $package instanceof AliasPackage) {
  11323. continue;
  11324. }
  11325. if ($request->isFixedPackage($package) || $request->isLockedPackage($package)) {
  11326. continue;
  11327. }
  11328. $packageIndex[$package->getName()][$package->id] = $package;
  11329. }
  11330. foreach ($request->getLockedPackages() as $package) {
  11331. $isUnusedPackage = true;
  11332. foreach ($package->getNames(false) as $packageName) {
  11333. if (isset($this->requireConstraintsPerPackage[$packageName])) {
  11334. $isUnusedPackage = false;
  11335. break;
  11336. }
  11337. }
  11338. if ($isUnusedPackage) {
  11339. continue;
  11340. }
  11341. foreach ($package->getRequires() as $link) {
  11342. $require = $link->getTarget();
  11343. if (!isset($packageIndex[$require])) {
  11344. continue;
  11345. }
  11346. $linkConstraint = $link->getConstraint();
  11347. foreach ($packageIndex[$require] as $id => $requiredPkg) {
  11348. if (false === CompilingMatcher::match($linkConstraint, Constraint::OP_EQ, $requiredPkg->getVersion())) {
  11349. $this->markPackageForRemoval($id);
  11350. unset($packageIndex[$require][$id]);
  11351. }
  11352. }
  11353. }
  11354. }
  11355. }
  11356. }
  11357. <?php
  11358. namespace Composer\DependencyResolver;
  11359. use Composer\Package\CompletePackageInterface;
  11360. use Composer\Package\AliasPackage;
  11361. use Composer\Package\BasePackage;
  11362. use Composer\Package\Link;
  11363. use Composer\Package\PackageInterface;
  11364. use Composer\Package\RootPackageInterface;
  11365. use Composer\Pcre\Preg;
  11366. use Composer\Repository\RepositorySet;
  11367. use Composer\Repository\LockArrayRepository;
  11368. use Composer\Semver\Constraint\Constraint;
  11369. use Composer\Semver\Constraint\ConstraintInterface;
  11370. use Composer\Package\Version\VersionParser;
  11371. use Composer\Repository\PlatformRepository;
  11372. class Problem
  11373. {
  11374. protected $reasonSeen;
  11375. protected $reasons = array();
  11376. protected $section = 0;
  11377. public function addRule(Rule $rule)
  11378. {
  11379. $this->addReason(spl_object_hash($rule), $rule);
  11380. }
  11381. public function getReasons()
  11382. {
  11383. return $this->reasons;
  11384. }
  11385. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  11386. {
  11387. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  11388. if (count($reasons) === 1) {
  11389. reset($reasons);
  11390. $rule = current($reasons);
  11391. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  11392. throw new \LogicException("Single reason problems must contain a request rule.");
  11393. }
  11394. $reasonData = $rule->getReasonData();
  11395. $packageName = $reasonData['packageName'];
  11396. $constraint = $reasonData['constraint'];
  11397. if (isset($constraint)) {
  11398. $packages = $pool->whatProvides($packageName, $constraint);
  11399. } else {
  11400. $packages = array();
  11401. }
  11402. if (empty($packages)) {
  11403. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  11404. }
  11405. }
  11406. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  11407. }
  11408. public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  11409. {
  11410. $messages = array();
  11411. $templates = array();
  11412. $parser = new VersionParser;
  11413. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  11414. foreach ($rules as $rule) {
  11415. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  11416. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && Preg::isMatch('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  11417. $template = Preg::replace('{^\S+ \S+ }', '%s%s ', $message);
  11418. $messages[] = $template;
  11419. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  11420. $sourcePackage = $rule->getSourcePackage($pool);
  11421. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($sourcePackage)) as $version => $prettyVersion) {
  11422. $templates[$template][$m[1]][$version] = $prettyVersion;
  11423. }
  11424. } elseif ($message !== '') {
  11425. $messages[] = $message;
  11426. }
  11427. }
  11428. $result = array();
  11429. foreach (array_unique($messages) as $message) {
  11430. if (isset($templates[$message])) {
  11431. foreach ($templates[$message] as $package => $versions) {
  11432. uksort($versions, 'version_compare');
  11433. if (!$isVerbose) {
  11434. $versions = self::condenseVersionList($versions, 1);
  11435. }
  11436. if (count($versions) > 1) {
  11437. $message = Preg::replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  11438. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  11439. } else {
  11440. $result[] = sprintf($message, $package, ' '.reset($versions));
  11441. }
  11442. }
  11443. } else {
  11444. $result[] = $message;
  11445. }
  11446. }
  11447. return "\n$indent- ".implode("\n$indent- ", $result);
  11448. }
  11449. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  11450. {
  11451. foreach ($this->reasons as $sectionRules) {
  11452. foreach ($sectionRules as $rule) {
  11453. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  11454. return true;
  11455. }
  11456. }
  11457. }
  11458. return false;
  11459. }
  11460. protected function addReason($id, Rule $reason)
  11461. {
  11462. if (!isset($this->reasonSeen[$id])) {
  11463. $this->reasonSeen[$id] = true;
  11464. $this->reasons[$this->section][] = $reason;
  11465. }
  11466. }
  11467. public function nextSection()
  11468. {
  11469. $this->section++;
  11470. }
  11471. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, ConstraintInterface $constraint = null)
  11472. {
  11473. if (PlatformRepository::isPlatformPackage($packageName)) {
  11474. if (0 === stripos($packageName, 'php') || $packageName === 'hhvm') {
  11475. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion());
  11476. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  11477. if (defined('HHVM_VERSION') || ($packageName === 'hhvm' && count($pool->whatProvides($packageName)) > 0)) {
  11478. return array($msg, 'your HHVM version does not satisfy that requirement.');
  11479. }
  11480. if ($packageName === 'hhvm') {
  11481. return array($msg, 'HHVM was not detected on this machine, make sure it is in your PATH.');
  11482. }
  11483. if (null === $version) {
  11484. return array($msg, 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".');
  11485. }
  11486. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  11487. }
  11488. if (0 === stripos($packageName, 'ext-')) {
  11489. if (false !== strpos($packageName, ' ')) {
  11490. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  11491. }
  11492. $ext = substr($packageName, 4);
  11493. $msg = "- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ';
  11494. $version = self::getPlatformPackageVersion($pool, $packageName, phpversion($ext) ?: '0');
  11495. if (null === $version) {
  11496. if (extension_loaded($ext)) {
  11497. return array(
  11498. $msg,
  11499. 'the '.$packageName.' package is disabled by your platform config. Enable it again with "composer config platform.'.$packageName.' --unset".',
  11500. );
  11501. }
  11502. return array($msg, 'it is missing from your system. Install or enable PHP\'s '.$ext.' extension.');
  11503. }
  11504. return array($msg, 'it has the wrong version installed ('.$version.').');
  11505. }
  11506. if (0 === stripos($packageName, 'lib-')) {
  11507. if (strtolower($packageName) === 'lib-icu') {
  11508. $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.';
  11509. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  11510. }
  11511. 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.');
  11512. }
  11513. }
  11514. $lockedPackage = null;
  11515. foreach ($request->getLockedPackages() as $package) {
  11516. if ($package->getName() === $packageName) {
  11517. $lockedPackage = $package;
  11518. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  11519. 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.');
  11520. }
  11521. break;
  11522. }
  11523. }
  11524. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  11525. $rootReqs = $repositorySet->getRootRequires();
  11526. if (isset($rootReqs[$packageName])) {
  11527. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName) {
  11528. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  11529. });
  11530. if (0 === count($filtered)) {
  11531. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but '.(self::hasMultipleNames($packages) ? 'these conflict' : 'it conflicts').' with your root composer.json require ('.$rootReqs[$packageName]->getPrettyString().').');
  11532. }
  11533. }
  11534. if ($lockedPackage) {
  11535. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  11536. $filtered = array_filter($packages, function ($p) use ($fixedConstraint) {
  11537. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  11538. });
  11539. if (0 === count($filtered)) {
  11540. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' 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.');
  11541. }
  11542. }
  11543. $nonLockedPackages = array_filter($packages, function ($p) {
  11544. return !$p->getRepository() instanceof LockArrayRepository;
  11545. });
  11546. if (!$nonLockedPackages) {
  11547. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' in the lock file but not in remote repositories, make sure you avoid updating this package to keep the one from the lock file.');
  11548. }
  11549. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but these were not loaded, likely because '.(self::hasMultipleNames($packages) ? 'they conflict' : 'it conflicts').' with another require.');
  11550. }
  11551. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  11552. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  11553. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'minimum-stability', $constraint);
  11554. }
  11555. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match your minimum-stability.');
  11556. }
  11557. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  11558. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  11559. return self::computeCheckForLowerPrioRepo($pool, $isVerbose, $packageName, $packages, $allReposPackages, 'constraint', $constraint);
  11560. }
  11561. $suffix = '';
  11562. if ($constraint instanceof Constraint && $constraint->getVersion() === 'dev-master') {
  11563. foreach ($packages as $candidate) {
  11564. if (in_array($candidate->getVersion(), array('dev-default', 'dev-main'), true)) {
  11565. $suffix = ' Perhaps dev-master was renamed to '.$candidate->getPrettyVersion().'?';
  11566. break;
  11567. }
  11568. }
  11569. }
  11570. $allReposPackages = $packages;
  11571. $topPackage = reset($allReposPackages);
  11572. if ($topPackage instanceof RootPackageInterface) {
  11573. $suffix = ' See https://getcomposer.org/dep-on-root for details and assistance.';
  11574. }
  11575. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose, $pool, $constraint).' but '.(self::hasMultipleNames($packages) ? 'these do' : 'it does').' not match the constraint.' . $suffix);
  11576. }
  11577. if (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  11578. $illegalChars = Preg::replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  11579. 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.');
  11580. }
  11581. if ($providers = $repositorySet->getProviders($packageName)) {
  11582. $maxProviders = 20;
  11583. $providersStr = implode(array_map(function ($p) {
  11584. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  11585. return " - ${p['name']}".$description."\n";
  11586. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  11587. if (count($providers) > $maxProviders + 1) {
  11588. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  11589. }
  11590. 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.");
  11591. }
  11592. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  11593. }
  11594. public static function getPackageList(array $packages, $isVerbose, Pool $pool = null, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false)
  11595. {
  11596. $prepared = array();
  11597. $hasDefaultBranch = array();
  11598. foreach ($packages as $package) {
  11599. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  11600. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  11601. if ($pool && $constraint) {
  11602. foreach ($pool->getRemovedVersions($package->getName(), $constraint) as $version => $prettyVersion) {
  11603. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  11604. }
  11605. }
  11606. if ($pool && $useRemovedVersionGroup) {
  11607. foreach ($pool->getRemovedVersionsByPackage(spl_object_hash($package)) as $version => $prettyVersion) {
  11608. $prepared[$package->getName()]['versions'][$version] = $prettyVersion;
  11609. }
  11610. }
  11611. if ($package->isDefaultBranch()) {
  11612. $hasDefaultBranch[$package->getName()] = true;
  11613. }
  11614. }
  11615. $preparedStrings = array();
  11616. foreach ($prepared as $name => $package) {
  11617. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  11618. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  11619. }
  11620. uksort($package['versions'], 'version_compare');
  11621. if (!$isVerbose) {
  11622. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  11623. }
  11624. $preparedStrings[] = $package['name'].'['.implode(', ', $package['versions']).']';
  11625. }
  11626. return implode(', ', $preparedStrings);
  11627. }
  11628. private static function getPlatformPackageVersion(Pool $pool, $packageName, $version)
  11629. {
  11630. $available = $pool->whatProvides($packageName);
  11631. if (count($available)) {
  11632. $selected = null;
  11633. foreach ($available as $pkg) {
  11634. if ($pkg->getRepository() instanceof PlatformRepository) {
  11635. $selected = $pkg;
  11636. break;
  11637. }
  11638. }
  11639. if ($selected === null) {
  11640. $selected = reset($available);
  11641. }
  11642. if ($selected->getName() !== $packageName) {
  11643. foreach (array_merge(array_values($selected->getProvides()), array_values($selected->getReplaces())) as $link) {
  11644. if ($link->getTarget() === $packageName) {
  11645. return $link->getPrettyConstraint().' '.substr($link->getDescription(), 0, -1).'d by '.$selected->getPrettyString();
  11646. }
  11647. }
  11648. }
  11649. $version = $selected->getPrettyVersion();
  11650. $extra = $selected->getExtra();
  11651. if ($selected instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  11652. $version .= '; ' . str_replace('Package ', '', $selected->getDescription());
  11653. }
  11654. } else {
  11655. return null;
  11656. }
  11657. return $version;
  11658. }
  11659. private static function condenseVersionList(array $versions, $max, $maxDev = 16)
  11660. {
  11661. if (count($versions) <= $max) {
  11662. return $versions;
  11663. }
  11664. $filtered = array();
  11665. $byMajor = array();
  11666. foreach ($versions as $version => $pretty) {
  11667. if (0 === stripos($version, 'dev-')) {
  11668. $byMajor['dev'][] = $pretty;
  11669. } else {
  11670. $byMajor[Preg::replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  11671. }
  11672. }
  11673. foreach ($byMajor as $majorVersion => $versionsForMajor) {
  11674. $maxVersions = $majorVersion === 'dev' ? $maxDev : $max;
  11675. if (count($versionsForMajor) > $maxVersions) {
  11676. $filtered[] = $versionsForMajor[0];
  11677. $filtered[] = '...';
  11678. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  11679. } else {
  11680. $filtered = array_merge($filtered, $versionsForMajor);
  11681. }
  11682. }
  11683. return $filtered;
  11684. }
  11685. private static function hasMultipleNames(array $packages)
  11686. {
  11687. $name = null;
  11688. foreach ($packages as $package) {
  11689. if ($name === null || $name === $package->getName()) {
  11690. $name = $package->getName();
  11691. } else {
  11692. return true;
  11693. }
  11694. }
  11695. return false;
  11696. }
  11697. private static function computeCheckForLowerPrioRepo(Pool $pool, $isVerbose, $packageName, array $higherRepoPackages, array $allReposPackages, $reason, ConstraintInterface $constraint = null)
  11698. {
  11699. $nextRepoPackages = array();
  11700. $nextRepo = null;
  11701. foreach ($allReposPackages as $package) {
  11702. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  11703. $nextRepoPackages[] = $package;
  11704. $nextRepo = $package->getRepository();
  11705. } else {
  11706. break;
  11707. }
  11708. }
  11709. if ($higherRepoPackages) {
  11710. $topPackage = reset($higherRepoPackages);
  11711. if ($topPackage instanceof RootPackageInterface) {
  11712. return array(
  11713. "- Root composer.json requires $packageName".self::constraintToText($constraint).', it is ',
  11714. 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.$topPackage->getPrettyName().' is the root package and cannot be modified. See https://getcomposer.org/dep-on-root for details and assistance.',
  11715. );
  11716. }
  11717. }
  11718. if ($nextRepo instanceof LockArrayRepository) {
  11719. $singular = count($higherRepoPackages) === 1;
  11720. $suggestion = 'Make sure you either fix the '.$reason.' or avoid updating this package to keep the one present in the lock file ('.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).').';
  11721. if ($nextRepoPackages[0]->getDistType() === 'path') {
  11722. $transportOptions = $nextRepoPackages[0]->getTransportOptions();
  11723. if (!isset($transportOptions['symlink']) || $transportOptions['symlink'] !== false) {
  11724. $suggestion = 'Make sure you fix the '.$reason.' as packages installed from symlinked path repos are updated even in partial updates and the one from the lock file can thus not be used.';
  11725. }
  11726. }
  11727. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ',
  11728. 'found ' . self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' but ' . ($singular ? 'it does' : 'these do') . ' not match your '.$reason.' and ' . ($singular ? 'is' : 'are') . ' therefore not installable. '.$suggestion,
  11729. );
  11730. }
  11731. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ', 'satisfiable by '.self::getPackageList($nextRepoPackages, $isVerbose, $pool, $constraint).' from '.$nextRepo->getRepoName().' but '.self::getPackageList($higherRepoPackages, $isVerbose, $pool, $constraint).' from '.reset($higherRepoPackages)->getRepository()->getRepoName().' has higher repository priority. The packages from the higher priority repository do not match your '.$reason.' and are therefore not installable. That repository is canonical so the lower priority repo\'s packages are not installable. See https://getcomposer.org/repoprio for details and assistance.');
  11732. }
  11733. protected static function constraintToText(ConstraintInterface $constraint = null)
  11734. {
  11735. return $constraint ? ' '.$constraint->getPrettyString() : '';
  11736. }
  11737. }
  11738. <?php
  11739. namespace Composer\DependencyResolver;
  11740. use Composer\Package\BasePackage;
  11741. use Composer\Package\PackageInterface;
  11742. use Composer\Repository\LockArrayRepository;
  11743. use Composer\Semver\Constraint\ConstraintInterface;
  11744. use Composer\Semver\Constraint\MatchAllConstraint;
  11745. class Request
  11746. {
  11747. const UPDATE_ONLY_LISTED = 0;
  11748. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  11749. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  11750. protected $lockedRepository;
  11751. protected $requires = array();
  11752. protected $fixedPackages = array();
  11753. protected $lockedPackages = array();
  11754. protected $fixedLockedPackages = array();
  11755. protected $updateAllowList = array();
  11756. protected $updateAllowTransitiveDependencies = false;
  11757. public function __construct(LockArrayRepository $lockedRepository = null)
  11758. {
  11759. $this->lockedRepository = $lockedRepository;
  11760. }
  11761. public function requireName($packageName, ConstraintInterface $constraint = null)
  11762. {
  11763. $packageName = strtolower($packageName);
  11764. if ($constraint === null) {
  11765. $constraint = new MatchAllConstraint();
  11766. }
  11767. if (isset($this->requires[$packageName])) {
  11768. 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');
  11769. }
  11770. $this->requires[$packageName] = $constraint;
  11771. }
  11772. public function fixPackage(BasePackage $package)
  11773. {
  11774. $this->fixedPackages[spl_object_hash($package)] = $package;
  11775. }
  11776. public function lockPackage(BasePackage $package)
  11777. {
  11778. $this->lockedPackages[spl_object_hash($package)] = $package;
  11779. }
  11780. public function fixLockedPackage(BasePackage $package)
  11781. {
  11782. $this->fixedPackages[spl_object_hash($package)] = $package;
  11783. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  11784. }
  11785. public function unlockPackage(BasePackage $package)
  11786. {
  11787. unset($this->lockedPackages[spl_object_hash($package)]);
  11788. }
  11789. public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)
  11790. {
  11791. $this->updateAllowList = $updateAllowList;
  11792. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  11793. }
  11794. public function getUpdateAllowList()
  11795. {
  11796. return $this->updateAllowList;
  11797. }
  11798. public function getUpdateAllowTransitiveDependencies()
  11799. {
  11800. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  11801. }
  11802. public function getUpdateAllowTransitiveRootDependencies()
  11803. {
  11804. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  11805. }
  11806. public function getRequires()
  11807. {
  11808. return $this->requires;
  11809. }
  11810. public function getFixedPackages()
  11811. {
  11812. return $this->fixedPackages;
  11813. }
  11814. public function isFixedPackage(BasePackage $package)
  11815. {
  11816. return isset($this->fixedPackages[spl_object_hash($package)]);
  11817. }
  11818. public function getLockedPackages()
  11819. {
  11820. return $this->lockedPackages;
  11821. }
  11822. public function isLockedPackage(PackageInterface $package)
  11823. {
  11824. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  11825. }
  11826. public function getFixedOrLockedPackages()
  11827. {
  11828. return array_merge($this->fixedPackages, $this->lockedPackages);
  11829. }
  11830. public function getPresentMap($packageIds = false)
  11831. {
  11832. $presentMap = array();
  11833. if ($this->lockedRepository) {
  11834. foreach ($this->lockedRepository->getPackages() as $package) {
  11835. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  11836. }
  11837. }
  11838. foreach ($this->fixedPackages as $package) {
  11839. $presentMap[$packageIds ? $package->getId() : spl_object_hash($package)] = $package;
  11840. }
  11841. return $presentMap;
  11842. }
  11843. public function getFixedPackagesMap()
  11844. {
  11845. $fixedPackagesMap = array();
  11846. foreach ($this->fixedPackages as $package) {
  11847. $fixedPackagesMap[$package->getId()] = $package;
  11848. }
  11849. return $fixedPackagesMap;
  11850. }
  11851. public function getLockedRepository()
  11852. {
  11853. return $this->lockedRepository;
  11854. }
  11855. }
  11856. <?php
  11857. namespace Composer\DependencyResolver;
  11858. use Composer\Package\AliasPackage;
  11859. use Composer\Package\BasePackage;
  11860. use Composer\Package\Link;
  11861. use Composer\Repository\PlatformRepository;
  11862. use Composer\Repository\RepositorySet;
  11863. use Composer\Package\Version\VersionParser;
  11864. use Composer\Semver\Constraint\Constraint;
  11865. use Composer\Semver\Constraint\ConstraintInterface;
  11866. abstract class Rule
  11867. {
  11868. const RULE_ROOT_REQUIRE = 2;
  11869. const RULE_FIXED = 3;
  11870. const RULE_PACKAGE_CONFLICT = 6;
  11871. const RULE_PACKAGE_REQUIRES = 7;
  11872. const RULE_PACKAGE_SAME_NAME = 10;
  11873. const RULE_LEARNED = 12;
  11874. const RULE_PACKAGE_ALIAS = 13;
  11875. const RULE_PACKAGE_INVERSE_ALIAS = 14;
  11876. const BITFIELD_TYPE = 0;
  11877. const BITFIELD_REASON = 8;
  11878. const BITFIELD_DISABLED = 16;
  11879. protected $bitfield;
  11880. protected $request;
  11881. protected $reasonData;
  11882. public function __construct($reason, $reasonData)
  11883. {
  11884. $this->reasonData = $reasonData;
  11885. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  11886. ($reason << self::BITFIELD_REASON) |
  11887. (255 << self::BITFIELD_TYPE);
  11888. }
  11889. abstract public function getLiterals();
  11890. abstract public function getHash();
  11891. abstract public function __toString();
  11892. abstract public function equals(Rule $rule);
  11893. public function getReason()
  11894. {
  11895. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  11896. }
  11897. public function getReasonData()
  11898. {
  11899. return $this->reasonData;
  11900. }
  11901. public function getRequiredPackage()
  11902. {
  11903. $reason = $this->getReason();
  11904. if ($reason === self::RULE_ROOT_REQUIRE) {
  11905. return $this->reasonData['packageName'];
  11906. }
  11907. if ($reason === self::RULE_FIXED) {
  11908. return $this->reasonData['package']->getName();
  11909. }
  11910. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  11911. return $this->reasonData->getTarget();
  11912. }
  11913. return null;
  11914. }
  11915. public function setType($type)
  11916. {
  11917. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  11918. }
  11919. public function getType()
  11920. {
  11921. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  11922. }
  11923. public function disable()
  11924. {
  11925. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  11926. }
  11927. public function enable()
  11928. {
  11929. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  11930. }
  11931. public function isDisabled()
  11932. {
  11933. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  11934. }
  11935. public function isEnabled()
  11936. {
  11937. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  11938. }
  11939. abstract public function isAssertion();
  11940. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  11941. {
  11942. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  11943. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  11944. return false;
  11945. }
  11946. if ($request->getLockedRepository()) {
  11947. foreach ($request->getLockedRepository()->getPackages() as $package) {
  11948. if ($package->getName() === $this->reasonData->getTarget()) {
  11949. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  11950. return true;
  11951. }
  11952. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  11953. return true;
  11954. }
  11955. if (!$request->isLockedPackage($package)) {
  11956. return true;
  11957. }
  11958. break;
  11959. }
  11960. }
  11961. }
  11962. }
  11963. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  11964. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  11965. return false;
  11966. }
  11967. if ($request->getLockedRepository()) {
  11968. foreach ($request->getLockedRepository()->getPackages() as $package) {
  11969. if ($package->getName() === $this->reasonData['packageName']) {
  11970. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  11971. return true;
  11972. }
  11973. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  11974. return true;
  11975. }
  11976. break;
  11977. }
  11978. }
  11979. }
  11980. }
  11981. return false;
  11982. }
  11983. public function getSourcePackage(Pool $pool)
  11984. {
  11985. $literals = $this->getLiterals();
  11986. switch ($this->getReason()) {
  11987. case self::RULE_PACKAGE_CONFLICT:
  11988. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  11989. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  11990. if ($reasonData = $this->getReasonData()) {
  11991. if ($reasonData->getSource() === $package1->getName()) {
  11992. list($package2, $package1) = array($package1, $package2);
  11993. }
  11994. }
  11995. return $package2;
  11996. case self::RULE_PACKAGE_REQUIRES:
  11997. $sourceLiteral = array_shift($literals);
  11998. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  11999. return $sourcePackage;
  12000. default:
  12001. throw new \LogicException('Not implemented');
  12002. }
  12003. }
  12004. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  12005. {
  12006. $literals = $this->getLiterals();
  12007. switch ($this->getReason()) {
  12008. case self::RULE_ROOT_REQUIRE:
  12009. $packageName = $this->reasonData['packageName'];
  12010. $constraint = $this->reasonData['constraint'];
  12011. $packages = $pool->whatProvides($packageName, $constraint);
  12012. if (!$packages) {
  12013. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  12014. }
  12015. $packagesNonAlias = array_values(array_filter($packages, function ($p) {
  12016. return !($p instanceof AliasPackage);
  12017. }));
  12018. if (count($packagesNonAlias) === 1) {
  12019. $package = $packagesNonAlias[0];
  12020. if ($request->isLockedPackage($package)) {
  12021. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  12022. }
  12023. }
  12024. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose, $constraint).'.';
  12025. case self::RULE_FIXED:
  12026. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  12027. if ($request->isLockedPackage($package)) {
  12028. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  12029. }
  12030. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  12031. case self::RULE_PACKAGE_CONFLICT:
  12032. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  12033. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  12034. $conflictTarget = $package1->getPrettyString();
  12035. if ($reasonData = $this->getReasonData()) {
  12036. assert($reasonData instanceof Link);
  12037. if ($reasonData->getSource() === $package1->getName()) {
  12038. list($package2, $package1) = array($package1, $package2);
  12039. $conflictTarget = $package1->getPrettyName().' '.$reasonData->getPrettyConstraint();
  12040. }
  12041. if ($reasonData->getTarget() !== $package1->getName()) {
  12042. $provideType = null;
  12043. $provided = null;
  12044. foreach ($package1->getProvides() as $provide) {
  12045. if ($provide->getTarget() === $reasonData->getTarget()) {
  12046. $provideType = 'provides';
  12047. $provided = $provide->getPrettyConstraint();
  12048. break;
  12049. }
  12050. }
  12051. foreach ($package1->getReplaces() as $replace) {
  12052. if ($replace->getTarget() === $reasonData->getTarget()) {
  12053. $provideType = 'replaces';
  12054. $provided = $replace->getPrettyConstraint();
  12055. break;
  12056. }
  12057. }
  12058. if (null !== $provideType) {
  12059. $conflictTarget = $reasonData->getTarget().' '.$reasonData->getPrettyConstraint().' ('.$package1->getPrettyString().' '.$provideType.' '.$reasonData->getTarget().' '.$provided.')';
  12060. }
  12061. }
  12062. }
  12063. return $package2->getPrettyString().' conflicts with '.$conflictTarget.'.';
  12064. case self::RULE_PACKAGE_REQUIRES:
  12065. $sourceLiteral = array_shift($literals);
  12066. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  12067. $reasonData = $this->reasonData;
  12068. $requires = array();
  12069. foreach ($literals as $literal) {
  12070. $requires[] = $pool->literalToPackage($literal);
  12071. }
  12072. $text = $reasonData->getPrettyString($sourcePackage);
  12073. if ($requires) {
  12074. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose, $this->reasonData->getConstraint()) . '.';
  12075. } else {
  12076. $targetName = $reasonData->getTarget();
  12077. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  12078. return $text . ' -> ' . $reason[1];
  12079. }
  12080. return $text;
  12081. case self::RULE_PACKAGE_SAME_NAME:
  12082. $packageNames = array();
  12083. foreach ($literals as $literal) {
  12084. $package = $pool->literalToPackage($literal);
  12085. $packageNames[$package->getName()] = true;
  12086. }
  12087. $replacedName = $this->reasonData;
  12088. if (count($packageNames) > 1) {
  12089. $reason = null;
  12090. if (!isset($packageNames[$replacedName])) {
  12091. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  12092. } else {
  12093. $replacerNames = $packageNames;
  12094. unset($replacerNames[$replacedName]);
  12095. $replacerNames = array_keys($replacerNames);
  12096. if (count($replacerNames) == 1) {
  12097. $reason = $replacerNames[0] . ' replaces ';
  12098. } else {
  12099. $reason = '['.implode(', ', $replacerNames).'] replace ';
  12100. }
  12101. $reason .= $replacedName.' and thus cannot coexist with it.';
  12102. }
  12103. $installedPackages = array();
  12104. $removablePackages = array();
  12105. foreach ($literals as $literal) {
  12106. if (isset($installedMap[abs($literal)])) {
  12107. $installedPackages[] = $pool->literalToPackage($literal);
  12108. } else {
  12109. $removablePackages[] = $pool->literalToPackage($literal);
  12110. }
  12111. }
  12112. if ($installedPackages && $removablePackages) {
  12113. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose, null, true).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose, null, true).'. '.$reason;
  12114. }
  12115. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose, null, true).'. '.$reason;
  12116. }
  12117. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose, null, true) . '.';
  12118. case self::RULE_LEARNED:
  12119. $learnedString = ' (conflict analysis result)';
  12120. if (count($literals) === 1) {
  12121. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  12122. } else {
  12123. $groups = array();
  12124. foreach ($literals as $literal) {
  12125. $package = $pool->literalToPackage($literal);
  12126. if (isset($installedMap[$package->id])) {
  12127. $group = $literal > 0 ? 'keep' : 'remove';
  12128. } else {
  12129. $group = $literal > 0 ? 'install' : 'don\'t install';
  12130. }
  12131. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  12132. }
  12133. $ruleTexts = array();
  12134. foreach ($groups as $group => $packages) {
  12135. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  12136. }
  12137. $ruleText = implode(' | ', $ruleTexts);
  12138. }
  12139. return 'Conclusion: '.$ruleText.$learnedString;
  12140. case self::RULE_PACKAGE_ALIAS:
  12141. $aliasPackage = $pool->literalToPackage($literals[0]);
  12142. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12143. return '';
  12144. }
  12145. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  12146. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  12147. case self::RULE_PACKAGE_INVERSE_ALIAS:
  12148. $aliasPackage = $pool->literalToPackage($literals[1]);
  12149. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12150. return '';
  12151. }
  12152. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  12153. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  12154. default:
  12155. $ruleText = '';
  12156. foreach ($literals as $i => $literal) {
  12157. if ($i != 0) {
  12158. $ruleText .= '|';
  12159. }
  12160. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  12161. }
  12162. return '('.$ruleText.')';
  12163. }
  12164. }
  12165. protected function formatPackagesUnique(Pool $pool, array $packages, $isVerbose, ConstraintInterface $constraint = null, $useRemovedVersionGroup = false)
  12166. {
  12167. foreach ($packages as $index => $package) {
  12168. if (!\is_object($package)) {
  12169. $packages[$index] = $pool->literalToPackage($package);
  12170. }
  12171. }
  12172. return Problem::getPackageList($packages, $isVerbose, $pool, $constraint, $useRemovedVersionGroup);
  12173. }
  12174. private function deduplicateDefaultBranchAlias(BasePackage $package)
  12175. {
  12176. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  12177. $package = $package->getAliasOf();
  12178. }
  12179. return $package;
  12180. }
  12181. }
  12182. <?php
  12183. namespace Composer\DependencyResolver;
  12184. class Rule2Literals extends Rule
  12185. {
  12186. protected $literal1;
  12187. protected $literal2;
  12188. public function __construct($literal1, $literal2, $reason, $reasonData)
  12189. {
  12190. parent::__construct($reason, $reasonData);
  12191. if ($literal1 < $literal2) {
  12192. $this->literal1 = $literal1;
  12193. $this->literal2 = $literal2;
  12194. } else {
  12195. $this->literal1 = $literal2;
  12196. $this->literal2 = $literal1;
  12197. }
  12198. }
  12199. public function getLiterals()
  12200. {
  12201. return array($this->literal1, $this->literal2);
  12202. }
  12203. public function getHash()
  12204. {
  12205. return $this->literal1.','.$this->literal2;
  12206. }
  12207. public function equals(Rule $rule)
  12208. {
  12209. if ($rule instanceof self) {
  12210. if ($this->literal1 !== $rule->literal1) {
  12211. return false;
  12212. }
  12213. if ($this->literal2 !== $rule->literal2) {
  12214. return false;
  12215. }
  12216. return true;
  12217. }
  12218. $literals = $rule->getLiterals();
  12219. if (2 != \count($literals)) {
  12220. return false;
  12221. }
  12222. if ($this->literal1 !== $literals[0]) {
  12223. return false;
  12224. }
  12225. if ($this->literal2 !== $literals[1]) {
  12226. return false;
  12227. }
  12228. return true;
  12229. }
  12230. public function isAssertion()
  12231. {
  12232. return false;
  12233. }
  12234. public function __toString()
  12235. {
  12236. $result = $this->isDisabled() ? 'disabled(' : '(';
  12237. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  12238. return $result;
  12239. }
  12240. }
  12241. <?php
  12242. namespace Composer\DependencyResolver;
  12243. use Composer\Repository\RepositorySet;
  12244. class RuleSet implements \IteratorAggregate, \Countable
  12245. {
  12246. const TYPE_PACKAGE = 0;
  12247. const TYPE_REQUEST = 1;
  12248. const TYPE_LEARNED = 4;
  12249. public $ruleById = array();
  12250. protected static $types = array(
  12251. self::TYPE_PACKAGE => 'PACKAGE',
  12252. self::TYPE_REQUEST => 'REQUEST',
  12253. self::TYPE_LEARNED => 'LEARNED',
  12254. );
  12255. protected $rules;
  12256. protected $nextRuleId = 0;
  12257. protected $rulesByHash = array();
  12258. public function __construct()
  12259. {
  12260. foreach ($this->getTypes() as $type) {
  12261. $this->rules[$type] = array();
  12262. }
  12263. }
  12264. public function add(Rule $rule, $type)
  12265. {
  12266. if (!isset(self::$types[$type])) {
  12267. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  12268. }
  12269. $hash = $rule->getHash();
  12270. if (isset($this->rulesByHash[$hash])) {
  12271. $potentialDuplicates = $this->rulesByHash[$hash];
  12272. if (\is_array($potentialDuplicates)) {
  12273. foreach ($potentialDuplicates as $potentialDuplicate) {
  12274. if ($rule->equals($potentialDuplicate)) {
  12275. return;
  12276. }
  12277. }
  12278. } else {
  12279. if ($rule->equals($potentialDuplicates)) {
  12280. return;
  12281. }
  12282. }
  12283. }
  12284. if (!isset($this->rules[$type])) {
  12285. $this->rules[$type] = array();
  12286. }
  12287. $this->rules[$type][] = $rule;
  12288. $this->ruleById[$this->nextRuleId] = $rule;
  12289. $rule->setType($type);
  12290. $this->nextRuleId++;
  12291. if (!isset($this->rulesByHash[$hash])) {
  12292. $this->rulesByHash[$hash] = $rule;
  12293. } elseif (\is_array($this->rulesByHash[$hash])) {
  12294. $this->rulesByHash[$hash][] = $rule;
  12295. } else {
  12296. $originalRule = $this->rulesByHash[$hash];
  12297. $this->rulesByHash[$hash] = array($originalRule, $rule);
  12298. }
  12299. }
  12300. #[\ReturnTypeWillChange]
  12301. public function count()
  12302. {
  12303. return $this->nextRuleId;
  12304. }
  12305. public function ruleById($id)
  12306. {
  12307. return $this->ruleById[$id];
  12308. }
  12309. public function getRules()
  12310. {
  12311. return $this->rules;
  12312. }
  12313. #[\ReturnTypeWillChange]
  12314. public function getIterator()
  12315. {
  12316. return new RuleSetIterator($this->getRules());
  12317. }
  12318. public function getIteratorFor($types)
  12319. {
  12320. if (!\is_array($types)) {
  12321. $types = array($types);
  12322. }
  12323. $allRules = $this->getRules();
  12324. $rules = array();
  12325. foreach ($types as $type) {
  12326. $rules[$type] = $allRules[$type];
  12327. }
  12328. return new RuleSetIterator($rules);
  12329. }
  12330. public function getIteratorWithout($types)
  12331. {
  12332. if (!\is_array($types)) {
  12333. $types = array($types);
  12334. }
  12335. $rules = $this->getRules();
  12336. foreach ($types as $type) {
  12337. unset($rules[$type]);
  12338. }
  12339. return new RuleSetIterator($rules);
  12340. }
  12341. public function getTypes()
  12342. {
  12343. $types = self::$types;
  12344. return array_keys($types);
  12345. }
  12346. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
  12347. {
  12348. $string = "\n";
  12349. foreach ($this->rules as $type => $rules) {
  12350. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  12351. foreach ($rules as $rule) {
  12352. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  12353. }
  12354. $string .= "\n\n";
  12355. }
  12356. return $string;
  12357. }
  12358. public function __toString()
  12359. {
  12360. return $this->getPrettyString();
  12361. }
  12362. }
  12363. <?php
  12364. namespace Composer\DependencyResolver;
  12365. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  12366. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  12367. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  12368. use Composer\Package\BasePackage;
  12369. use Composer\Package\AliasPackage;
  12370. use Composer\Repository\PlatformRepository;
  12371. class RuleSetGenerator
  12372. {
  12373. protected $policy;
  12374. protected $pool;
  12375. protected $rules;
  12376. protected $addedMap = array();
  12377. protected $addedPackagesByNames = array();
  12378. public function __construct(PolicyInterface $policy, Pool $pool)
  12379. {
  12380. $this->policy = $policy;
  12381. $this->pool = $pool;
  12382. $this->rules = new RuleSet;
  12383. }
  12384. protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData = null)
  12385. {
  12386. $literals = array(-$package->id);
  12387. foreach ($providers as $provider) {
  12388. if ($provider === $package) {
  12389. return null;
  12390. }
  12391. $literals[] = $provider->id;
  12392. }
  12393. return new GenericRule($literals, $reason, $reasonData);
  12394. }
  12395. protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
  12396. {
  12397. $literals = array();
  12398. foreach ($packages as $package) {
  12399. $literals[] = $package->id;
  12400. }
  12401. return new GenericRule($literals, $reason, $reasonData);
  12402. }
  12403. protected function createRule2Literals(BasePackage $issuer, BasePackage $provider, $reason, $reasonData = null)
  12404. {
  12405. if ($issuer === $provider) {
  12406. return null;
  12407. }
  12408. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  12409. }
  12410. protected function createMultiConflictRule(array $packages, $reason, $reasonData)
  12411. {
  12412. $literals = array();
  12413. foreach ($packages as $package) {
  12414. $literals[] = -$package->id;
  12415. }
  12416. if (\count($literals) == 2) {
  12417. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  12418. }
  12419. return new MultiConflictRule($literals, $reason, $reasonData);
  12420. }
  12421. private function addRule($type, Rule $newRule = null)
  12422. {
  12423. if (!$newRule) {
  12424. return;
  12425. }
  12426. $this->rules->add($newRule, $type);
  12427. }
  12428. protected function addRulesForPackage(BasePackage $package, PlatformRequirementFilterInterface $platformRequirementFilter)
  12429. {
  12430. $workQueue = new \SplQueue;
  12431. $workQueue->enqueue($package);
  12432. while (!$workQueue->isEmpty()) {
  12433. $package = $workQueue->dequeue();
  12434. if (isset($this->addedMap[$package->id])) {
  12435. continue;
  12436. }
  12437. $this->addedMap[$package->id] = $package;
  12438. if (!$package instanceof AliasPackage) {
  12439. foreach ($package->getNames(false) as $name) {
  12440. $this->addedPackagesByNames[$name][] = $package;
  12441. }
  12442. } else {
  12443. $workQueue->enqueue($package->getAliasOf());
  12444. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  12445. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), array($package), Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  12446. if (!$package->hasSelfVersionRequires()) {
  12447. continue;
  12448. }
  12449. }
  12450. foreach ($package->getRequires() as $link) {
  12451. $constraint = $link->getConstraint();
  12452. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  12453. continue;
  12454. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  12455. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint);
  12456. }
  12457. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $constraint);
  12458. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  12459. foreach ($possibleRequires as $require) {
  12460. $workQueue->enqueue($require);
  12461. }
  12462. }
  12463. }
  12464. }
  12465. protected function addConflictRules(PlatformRequirementFilterInterface $platformRequirementFilter)
  12466. {
  12467. foreach ($this->addedMap as $package) {
  12468. foreach ($package->getConflicts() as $link) {
  12469. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  12470. continue;
  12471. }
  12472. $constraint = $link->getConstraint();
  12473. if ($platformRequirementFilter->isIgnored($link->getTarget())) {
  12474. continue;
  12475. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  12476. $constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint);
  12477. }
  12478. $conflicts = $this->pool->whatProvides($link->getTarget(), $constraint);
  12479. foreach ($conflicts as $conflict) {
  12480. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  12481. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  12482. }
  12483. }
  12484. }
  12485. }
  12486. foreach ($this->addedPackagesByNames as $name => $packages) {
  12487. if (\count($packages) > 1) {
  12488. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  12489. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  12490. }
  12491. }
  12492. }
  12493. protected function addRulesForRequest(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter)
  12494. {
  12495. foreach ($request->getFixedPackages() as $package) {
  12496. if ($package->id == -1) {
  12497. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  12498. continue;
  12499. }
  12500. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  12501. }
  12502. $this->addRulesForPackage($package, $platformRequirementFilter);
  12503. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  12504. 'package' => $package,
  12505. ));
  12506. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  12507. }
  12508. foreach ($request->getRequires() as $packageName => $constraint) {
  12509. if ($platformRequirementFilter->isIgnored($packageName)) {
  12510. continue;
  12511. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  12512. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  12513. }
  12514. $packages = $this->pool->whatProvides($packageName, $constraint);
  12515. if ($packages) {
  12516. foreach ($packages as $package) {
  12517. $this->addRulesForPackage($package, $platformRequirementFilter);
  12518. }
  12519. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  12520. 'packageName' => $packageName,
  12521. 'constraint' => $constraint,
  12522. ));
  12523. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  12524. }
  12525. }
  12526. }
  12527. protected function addRulesForRootAliases(PlatformRequirementFilterInterface $platformRequirementFilter)
  12528. {
  12529. foreach ($this->pool->getPackages() as $package) {
  12530. if (!isset($this->addedMap[$package->id]) &&
  12531. $package instanceof AliasPackage &&
  12532. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  12533. ) {
  12534. $this->addRulesForPackage($package, $platformRequirementFilter);
  12535. }
  12536. }
  12537. }
  12538. public function getRulesFor(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null)
  12539. {
  12540. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  12541. $this->addRulesForRequest($request, $platformRequirementFilter);
  12542. $this->addRulesForRootAliases($platformRequirementFilter);
  12543. $this->addConflictRules($platformRequirementFilter);
  12544. $this->addedMap = $this->addedPackagesByNames = array();
  12545. $rules = $this->rules;
  12546. $this->rules = new RuleSet;
  12547. return $rules;
  12548. }
  12549. }
  12550. <?php
  12551. namespace Composer\DependencyResolver;
  12552. class RuleSetIterator implements \Iterator
  12553. {
  12554. protected $rules;
  12555. protected $types;
  12556. protected $currentOffset;
  12557. protected $currentType;
  12558. protected $currentTypeOffset;
  12559. public function __construct(array $rules)
  12560. {
  12561. $this->rules = $rules;
  12562. $this->types = array_keys($rules);
  12563. sort($this->types);
  12564. $this->rewind();
  12565. }
  12566. #[\ReturnTypeWillChange]
  12567. public function current()
  12568. {
  12569. return $this->rules[$this->currentType][$this->currentOffset];
  12570. }
  12571. #[\ReturnTypeWillChange]
  12572. public function key()
  12573. {
  12574. return $this->currentType;
  12575. }
  12576. #[\ReturnTypeWillChange]
  12577. public function next()
  12578. {
  12579. $this->currentOffset++;
  12580. if (!isset($this->rules[$this->currentType])) {
  12581. return;
  12582. }
  12583. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  12584. $this->currentOffset = 0;
  12585. do {
  12586. $this->currentTypeOffset++;
  12587. if (!isset($this->types[$this->currentTypeOffset])) {
  12588. $this->currentType = -1;
  12589. break;
  12590. }
  12591. $this->currentType = $this->types[$this->currentTypeOffset];
  12592. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  12593. }
  12594. }
  12595. #[\ReturnTypeWillChange]
  12596. public function rewind()
  12597. {
  12598. $this->currentOffset = 0;
  12599. $this->currentTypeOffset = -1;
  12600. $this->currentType = -1;
  12601. do {
  12602. $this->currentTypeOffset++;
  12603. if (!isset($this->types[$this->currentTypeOffset])) {
  12604. $this->currentType = -1;
  12605. break;
  12606. }
  12607. $this->currentType = $this->types[$this->currentTypeOffset];
  12608. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  12609. }
  12610. #[\ReturnTypeWillChange]
  12611. public function valid()
  12612. {
  12613. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  12614. }
  12615. }
  12616. <?php
  12617. namespace Composer\DependencyResolver;
  12618. class RuleWatchChain extends \SplDoublyLinkedList
  12619. {
  12620. public function seek($offset)
  12621. {
  12622. $this->rewind();
  12623. for ($i = 0; $i < $offset; $i++, $this->next());
  12624. }
  12625. public function remove()
  12626. {
  12627. $offset = $this->key();
  12628. $this->offsetUnset($offset);
  12629. $this->seek($offset);
  12630. }
  12631. }
  12632. <?php
  12633. namespace Composer\DependencyResolver;
  12634. class RuleWatchGraph
  12635. {
  12636. protected $watchChains = array();
  12637. public function insert(RuleWatchNode $node)
  12638. {
  12639. if ($node->getRule()->isAssertion()) {
  12640. return;
  12641. }
  12642. if (!$node->getRule() instanceof MultiConflictRule) {
  12643. foreach (array($node->watch1, $node->watch2) as $literal) {
  12644. if (!isset($this->watchChains[$literal])) {
  12645. $this->watchChains[$literal] = new RuleWatchChain;
  12646. }
  12647. $this->watchChains[$literal]->unshift($node);
  12648. }
  12649. } else {
  12650. foreach ($node->getRule()->getLiterals() as $literal) {
  12651. if (!isset($this->watchChains[$literal])) {
  12652. $this->watchChains[$literal] = new RuleWatchChain;
  12653. }
  12654. $this->watchChains[$literal]->unshift($node);
  12655. }
  12656. }
  12657. }
  12658. public function propagateLiteral($decidedLiteral, $level, Decisions $decisions)
  12659. {
  12660. $literal = -$decidedLiteral;
  12661. if (!isset($this->watchChains[$literal])) {
  12662. return null;
  12663. }
  12664. $chain = $this->watchChains[$literal];
  12665. $chain->rewind();
  12666. while ($chain->valid()) {
  12667. $node = $chain->current();
  12668. if (!$node->getRule() instanceof MultiConflictRule) {
  12669. $otherWatch = $node->getOtherWatch($literal);
  12670. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  12671. $ruleLiterals = $node->getRule()->getLiterals();
  12672. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  12673. return $literal !== $ruleLiteral &&
  12674. $otherWatch !== $ruleLiteral &&
  12675. !$decisions->conflict($ruleLiteral);
  12676. });
  12677. if ($alternativeLiterals) {
  12678. reset($alternativeLiterals);
  12679. $this->moveWatch($literal, current($alternativeLiterals), $node);
  12680. continue;
  12681. }
  12682. if ($decisions->conflict($otherWatch)) {
  12683. return $node->getRule();
  12684. }
  12685. $decisions->decide($otherWatch, $level, $node->getRule());
  12686. }
  12687. } else {
  12688. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  12689. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  12690. if ($decisions->conflict($otherLiteral)) {
  12691. return $node->getRule();
  12692. }
  12693. $decisions->decide($otherLiteral, $level, $node->getRule());
  12694. }
  12695. }
  12696. }
  12697. $chain->next();
  12698. }
  12699. return null;
  12700. }
  12701. protected function moveWatch($fromLiteral, $toLiteral, RuleWatchNode $node)
  12702. {
  12703. if (!isset($this->watchChains[$toLiteral])) {
  12704. $this->watchChains[$toLiteral] = new RuleWatchChain;
  12705. }
  12706. $node->moveWatch($fromLiteral, $toLiteral);
  12707. $this->watchChains[$fromLiteral]->remove();
  12708. $this->watchChains[$toLiteral]->unshift($node);
  12709. }
  12710. }
  12711. <?php
  12712. namespace Composer\DependencyResolver;
  12713. class RuleWatchNode
  12714. {
  12715. public $watch1;
  12716. public $watch2;
  12717. protected $rule;
  12718. public function __construct(Rule $rule)
  12719. {
  12720. $this->rule = $rule;
  12721. $literals = $rule->getLiterals();
  12722. $literalCount = \count($literals);
  12723. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  12724. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  12725. }
  12726. public function watch2OnHighest(Decisions $decisions)
  12727. {
  12728. $literals = $this->rule->getLiterals();
  12729. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  12730. return;
  12731. }
  12732. $watchLevel = 0;
  12733. foreach ($literals as $literal) {
  12734. $level = $decisions->decisionLevel($literal);
  12735. if ($level > $watchLevel) {
  12736. $this->watch2 = $literal;
  12737. $watchLevel = $level;
  12738. }
  12739. }
  12740. }
  12741. public function getRule()
  12742. {
  12743. return $this->rule;
  12744. }
  12745. public function getOtherWatch($literal)
  12746. {
  12747. if ($this->watch1 == $literal) {
  12748. return $this->watch2;
  12749. }
  12750. return $this->watch1;
  12751. }
  12752. public function moveWatch($from, $to)
  12753. {
  12754. if ($this->watch1 == $from) {
  12755. $this->watch1 = $to;
  12756. } else {
  12757. $this->watch2 = $to;
  12758. }
  12759. }
  12760. }
  12761. <?php
  12762. namespace Composer\DependencyResolver;
  12763. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  12764. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  12765. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  12766. use Composer\IO\IOInterface;
  12767. use Composer\Package\BasePackage;
  12768. class Solver
  12769. {
  12770. const BRANCH_LITERALS = 0;
  12771. const BRANCH_LEVEL = 1;
  12772. protected $policy;
  12773. protected $pool;
  12774. protected $rules;
  12775. protected $watchGraph;
  12776. protected $decisions;
  12777. protected $fixedMap;
  12778. protected $propagateIndex;
  12779. protected $branches = array();
  12780. protected $problems = array();
  12781. protected $learnedPool = array();
  12782. protected $learnedWhy = array();
  12783. public $testFlagLearnedPositiveLiteral = false;
  12784. protected $io;
  12785. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  12786. {
  12787. $this->io = $io;
  12788. $this->policy = $policy;
  12789. $this->pool = $pool;
  12790. }
  12791. public function getRuleSetSize()
  12792. {
  12793. return \count($this->rules);
  12794. }
  12795. public function getPool()
  12796. {
  12797. return $this->pool;
  12798. }
  12799. private function makeAssertionRuleDecisions()
  12800. {
  12801. $decisionStart = \count($this->decisions) - 1;
  12802. $rulesCount = \count($this->rules);
  12803. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  12804. $rule = $this->rules->ruleById[$ruleIndex];
  12805. if (!$rule->isAssertion() || $rule->isDisabled()) {
  12806. continue;
  12807. }
  12808. $literals = $rule->getLiterals();
  12809. $literal = $literals[0];
  12810. if (!$this->decisions->decided($literal)) {
  12811. $this->decisions->decide($literal, 1, $rule);
  12812. continue;
  12813. }
  12814. if ($this->decisions->satisfy($literal)) {
  12815. continue;
  12816. }
  12817. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  12818. $rule->disable();
  12819. continue;
  12820. }
  12821. $conflict = $this->decisions->decisionRule($literal);
  12822. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  12823. $problem = new Problem();
  12824. $problem->addRule($rule);
  12825. $problem->addRule($conflict);
  12826. $rule->disable();
  12827. $this->problems[] = $problem;
  12828. continue;
  12829. }
  12830. $problem = new Problem();
  12831. $problem->addRule($rule);
  12832. $problem->addRule($conflict);
  12833. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  12834. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  12835. continue;
  12836. }
  12837. $assertRuleLiterals = $assertRule->getLiterals();
  12838. $assertRuleLiteral = $assertRuleLiterals[0];
  12839. if (abs($literal) !== abs($assertRuleLiteral)) {
  12840. continue;
  12841. }
  12842. $problem->addRule($assertRule);
  12843. $assertRule->disable();
  12844. }
  12845. $this->problems[] = $problem;
  12846. $this->decisions->resetToOffset($decisionStart);
  12847. $ruleIndex = -1;
  12848. }
  12849. }
  12850. protected function setupFixedMap(Request $request)
  12851. {
  12852. $this->fixedMap = array();
  12853. foreach ($request->getFixedPackages() as $package) {
  12854. $this->fixedMap[$package->id] = $package;
  12855. }
  12856. }
  12857. protected function checkForRootRequireProblems(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter)
  12858. {
  12859. foreach ($request->getRequires() as $packageName => $constraint) {
  12860. if ($platformRequirementFilter->isIgnored($packageName)) {
  12861. continue;
  12862. } elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  12863. $constraint = $platformRequirementFilter->filterConstraint($packageName, $constraint);
  12864. }
  12865. if (!$this->pool->whatProvides($packageName, $constraint)) {
  12866. $problem = new Problem();
  12867. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  12868. $this->problems[] = $problem;
  12869. }
  12870. }
  12871. }
  12872. public function solve(Request $request, PlatformRequirementFilterInterface $platformRequirementFilter = null)
  12873. {
  12874. $platformRequirementFilter = $platformRequirementFilter ?: PlatformRequirementFilterFactory::ignoreNothing();
  12875. $this->setupFixedMap($request);
  12876. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  12877. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  12878. $this->rules = $ruleSetGenerator->getRulesFor($request, $platformRequirementFilter);
  12879. unset($ruleSetGenerator);
  12880. $this->checkForRootRequireProblems($request, $platformRequirementFilter);
  12881. $this->decisions = new Decisions($this->pool);
  12882. $this->watchGraph = new RuleWatchGraph;
  12883. foreach ($this->rules as $rule) {
  12884. $this->watchGraph->insert(new RuleWatchNode($rule));
  12885. }
  12886. $this->makeAssertionRuleDecisions();
  12887. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  12888. $before = microtime(true);
  12889. $this->runSat();
  12890. $this->io->writeError('', true, IOInterface::DEBUG);
  12891. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  12892. if ($this->problems) {
  12893. throw new SolverProblemsException($this->problems, $this->learnedPool);
  12894. }
  12895. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  12896. }
  12897. protected function propagate($level)
  12898. {
  12899. while ($this->decisions->validOffset($this->propagateIndex)) {
  12900. $decision = $this->decisions->atOffset($this->propagateIndex);
  12901. $conflict = $this->watchGraph->propagateLiteral(
  12902. $decision[Decisions::DECISION_LITERAL],
  12903. $level,
  12904. $this->decisions
  12905. );
  12906. $this->propagateIndex++;
  12907. if ($conflict) {
  12908. return $conflict;
  12909. }
  12910. }
  12911. return null;
  12912. }
  12913. private function revert($level)
  12914. {
  12915. while (!$this->decisions->isEmpty()) {
  12916. $literal = $this->decisions->lastLiteral();
  12917. if ($this->decisions->undecided($literal)) {
  12918. break;
  12919. }
  12920. $decisionLevel = $this->decisions->decisionLevel($literal);
  12921. if ($decisionLevel <= $level) {
  12922. break;
  12923. }
  12924. $this->decisions->revertLast();
  12925. $this->propagateIndex = \count($this->decisions);
  12926. }
  12927. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  12928. array_pop($this->branches);
  12929. }
  12930. }
  12931. private function setPropagateLearn($level, $literal, Rule $rule)
  12932. {
  12933. $level++;
  12934. $this->decisions->decide($literal, $level, $rule);
  12935. while (true) {
  12936. $rule = $this->propagate($level);
  12937. if (!$rule) {
  12938. break;
  12939. }
  12940. if ($level == 1) {
  12941. return $this->analyzeUnsolvable($rule);
  12942. }
  12943. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  12944. if ($newLevel <= 0 || $newLevel >= $level) {
  12945. throw new SolverBugException(
  12946. "Trying to revert to invalid level ".$newLevel." from level ".$level."."
  12947. );
  12948. }
  12949. $level = $newLevel;
  12950. $this->revert($level);
  12951. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  12952. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  12953. $ruleNode = new RuleWatchNode($newRule);
  12954. $ruleNode->watch2OnHighest($this->decisions);
  12955. $this->watchGraph->insert($ruleNode);
  12956. $this->decisions->decide($learnLiteral, $level, $newRule);
  12957. }
  12958. return $level;
  12959. }
  12960. private function selectAndInstall($level, array $decisionQueue, Rule $rule)
  12961. {
  12962. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  12963. $selectedLiteral = array_shift($literals);
  12964. if (\count($literals)) {
  12965. $this->branches[] = array($literals, $level);
  12966. }
  12967. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  12968. }
  12969. protected function analyze($level, Rule $rule)
  12970. {
  12971. $analyzedRule = $rule;
  12972. $ruleLevel = 1;
  12973. $num = 0;
  12974. $l1num = 0;
  12975. $seen = array();
  12976. $learnedLiterals = array(null);
  12977. $decisionId = \count($this->decisions);
  12978. $this->learnedPool[] = array();
  12979. while (true) {
  12980. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  12981. foreach ($rule->getLiterals() as $literal) {
  12982. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  12983. continue;
  12984. }
  12985. if ($this->decisions->satisfy($literal)) {
  12986. continue;
  12987. }
  12988. if (isset($seen[abs($literal)])) {
  12989. continue;
  12990. }
  12991. $seen[abs($literal)] = true;
  12992. $l = $this->decisions->decisionLevel($literal);
  12993. if (1 === $l) {
  12994. $l1num++;
  12995. } elseif ($level === $l) {
  12996. $num++;
  12997. } else {
  12998. $learnedLiterals[] = $literal;
  12999. if ($l > $ruleLevel) {
  13000. $ruleLevel = $l;
  13001. }
  13002. }
  13003. }
  13004. unset($literal);
  13005. $l1retry = true;
  13006. while ($l1retry) {
  13007. $l1retry = false;
  13008. if (0 === $num && 0 === --$l1num) {
  13009. break 2;
  13010. }
  13011. while (true) {
  13012. if ($decisionId <= 0) {
  13013. throw new SolverBugException(
  13014. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  13015. );
  13016. }
  13017. $decisionId--;
  13018. $decision = $this->decisions->atOffset($decisionId);
  13019. $literal = $decision[Decisions::DECISION_LITERAL];
  13020. if (isset($seen[abs($literal)])) {
  13021. break;
  13022. }
  13023. }
  13024. unset($seen[abs($literal)]);
  13025. if (0 !== $num && 0 === --$num) {
  13026. if ($literal < 0) {
  13027. $this->testFlagLearnedPositiveLiteral = true;
  13028. }
  13029. $learnedLiterals[0] = -$literal;
  13030. if (!$l1num) {
  13031. break 2;
  13032. }
  13033. foreach ($learnedLiterals as $i => $learnedLiteral) {
  13034. if ($i !== 0) {
  13035. unset($seen[abs($learnedLiteral)]);
  13036. }
  13037. }
  13038. $l1num++;
  13039. $l1retry = true;
  13040. } else {
  13041. $decision = $this->decisions->atOffset($decisionId);
  13042. $rule = $decision[Decisions::DECISION_REASON];
  13043. if ($rule instanceof MultiConflictRule) {
  13044. foreach ($rule->getLiterals() as $literal) {
  13045. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  13046. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  13047. $l = $this->decisions->decisionLevel($literal);
  13048. if (1 === $l) {
  13049. $l1num++;
  13050. } elseif ($level === $l) {
  13051. $num++;
  13052. } else {
  13053. $learnedLiterals[] = $literal;
  13054. if ($l > $ruleLevel) {
  13055. $ruleLevel = $l;
  13056. }
  13057. }
  13058. $seen[abs($literal)] = true;
  13059. break;
  13060. }
  13061. }
  13062. $l1retry = true;
  13063. }
  13064. }
  13065. }
  13066. $decision = $this->decisions->atOffset($decisionId);
  13067. $rule = $decision[Decisions::DECISION_REASON];
  13068. }
  13069. $why = \count($this->learnedPool) - 1;
  13070. if (!$learnedLiterals[0]) {
  13071. throw new SolverBugException(
  13072. "Did not find a learnable literal in analyzed rule $analyzedRule."
  13073. );
  13074. }
  13075. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  13076. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  13077. }
  13078. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen)
  13079. {
  13080. $why = spl_object_hash($conflictRule);
  13081. $ruleSeen[$why] = true;
  13082. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  13083. $learnedWhy = $this->learnedWhy[$why];
  13084. $problemRules = $this->learnedPool[$learnedWhy];
  13085. foreach ($problemRules as $problemRule) {
  13086. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  13087. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  13088. }
  13089. }
  13090. return;
  13091. }
  13092. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  13093. return;
  13094. }
  13095. $problem->nextSection();
  13096. $problem->addRule($conflictRule);
  13097. }
  13098. private function analyzeUnsolvable(Rule $conflictRule)
  13099. {
  13100. $problem = new Problem();
  13101. $problem->addRule($conflictRule);
  13102. $ruleSeen = array();
  13103. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  13104. $this->problems[] = $problem;
  13105. $seen = array();
  13106. $literals = $conflictRule->getLiterals();
  13107. foreach ($literals as $literal) {
  13108. if ($this->decisions->satisfy($literal)) {
  13109. continue;
  13110. }
  13111. $seen[abs($literal)] = true;
  13112. }
  13113. foreach ($this->decisions as $decision) {
  13114. $literal = $decision[Decisions::DECISION_LITERAL];
  13115. if (!isset($seen[abs($literal)])) {
  13116. continue;
  13117. }
  13118. $why = $decision[Decisions::DECISION_REASON];
  13119. $problem->addRule($why);
  13120. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  13121. $literals = $why->getLiterals();
  13122. foreach ($literals as $literal) {
  13123. if ($this->decisions->satisfy($literal)) {
  13124. continue;
  13125. }
  13126. $seen[abs($literal)] = true;
  13127. }
  13128. }
  13129. return 0;
  13130. }
  13131. private function enableDisableLearnedRules()
  13132. {
  13133. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  13134. $why = $this->learnedWhy[spl_object_hash($rule)];
  13135. $problemRules = $this->learnedPool[$why];
  13136. $foundDisabled = false;
  13137. foreach ($problemRules as $problemRule) {
  13138. if ($problemRule->isDisabled()) {
  13139. $foundDisabled = true;
  13140. break;
  13141. }
  13142. }
  13143. if ($foundDisabled && $rule->isEnabled()) {
  13144. $rule->disable();
  13145. } elseif (!$foundDisabled && $rule->isDisabled()) {
  13146. $rule->enable();
  13147. }
  13148. }
  13149. }
  13150. private function runSat()
  13151. {
  13152. $this->propagateIndex = 0;
  13153. $level = 1;
  13154. $systemLevel = $level + 1;
  13155. while (true) {
  13156. if (1 === $level) {
  13157. $conflictRule = $this->propagate($level);
  13158. if (null !== $conflictRule) {
  13159. if ($this->analyzeUnsolvable($conflictRule)) {
  13160. continue;
  13161. }
  13162. return;
  13163. }
  13164. }
  13165. if ($level < $systemLevel) {
  13166. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  13167. foreach ($iterator as $rule) {
  13168. if ($rule->isEnabled()) {
  13169. $decisionQueue = array();
  13170. $noneSatisfied = true;
  13171. foreach ($rule->getLiterals() as $literal) {
  13172. if ($this->decisions->satisfy($literal)) {
  13173. $noneSatisfied = false;
  13174. break;
  13175. }
  13176. if ($literal > 0 && $this->decisions->undecided($literal)) {
  13177. $decisionQueue[] = $literal;
  13178. }
  13179. }
  13180. if ($noneSatisfied && \count($decisionQueue)) {
  13181. $prunedQueue = array();
  13182. foreach ($decisionQueue as $literal) {
  13183. if (isset($this->fixedMap[abs($literal)])) {
  13184. $prunedQueue[] = $literal;
  13185. }
  13186. }
  13187. if (!empty($prunedQueue)) {
  13188. $decisionQueue = $prunedQueue;
  13189. }
  13190. }
  13191. if ($noneSatisfied && \count($decisionQueue)) {
  13192. $oLevel = $level;
  13193. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  13194. if (0 === $level) {
  13195. return;
  13196. }
  13197. if ($level <= $oLevel) {
  13198. break;
  13199. }
  13200. }
  13201. }
  13202. }
  13203. $systemLevel = $level + 1;
  13204. $iterator->next();
  13205. if ($iterator->valid()) {
  13206. continue;
  13207. }
  13208. }
  13209. if ($level < $systemLevel) {
  13210. $systemLevel = $level;
  13211. }
  13212. $rulesCount = \count($this->rules);
  13213. $pass = 1;
  13214. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  13215. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  13216. if ($i == $rulesCount) {
  13217. if (1 === $pass) {
  13218. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  13219. } else {
  13220. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  13221. }
  13222. $i = 0;
  13223. $pass++;
  13224. }
  13225. $rule = $this->rules->ruleById[$i];
  13226. $literals = $rule->getLiterals();
  13227. if ($rule->isDisabled()) {
  13228. continue;
  13229. }
  13230. $decisionQueue = array();
  13231. foreach ($literals as $literal) {
  13232. if ($literal <= 0) {
  13233. if (!$this->decisions->decidedInstall($literal)) {
  13234. continue 2;
  13235. }
  13236. } else {
  13237. if ($this->decisions->decidedInstall($literal)) {
  13238. continue 2;
  13239. }
  13240. if ($this->decisions->undecided($literal)) {
  13241. $decisionQueue[] = $literal;
  13242. }
  13243. }
  13244. }
  13245. if (\count($decisionQueue) < 2) {
  13246. continue;
  13247. }
  13248. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  13249. if (0 === $level) {
  13250. return;
  13251. }
  13252. $rulesCount = \count($this->rules);
  13253. $n = -1;
  13254. }
  13255. if ($level < $systemLevel) {
  13256. continue;
  13257. }
  13258. if (\count($this->branches)) {
  13259. $lastLiteral = null;
  13260. $lastLevel = null;
  13261. $lastBranchIndex = 0;
  13262. $lastBranchOffset = 0;
  13263. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  13264. list($literals, $l) = $this->branches[$i];
  13265. foreach ($literals as $offset => $literal) {
  13266. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  13267. $lastLiteral = $literal;
  13268. $lastBranchIndex = $i;
  13269. $lastBranchOffset = $offset;
  13270. $lastLevel = $l;
  13271. }
  13272. }
  13273. }
  13274. if ($lastLiteral) {
  13275. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  13276. $level = $lastLevel;
  13277. $this->revert($level);
  13278. $why = $this->decisions->lastReason();
  13279. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  13280. if ($level == 0) {
  13281. return;
  13282. }
  13283. continue;
  13284. }
  13285. }
  13286. break;
  13287. }
  13288. }
  13289. }
  13290. <?php
  13291. namespace Composer\DependencyResolver;
  13292. class SolverBugException extends \RuntimeException
  13293. {
  13294. public function __construct($message)
  13295. {
  13296. parent::__construct(
  13297. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  13298. "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"
  13299. );
  13300. }
  13301. }
  13302. <?php
  13303. namespace Composer\DependencyResolver;
  13304. use Composer\Util\IniHelper;
  13305. use Composer\Repository\RepositorySet;
  13306. class SolverProblemsException extends \RuntimeException
  13307. {
  13308. const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  13309. protected $problems;
  13310. protected $learnedPool;
  13311. public function __construct(array $problems, array $learnedPool)
  13312. {
  13313. $this->problems = $problems;
  13314. $this->learnedPool = $learnedPool;
  13315. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', self::ERROR_DEPENDENCY_RESOLUTION_FAILED);
  13316. }
  13317. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
  13318. {
  13319. $installedMap = $request->getPresentMap(true);
  13320. $missingExtensions = array();
  13321. $isCausedByLock = false;
  13322. $problems = array();
  13323. foreach ($this->problems as $problem) {
  13324. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  13325. $missingExtensions = array_merge($missingExtensions, $this->getExtensionProblems($problem->getReasons()));
  13326. $isCausedByLock = $isCausedByLock || $problem->isCausedByLock($repositorySet, $request, $pool);
  13327. }
  13328. $i = 1;
  13329. $text = "\n";
  13330. foreach (array_unique($problems) as $problem) {
  13331. $text .= " Problem ".($i++).$problem;
  13332. }
  13333. $hints = array();
  13334. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  13335. $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.";
  13336. }
  13337. if (!empty($missingExtensions)) {
  13338. $hints[] = $this->createExtensionHint($missingExtensions);
  13339. }
  13340. if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
  13341. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  13342. }
  13343. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  13344. $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+.";
  13345. }
  13346. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  13347. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  13348. $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.";
  13349. }
  13350. }
  13351. if ($hints) {
  13352. $text .= "\n" . implode("\n\n", $hints);
  13353. }
  13354. return $text;
  13355. }
  13356. public function getProblems()
  13357. {
  13358. return $this->problems;
  13359. }
  13360. private function createExtensionHint(array $missingExtensions)
  13361. {
  13362. $paths = IniHelper::getAll();
  13363. if (count($paths) === 1 && empty($paths[0])) {
  13364. return '';
  13365. }
  13366. $ignoreExtensionsArguments = implode(" ", array_map(function ($extension) {
  13367. return "--ignore-platform-req=$extension";
  13368. }, $missingExtensions));
  13369. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  13370. $text .= implode("\n - ", $paths);
  13371. $text .= "\nYou can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.";
  13372. $text .= "\nAlternatively, you can run Composer with `$ignoreExtensionsArguments` to temporarily ignore these required extensions.";
  13373. return $text;
  13374. }
  13375. private function getExtensionProblems(array $reasonSets)
  13376. {
  13377. $missingExtensions = array();
  13378. foreach ($reasonSets as $reasonSet) {
  13379. foreach ($reasonSet as $rule) {
  13380. $required = $rule->getRequiredPackage();
  13381. if (null !== $required && 0 === strpos($required, 'ext-')) {
  13382. $missingExtensions[$required] = 1;
  13383. }
  13384. }
  13385. }
  13386. return array_keys($missingExtensions);
  13387. }
  13388. }
  13389. <?php
  13390. namespace Composer\DependencyResolver;
  13391. use Composer\Package\AliasPackage;
  13392. use Composer\Package\Link;
  13393. use Composer\Package\PackageInterface;
  13394. use Composer\Repository\PlatformRepository;
  13395. use Composer\DependencyResolver\Operation\OperationInterface;
  13396. class Transaction
  13397. {
  13398. protected $operations;
  13399. protected $presentPackages;
  13400. protected $resultPackageMap;
  13401. protected $resultPackagesByName = array();
  13402. public function __construct($presentPackages, $resultPackages)
  13403. {
  13404. $this->presentPackages = $presentPackages;
  13405. $this->setResultPackageMaps($resultPackages);
  13406. $this->operations = $this->calculateOperations();
  13407. }
  13408. public function getOperations()
  13409. {
  13410. return $this->operations;
  13411. }
  13412. private function setResultPackageMaps($resultPackages)
  13413. {
  13414. $packageSort = function (PackageInterface $a, PackageInterface $b) {
  13415. if ($a->getName() == $b->getName()) {
  13416. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  13417. return $a instanceof AliasPackage ? -1 : 1;
  13418. }
  13419. return strcmp($b->getVersion(), $a->getVersion());
  13420. }
  13421. return strcmp($b->getName(), $a->getName());
  13422. };
  13423. $this->resultPackageMap = array();
  13424. foreach ($resultPackages as $package) {
  13425. $this->resultPackageMap[spl_object_hash($package)] = $package;
  13426. foreach ($package->getNames() as $name) {
  13427. $this->resultPackagesByName[$name][] = $package;
  13428. }
  13429. }
  13430. uasort($this->resultPackageMap, $packageSort);
  13431. foreach ($this->resultPackagesByName as $name => $packages) {
  13432. uasort($this->resultPackagesByName[$name], $packageSort);
  13433. }
  13434. }
  13435. protected function calculateOperations()
  13436. {
  13437. $operations = array();
  13438. $presentPackageMap = array();
  13439. $removeMap = array();
  13440. $presentAliasMap = array();
  13441. $removeAliasMap = array();
  13442. foreach ($this->presentPackages as $package) {
  13443. if ($package instanceof AliasPackage) {
  13444. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  13445. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  13446. } else {
  13447. $presentPackageMap[$package->getName()] = $package;
  13448. $removeMap[$package->getName()] = $package;
  13449. }
  13450. }
  13451. $stack = $this->getRootPackages();
  13452. $visited = array();
  13453. $processed = array();
  13454. while (!empty($stack)) {
  13455. $package = array_pop($stack);
  13456. if (isset($processed[spl_object_hash($package)])) {
  13457. continue;
  13458. }
  13459. if (!isset($visited[spl_object_hash($package)])) {
  13460. $visited[spl_object_hash($package)] = true;
  13461. $stack[] = $package;
  13462. if ($package instanceof AliasPackage) {
  13463. $stack[] = $package->getAliasOf();
  13464. } else {
  13465. foreach ($package->getRequires() as $link) {
  13466. $possibleRequires = $this->getProvidersInResult($link);
  13467. foreach ($possibleRequires as $require) {
  13468. $stack[] = $require;
  13469. }
  13470. }
  13471. }
  13472. } elseif (!isset($processed[spl_object_hash($package)])) {
  13473. $processed[spl_object_hash($package)] = true;
  13474. if ($package instanceof AliasPackage) {
  13475. $aliasKey = $package->getName().'::'.$package->getVersion();
  13476. if (isset($presentAliasMap[$aliasKey])) {
  13477. unset($removeAliasMap[$aliasKey]);
  13478. } else {
  13479. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  13480. }
  13481. } else {
  13482. if (isset($presentPackageMap[$package->getName()])) {
  13483. $source = $presentPackageMap[$package->getName()];
  13484. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  13485. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  13486. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  13487. ) {
  13488. $operations[] = new Operation\UpdateOperation($source, $package);
  13489. }
  13490. unset($removeMap[$package->getName()]);
  13491. } else {
  13492. $operations[] = new Operation\InstallOperation($package);
  13493. unset($removeMap[$package->getName()]);
  13494. }
  13495. }
  13496. }
  13497. }
  13498. foreach ($removeMap as $name => $package) {
  13499. array_unshift($operations, new Operation\UninstallOperation($package));
  13500. }
  13501. foreach ($removeAliasMap as $nameVersion => $package) {
  13502. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  13503. }
  13504. $operations = $this->movePluginsToFront($operations);
  13505. $operations = $this->moveUninstallsToFront($operations);
  13506. return $this->operations = $operations;
  13507. }
  13508. protected function getRootPackages()
  13509. {
  13510. $roots = $this->resultPackageMap;
  13511. foreach ($this->resultPackageMap as $packageHash => $package) {
  13512. if (!isset($roots[$packageHash])) {
  13513. continue;
  13514. }
  13515. foreach ($package->getRequires() as $link) {
  13516. $possibleRequires = $this->getProvidersInResult($link);
  13517. foreach ($possibleRequires as $require) {
  13518. if ($require !== $package) {
  13519. unset($roots[spl_object_hash($require)]);
  13520. }
  13521. }
  13522. }
  13523. }
  13524. return $roots;
  13525. }
  13526. protected function getProvidersInResult(Link $link)
  13527. {
  13528. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  13529. return array();
  13530. }
  13531. return $this->resultPackagesByName[$link->getTarget()];
  13532. }
  13533. private function movePluginsToFront(array $operations)
  13534. {
  13535. $dlModifyingPluginsNoDeps = array();
  13536. $dlModifyingPluginsWithDeps = array();
  13537. $dlModifyingPluginRequires = array();
  13538. $pluginsNoDeps = array();
  13539. $pluginsWithDeps = array();
  13540. $pluginRequires = array();
  13541. foreach (array_reverse($operations, true) as $idx => $op) {
  13542. if ($op instanceof Operation\InstallOperation) {
  13543. $package = $op->getPackage();
  13544. } elseif ($op instanceof Operation\UpdateOperation) {
  13545. $package = $op->getTargetPackage();
  13546. } else {
  13547. continue;
  13548. }
  13549. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  13550. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  13551. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  13552. return !PlatformRepository::isPlatformPackage($req);
  13553. });
  13554. if ($isDownloadsModifyingPlugin && !count($requires)) {
  13555. array_unshift($dlModifyingPluginsNoDeps, $op);
  13556. } else {
  13557. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  13558. array_unshift($dlModifyingPluginsWithDeps, $op);
  13559. }
  13560. unset($operations[$idx]);
  13561. continue;
  13562. }
  13563. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  13564. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  13565. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  13566. return !PlatformRepository::isPlatformPackage($req);
  13567. });
  13568. if ($isPlugin && !count($requires)) {
  13569. array_unshift($pluginsNoDeps, $op);
  13570. } else {
  13571. $pluginRequires = array_merge($pluginRequires, $requires);
  13572. array_unshift($pluginsWithDeps, $op);
  13573. }
  13574. unset($operations[$idx]);
  13575. }
  13576. }
  13577. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  13578. }
  13579. private function moveUninstallsToFront(array $operations)
  13580. {
  13581. $uninstOps = array();
  13582. foreach ($operations as $idx => $op) {
  13583. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  13584. $uninstOps[] = $op;
  13585. unset($operations[$idx]);
  13586. }
  13587. }
  13588. return array_merge($uninstOps, $operations);
  13589. }
  13590. }
  13591. <?php
  13592. namespace Composer\Downloader;
  13593. use Composer\Package\PackageInterface;
  13594. use Symfony\Component\Finder\Finder;
  13595. use React\Promise\PromiseInterface;
  13596. use Composer\DependencyResolver\Operation\InstallOperation;
  13597. abstract class ArchiveDownloader extends FileDownloader
  13598. {
  13599. public $cleanupExecuted = array();
  13600. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13601. {
  13602. unset($this->cleanupExecuted[$package->getName()]);
  13603. return parent::prepare($type, $package, $path, $prevPackage);
  13604. }
  13605. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13606. {
  13607. $this->cleanupExecuted[$package->getName()] = true;
  13608. return parent::cleanup($type, $package, $path, $prevPackage);
  13609. }
  13610. public function install(PackageInterface $package, $path, $output = true)
  13611. {
  13612. if ($output) {
  13613. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  13614. }
  13615. $vendorDir = $this->config->get('vendor-dir');
  13616. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  13617. $this->filesystem->emptyDirectory($path);
  13618. }
  13619. do {
  13620. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  13621. } while (is_dir($temporaryDir));
  13622. $this->addCleanupPath($package, $temporaryDir);
  13623. if (!is_dir($path) || realpath($path) !== getcwd()) {
  13624. $this->addCleanupPath($package, $path);
  13625. }
  13626. $this->filesystem->ensureDirectoryExists($temporaryDir);
  13627. $fileName = $this->getFileName($package, $path);
  13628. $filesystem = $this->filesystem;
  13629. $self = $this;
  13630. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package, $self) {
  13631. $self->clearLastCacheWrite($package);
  13632. $filesystem->removeDirectory($temporaryDir);
  13633. if (is_dir($path) && realpath($path) !== getcwd()) {
  13634. $filesystem->removeDirectory($path);
  13635. }
  13636. $self->removeCleanupPath($package, $temporaryDir);
  13637. $self->removeCleanupPath($package, realpath($path));
  13638. };
  13639. $promise = null;
  13640. try {
  13641. $promise = $this->extract($package, $fileName, $temporaryDir);
  13642. } catch (\Exception $e) {
  13643. $cleanup();
  13644. throw $e;
  13645. }
  13646. if (!$promise instanceof PromiseInterface) {
  13647. $promise = \React\Promise\resolve();
  13648. }
  13649. return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) {
  13650. $filesystem->unlink($fileName);
  13651. $getFolderContent = function ($dir) {
  13652. $finder = Finder::create()
  13653. ->ignoreVCS(false)
  13654. ->ignoreDotFiles(false)
  13655. ->notName('.DS_Store')
  13656. ->depth(0)
  13657. ->in($dir);
  13658. return iterator_to_array($finder);
  13659. };
  13660. $renameRecursively = null;
  13661. $renameRecursively = function ($from, $to) use ($filesystem, $getFolderContent, $package, &$renameRecursively) {
  13662. $contentDir = $getFolderContent($from);
  13663. foreach ($contentDir as $file) {
  13664. $file = (string) $file;
  13665. if (is_dir($to . '/' . basename($file))) {
  13666. if (!is_dir($file)) {
  13667. throw new \RuntimeException('Installing '.$package.' would lead to overwriting the '.$to.'/'.basename($file).' directory with a file from the package, invalid operation.');
  13668. }
  13669. $renameRecursively($file, $to . '/' . basename($file));
  13670. } else {
  13671. $filesystem->rename($file, $to . '/' . basename($file));
  13672. }
  13673. }
  13674. };
  13675. $renameAsOne = false;
  13676. if (!file_exists($path)) {
  13677. $renameAsOne = true;
  13678. } elseif ($filesystem->isDirEmpty($path)) {
  13679. try {
  13680. if ($filesystem->removeDirectoryPhp($path)) {
  13681. $renameAsOne = true;
  13682. }
  13683. } catch (\RuntimeException $e) {
  13684. }
  13685. }
  13686. $contentDir = $getFolderContent($temporaryDir);
  13687. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));
  13688. if ($renameAsOne) {
  13689. if ($singleDirAtTopLevel) {
  13690. $extractedDir = (string) reset($contentDir);
  13691. } else {
  13692. $extractedDir = $temporaryDir;
  13693. }
  13694. $filesystem->rename($extractedDir, $path);
  13695. } else {
  13696. $from = $temporaryDir;
  13697. if ($singleDirAtTopLevel) {
  13698. $from = (string) reset($contentDir);
  13699. }
  13700. $renameRecursively($from, $path);
  13701. }
  13702. $promise = $filesystem->removeDirectoryAsync($temporaryDir);
  13703. return $promise->then(function () use ($self, $package, $path, $temporaryDir) {
  13704. $self->removeCleanupPath($package, $temporaryDir);
  13705. $self->removeCleanupPath($package, $path);
  13706. });
  13707. }, function ($e) use ($cleanup) {
  13708. $cleanup();
  13709. throw $e;
  13710. });
  13711. }
  13712. protected function getInstallOperationAppendix(PackageInterface $package, $path)
  13713. {
  13714. return ': Extracting archive';
  13715. }
  13716. abstract protected function extract(PackageInterface $package, $file, $path);
  13717. }
  13718. <?php
  13719. namespace Composer\Downloader;
  13720. use Composer\Package\PackageInterface;
  13721. interface ChangeReportInterface
  13722. {
  13723. public function getLocalChanges(PackageInterface $package, $path);
  13724. }
  13725. <?php
  13726. namespace Composer\Downloader;
  13727. use Composer\Package\PackageInterface;
  13728. use Composer\IO\IOInterface;
  13729. use Composer\Pcre\Preg;
  13730. use Composer\Util\Filesystem;
  13731. use Composer\Exception\IrrecoverableDownloadException;
  13732. use React\Promise\PromiseInterface;
  13733. class DownloadManager
  13734. {
  13735. private $io;
  13736. private $preferDist = false;
  13737. private $preferSource;
  13738. private $packagePreferences = array();
  13739. private $filesystem;
  13740. private $downloaders = array();
  13741. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  13742. {
  13743. $this->io = $io;
  13744. $this->preferSource = $preferSource;
  13745. $this->filesystem = $filesystem ?: new Filesystem();
  13746. }
  13747. public function setPreferSource($preferSource)
  13748. {
  13749. $this->preferSource = $preferSource;
  13750. return $this;
  13751. }
  13752. public function setPreferDist($preferDist)
  13753. {
  13754. $this->preferDist = $preferDist;
  13755. return $this;
  13756. }
  13757. public function setPreferences(array $preferences)
  13758. {
  13759. $this->packagePreferences = $preferences;
  13760. return $this;
  13761. }
  13762. public function setDownloader($type, DownloaderInterface $downloader)
  13763. {
  13764. $type = strtolower($type);
  13765. $this->downloaders[$type] = $downloader;
  13766. return $this;
  13767. }
  13768. public function getDownloader($type)
  13769. {
  13770. $type = strtolower($type);
  13771. if (!isset($this->downloaders[$type])) {
  13772. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  13773. }
  13774. return $this->downloaders[$type];
  13775. }
  13776. public function getDownloaderForPackage(PackageInterface $package)
  13777. {
  13778. $installationSource = $package->getInstallationSource();
  13779. if ('metapackage' === $package->getType()) {
  13780. return null;
  13781. }
  13782. if ('dist' === $installationSource) {
  13783. $downloader = $this->getDownloader($package->getDistType());
  13784. } elseif ('source' === $installationSource) {
  13785. $downloader = $this->getDownloader($package->getSourceType());
  13786. } else {
  13787. throw new \InvalidArgumentException(
  13788. 'Package '.$package.' does not have an installation source set'
  13789. );
  13790. }
  13791. if ($installationSource !== $downloader->getInstallationSource()) {
  13792. throw new \LogicException(sprintf(
  13793. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  13794. get_class($downloader),
  13795. $downloader->getInstallationSource(),
  13796. $installationSource,
  13797. $package
  13798. ));
  13799. }
  13800. return $downloader;
  13801. }
  13802. public function getDownloaderType(DownloaderInterface $downloader)
  13803. {
  13804. return array_search($downloader, $this->downloaders);
  13805. }
  13806. public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  13807. {
  13808. $targetDir = $this->normalizeTargetDir($targetDir);
  13809. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  13810. $sources = $this->getAvailableSources($package, $prevPackage);
  13811. $io = $this->io;
  13812. $self = $this;
  13813. $download = function ($retry = false) use (&$sources, $io, $package, $self, $targetDir, &$download, $prevPackage) {
  13814. $source = array_shift($sources);
  13815. if ($retry) {
  13816. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  13817. }
  13818. $package->setInstallationSource($source);
  13819. $downloader = $self->getDownloaderForPackage($package);
  13820. if (!$downloader) {
  13821. return \React\Promise\resolve();
  13822. }
  13823. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  13824. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  13825. if (!$sources) {
  13826. throw $e;
  13827. }
  13828. $io->writeError(
  13829. ' <warning>Failed to download '.
  13830. $package->getPrettyName().
  13831. ' from ' . $source . ': '.
  13832. $e->getMessage().'</warning>'
  13833. );
  13834. return $download(true);
  13835. }
  13836. throw $e;
  13837. };
  13838. try {
  13839. $result = $downloader->download($package, $targetDir, $prevPackage);
  13840. } catch (\Exception $e) {
  13841. return $handleError($e);
  13842. }
  13843. if (!$result instanceof PromiseInterface) {
  13844. return \React\Promise\resolve($result);
  13845. }
  13846. $res = $result->then(function ($res) {
  13847. return $res;
  13848. }, $handleError);
  13849. return $res;
  13850. };
  13851. return $download();
  13852. }
  13853. public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  13854. {
  13855. $targetDir = $this->normalizeTargetDir($targetDir);
  13856. $downloader = $this->getDownloaderForPackage($package);
  13857. if ($downloader) {
  13858. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  13859. }
  13860. return \React\Promise\resolve();
  13861. }
  13862. public function install(PackageInterface $package, $targetDir)
  13863. {
  13864. $targetDir = $this->normalizeTargetDir($targetDir);
  13865. $downloader = $this->getDownloaderForPackage($package);
  13866. if ($downloader) {
  13867. return $downloader->install($package, $targetDir);
  13868. }
  13869. return \React\Promise\resolve();
  13870. }
  13871. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  13872. {
  13873. $targetDir = $this->normalizeTargetDir($targetDir);
  13874. $downloader = $this->getDownloaderForPackage($target);
  13875. $initialDownloader = $this->getDownloaderForPackage($initial);
  13876. if (!$initialDownloader && !$downloader) {
  13877. return \React\Promise\resolve();
  13878. }
  13879. if (!$downloader) {
  13880. return $initialDownloader->remove($initial, $targetDir);
  13881. }
  13882. $initialType = $this->getDownloaderType($initialDownloader);
  13883. $targetType = $this->getDownloaderType($downloader);
  13884. if ($initialType === $targetType) {
  13885. try {
  13886. return $downloader->update($initial, $target, $targetDir);
  13887. } catch (\RuntimeException $e) {
  13888. if (!$this->io->isInteractive()) {
  13889. throw $e;
  13890. }
  13891. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  13892. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  13893. throw $e;
  13894. }
  13895. }
  13896. }
  13897. $promise = $initialDownloader->remove($initial, $targetDir);
  13898. if ($promise) {
  13899. $self = $this;
  13900. return $promise->then(function ($res) use ($self, $target, $targetDir) {
  13901. return $self->install($target, $targetDir);
  13902. });
  13903. }
  13904. return $this->install($target, $targetDir);
  13905. }
  13906. public function remove(PackageInterface $package, $targetDir)
  13907. {
  13908. $targetDir = $this->normalizeTargetDir($targetDir);
  13909. $downloader = $this->getDownloaderForPackage($package);
  13910. if ($downloader) {
  13911. return $downloader->remove($package, $targetDir);
  13912. }
  13913. return \React\Promise\resolve();
  13914. }
  13915. public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  13916. {
  13917. $targetDir = $this->normalizeTargetDir($targetDir);
  13918. $downloader = $this->getDownloaderForPackage($package);
  13919. if ($downloader) {
  13920. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  13921. }
  13922. return \React\Promise\resolve();
  13923. }
  13924. protected function resolvePackageInstallPreference(PackageInterface $package)
  13925. {
  13926. foreach ($this->packagePreferences as $pattern => $preference) {
  13927. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  13928. if (Preg::isMatch($pattern, $package->getName())) {
  13929. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  13930. return 'dist';
  13931. }
  13932. return 'source';
  13933. }
  13934. }
  13935. return $package->isDev() ? 'source' : 'dist';
  13936. }
  13937. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
  13938. {
  13939. $sourceType = $package->getSourceType();
  13940. $distType = $package->getDistType();
  13941. $sources = array();
  13942. if ($sourceType) {
  13943. $sources[] = 'source';
  13944. }
  13945. if ($distType) {
  13946. $sources[] = 'dist';
  13947. }
  13948. if (empty($sources)) {
  13949. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  13950. }
  13951. if (
  13952. $prevPackage
  13953. && in_array($prevPackage->getInstallationSource(), $sources, true)
  13954. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  13955. ) {
  13956. $prevSource = $prevPackage->getInstallationSource();
  13957. usort($sources, function ($a, $b) use ($prevSource) {
  13958. return $a === $prevSource ? -1 : 1;
  13959. });
  13960. return $sources;
  13961. }
  13962. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  13963. $sources = array_reverse($sources);
  13964. }
  13965. return $sources;
  13966. }
  13967. private function normalizeTargetDir($dir)
  13968. {
  13969. if ($dir === '\\' || $dir === '/') {
  13970. return $dir;
  13971. }
  13972. return rtrim($dir, '\\/');
  13973. }
  13974. }
  13975. <?php
  13976. namespace Composer\Downloader;
  13977. use Composer\Package\PackageInterface;
  13978. use React\Promise\PromiseInterface;
  13979. interface DownloaderInterface
  13980. {
  13981. public function getInstallationSource();
  13982. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
  13983. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  13984. public function install(PackageInterface $package, $path);
  13985. public function update(PackageInterface $initial, PackageInterface $target, $path);
  13986. public function remove(PackageInterface $package, $path);
  13987. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  13988. }
  13989. <?php
  13990. namespace Composer\Downloader;
  13991. use Composer\Package\PackageInterface;
  13992. interface DvcsDownloaderInterface
  13993. {
  13994. public function getUnpushedChanges(PackageInterface $package, $path);
  13995. }
  13996. <?php
  13997. namespace Composer\Downloader;
  13998. use Composer\Config;
  13999. use Composer\Cache;
  14000. use Composer\IO\IOInterface;
  14001. use Composer\IO\NullIO;
  14002. use Composer\Exception\IrrecoverableDownloadException;
  14003. use Composer\Package\Comparer\Comparer;
  14004. use Composer\DependencyResolver\Operation\UpdateOperation;
  14005. use Composer\DependencyResolver\Operation\InstallOperation;
  14006. use Composer\DependencyResolver\Operation\UninstallOperation;
  14007. use Composer\Package\PackageInterface;
  14008. use Composer\Plugin\PluginEvents;
  14009. use Composer\Plugin\PostFileDownloadEvent;
  14010. use Composer\Plugin\PreFileDownloadEvent;
  14011. use Composer\EventDispatcher\EventDispatcher;
  14012. use Composer\Util\Filesystem;
  14013. use Composer\Util\Silencer;
  14014. use Composer\Util\HttpDownloader;
  14015. use Composer\Util\Url as UrlUtil;
  14016. use Composer\Util\ProcessExecutor;
  14017. use React\Promise\PromiseInterface;
  14018. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  14019. {
  14020. protected $io;
  14021. protected $config;
  14022. protected $httpDownloader;
  14023. protected $filesystem;
  14024. protected $cache;
  14025. protected $eventDispatcher;
  14026. protected $process;
  14027. public static $downloadMetadata = array();
  14028. public $lastCacheWrites = array();
  14029. private $additionalCleanupPaths = array();
  14030. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  14031. {
  14032. $this->io = $io;
  14033. $this->config = $config;
  14034. $this->eventDispatcher = $eventDispatcher;
  14035. $this->httpDownloader = $httpDownloader;
  14036. $this->cache = $cache;
  14037. $this->process = $process ?: new ProcessExecutor($io);
  14038. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  14039. if ($this->cache && $this->cache->gcIsNecessary()) {
  14040. $this->io->writeError('Running cache garbage collection', true, IOInterface::VERY_VERBOSE);
  14041. $this->cache->gc((int) $config->get('cache-files-ttl'), (int) $config->get('cache-files-maxsize'));
  14042. }
  14043. }
  14044. public function getInstallationSource()
  14045. {
  14046. return 'dist';
  14047. }
  14048. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  14049. {
  14050. if (!$package->getDistUrl()) {
  14051. throw new \InvalidArgumentException('The given package is missing url information');
  14052. }
  14053. $cacheKeyGenerator = function (PackageInterface $package, $key) {
  14054. $cacheKey = sha1($key);
  14055. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  14056. };
  14057. $retries = 3;
  14058. $distUrls = $package->getDistUrls();
  14059. $urls = array();
  14060. foreach ($distUrls as $index => $url) {
  14061. $processedUrl = $this->processUrl($package, $url);
  14062. $urls[$index] = array(
  14063. 'base' => $url,
  14064. 'processed' => $processedUrl,
  14065. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  14066. );
  14067. }
  14068. $fileName = $this->getFileName($package, $path);
  14069. $this->filesystem->ensureDirectoryExists($path);
  14070. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  14071. $io = $this->io;
  14072. $cache = $this->cache;
  14073. $httpDownloader = $this->httpDownloader;
  14074. $eventDispatcher = $this->eventDispatcher;
  14075. $filesystem = $this->filesystem;
  14076. $self = $this;
  14077. $accept = null;
  14078. $reject = null;
  14079. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject, $self) {
  14080. $url = reset($urls);
  14081. $index = key($urls);
  14082. if ($eventDispatcher) {
  14083. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  14084. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  14085. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  14086. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  14087. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  14088. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  14089. }
  14090. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  14091. }
  14092. $urls[$index] = $url;
  14093. $checksum = $package->getDistSha1Checksum();
  14094. $cacheKey = $url['cacheKey'];
  14095. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  14096. if ($output) {
  14097. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  14098. }
  14099. if (!$cache->isReadOnly()) {
  14100. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  14101. }
  14102. $result = \React\Promise\resolve($fileName);
  14103. } else {
  14104. if ($output) {
  14105. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  14106. }
  14107. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  14108. ->then($accept, $reject);
  14109. }
  14110. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher) {
  14111. if (null === $result) {
  14112. return $fileName;
  14113. }
  14114. if (!file_exists($fileName)) {
  14115. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  14116. .' directory is writable and you have internet connectivity');
  14117. }
  14118. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  14119. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  14120. }
  14121. if ($eventDispatcher) {
  14122. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], 'package', $package);
  14123. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  14124. }
  14125. return $fileName;
  14126. });
  14127. };
  14128. $accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
  14129. $url = reset($urls);
  14130. $cacheKey = $url['cacheKey'];
  14131. FileDownloader::$downloadMetadata[$package->getName()] = @filesize($fileName) ?: $response->getHeader('Content-Length') ?: '?';
  14132. if ($cache && !$cache->isReadOnly()) {
  14133. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  14134. $cache->copyFrom($cacheKey, $fileName);
  14135. }
  14136. $response->collect();
  14137. return $fileName;
  14138. };
  14139. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem, $self) {
  14140. if (file_exists($fileName)) {
  14141. $filesystem->unlink($fileName);
  14142. }
  14143. $self->clearLastCacheWrite($package);
  14144. if ($e instanceof IrrecoverableDownloadException) {
  14145. throw $e;
  14146. }
  14147. if ($e instanceof MaxFileSizeExceededException) {
  14148. throw $e;
  14149. }
  14150. if ($e instanceof TransportException) {
  14151. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  14152. $retries = 0;
  14153. }
  14154. }
  14155. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  14156. $retries = 0;
  14157. $urls = array();
  14158. }
  14159. if ($retries) {
  14160. usleep(500000);
  14161. $retries--;
  14162. return $download();
  14163. }
  14164. array_shift($urls);
  14165. if ($urls) {
  14166. if ($io->isDebug()) {
  14167. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  14168. $io->writeError(' Trying the next URL for '.$package->getName());
  14169. } else {
  14170. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  14171. }
  14172. $retries = 3;
  14173. usleep(100000);
  14174. return $download();
  14175. }
  14176. throw $e;
  14177. };
  14178. return $download();
  14179. }
  14180. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  14181. {
  14182. return \React\Promise\resolve();
  14183. }
  14184. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  14185. {
  14186. $fileName = $this->getFileName($package, $path);
  14187. if (file_exists($fileName)) {
  14188. $this->filesystem->unlink($fileName);
  14189. }
  14190. $dirsToCleanUp = array(
  14191. $this->config->get('vendor-dir').'/composer/',
  14192. $this->config->get('vendor-dir'),
  14193. $path,
  14194. );
  14195. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  14196. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  14197. $this->filesystem->remove($path);
  14198. }
  14199. }
  14200. foreach ($dirsToCleanUp as $dir) {
  14201. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
  14202. $this->filesystem->removeDirectoryPhp($dir);
  14203. }
  14204. }
  14205. return \React\Promise\resolve();
  14206. }
  14207. public function install(PackageInterface $package, $path, $output = true)
  14208. {
  14209. if ($output) {
  14210. $this->io->writeError(" - " . InstallOperation::format($package));
  14211. }
  14212. $this->filesystem->emptyDirectory($path);
  14213. $this->filesystem->ensureDirectoryExists($path);
  14214. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
  14215. if ($package->getBinaries()) {
  14216. foreach ($package->getBinaries() as $bin) {
  14217. if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
  14218. Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
  14219. }
  14220. }
  14221. }
  14222. return \React\Promise\resolve();
  14223. }
  14224. public function clearLastCacheWrite(PackageInterface $package)
  14225. {
  14226. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  14227. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  14228. unset($this->lastCacheWrites[$package->getName()]);
  14229. }
  14230. }
  14231. public function addCleanupPath(PackageInterface $package, $path)
  14232. {
  14233. $this->additionalCleanupPaths[$package->getName()][] = $path;
  14234. }
  14235. public function removeCleanupPath(PackageInterface $package, $path)
  14236. {
  14237. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  14238. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  14239. if (false !== $idx) {
  14240. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  14241. }
  14242. }
  14243. }
  14244. public function update(PackageInterface $initial, PackageInterface $target, $path)
  14245. {
  14246. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . $this->getInstallOperationAppendix($target, $path));
  14247. $promise = $this->remove($initial, $path, false);
  14248. if (!$promise instanceof PromiseInterface) {
  14249. $promise = \React\Promise\resolve();
  14250. }
  14251. $self = $this;
  14252. $io = $this->io;
  14253. return $promise->then(function () use ($self, $target, $path) {
  14254. $promise = $self->install($target, $path, false);
  14255. return $promise;
  14256. });
  14257. }
  14258. public function remove(PackageInterface $package, $path, $output = true)
  14259. {
  14260. if ($output) {
  14261. $this->io->writeError(" - " . UninstallOperation::format($package));
  14262. }
  14263. $promise = $this->filesystem->removeDirectoryAsync($path);
  14264. return $promise->then(function ($result) use ($path) {
  14265. if (!$result) {
  14266. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  14267. }
  14268. });
  14269. }
  14270. protected function getFileName(PackageInterface $package, $path)
  14271. {
  14272. 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), '.');
  14273. }
  14274. protected function getInstallOperationAppendix(PackageInterface $package, $path)
  14275. {
  14276. return '';
  14277. }
  14278. protected function processUrl(PackageInterface $package, $url)
  14279. {
  14280. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  14281. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  14282. }
  14283. if ($package->getDistReference()) {
  14284. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  14285. }
  14286. return $url;
  14287. }
  14288. public function getLocalChanges(PackageInterface $package, $targetDir)
  14289. {
  14290. $prevIO = $this->io;
  14291. $this->io = new NullIO;
  14292. $this->io->loadConfiguration($this->config);
  14293. $e = null;
  14294. $output = '';
  14295. $targetDir = Filesystem::trimTrailingSlash($targetDir);
  14296. try {
  14297. if (is_dir($targetDir.'_compare')) {
  14298. $this->filesystem->removeDirectory($targetDir.'_compare');
  14299. }
  14300. $this->download($package, $targetDir.'_compare', null, false);
  14301. $this->httpDownloader->wait();
  14302. $this->install($package, $targetDir.'_compare', false);
  14303. $this->process->wait();
  14304. $comparer = new Comparer();
  14305. $comparer->setSource($targetDir.'_compare');
  14306. $comparer->setUpdate($targetDir);
  14307. $comparer->doCompare();
  14308. $output = $comparer->getChanged(true, true);
  14309. $this->filesystem->removeDirectory($targetDir.'_compare');
  14310. } catch (\Exception $e) {
  14311. }
  14312. $this->io = $prevIO;
  14313. if ($e) {
  14314. throw $e;
  14315. }
  14316. return trim($output);
  14317. }
  14318. }
  14319. <?php
  14320. namespace Composer\Downloader;
  14321. class FilesystemException extends \Exception
  14322. {
  14323. public function __construct($message = '', $code = 0, \Exception $previous = null)
  14324. {
  14325. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  14326. }
  14327. }
  14328. <?php
  14329. namespace Composer\Downloader;
  14330. use Composer\Package\PackageInterface;
  14331. use Composer\Pcre\Preg;
  14332. use Composer\Util\ProcessExecutor;
  14333. class FossilDownloader extends VcsDownloader
  14334. {
  14335. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  14336. {
  14337. return \React\Promise\resolve();
  14338. }
  14339. protected function doInstall(PackageInterface $package, $path, $url)
  14340. {
  14341. $this->config->prohibitUrlByConfig($url, $this->io);
  14342. $url = ProcessExecutor::escape($url);
  14343. $ref = ProcessExecutor::escape($package->getSourceReference());
  14344. $repoFile = $path . '.fossil';
  14345. $this->io->writeError("Cloning ".$package->getSourceReference());
  14346. $command = sprintf('fossil clone -- %s %s', $url, ProcessExecutor::escape($repoFile));
  14347. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  14348. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14349. }
  14350. $command = sprintf('fossil open --nested -- %s', ProcessExecutor::escape($repoFile));
  14351. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14352. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14353. }
  14354. $command = sprintf('fossil update -- %s', $ref);
  14355. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14356. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14357. }
  14358. return \React\Promise\resolve();
  14359. }
  14360. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  14361. {
  14362. $this->config->prohibitUrlByConfig($url, $this->io);
  14363. $ref = ProcessExecutor::escape($target->getSourceReference());
  14364. $this->io->writeError(" Updating to ".$target->getSourceReference());
  14365. if (!$this->hasMetadataRepository($path)) {
  14366. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  14367. }
  14368. $command = sprintf('fossil pull && fossil up %s', $ref);
  14369. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14370. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14371. }
  14372. return \React\Promise\resolve();
  14373. }
  14374. public function getLocalChanges(PackageInterface $package, $path)
  14375. {
  14376. if (!$this->hasMetadataRepository($path)) {
  14377. return null;
  14378. }
  14379. $this->process->execute('fossil changes', $output, realpath($path));
  14380. return trim($output) ?: null;
  14381. }
  14382. protected function getCommitLogs($fromReference, $toReference, $path)
  14383. {
  14384. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  14385. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  14386. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14387. }
  14388. $log = '';
  14389. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  14390. foreach ($this->process->splitLines($output) as $line) {
  14391. if (Preg::isMatch($match, $line)) {
  14392. break;
  14393. }
  14394. $log .= $line;
  14395. }
  14396. return $log;
  14397. }
  14398. protected function hasMetadataRepository($path)
  14399. {
  14400. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  14401. }
  14402. }
  14403. <?php
  14404. namespace Composer\Downloader;
  14405. use Composer\Config;
  14406. use Composer\IO\IOInterface;
  14407. use Composer\Package\PackageInterface;
  14408. use Composer\Pcre\Preg;
  14409. use Composer\Util\Filesystem;
  14410. use Composer\Util\Git as GitUtil;
  14411. use Composer\Util\Url;
  14412. use Composer\Util\Platform;
  14413. use Composer\Util\ProcessExecutor;
  14414. use Composer\Cache;
  14415. use React\Promise\PromiseInterface;
  14416. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  14417. {
  14418. private $hasStashedChanges = array();
  14419. private $hasDiscardedChanges = array();
  14420. private $gitUtil;
  14421. private $cachedPackages = array();
  14422. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  14423. {
  14424. parent::__construct($io, $config, $process, $fs);
  14425. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  14426. }
  14427. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  14428. {
  14429. GitUtil::cleanEnv();
  14430. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  14431. $gitVersion = GitUtil::getVersion($this->process);
  14432. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  14433. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  14434. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  14435. $ref = $package->getSourceReference();
  14436. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  14437. $this->cachedPackages[$package->getId()][$ref] = true;
  14438. }
  14439. } elseif (null === $gitVersion) {
  14440. throw new \RuntimeException('git was not found in your PATH, skipping source download');
  14441. }
  14442. return \React\Promise\resolve();
  14443. }
  14444. protected function doInstall(PackageInterface $package, $path, $url)
  14445. {
  14446. GitUtil::cleanEnv();
  14447. $path = $this->normalizePath($path);
  14448. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  14449. $ref = $package->getSourceReference();
  14450. $flag = Platform::isWindows() ? '/D ' : '';
  14451. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  14452. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  14453. $cloneFlags = '--dissociate --reference %cachePath% ';
  14454. $transportOptions = $package->getTransportOptions();
  14455. if (isset($transportOptions['git']['single_use_clone']) && $transportOptions['git']['single_use_clone']) {
  14456. $cloneFlags = '';
  14457. }
  14458. $command =
  14459. 'git clone --no-checkout %cachePath% %path% ' . $cloneFlags
  14460. . '&& cd '.$flag.'%path% '
  14461. . '&& git remote set-url origin -- %sanitizedUrl% && git remote add composer -- %sanitizedUrl%';
  14462. } else {
  14463. $msg = "Cloning ".$this->getShortHash($ref);
  14464. $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%';
  14465. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  14466. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  14467. }
  14468. }
  14469. $this->io->writeError($msg);
  14470. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  14471. return str_replace(
  14472. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  14473. array(
  14474. ProcessExecutor::escape($url),
  14475. ProcessExecutor::escape($path),
  14476. ProcessExecutor::escape($cachePath),
  14477. ProcessExecutor::escape(Preg::replace('{://([^@]+?):(.+?)@}', '://', $url)),
  14478. ),
  14479. $command
  14480. );
  14481. };
  14482. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  14483. $sourceUrl = $package->getSourceUrl();
  14484. if ($url !== $sourceUrl && $sourceUrl !== null) {
  14485. $this->updateOriginUrl($path, $sourceUrl);
  14486. } else {
  14487. $this->setPushUrl($path, $url);
  14488. }
  14489. if ($newRef = $this->updateToCommit($package, $path, (string) $ref, $package->getPrettyVersion())) {
  14490. if ($package->getDistReference() === $package->getSourceReference()) {
  14491. $package->setDistReference($newRef);
  14492. }
  14493. $package->setSourceReference($newRef);
  14494. }
  14495. return \React\Promise\resolve();
  14496. }
  14497. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  14498. {
  14499. GitUtil::cleanEnv();
  14500. $path = $this->normalizePath($path);
  14501. if (!$this->hasMetadataRepository($path)) {
  14502. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  14503. }
  14504. $cachePath = $this->config->get('cache-vcs-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', $url).'/';
  14505. $ref = $target->getSourceReference();
  14506. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  14507. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  14508. $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%';
  14509. } else {
  14510. $msg = "Checking out ".$this->getShortHash($ref);
  14511. $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%';
  14512. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
  14513. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  14514. }
  14515. }
  14516. $this->io->writeError($msg);
  14517. $commandCallable = function ($url) use ($ref, $command, $cachePath) {
  14518. return str_replace(
  14519. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  14520. array(
  14521. ProcessExecutor::escape($url),
  14522. ProcessExecutor::escape($ref.'^{commit}'),
  14523. ProcessExecutor::escape($cachePath),
  14524. ProcessExecutor::escape(Preg::replace('{://([^@]+?):(.+?)@}', '://', $url)),
  14525. ),
  14526. $command
  14527. );
  14528. };
  14529. $this->gitUtil->runCommand($commandCallable, $url, $path);
  14530. if ($newRef = $this->updateToCommit($target, $path, (string) $ref, $target->getPrettyVersion())) {
  14531. if ($target->getDistReference() === $target->getSourceReference()) {
  14532. $target->setDistReference($newRef);
  14533. }
  14534. $target->setSourceReference($newRef);
  14535. }
  14536. $updateOriginUrl = false;
  14537. if (
  14538. 0 === $this->process->execute('git remote -v', $output, $path)
  14539. && Preg::isMatch('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  14540. && Preg::isMatch('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  14541. ) {
  14542. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  14543. $updateOriginUrl = true;
  14544. }
  14545. }
  14546. if ($updateOriginUrl && $target->getSourceUrl() !== null) {
  14547. $this->updateOriginUrl($path, $target->getSourceUrl());
  14548. }
  14549. return \React\Promise\resolve();
  14550. }
  14551. public function getLocalChanges(PackageInterface $package, $path)
  14552. {
  14553. GitUtil::cleanEnv();
  14554. if (!$this->hasMetadataRepository($path)) {
  14555. return null;
  14556. }
  14557. $command = 'git status --porcelain --untracked-files=no';
  14558. if (0 !== $this->process->execute($command, $output, $path)) {
  14559. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14560. }
  14561. return trim($output) ?: null;
  14562. }
  14563. public function getUnpushedChanges(PackageInterface $package, $path)
  14564. {
  14565. GitUtil::cleanEnv();
  14566. $path = $this->normalizePath($path);
  14567. if (!$this->hasMetadataRepository($path)) {
  14568. return null;
  14569. }
  14570. $command = 'git show-ref --head -d';
  14571. if (0 !== $this->process->execute($command, $output, $path)) {
  14572. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14573. }
  14574. $refs = trim($output);
  14575. if (!Preg::isMatch('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  14576. return null;
  14577. }
  14578. $headRef = $match[1];
  14579. if (!Preg::isMatchAll('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  14580. return null;
  14581. }
  14582. $candidateBranches = $matches[1];
  14583. $branch = $candidateBranches[0];
  14584. $unpushedChanges = null;
  14585. $branchNotFoundError = false;
  14586. for ($i = 0; $i <= 1; $i++) {
  14587. $remoteBranches = array();
  14588. foreach ($candidateBranches as $candidate) {
  14589. if (Preg::isMatchAll('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  14590. foreach ($matches[1] as $match) {
  14591. $branch = $candidate;
  14592. $remoteBranches[] = $match;
  14593. }
  14594. break;
  14595. }
  14596. }
  14597. if (!$remoteBranches) {
  14598. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  14599. $branchNotFoundError = true;
  14600. } else {
  14601. if ($branchNotFoundError) {
  14602. $unpushedChanges = null;
  14603. }
  14604. foreach ($remoteBranches as $remoteBranch) {
  14605. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  14606. if (0 !== $this->process->execute($command, $output, $path)) {
  14607. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14608. }
  14609. $output = trim($output);
  14610. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  14611. $unpushedChanges = $output;
  14612. }
  14613. }
  14614. }
  14615. if ($unpushedChanges && $i === 0) {
  14616. $this->process->execute('git fetch --all', $output, $path);
  14617. $command = 'git show-ref --head -d';
  14618. if (0 !== $this->process->execute($command, $output, $path)) {
  14619. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14620. }
  14621. $refs = trim($output);
  14622. }
  14623. if (!$unpushedChanges) {
  14624. break;
  14625. }
  14626. }
  14627. return $unpushedChanges;
  14628. }
  14629. protected function cleanChanges(PackageInterface $package, $path, $update)
  14630. {
  14631. GitUtil::cleanEnv();
  14632. $path = $this->normalizePath($path);
  14633. $unpushed = $this->getUnpushedChanges($package, $path);
  14634. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  14635. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  14636. }
  14637. if (!$changes = $this->getLocalChanges($package, $path)) {
  14638. return \React\Promise\resolve();
  14639. }
  14640. if (!$this->io->isInteractive()) {
  14641. $discardChanges = $this->config->get('discard-changes');
  14642. if (true === $discardChanges) {
  14643. return $this->discardChanges($path);
  14644. }
  14645. if ('stash' === $discardChanges) {
  14646. if (!$update) {
  14647. return parent::cleanChanges($package, $path, $update);
  14648. }
  14649. return $this->stashChanges($path);
  14650. }
  14651. return parent::cleanChanges($package, $path, $update);
  14652. }
  14653. $changes = array_map(function ($elem) {
  14654. return ' '.$elem;
  14655. }, Preg::split('{\s*\r?\n\s*}', $changes));
  14656. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  14657. $this->io->writeError(array_slice($changes, 0, 10));
  14658. if (count($changes) > 10) {
  14659. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  14660. }
  14661. while (true) {
  14662. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  14663. case 'y':
  14664. $this->discardChanges($path);
  14665. break 2;
  14666. case 's':
  14667. if (!$update) {
  14668. goto help;
  14669. }
  14670. $this->stashChanges($path);
  14671. break 2;
  14672. case 'n':
  14673. throw new \RuntimeException('Update aborted');
  14674. case 'v':
  14675. $this->io->writeError($changes);
  14676. break;
  14677. case 'd':
  14678. $this->viewDiff($path);
  14679. break;
  14680. case '?':
  14681. default:
  14682. help :
  14683. $this->io->writeError(array(
  14684. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  14685. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  14686. ' v - view modified files',
  14687. ' d - view local modifications (diff)',
  14688. ));
  14689. if ($update) {
  14690. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  14691. }
  14692. $this->io->writeError(' ? - print help');
  14693. break;
  14694. }
  14695. }
  14696. return \React\Promise\resolve();
  14697. }
  14698. protected function reapplyChanges($path)
  14699. {
  14700. $path = $this->normalizePath($path);
  14701. if (!empty($this->hasStashedChanges[$path])) {
  14702. unset($this->hasStashedChanges[$path]);
  14703. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  14704. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  14705. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  14706. }
  14707. }
  14708. unset($this->hasDiscardedChanges[$path]);
  14709. }
  14710. protected function updateToCommit(PackageInterface $package, $path, $reference, $prettyVersion)
  14711. {
  14712. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  14713. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  14714. $branch = Preg::replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $prettyVersion);
  14715. $branches = null;
  14716. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  14717. $branches = $output;
  14718. }
  14719. $gitRef = $reference;
  14720. if (!Preg::isMatch('{^[a-f0-9]{40}$}', $reference)
  14721. && $branches
  14722. && Preg::isMatch('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  14723. ) {
  14724. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  14725. if (0 === $this->process->execute($command, $output, $path)) {
  14726. return null;
  14727. }
  14728. }
  14729. if (Preg::isMatch('{^[a-f0-9]{40}$}', $reference)) {
  14730. if (!Preg::isMatch('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && Preg::isMatch('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  14731. $branch = 'v' . $branch;
  14732. }
  14733. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  14734. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  14735. $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  14736. if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
  14737. return null;
  14738. }
  14739. }
  14740. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  14741. if (0 === $this->process->execute($command, $output, $path)) {
  14742. return null;
  14743. }
  14744. $exceptionExtra = '';
  14745. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  14746. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  14747. $exceptionExtra = "\nIt looks like the commit hash is not available in the repository, maybe ".($package->isDev() ? 'the commit was removed from the branch' : 'the tag was recreated').'? Run "composer update '.$package->getPrettyName().'" to resolve this.';
  14748. }
  14749. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput() . $exceptionExtra));
  14750. }
  14751. protected function updateOriginUrl($path, $url)
  14752. {
  14753. $this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
  14754. $this->setPushUrl($path, $url);
  14755. }
  14756. protected function setPushUrl($path, $url)
  14757. {
  14758. if (Preg::isMatch('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  14759. $protocols = $this->config->get('github-protocols');
  14760. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  14761. if (!in_array('ssh', $protocols, true)) {
  14762. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  14763. }
  14764. $cmd = sprintf('git remote set-url --push origin -- %s', ProcessExecutor::escape($pushUrl));
  14765. $this->process->execute($cmd, $ignoredOutput, $path);
  14766. }
  14767. }
  14768. protected function getCommitLogs($fromReference, $toReference, $path)
  14769. {
  14770. $path = $this->normalizePath($path);
  14771. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  14772. if (0 !== $this->process->execute($command, $output, $path)) {
  14773. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14774. }
  14775. return $output;
  14776. }
  14777. protected function discardChanges($path)
  14778. {
  14779. $path = $this->normalizePath($path);
  14780. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  14781. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  14782. }
  14783. $this->hasDiscardedChanges[$path] = true;
  14784. return \React\Promise\resolve();
  14785. }
  14786. protected function stashChanges($path)
  14787. {
  14788. $path = $this->normalizePath($path);
  14789. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  14790. throw new \RuntimeException("Could not stash changes\n\n:".$output);
  14791. }
  14792. $this->hasStashedChanges[$path] = true;
  14793. return \React\Promise\resolve();
  14794. }
  14795. protected function viewDiff($path)
  14796. {
  14797. $path = $this->normalizePath($path);
  14798. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  14799. throw new \RuntimeException("Could not view diff\n\n:".$output);
  14800. }
  14801. $this->io->writeError($output);
  14802. }
  14803. protected function normalizePath($path)
  14804. {
  14805. if (Platform::isWindows() && strlen($path) > 0) {
  14806. $basePath = $path;
  14807. $removed = array();
  14808. while (!is_dir($basePath) && $basePath !== '\\') {
  14809. array_unshift($removed, basename($basePath));
  14810. $basePath = dirname($basePath);
  14811. }
  14812. if ($basePath === '\\') {
  14813. return $path;
  14814. }
  14815. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  14816. }
  14817. return $path;
  14818. }
  14819. protected function hasMetadataRepository($path)
  14820. {
  14821. $path = $this->normalizePath($path);
  14822. return is_dir($path.'/.git');
  14823. }
  14824. protected function getShortHash($reference)
  14825. {
  14826. if (!$this->io->isVerbose() && Preg::isMatch('{^[0-9a-f]{40}$}', $reference)) {
  14827. return substr($reference, 0, 10);
  14828. }
  14829. return $reference;
  14830. }
  14831. }
  14832. <?php
  14833. namespace Composer\Downloader;
  14834. use Composer\Package\PackageInterface;
  14835. use Composer\Util\Platform;
  14836. use Composer\Util\ProcessExecutor;
  14837. class GzipDownloader extends ArchiveDownloader
  14838. {
  14839. protected function extract(PackageInterface $package, $file, $path)
  14840. {
  14841. $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
  14842. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  14843. if (!Platform::isWindows()) {
  14844. $command = 'gzip -cd -- ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  14845. if (0 === $this->process->execute($command, $ignoredOutput)) {
  14846. return \React\Promise\resolve();
  14847. }
  14848. if (extension_loaded('zlib')) {
  14849. $this->extractUsingExt($file, $targetFilepath);
  14850. return \React\Promise\resolve();
  14851. }
  14852. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  14853. throw new \RuntimeException($processError);
  14854. }
  14855. $this->extractUsingExt($file, $targetFilepath);
  14856. return \React\Promise\resolve();
  14857. }
  14858. private function extractUsingExt($file, $targetFilepath)
  14859. {
  14860. $archiveFile = gzopen($file, 'rb');
  14861. $targetFile = fopen($targetFilepath, 'wb');
  14862. while ($string = gzread($archiveFile, 4096)) {
  14863. fwrite($targetFile, $string, Platform::strlen($string));
  14864. }
  14865. gzclose($archiveFile);
  14866. fclose($targetFile);
  14867. }
  14868. }
  14869. <?php
  14870. namespace Composer\Downloader;
  14871. use Composer\Package\PackageInterface;
  14872. use Composer\Util\ProcessExecutor;
  14873. use Composer\Util\Hg as HgUtils;
  14874. class HgDownloader extends VcsDownloader
  14875. {
  14876. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  14877. {
  14878. if (null === HgUtils::getVersion($this->process)) {
  14879. throw new \RuntimeException('hg was not found in your PATH, skipping source download');
  14880. }
  14881. return \React\Promise\resolve();
  14882. }
  14883. protected function doInstall(PackageInterface $package, $path, $url)
  14884. {
  14885. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  14886. $cloneCommand = function ($url) use ($path) {
  14887. return sprintf('hg clone -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  14888. };
  14889. $hgUtils->runCommand($cloneCommand, $url, $path);
  14890. $ref = ProcessExecutor::escape($package->getSourceReference());
  14891. $command = sprintf('hg up -- %s', $ref);
  14892. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  14893. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14894. }
  14895. return \React\Promise\resolve();
  14896. }
  14897. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  14898. {
  14899. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  14900. $ref = $target->getSourceReference();
  14901. $this->io->writeError(" Updating to ".$target->getSourceReference());
  14902. if (!$this->hasMetadataRepository($path)) {
  14903. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  14904. }
  14905. $command = function ($url) use ($ref) {
  14906. return sprintf('hg pull -- %s && hg up -- %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  14907. };
  14908. $hgUtils->runCommand($command, $url, $path);
  14909. return \React\Promise\resolve();
  14910. }
  14911. public function getLocalChanges(PackageInterface $package, $path)
  14912. {
  14913. if (!is_dir($path.'/.hg')) {
  14914. return null;
  14915. }
  14916. $this->process->execute('hg st', $output, realpath($path));
  14917. return trim($output) ?: null;
  14918. }
  14919. protected function getCommitLogs($fromReference, $toReference, $path)
  14920. {
  14921. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  14922. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  14923. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  14924. }
  14925. return $output;
  14926. }
  14927. protected function hasMetadataRepository($path)
  14928. {
  14929. return is_dir($path . '/.hg');
  14930. }
  14931. }
  14932. <?php
  14933. namespace Composer\Downloader;
  14934. class MaxFileSizeExceededException extends TransportException
  14935. {
  14936. }
  14937. <?php
  14938. namespace Composer\Downloader;
  14939. use Composer\Package\Archiver\ArchivableFilesFinder;
  14940. use Composer\Package\Dumper\ArrayDumper;
  14941. use Composer\Package\PackageInterface;
  14942. use Composer\Package\Version\VersionGuesser;
  14943. use Composer\Package\Version\VersionParser;
  14944. use Composer\Util\Platform;
  14945. use Composer\Util\Filesystem;
  14946. use Symfony\Component\Filesystem\Exception\IOException;
  14947. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  14948. use Composer\DependencyResolver\Operation\InstallOperation;
  14949. use Composer\DependencyResolver\Operation\UninstallOperation;
  14950. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  14951. {
  14952. const STRATEGY_SYMLINK = 10;
  14953. const STRATEGY_MIRROR = 20;
  14954. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  14955. {
  14956. $path = Filesystem::trimTrailingSlash($path);
  14957. $url = $package->getDistUrl();
  14958. $realUrl = realpath($url);
  14959. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  14960. throw new \RuntimeException(sprintf(
  14961. 'Source path "%s" is not found for package %s',
  14962. $url,
  14963. $package->getName()
  14964. ));
  14965. }
  14966. if (realpath($path) === $realUrl) {
  14967. return \React\Promise\resolve();
  14968. }
  14969. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  14970. throw new \RuntimeException(sprintf(
  14971. 'Package %s cannot install to "%s" inside its source at "%s"',
  14972. $package->getName(),
  14973. realpath($path),
  14974. $realUrl
  14975. ));
  14976. }
  14977. return \React\Promise\resolve();
  14978. }
  14979. public function install(PackageInterface $package, $path, $output = true)
  14980. {
  14981. $path = Filesystem::trimTrailingSlash($path);
  14982. $url = $package->getDistUrl();
  14983. $realUrl = realpath($url);
  14984. if (realpath($path) === $realUrl) {
  14985. if ($output) {
  14986. $this->io->writeError(" - " . InstallOperation::format($package) . $this->getInstallOperationAppendix($package, $path));
  14987. }
  14988. return \React\Promise\resolve();
  14989. }
  14990. $transportOptions = $package->getTransportOptions() + array('relative' => true);
  14991. list($currentStrategy, $allowedStrategies) = $this->computeAllowedStrategies($transportOptions);
  14992. $symfonyFilesystem = new SymfonyFilesystem();
  14993. $this->filesystem->removeDirectory($path);
  14994. if ($output) {
  14995. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  14996. }
  14997. $isFallback = false;
  14998. if (self::STRATEGY_SYMLINK === $currentStrategy) {
  14999. try {
  15000. if (Platform::isWindows()) {
  15001. if ($output) {
  15002. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  15003. }
  15004. $this->filesystem->junction($realUrl, $path);
  15005. } else {
  15006. $absolutePath = $path;
  15007. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  15008. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  15009. }
  15010. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  15011. $path = rtrim($path, "/");
  15012. if ($output) {
  15013. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  15014. }
  15015. if ($transportOptions['relative']) {
  15016. $symfonyFilesystem->symlink($shortestPath, $path);
  15017. } else {
  15018. $symfonyFilesystem->symlink($realUrl, $path);
  15019. }
  15020. }
  15021. } catch (IOException $e) {
  15022. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  15023. if ($output) {
  15024. $this->io->writeError('');
  15025. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  15026. }
  15027. $currentStrategy = self::STRATEGY_MIRROR;
  15028. $isFallback = true;
  15029. } else {
  15030. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  15031. }
  15032. }
  15033. }
  15034. if (self::STRATEGY_MIRROR === $currentStrategy) {
  15035. $realUrl = $this->filesystem->normalizePath($realUrl);
  15036. if ($output) {
  15037. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  15038. }
  15039. $iterator = new ArchivableFilesFinder($realUrl, array());
  15040. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  15041. }
  15042. if ($output) {
  15043. $this->io->writeError('');
  15044. }
  15045. return \React\Promise\resolve();
  15046. }
  15047. public function remove(PackageInterface $package, $path, $output = true)
  15048. {
  15049. $path = Filesystem::trimTrailingSlash($path);
  15050. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  15051. if ($output) {
  15052. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  15053. }
  15054. if (!$this->filesystem->removeJunction($path)) {
  15055. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  15056. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  15057. }
  15058. return \React\Promise\resolve();
  15059. }
  15060. $fs = new Filesystem;
  15061. $absPath = $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path;
  15062. $absDistUrl = $fs->isAbsolutePath($package->getDistUrl()) ? $package->getDistUrl() : getcwd() . '/' . $package->getDistUrl();
  15063. if ($fs->normalizePath($absPath) === $fs->normalizePath($absDistUrl)) {
  15064. if ($output) {
  15065. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  15066. }
  15067. return \React\Promise\resolve();
  15068. }
  15069. return parent::remove($package, $path, $output);
  15070. }
  15071. public function getVcsReference(PackageInterface $package, $path)
  15072. {
  15073. $path = Filesystem::trimTrailingSlash($path);
  15074. $parser = new VersionParser;
  15075. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  15076. $dumper = new ArrayDumper;
  15077. $packageConfig = $dumper->dump($package);
  15078. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  15079. return $packageVersion['commit'];
  15080. }
  15081. return null;
  15082. }
  15083. protected function getInstallOperationAppendix(PackageInterface $package, $path)
  15084. {
  15085. $realUrl = realpath($package->getDistUrl());
  15086. if (realpath($path) === $realUrl) {
  15087. return ': Source already present';
  15088. }
  15089. list($currentStrategy) = $this->computeAllowedStrategies($package->getTransportOptions());
  15090. if ($currentStrategy === self::STRATEGY_SYMLINK) {
  15091. if (Platform::isWindows()) {
  15092. return ': Junctioning from '.$package->getDistUrl();
  15093. }
  15094. return ': Symlinking from '.$package->getDistUrl();
  15095. }
  15096. return ': Mirroring from '.$package->getDistUrl();
  15097. }
  15098. private function computeAllowedStrategies(array $transportOptions)
  15099. {
  15100. $currentStrategy = self::STRATEGY_SYMLINK;
  15101. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  15102. $mirrorPathRepos = Platform::getEnv('COMPOSER_MIRROR_PATH_REPOS');
  15103. if ($mirrorPathRepos) {
  15104. $currentStrategy = self::STRATEGY_MIRROR;
  15105. }
  15106. $symlinkOption = isset($transportOptions['symlink']) ? $transportOptions['symlink'] : null;
  15107. if (true === $symlinkOption) {
  15108. $currentStrategy = self::STRATEGY_SYMLINK;
  15109. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  15110. } elseif (false === $symlinkOption) {
  15111. $currentStrategy = self::STRATEGY_MIRROR;
  15112. $allowedStrategies = array(self::STRATEGY_MIRROR);
  15113. }
  15114. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  15115. if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) {
  15116. throw new \RuntimeException('You are on an old Windows / old PHP combo which does not allow Composer to use junctions/symlinks and this path repository has symlink:true in its options so copying is not allowed');
  15117. }
  15118. $currentStrategy = self::STRATEGY_MIRROR;
  15119. $allowedStrategies = array(self::STRATEGY_MIRROR);
  15120. }
  15121. return array($currentStrategy, $allowedStrategies);
  15122. }
  15123. private function safeJunctions()
  15124. {
  15125. return function_exists('proc_open') &&
  15126. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  15127. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  15128. }
  15129. }
  15130. <?php
  15131. namespace Composer\Downloader;
  15132. use Composer\Package\PackageInterface;
  15133. use Composer\Repository\VcsRepository;
  15134. use Composer\Util\Perforce;
  15135. class PerforceDownloader extends VcsDownloader
  15136. {
  15137. protected $perforce;
  15138. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  15139. {
  15140. return \React\Promise\resolve();
  15141. }
  15142. public function doInstall(PackageInterface $package, $path, $url)
  15143. {
  15144. $ref = $package->getSourceReference();
  15145. $label = $this->getLabelFromSourceReference((string) $ref);
  15146. $this->io->writeError('Cloning ' . $ref);
  15147. $this->initPerforce($package, $path, $url);
  15148. $this->perforce->setStream($ref);
  15149. $this->perforce->p4Login();
  15150. $this->perforce->writeP4ClientSpec();
  15151. $this->perforce->connectClient();
  15152. $this->perforce->syncCodeBase($label);
  15153. $this->perforce->cleanupClientSpec();
  15154. return \React\Promise\resolve();
  15155. }
  15156. private function getLabelFromSourceReference($ref)
  15157. {
  15158. $pos = strpos($ref, '@');
  15159. if (false !== $pos) {
  15160. return substr($ref, $pos + 1);
  15161. }
  15162. return null;
  15163. }
  15164. public function initPerforce(PackageInterface $package, $path, $url)
  15165. {
  15166. if (!empty($this->perforce)) {
  15167. $this->perforce->initializePath($path);
  15168. return;
  15169. }
  15170. $repository = $package->getRepository();
  15171. $repoConfig = null;
  15172. if ($repository instanceof VcsRepository) {
  15173. $repoConfig = $this->getRepoConfig($repository);
  15174. }
  15175. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  15176. }
  15177. private function getRepoConfig(VcsRepository $repository)
  15178. {
  15179. return $repository->getRepoConfig();
  15180. }
  15181. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  15182. {
  15183. return $this->doInstall($target, $path, $url);
  15184. }
  15185. public function getLocalChanges(PackageInterface $package, $path)
  15186. {
  15187. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  15188. return null;
  15189. }
  15190. protected function getCommitLogs($fromReference, $toReference, $path)
  15191. {
  15192. return $this->perforce->getCommitLogs($fromReference, $toReference);
  15193. }
  15194. public function setPerforce(Perforce $perforce)
  15195. {
  15196. $this->perforce = $perforce;
  15197. }
  15198. protected function hasMetadataRepository($path)
  15199. {
  15200. return true;
  15201. }
  15202. }
  15203. <?php
  15204. namespace Composer\Downloader;
  15205. use Composer\Package\PackageInterface;
  15206. class PharDownloader extends ArchiveDownloader
  15207. {
  15208. protected function extract(PackageInterface $package, $file, $path)
  15209. {
  15210. $archive = new \Phar($file);
  15211. $archive->extractTo($path, null, true);
  15212. return \React\Promise\resolve();
  15213. }
  15214. }
  15215. <?php
  15216. namespace Composer\Downloader;
  15217. use Composer\Util\IniHelper;
  15218. use Composer\Util\Platform;
  15219. use Composer\Util\ProcessExecutor;
  15220. use Composer\Package\PackageInterface;
  15221. use RarArchive;
  15222. class RarDownloader extends ArchiveDownloader
  15223. {
  15224. protected function extract(PackageInterface $package, $file, $path)
  15225. {
  15226. $processError = null;
  15227. if (!Platform::isWindows()) {
  15228. $command = 'unrar x -- ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  15229. if (0 === $this->process->execute($command, $ignoredOutput)) {
  15230. return \React\Promise\resolve();
  15231. }
  15232. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  15233. }
  15234. if (!class_exists('RarArchive')) {
  15235. $iniMessage = IniHelper::getMessage();
  15236. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  15237. . $iniMessage . "\n" . $processError;
  15238. if (!Platform::isWindows()) {
  15239. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  15240. }
  15241. throw new \RuntimeException($error);
  15242. }
  15243. $rarArchive = RarArchive::open($file);
  15244. if (false === $rarArchive) {
  15245. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  15246. }
  15247. $entries = $rarArchive->getEntries();
  15248. if (false === $entries) {
  15249. throw new \RuntimeException('Could not retrieve RAR archive entries');
  15250. }
  15251. foreach ($entries as $entry) {
  15252. if (false === $entry->extract($path)) {
  15253. throw new \RuntimeException('Could not extract entry');
  15254. }
  15255. }
  15256. $rarArchive->close();
  15257. return \React\Promise\resolve();
  15258. }
  15259. }
  15260. <?php
  15261. namespace Composer\Downloader;
  15262. use Composer\Package\PackageInterface;
  15263. use Composer\Pcre\Preg;
  15264. use Composer\Util\Svn as SvnUtil;
  15265. use Composer\Repository\VcsRepository;
  15266. use Composer\Util\ProcessExecutor;
  15267. use React\Promise\PromiseInterface;
  15268. class SvnDownloader extends VcsDownloader
  15269. {
  15270. protected $cacheCredentials = true;
  15271. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  15272. {
  15273. SvnUtil::cleanEnv();
  15274. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  15275. if (null === $util->binaryVersion()) {
  15276. throw new \RuntimeException('svn was not found in your PATH, skipping source download');
  15277. }
  15278. return \React\Promise\resolve();
  15279. }
  15280. protected function doInstall(PackageInterface $package, $path, $url)
  15281. {
  15282. SvnUtil::cleanEnv();
  15283. $ref = $package->getSourceReference();
  15284. $repo = $package->getRepository();
  15285. if ($repo instanceof VcsRepository) {
  15286. $repoConfig = $repo->getRepoConfig();
  15287. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  15288. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  15289. }
  15290. }
  15291. $this->io->writeError(" Checking out ".$package->getSourceReference());
  15292. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  15293. return \React\Promise\resolve();
  15294. }
  15295. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  15296. {
  15297. SvnUtil::cleanEnv();
  15298. $ref = $target->getSourceReference();
  15299. if (!$this->hasMetadataRepository($path)) {
  15300. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  15301. }
  15302. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  15303. $flags = "";
  15304. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  15305. $flags .= ' --ignore-ancestry';
  15306. }
  15307. $this->io->writeError(" Checking out " . $ref);
  15308. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  15309. return \React\Promise\resolve();
  15310. }
  15311. public function getLocalChanges(PackageInterface $package, $path)
  15312. {
  15313. if (!$this->hasMetadataRepository($path)) {
  15314. return null;
  15315. }
  15316. $this->process->execute('svn status --ignore-externals', $output, $path);
  15317. return Preg::isMatch('{^ *[^X ] +}m', $output) ? $output : null;
  15318. }
  15319. protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
  15320. {
  15321. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  15322. $util->setCacheCredentials($this->cacheCredentials);
  15323. try {
  15324. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  15325. } catch (\RuntimeException $e) {
  15326. throw new \RuntimeException(
  15327. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  15328. );
  15329. }
  15330. }
  15331. protected function cleanChanges(PackageInterface $package, $path, $update)
  15332. {
  15333. if (!$changes = $this->getLocalChanges($package, $path)) {
  15334. return \React\Promise\resolve();
  15335. }
  15336. if (!$this->io->isInteractive()) {
  15337. if (true === $this->config->get('discard-changes')) {
  15338. return $this->discardChanges($path);
  15339. }
  15340. return parent::cleanChanges($package, $path, $update);
  15341. }
  15342. $changes = array_map(function ($elem) {
  15343. return ' '.$elem;
  15344. }, Preg::split('{\s*\r?\n\s*}', $changes));
  15345. $countChanges = count($changes);
  15346. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  15347. $this->io->writeError(array_slice($changes, 0, 10));
  15348. if ($countChanges > 10) {
  15349. $remainingChanges = $countChanges - 10;
  15350. $this->io->writeError(
  15351. sprintf(
  15352. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  15353. $remainingChanges === 1 ? '' : 's'
  15354. )
  15355. );
  15356. }
  15357. while (true) {
  15358. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  15359. case 'y':
  15360. $this->discardChanges($path);
  15361. break 2;
  15362. case 'n':
  15363. throw new \RuntimeException('Update aborted');
  15364. case 'v':
  15365. $this->io->writeError($changes);
  15366. break;
  15367. case '?':
  15368. default:
  15369. $this->io->writeError(array(
  15370. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  15371. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  15372. ' v - view modified files',
  15373. ' ? - print help',
  15374. ));
  15375. break;
  15376. }
  15377. }
  15378. return \React\Promise\resolve();
  15379. }
  15380. protected function getCommitLogs($fromReference, $toReference, $path)
  15381. {
  15382. if (Preg::isMatch('{@(\d+)$}', $fromReference) && Preg::isMatch('{@(\d+)$}', $toReference)) {
  15383. $command = sprintf('svn info --non-interactive --xml -- %s', ProcessExecutor::escape($path));
  15384. if (0 !== $this->process->execute($command, $output, $path)) {
  15385. throw new \RuntimeException(
  15386. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  15387. );
  15388. }
  15389. $urlPattern = '#<url>(.*)</url>#';
  15390. if (Preg::isMatch($urlPattern, $output, $matches)) {
  15391. $baseUrl = $matches[1];
  15392. } else {
  15393. throw new \RuntimeException(
  15394. 'Unable to determine svn url for path '. $path
  15395. );
  15396. }
  15397. $fromRevision = Preg::replace('{.*@(\d+)$}', '$1', $fromReference);
  15398. $toRevision = Preg::replace('{.*@(\d+)$}', '$1', $toReference);
  15399. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  15400. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  15401. $util->setCacheCredentials($this->cacheCredentials);
  15402. try {
  15403. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  15404. } catch (\RuntimeException $e) {
  15405. throw new \RuntimeException(
  15406. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  15407. );
  15408. }
  15409. }
  15410. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  15411. }
  15412. protected function discardChanges($path)
  15413. {
  15414. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  15415. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  15416. }
  15417. return \React\Promise\resolve();
  15418. }
  15419. protected function hasMetadataRepository($path)
  15420. {
  15421. return is_dir($path.'/.svn');
  15422. }
  15423. }
  15424. <?php
  15425. namespace Composer\Downloader;
  15426. use Composer\Package\PackageInterface;
  15427. class TarDownloader extends ArchiveDownloader
  15428. {
  15429. protected function extract(PackageInterface $package, $file, $path)
  15430. {
  15431. $archive = new \PharData($file);
  15432. $archive->extractTo($path, null, true);
  15433. return \React\Promise\resolve();
  15434. }
  15435. }
  15436. <?php
  15437. namespace Composer\Downloader;
  15438. class TransportException extends \RuntimeException
  15439. {
  15440. protected $headers;
  15441. protected $response;
  15442. protected $statusCode;
  15443. protected $responseInfo = array();
  15444. public function setHeaders($headers)
  15445. {
  15446. $this->headers = $headers;
  15447. }
  15448. public function getHeaders()
  15449. {
  15450. return $this->headers;
  15451. }
  15452. public function setResponse($response)
  15453. {
  15454. $this->response = $response;
  15455. }
  15456. public function getResponse()
  15457. {
  15458. return $this->response;
  15459. }
  15460. public function setStatusCode($statusCode)
  15461. {
  15462. $this->statusCode = $statusCode;
  15463. }
  15464. public function getStatusCode()
  15465. {
  15466. return $this->statusCode;
  15467. }
  15468. public function getResponseInfo()
  15469. {
  15470. return $this->responseInfo;
  15471. }
  15472. public function setResponseInfo(array $responseInfo)
  15473. {
  15474. $this->responseInfo = $responseInfo;
  15475. }
  15476. }
  15477. <?php
  15478. namespace Composer\Downloader;
  15479. use Composer\Package\PackageInterface;
  15480. interface VcsCapableDownloaderInterface
  15481. {
  15482. public function getVcsReference(PackageInterface $package, $path);
  15483. }
  15484. <?php
  15485. namespace Composer\Downloader;
  15486. use Composer\Config;
  15487. use Composer\Package\Dumper\ArrayDumper;
  15488. use Composer\Package\PackageInterface;
  15489. use Composer\Package\Version\VersionGuesser;
  15490. use Composer\Package\Version\VersionParser;
  15491. use Composer\Util\ProcessExecutor;
  15492. use Composer\IO\IOInterface;
  15493. use Composer\Util\Filesystem;
  15494. use React\Promise\PromiseInterface;
  15495. use Composer\DependencyResolver\Operation\UpdateOperation;
  15496. use Composer\DependencyResolver\Operation\InstallOperation;
  15497. use Composer\DependencyResolver\Operation\UninstallOperation;
  15498. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  15499. {
  15500. protected $io;
  15501. protected $config;
  15502. protected $process;
  15503. protected $filesystem;
  15504. protected $hasCleanedChanges = array();
  15505. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  15506. {
  15507. $this->io = $io;
  15508. $this->config = $config;
  15509. $this->process = $process ?: new ProcessExecutor($io);
  15510. $this->filesystem = $fs ?: new Filesystem($this->process);
  15511. }
  15512. public function getInstallationSource()
  15513. {
  15514. return 'source';
  15515. }
  15516. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
  15517. {
  15518. if (!$package->getSourceReference()) {
  15519. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  15520. }
  15521. $urls = $this->prepareUrls($package->getSourceUrls());
  15522. while ($url = array_shift($urls)) {
  15523. try {
  15524. return $this->doDownload($package, $path, $url, $prevPackage);
  15525. } catch (\Exception $e) {
  15526. if ($e instanceof \PHPUnit\Framework\Exception) {
  15527. throw $e;
  15528. }
  15529. if ($this->io->isDebug()) {
  15530. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  15531. } elseif (count($urls)) {
  15532. $this->io->writeError(' Failed, trying the next URL');
  15533. }
  15534. if (!count($urls)) {
  15535. throw $e;
  15536. }
  15537. }
  15538. }
  15539. return \React\Promise\resolve();
  15540. }
  15541. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  15542. {
  15543. if ($type === 'update') {
  15544. $this->cleanChanges($prevPackage, $path, true);
  15545. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  15546. } elseif ($type === 'install') {
  15547. $this->filesystem->emptyDirectory($path);
  15548. } elseif ($type === 'uninstall') {
  15549. $this->cleanChanges($package, $path, false);
  15550. }
  15551. return \React\Promise\resolve();
  15552. }
  15553. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  15554. {
  15555. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  15556. $this->reapplyChanges($path);
  15557. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  15558. }
  15559. return \React\Promise\resolve();
  15560. }
  15561. public function install(PackageInterface $package, $path)
  15562. {
  15563. if (!$package->getSourceReference()) {
  15564. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  15565. }
  15566. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  15567. $urls = $this->prepareUrls($package->getSourceUrls());
  15568. while ($url = array_shift($urls)) {
  15569. try {
  15570. $this->doInstall($package, $path, $url);
  15571. break;
  15572. } catch (\Exception $e) {
  15573. if ($e instanceof \PHPUnit\Framework\Exception) {
  15574. throw $e;
  15575. }
  15576. if ($this->io->isDebug()) {
  15577. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  15578. } elseif (count($urls)) {
  15579. $this->io->writeError(' Failed, trying the next URL');
  15580. }
  15581. if (!count($urls)) {
  15582. throw $e;
  15583. }
  15584. }
  15585. }
  15586. return \React\Promise\resolve();
  15587. }
  15588. public function update(PackageInterface $initial, PackageInterface $target, $path)
  15589. {
  15590. if (!$target->getSourceReference()) {
  15591. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  15592. }
  15593. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  15594. $urls = $this->prepareUrls($target->getSourceUrls());
  15595. $exception = null;
  15596. while ($url = array_shift($urls)) {
  15597. try {
  15598. $this->doUpdate($initial, $target, $path, $url);
  15599. $exception = null;
  15600. break;
  15601. } catch (\Exception $exception) {
  15602. if ($exception instanceof \PHPUnit\Framework\Exception) {
  15603. throw $exception;
  15604. }
  15605. if ($this->io->isDebug()) {
  15606. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  15607. } elseif (count($urls)) {
  15608. $this->io->writeError(' Failed, trying the next URL');
  15609. }
  15610. }
  15611. }
  15612. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  15613. $message = 'Pulling in changes:';
  15614. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  15615. if (!trim($logs)) {
  15616. $message = 'Rolling back changes:';
  15617. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  15618. }
  15619. if (trim($logs)) {
  15620. $logs = implode("\n", array_map(function ($line) {
  15621. return ' ' . $line;
  15622. }, explode("\n", $logs)));
  15623. $logs = str_replace('<', '\<', $logs);
  15624. $this->io->writeError(' '.$message);
  15625. $this->io->writeError($logs);
  15626. }
  15627. }
  15628. if (!$urls && $exception) {
  15629. throw $exception;
  15630. }
  15631. return \React\Promise\resolve();
  15632. }
  15633. public function remove(PackageInterface $package, $path)
  15634. {
  15635. $this->io->writeError(" - " . UninstallOperation::format($package));
  15636. $promise = $this->filesystem->removeDirectoryAsync($path);
  15637. return $promise->then(function ($result) use ($path) {
  15638. if (!$result) {
  15639. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  15640. }
  15641. });
  15642. }
  15643. public function getVcsReference(PackageInterface $package, $path)
  15644. {
  15645. $parser = new VersionParser;
  15646. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  15647. $dumper = new ArrayDumper;
  15648. $packageConfig = $dumper->dump($package);
  15649. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  15650. return $packageVersion['commit'];
  15651. }
  15652. return null;
  15653. }
  15654. protected function cleanChanges(PackageInterface $package, $path, $update)
  15655. {
  15656. if (null !== $this->getLocalChanges($package, $path)) {
  15657. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  15658. }
  15659. return \React\Promise\resolve();
  15660. }
  15661. protected function reapplyChanges($path)
  15662. {
  15663. }
  15664. abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
  15665. abstract protected function doInstall(PackageInterface $package, $path, $url);
  15666. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  15667. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  15668. abstract protected function hasMetadataRepository($path);
  15669. private function prepareUrls(array $urls)
  15670. {
  15671. foreach ($urls as $index => $url) {
  15672. if (Filesystem::isLocalPath($url)) {
  15673. $fileProtocol = 'file://';
  15674. $isFileProtocol = false;
  15675. if (0 === strpos($url, $fileProtocol)) {
  15676. $url = substr($url, strlen($fileProtocol));
  15677. $isFileProtocol = true;
  15678. }
  15679. if (false !== strpos($url, '%')) {
  15680. $url = rawurldecode($url);
  15681. }
  15682. $urls[$index] = realpath($url);
  15683. if ($isFileProtocol) {
  15684. $urls[$index] = $fileProtocol . $urls[$index];
  15685. }
  15686. }
  15687. }
  15688. return $urls;
  15689. }
  15690. }
  15691. <?php
  15692. namespace Composer\Downloader;
  15693. use Composer\Package\PackageInterface;
  15694. use Composer\Util\ProcessExecutor;
  15695. class XzDownloader extends ArchiveDownloader
  15696. {
  15697. protected function extract(PackageInterface $package, $file, $path)
  15698. {
  15699. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  15700. if (0 === $this->process->execute($command, $ignoredOutput)) {
  15701. return \React\Promise\resolve();
  15702. }
  15703. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  15704. throw new \RuntimeException($processError);
  15705. }
  15706. }
  15707. <?php
  15708. namespace Composer\Downloader;
  15709. use Composer\Package\PackageInterface;
  15710. use Composer\Util\IniHelper;
  15711. use Composer\Util\Platform;
  15712. use Composer\Util\ProcessExecutor;
  15713. use Symfony\Component\Process\ExecutableFinder;
  15714. use React\Promise\PromiseInterface;
  15715. use ZipArchive;
  15716. class ZipDownloader extends ArchiveDownloader
  15717. {
  15718. private static $unzipCommands;
  15719. private static $hasZipArchive;
  15720. private static $isWindows;
  15721. private $zipArchiveObject;
  15722. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  15723. {
  15724. if (null === self::$unzipCommands) {
  15725. self::$unzipCommands = array();
  15726. $finder = new ExecutableFinder;
  15727. if (Platform::isWindows() && ($cmd = $finder->find('7z', null, array('C:\Program Files\7-Zip')))) {
  15728. self::$unzipCommands[] = array('7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15729. }
  15730. if ($cmd = $finder->find('unzip')) {
  15731. self::$unzipCommands[] = array('unzip', ProcessExecutor::escape($cmd).' -qq %s -d %s');
  15732. }
  15733. if (!Platform::isWindows() && ($cmd = $finder->find('7z'))) {
  15734. self::$unzipCommands[] = array('7z', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15735. }
  15736. if (!Platform::isWindows() && ($cmd = $finder->find('7zz'))) {
  15737. self::$unzipCommands[] = array('7zz', ProcessExecutor::escape($cmd).' x -bb0 -y %s -o%s');
  15738. }
  15739. }
  15740. $procOpenMissing = false;
  15741. if (!function_exists('proc_open')) {
  15742. self::$unzipCommands = array();
  15743. $procOpenMissing = true;
  15744. }
  15745. if (null === self::$hasZipArchive) {
  15746. self::$hasZipArchive = class_exists('ZipArchive');
  15747. }
  15748. if (!self::$hasZipArchive && !self::$unzipCommands) {
  15749. $iniMessage = IniHelper::getMessage();
  15750. if ($procOpenMissing) {
  15751. $error = "The zip extension is missing and unzip/7z commands cannot be called as proc_open is disabled, skipping.\n" . $iniMessage;
  15752. } else {
  15753. $error = "The zip extension and unzip/7z commands are both missing, skipping.\n" . $iniMessage;
  15754. }
  15755. throw new \RuntimeException($error);
  15756. }
  15757. if (null === self::$isWindows) {
  15758. self::$isWindows = Platform::isWindows();
  15759. if (!self::$isWindows && !self::$unzipCommands) {
  15760. if ($procOpenMissing) {
  15761. $this->io->writeError("<warning>proc_open is disabled so 'unzip' and '7z' commands cannot be used, zip files are being unpacked using the PHP zip extension.</warning>");
  15762. $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>");
  15763. $this->io->writeError("<warning>Enabling proc_open and installing 'unzip' or '7z' may remediate them.</warning>");
  15764. } else {
  15765. $this->io->writeError("<warning>As there is no 'unzip' nor '7z' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  15766. $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>");
  15767. $this->io->writeError("<warning>Installing 'unzip' or '7z' may remediate them.</warning>");
  15768. }
  15769. }
  15770. }
  15771. return parent::download($package, $path, $prevPackage, $output);
  15772. }
  15773. private function extractWithSystemUnzip(PackageInterface $package, $file, $path)
  15774. {
  15775. $isLastChance = !self::$hasZipArchive;
  15776. if (!self::$unzipCommands) {
  15777. return $this->extractWithZipArchive($package, $file, $path);
  15778. }
  15779. $commandSpec = reset(self::$unzipCommands);
  15780. $command = sprintf($commandSpec[1], ProcessExecutor::escape($file), ProcessExecutor::escape($path));
  15781. if (Platform::isWindows()) {
  15782. $command = sprintf($commandSpec[1], ProcessExecutor::escape(strtr($file, '/', '\\')), ProcessExecutor::escape(strtr($path, '/', '\\')));
  15783. }
  15784. $executable = $commandSpec[0];
  15785. $self = $this;
  15786. $io = $this->io;
  15787. $tryFallback = function ($processError) use ($isLastChance, $io, $self, $file, $path, $package, $executable) {
  15788. if ($isLastChance) {
  15789. throw $processError;
  15790. }
  15791. if (!is_file($file)) {
  15792. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  15793. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  15794. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  15795. } else {
  15796. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  15797. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  15798. $io->writeError(' Unzip with '.$executable.' command failed, falling back to ZipArchive class');
  15799. }
  15800. return $self->extractWithZipArchive($package, $file, $path);
  15801. };
  15802. try {
  15803. $promise = $this->process->executeAsync($command);
  15804. return $promise->then(function ($process) use ($tryFallback, $command, $package, $file, $self) {
  15805. if (!$process->isSuccessful()) {
  15806. if (isset($self->cleanupExecuted[$package->getName()])) {
  15807. throw new \RuntimeException('Failed to extract '.$package->getName().' as the installation was aborted by another package operation.');
  15808. }
  15809. $output = $process->getErrorOutput();
  15810. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  15811. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  15812. }
  15813. });
  15814. } catch (\Exception $e) {
  15815. return $tryFallback($e);
  15816. } catch (\Throwable $e) {
  15817. return $tryFallback($e);
  15818. }
  15819. }
  15820. public function extractWithZipArchive(PackageInterface $package, $file, $path)
  15821. {
  15822. $processError = null;
  15823. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  15824. try {
  15825. if (true === ($retval = $zipArchive->open($file))) {
  15826. $extractResult = $zipArchive->extractTo($path);
  15827. if (true === $extractResult) {
  15828. $zipArchive->close();
  15829. return \React\Promise\resolve();
  15830. }
  15831. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  15832. } else {
  15833. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  15834. }
  15835. } catch (\ErrorException $e) {
  15836. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  15837. } catch (\Exception $e) {
  15838. $processError = $e;
  15839. } catch (\Throwable $e) {
  15840. $processError = $e;
  15841. }
  15842. throw $processError;
  15843. }
  15844. public function extract(PackageInterface $package, $file, $path)
  15845. {
  15846. return $this->extractWithSystemUnzip($package, $file, $path);
  15847. }
  15848. protected function getErrorMessage($retval, $file)
  15849. {
  15850. switch ($retval) {
  15851. case ZipArchive::ER_EXISTS:
  15852. return sprintf("File '%s' already exists.", $file);
  15853. case ZipArchive::ER_INCONS:
  15854. return sprintf("Zip archive '%s' is inconsistent.", $file);
  15855. case ZipArchive::ER_INVAL:
  15856. return sprintf("Invalid argument (%s)", $file);
  15857. case ZipArchive::ER_MEMORY:
  15858. return sprintf("Malloc failure (%s)", $file);
  15859. case ZipArchive::ER_NOENT:
  15860. return sprintf("No such zip file: '%s'", $file);
  15861. case ZipArchive::ER_NOZIP:
  15862. return sprintf("'%s' is not a zip archive.", $file);
  15863. case ZipArchive::ER_OPEN:
  15864. return sprintf("Can't open zip file: %s", $file);
  15865. case ZipArchive::ER_READ:
  15866. return sprintf("Zip read error (%s)", $file);
  15867. case ZipArchive::ER_SEEK:
  15868. return sprintf("Zip seek error (%s)", $file);
  15869. default:
  15870. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  15871. }
  15872. }
  15873. }
  15874. <?php
  15875. namespace Composer\EventDispatcher;
  15876. class Event
  15877. {
  15878. protected $name;
  15879. protected $args;
  15880. protected $flags;
  15881. private $propagationStopped = false;
  15882. public function __construct($name, array $args = array(), array $flags = array())
  15883. {
  15884. $this->name = $name;
  15885. $this->args = $args;
  15886. $this->flags = $flags;
  15887. }
  15888. public function getName()
  15889. {
  15890. return $this->name;
  15891. }
  15892. public function getArguments()
  15893. {
  15894. return $this->args;
  15895. }
  15896. public function getFlags()
  15897. {
  15898. return $this->flags;
  15899. }
  15900. public function isPropagationStopped()
  15901. {
  15902. return $this->propagationStopped;
  15903. }
  15904. public function stopPropagation()
  15905. {
  15906. $this->propagationStopped = true;
  15907. }
  15908. }
  15909. <?php
  15910. namespace Composer\EventDispatcher;
  15911. use Composer\DependencyResolver\Transaction;
  15912. use Composer\Installer\InstallerEvent;
  15913. use Composer\IO\IOInterface;
  15914. use Composer\Composer;
  15915. use Composer\Pcre\Preg;
  15916. use Composer\Util\Platform;
  15917. use Composer\DependencyResolver\Operation\OperationInterface;
  15918. use Composer\Repository\RepositoryInterface;
  15919. use Composer\Script;
  15920. use Composer\Installer\PackageEvent;
  15921. use Composer\Installer\BinaryInstaller;
  15922. use Composer\Util\ProcessExecutor;
  15923. use Composer\Script\Event as ScriptEvent;
  15924. use Composer\Autoload\ClassLoader;
  15925. use Symfony\Component\Process\PhpExecutableFinder;
  15926. use Symfony\Component\Process\ExecutableFinder;
  15927. class EventDispatcher
  15928. {
  15929. protected $composer;
  15930. protected $io;
  15931. protected $loader;
  15932. protected $process;
  15933. protected $listeners = array();
  15934. protected $runScripts = true;
  15935. private $eventStack;
  15936. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  15937. {
  15938. $this->composer = $composer;
  15939. $this->io = $io;
  15940. $this->process = $process ?: new ProcessExecutor($io);
  15941. $this->eventStack = array();
  15942. }
  15943. public function setRunScripts($runScripts = true)
  15944. {
  15945. $this->runScripts = (bool) $runScripts;
  15946. return $this;
  15947. }
  15948. public function dispatch($eventName, Event $event = null)
  15949. {
  15950. if (null === $event) {
  15951. $event = new Event($eventName);
  15952. }
  15953. return $this->doDispatch($event);
  15954. }
  15955. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  15956. {
  15957. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  15958. }
  15959. public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  15960. {
  15961. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  15962. }
  15963. public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
  15964. {
  15965. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  15966. }
  15967. protected function doDispatch(Event $event)
  15968. {
  15969. if (Platform::getEnv('COMPOSER_DEBUG_EVENTS')) {
  15970. $details = null;
  15971. if ($event instanceof PackageEvent) {
  15972. $details = (string) $event->getOperation();
  15973. }
  15974. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  15975. }
  15976. $listeners = $this->getListeners($event);
  15977. $this->pushEvent($event);
  15978. try {
  15979. $returnMax = 0;
  15980. foreach ($listeners as $callable) {
  15981. $return = 0;
  15982. $this->ensureBinDirIsInPath();
  15983. if (!is_string($callable)) {
  15984. if (!is_callable($callable)) {
  15985. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  15986. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  15987. }
  15988. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  15989. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  15990. }
  15991. $return = false === call_user_func($callable, $event) ? 1 : 0;
  15992. } elseif ($this->isComposerScript($callable)) {
  15993. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  15994. $script = explode(' ', substr($callable, 1));
  15995. $scriptName = $script[0];
  15996. unset($script[0]);
  15997. $args = array_merge($script, $event->getArguments());
  15998. $flags = $event->getFlags();
  15999. if (strpos($callable, '@composer ') === 0) {
  16000. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  16001. if (0 !== ($exitCode = $this->executeTty($exec))) {
  16002. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  16003. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  16004. }
  16005. } else {
  16006. if (!$this->getListeners(new Event($scriptName))) {
  16007. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  16008. }
  16009. try {
  16010. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  16011. $scriptEvent->setOriginatingEvent($event);
  16012. $return = $this->dispatch($scriptName, $scriptEvent);
  16013. } catch (ScriptExecutionException $e) {
  16014. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  16015. throw $e;
  16016. }
  16017. }
  16018. } elseif ($this->isPhpScript($callable)) {
  16019. $className = substr($callable, 0, strpos($callable, '::'));
  16020. $methodName = substr($callable, strpos($callable, '::') + 2);
  16021. if (!class_exists($className)) {
  16022. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  16023. continue;
  16024. }
  16025. if (!is_callable($callable)) {
  16026. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  16027. continue;
  16028. }
  16029. try {
  16030. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  16031. } catch (\Exception $e) {
  16032. $message = "Script %s handling the %s event terminated with an exception";
  16033. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  16034. throw $e;
  16035. }
  16036. } else {
  16037. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  16038. $exec = $callable . ($args === '' ? '' : ' '.$args);
  16039. if ($this->io->isVerbose()) {
  16040. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  16041. } elseif ($event->getName() !== '__exec_command') {
  16042. $this->io->writeError(sprintf('> %s', $exec));
  16043. }
  16044. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  16045. if ($possibleLocalBinaries) {
  16046. foreach ($possibleLocalBinaries as $localExec) {
  16047. if (Preg::isMatch('{\b'.preg_quote($callable).'$}', $localExec)) {
  16048. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  16049. $exec = Preg::replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  16050. break;
  16051. }
  16052. }
  16053. }
  16054. if (strpos($exec, '@putenv ') === 0) {
  16055. if (false === strpos($exec, '=')) {
  16056. Platform::clearEnv(substr($exec, 8));
  16057. } else {
  16058. list($var, $value) = explode('=', substr($exec, 8), 2);
  16059. Platform::putEnv($var, $value);
  16060. }
  16061. continue;
  16062. }
  16063. if (strpos($exec, '@php ') === 0) {
  16064. $pathAndArgs = substr($exec, 5);
  16065. if (Platform::isWindows()) {
  16066. $pathAndArgs = Preg::replaceCallback('{^\S+}', function ($path) {
  16067. return str_replace('/', '\\', $path[0]);
  16068. }, $pathAndArgs);
  16069. }
  16070. $matched = Preg::isMatch('{^[^\'"\s/\\\\]+}', $pathAndArgs, $match);
  16071. if ($matched && !file_exists($match[0])) {
  16072. $finder = new ExecutableFinder;
  16073. if ($pathToExec = $finder->find($match[0])) {
  16074. $pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0]));
  16075. }
  16076. }
  16077. $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
  16078. } else {
  16079. $finder = new PhpExecutableFinder();
  16080. $phpPath = $finder->find(false);
  16081. if ($phpPath) {
  16082. Platform::putEnv('PHP_BINARY', $phpPath);
  16083. }
  16084. if (Platform::isWindows()) {
  16085. $exec = Preg::replaceCallback('{^\S+}', function ($path) {
  16086. return str_replace('/', '\\', $path[0]);
  16087. }, $exec);
  16088. }
  16089. }
  16090. if (strpos($exec, 'composer ') === 0) {
  16091. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(Platform::getEnv('COMPOSER_BINARY')) . substr($exec, 8);
  16092. }
  16093. if (0 !== ($exitCode = $this->executeTty($exec))) {
  16094. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  16095. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  16096. }
  16097. }
  16098. $returnMax = max($returnMax, $return);
  16099. if ($event->isPropagationStopped()) {
  16100. break;
  16101. }
  16102. }
  16103. } catch (\Exception $e) {
  16104. $this->popEvent();
  16105. throw $e;
  16106. } catch (\Throwable $e) {
  16107. $this->popEvent();
  16108. throw $e;
  16109. }
  16110. $this->popEvent();
  16111. return $returnMax;
  16112. }
  16113. protected function executeTty($exec)
  16114. {
  16115. if ($this->io->isInteractive()) {
  16116. return $this->process->executeTty($exec);
  16117. }
  16118. return $this->process->execute($exec);
  16119. }
  16120. protected function getPhpExecCommand()
  16121. {
  16122. $finder = new PhpExecutableFinder();
  16123. $phpPath = $finder->find(false);
  16124. if (!$phpPath) {
  16125. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  16126. }
  16127. $phpArgs = $finder->findArguments();
  16128. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  16129. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  16130. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  16131. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  16132. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  16133. }
  16134. protected function executeEventPhpScript($className, $methodName, Event $event)
  16135. {
  16136. if ($this->io->isVerbose()) {
  16137. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  16138. } else {
  16139. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  16140. }
  16141. return $className::$methodName($event);
  16142. }
  16143. public function addListener($eventName, $listener, $priority = 0)
  16144. {
  16145. $this->listeners[$eventName][$priority][] = $listener;
  16146. }
  16147. public function removeListener($listener)
  16148. {
  16149. foreach ($this->listeners as $eventName => $priorities) {
  16150. foreach ($priorities as $priority => $listeners) {
  16151. foreach ($listeners as $index => $candidate) {
  16152. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  16153. unset($this->listeners[$eventName][$priority][$index]);
  16154. }
  16155. }
  16156. }
  16157. }
  16158. }
  16159. public function addSubscriber(EventSubscriberInterface $subscriber)
  16160. {
  16161. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  16162. if (is_string($params)) {
  16163. $this->addListener($eventName, array($subscriber, $params));
  16164. } elseif (is_string($params[0])) {
  16165. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  16166. } else {
  16167. foreach ($params as $listener) {
  16168. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  16169. }
  16170. }
  16171. }
  16172. }
  16173. protected function getListeners(Event $event)
  16174. {
  16175. $scriptListeners = $this->runScripts ? $this->getScriptListeners($event) : array();
  16176. if (!isset($this->listeners[$event->getName()][0])) {
  16177. $this->listeners[$event->getName()][0] = array();
  16178. }
  16179. krsort($this->listeners[$event->getName()]);
  16180. $listeners = $this->listeners;
  16181. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  16182. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  16183. }
  16184. public function hasEventListeners(Event $event)
  16185. {
  16186. $listeners = $this->getListeners($event);
  16187. return count($listeners) > 0;
  16188. }
  16189. protected function getScriptListeners(Event $event)
  16190. {
  16191. $package = $this->composer->getPackage();
  16192. $scripts = $package->getScripts();
  16193. if (empty($scripts[$event->getName()])) {
  16194. return array();
  16195. }
  16196. if ($this->loader) {
  16197. $this->loader->unregister();
  16198. }
  16199. $generator = $this->composer->getAutoloadGenerator();
  16200. if ($event instanceof ScriptEvent) {
  16201. $generator->setDevMode($event->isDevMode());
  16202. }
  16203. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  16204. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  16205. $map = $generator->parseAutoloads($packageMap, $package);
  16206. $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  16207. $this->loader->register(false);
  16208. return $scripts[$event->getName()];
  16209. }
  16210. protected function isPhpScript($callable)
  16211. {
  16212. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  16213. }
  16214. protected function isComposerScript($callable)
  16215. {
  16216. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  16217. }
  16218. protected function pushEvent(Event $event)
  16219. {
  16220. $eventName = $event->getName();
  16221. if (in_array($eventName, $this->eventStack)) {
  16222. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  16223. }
  16224. return array_push($this->eventStack, $eventName);
  16225. }
  16226. protected function popEvent()
  16227. {
  16228. return array_pop($this->eventStack);
  16229. }
  16230. private function ensureBinDirIsInPath()
  16231. {
  16232. $pathEnv = 'PATH';
  16233. if (false === Platform::getEnv('PATH') && false !== Platform::getEnv('Path')) {
  16234. $pathEnv = 'Path';
  16235. }
  16236. $binDir = $this->composer->getConfig()->get('bin-dir');
  16237. if (is_dir($binDir)) {
  16238. $binDir = realpath($binDir);
  16239. $pathValue = Platform::getEnv($pathEnv);
  16240. if (!Preg::isMatch('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $pathValue)) {
  16241. Platform::putEnv($pathEnv, $binDir.PATH_SEPARATOR.$pathValue);
  16242. }
  16243. }
  16244. }
  16245. }
  16246. <?php
  16247. namespace Composer\EventDispatcher;
  16248. interface EventSubscriberInterface
  16249. {
  16250. public static function getSubscribedEvents();
  16251. }
  16252. <?php
  16253. namespace Composer\EventDispatcher;
  16254. class ScriptExecutionException extends \RuntimeException
  16255. {
  16256. }
  16257. <?php
  16258. namespace Composer\Exception;
  16259. class IrrecoverableDownloadException extends \RuntimeException
  16260. {
  16261. }
  16262. <?php
  16263. namespace Composer\Exception;
  16264. class NoSslException extends \RuntimeException
  16265. {
  16266. }
  16267. <?php
  16268. namespace Composer;
  16269. use Composer\Config\JsonConfigSource;
  16270. use Composer\Json\JsonFile;
  16271. use Composer\IO\IOInterface;
  16272. use Composer\Package\Archiver;
  16273. use Composer\Package\Version\VersionGuesser;
  16274. use Composer\Package\RootPackageInterface;
  16275. use Composer\Repository\RepositoryManager;
  16276. use Composer\Repository\RepositoryFactory;
  16277. use Composer\Util\Filesystem;
  16278. use Composer\Util\Platform;
  16279. use Composer\Util\ProcessExecutor;
  16280. use Composer\Util\HttpDownloader;
  16281. use Composer\Util\Loop;
  16282. use Composer\Util\Silencer;
  16283. use Composer\Plugin\PluginEvents;
  16284. use Composer\EventDispatcher\Event;
  16285. use Seld\JsonLint\DuplicateKeyException;
  16286. use Symfony\Component\Console\Formatter\OutputFormatter;
  16287. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  16288. use Symfony\Component\Console\Output\ConsoleOutput;
  16289. use Composer\EventDispatcher\EventDispatcher;
  16290. use Composer\Autoload\AutoloadGenerator;
  16291. use Composer\Package\Version\VersionParser;
  16292. use Composer\Downloader\TransportException;
  16293. use Composer\Json\JsonValidationException;
  16294. use Composer\Repository\InstalledRepositoryInterface;
  16295. use Seld\JsonLint\JsonParser;
  16296. class Factory
  16297. {
  16298. protected static function getHomeDir()
  16299. {
  16300. $home = Platform::getEnv('COMPOSER_HOME');
  16301. if ($home) {
  16302. return $home;
  16303. }
  16304. if (Platform::isWindows()) {
  16305. if (!Platform::getEnv('APPDATA')) {
  16306. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  16307. }
  16308. return rtrim(strtr(Platform::getEnv('APPDATA'), '\\', '/'), '/') . '/Composer';
  16309. }
  16310. $userDir = self::getUserDir();
  16311. $dirs = array();
  16312. if (self::useXdg()) {
  16313. $xdgConfig = Platform::getEnv('XDG_CONFIG_HOME');
  16314. if (!$xdgConfig) {
  16315. $xdgConfig = $userDir . '/.config';
  16316. }
  16317. $dirs[] = $xdgConfig . '/composer';
  16318. }
  16319. $dirs[] = $userDir . '/.composer';
  16320. foreach ($dirs as $dir) {
  16321. if (Silencer::call('is_dir', $dir)) {
  16322. return $dir;
  16323. }
  16324. }
  16325. return $dirs[0];
  16326. }
  16327. protected static function getCacheDir($home)
  16328. {
  16329. $cacheDir = Platform::getEnv('COMPOSER_CACHE_DIR');
  16330. if ($cacheDir) {
  16331. return $cacheDir;
  16332. }
  16333. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  16334. if ($homeEnv) {
  16335. return $homeEnv . '/cache';
  16336. }
  16337. if (Platform::isWindows()) {
  16338. if ($cacheDir = Platform::getEnv('LOCALAPPDATA')) {
  16339. $cacheDir .= '/Composer';
  16340. } else {
  16341. $cacheDir = $home . '/cache';
  16342. }
  16343. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  16344. }
  16345. $userDir = self::getUserDir();
  16346. if (PHP_OS === 'Darwin') {
  16347. if (is_dir($home . '/cache') && !is_dir($userDir . '/Library/Caches/composer')) {
  16348. Silencer::call('rename', $home . '/cache', $userDir . '/Library/Caches/composer');
  16349. }
  16350. return $userDir . '/Library/Caches/composer';
  16351. }
  16352. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  16353. return $home . '/cache';
  16354. }
  16355. if (self::useXdg()) {
  16356. $xdgCache = Platform::getEnv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  16357. return $xdgCache . '/composer';
  16358. }
  16359. return $home . '/cache';
  16360. }
  16361. protected static function getDataDir($home)
  16362. {
  16363. $homeEnv = Platform::getEnv('COMPOSER_HOME');
  16364. if ($homeEnv) {
  16365. return $homeEnv;
  16366. }
  16367. if (Platform::isWindows()) {
  16368. return strtr($home, '\\', '/');
  16369. }
  16370. $userDir = self::getUserDir();
  16371. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  16372. $xdgData = Platform::getEnv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  16373. return $xdgData . '/composer';
  16374. }
  16375. return $home;
  16376. }
  16377. public static function createConfig(IOInterface $io = null, $cwd = null)
  16378. {
  16379. $cwd = $cwd ?: (string) getcwd();
  16380. $config = new Config(true, $cwd);
  16381. $home = self::getHomeDir();
  16382. $config->merge(array('config' => array(
  16383. 'home' => $home,
  16384. 'cache-dir' => self::getCacheDir($home),
  16385. 'data-dir' => self::getDataDir($home),
  16386. )), Config::SOURCE_DEFAULT);
  16387. $file = new JsonFile($config->get('home').'/config.json');
  16388. if ($file->exists()) {
  16389. if ($io && $io->isDebug()) {
  16390. $io->writeError('Loading config file ' . $file->getPath());
  16391. }
  16392. $config->merge($file->read(), $file->getPath());
  16393. }
  16394. $config->setConfigSource(new JsonConfigSource($file));
  16395. $htaccessProtect = (bool) $config->get('htaccess-protect');
  16396. if ($htaccessProtect) {
  16397. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  16398. foreach ($dirs as $dir) {
  16399. if (!file_exists($dir . '/.htaccess')) {
  16400. if (!is_dir($dir)) {
  16401. Silencer::call('mkdir', $dir, 0777, true);
  16402. }
  16403. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  16404. }
  16405. }
  16406. }
  16407. $file = new JsonFile($config->get('home').'/auth.json');
  16408. if ($file->exists()) {
  16409. if ($io && $io->isDebug()) {
  16410. $io->writeError('Loading config file ' . $file->getPath());
  16411. }
  16412. $config->merge(array('config' => $file->read()), $file->getPath());
  16413. }
  16414. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  16415. if ($composerAuthEnv = Platform::getEnv('COMPOSER_AUTH')) {
  16416. $authData = json_decode($composerAuthEnv, true);
  16417. if (null === $authData) {
  16418. if ($io) {
  16419. $io->writeError('<error>COMPOSER_AUTH environment variable is malformed, should be a valid JSON object</error>');
  16420. }
  16421. } else {
  16422. if ($io && $io->isDebug()) {
  16423. $io->writeError('Loading auth config from COMPOSER_AUTH');
  16424. }
  16425. $config->merge(array('config' => $authData), 'COMPOSER_AUTH');
  16426. }
  16427. }
  16428. return $config;
  16429. }
  16430. public static function getComposerFile()
  16431. {
  16432. return trim(Platform::getEnv('COMPOSER')) ?: './composer.json';
  16433. }
  16434. public static function getLockFile($composerFile)
  16435. {
  16436. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  16437. ? substr($composerFile, 0, -4).'lock'
  16438. : $composerFile . '.lock';
  16439. }
  16440. public static function createAdditionalStyles()
  16441. {
  16442. return array(
  16443. 'highlight' => new OutputFormatterStyle('red'),
  16444. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  16445. );
  16446. }
  16447. public static function createOutput()
  16448. {
  16449. $styles = self::createAdditionalStyles();
  16450. $formatter = new OutputFormatter(false, $styles);
  16451. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  16452. }
  16453. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true, $disableScripts = false)
  16454. {
  16455. $cwd = $cwd ?: (string) getcwd();
  16456. if (null === $localConfig) {
  16457. $localConfig = static::getComposerFile();
  16458. }
  16459. $localConfigSource = Config::SOURCE_UNKNOWN;
  16460. if (is_string($localConfig)) {
  16461. $composerFile = $localConfig;
  16462. $file = new JsonFile($localConfig, null, $io);
  16463. if (!$file->exists()) {
  16464. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  16465. $message = 'Composer could not find a composer.json file in '.$cwd;
  16466. } else {
  16467. $message = 'Composer could not find the config file: '.$localConfig;
  16468. }
  16469. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage' : '';
  16470. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  16471. }
  16472. try {
  16473. $file->validateSchema(JsonFile::LAX_SCHEMA);
  16474. } catch (JsonValidationException $e) {
  16475. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  16476. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  16477. throw new JsonValidationException($message);
  16478. }
  16479. $jsonParser = new JsonParser;
  16480. try {
  16481. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  16482. } catch (DuplicateKeyException $e) {
  16483. $details = $e->getDetails();
  16484. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  16485. }
  16486. $localConfig = $file->read();
  16487. $localConfigSource = $file->getPath();
  16488. }
  16489. $config = static::createConfig($io, $cwd);
  16490. $config->merge($localConfig, $localConfigSource);
  16491. if (isset($composerFile)) {
  16492. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  16493. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  16494. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  16495. if ($localAuthFile->exists()) {
  16496. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  16497. $config->merge(array('config' => $localAuthFile->read()), $localAuthFile->getPath());
  16498. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  16499. }
  16500. }
  16501. $vendorDir = $config->get('vendor-dir');
  16502. $composer = new Composer();
  16503. $composer->setConfig($config);
  16504. if ($fullLoad) {
  16505. $io->loadConfiguration($config);
  16506. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  16507. include $installedVersionsPath;
  16508. }
  16509. }
  16510. $httpDownloader = self::createHttpDownloader($io, $config);
  16511. $process = new ProcessExecutor($io);
  16512. $loop = new Loop($httpDownloader, $process);
  16513. $composer->setLoop($loop);
  16514. $dispatcher = new EventDispatcher($composer, $io, $process);
  16515. $dispatcher->setRunScripts(!$disableScripts);
  16516. $composer->setEventDispatcher($dispatcher);
  16517. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  16518. $composer->setRepositoryManager($rm);
  16519. if (!$fullLoad && !isset($localConfig['version'])) {
  16520. $localConfig['version'] = '1.0.0';
  16521. }
  16522. $parser = new VersionParser;
  16523. $guesser = new VersionGuesser($config, $process, $parser);
  16524. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  16525. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  16526. $composer->setPackage($package);
  16527. $this->addLocalRepository($io, $rm, $vendorDir, $package, $process);
  16528. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  16529. $composer->setInstallationManager($im);
  16530. if ($fullLoad) {
  16531. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  16532. $composer->setDownloadManager($dm);
  16533. $generator = new AutoloadGenerator($dispatcher, $io);
  16534. $composer->setAutoloadGenerator($generator);
  16535. $am = $this->createArchiveManager($config, $dm, $loop);
  16536. $composer->setArchiveManager($am);
  16537. }
  16538. $this->createDefaultInstallers($im, $composer, $io, $process);
  16539. if ($fullLoad) {
  16540. $globalComposer = null;
  16541. if (realpath($config->get('home')) !== $cwd) {
  16542. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins, $disableScripts);
  16543. }
  16544. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  16545. $composer->setPluginManager($pm);
  16546. $pm->loadInstalledPlugins();
  16547. }
  16548. if ($fullLoad && isset($composerFile)) {
  16549. $lockFile = self::getLockFile($composerFile);
  16550. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
  16551. $composer->setLocker($locker);
  16552. }
  16553. if ($fullLoad) {
  16554. $initEvent = new Event(PluginEvents::INIT);
  16555. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  16556. $this->purgePackages($rm->getLocalRepository(), $im);
  16557. }
  16558. return $composer;
  16559. }
  16560. public static function createGlobal(IOInterface $io, $disablePlugins = false, $disableScripts = false)
  16561. {
  16562. $factory = new static();
  16563. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, $disableScripts, true);
  16564. }
  16565. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage, ProcessExecutor $process = null)
  16566. {
  16567. $fs = null;
  16568. if ($process) {
  16569. $fs = new Filesystem($process);
  16570. }
  16571. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage, $fs));
  16572. }
  16573. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $disableScripts, $fullLoad = false)
  16574. {
  16575. $composer = null;
  16576. try {
  16577. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad, $disableScripts);
  16578. } catch (\Exception $e) {
  16579. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  16580. }
  16581. return $composer;
  16582. }
  16583. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null)
  16584. {
  16585. $cache = null;
  16586. if ($config->get('cache-files-ttl') > 0) {
  16587. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  16588. $cache->setReadOnly($config->get('cache-read-only'));
  16589. }
  16590. $fs = new Filesystem($process);
  16591. $dm = new Downloader\DownloadManager($io, false, $fs);
  16592. switch ($preferred = $config->get('preferred-install')) {
  16593. case 'dist':
  16594. $dm->setPreferDist(true);
  16595. break;
  16596. case 'source':
  16597. $dm->setPreferSource(true);
  16598. break;
  16599. case 'auto':
  16600. default:
  16601. break;
  16602. }
  16603. if (is_array($preferred)) {
  16604. $dm->setPreferences($preferred);
  16605. }
  16606. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  16607. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  16608. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  16609. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  16610. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  16611. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16612. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16613. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16614. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16615. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16616. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16617. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16618. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  16619. return $dm;
  16620. }
  16621. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  16622. {
  16623. $am = new Archiver\ArchiveManager($dm, $loop);
  16624. $am->addArchiver(new Archiver\ZipArchiver);
  16625. $am->addArchiver(new Archiver\PharArchiver);
  16626. return $am;
  16627. }
  16628. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  16629. {
  16630. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  16631. }
  16632. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  16633. {
  16634. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  16635. }
  16636. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  16637. {
  16638. $fs = new Filesystem($process);
  16639. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs, rtrim($composer->getConfig()->get('vendor-dir'), '/'));
  16640. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  16641. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  16642. $im->addInstaller(new Installer\MetapackageInstaller($io));
  16643. }
  16644. protected function purgePackages(InstalledRepositoryInterface $repo, Installer\InstallationManager $im)
  16645. {
  16646. foreach ($repo->getPackages() as $package) {
  16647. if (!$im->isPackageInstalled($repo, $package)) {
  16648. $repo->removePackage($package);
  16649. }
  16650. }
  16651. }
  16652. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
  16653. {
  16654. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  16655. }
  16656. public static function create(IOInterface $io, $config = null, $disablePlugins = false, $disableScripts = false)
  16657. {
  16658. $factory = new static();
  16659. return $factory->createComposer($io, $config, $disablePlugins, null, true, $disableScripts);
  16660. }
  16661. public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())
  16662. {
  16663. static $warned = false;
  16664. $disableTls = false;
  16665. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  16666. $warned = true;
  16667. $disableTls = !extension_loaded('openssl');
  16668. } elseif ($config->get('disable-tls') === true) {
  16669. if (!$warned) {
  16670. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  16671. }
  16672. $warned = true;
  16673. $disableTls = true;
  16674. } elseif (!extension_loaded('openssl')) {
  16675. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  16676. . '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.');
  16677. }
  16678. $httpDownloaderOptions = array();
  16679. if ($disableTls === false) {
  16680. if ($config->get('cafile')) {
  16681. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  16682. }
  16683. if ($config->get('capath')) {
  16684. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  16685. }
  16686. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  16687. }
  16688. try {
  16689. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  16690. } catch (TransportException $e) {
  16691. if (false !== strpos($e->getMessage(), 'cafile')) {
  16692. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  16693. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  16694. if (PHP_VERSION_ID < 50600) {
  16695. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  16696. }
  16697. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  16698. }
  16699. throw $e;
  16700. }
  16701. return $httpDownloader;
  16702. }
  16703. private static function useXdg()
  16704. {
  16705. foreach (array_keys($_SERVER) as $key) {
  16706. if (strpos($key, 'XDG_') === 0) {
  16707. return true;
  16708. }
  16709. }
  16710. if (Silencer::call('is_dir', '/etc/xdg')) {
  16711. return true;
  16712. }
  16713. return false;
  16714. }
  16715. private static function getUserDir()
  16716. {
  16717. $home = Platform::getEnv('HOME');
  16718. if (!$home) {
  16719. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  16720. }
  16721. return rtrim(strtr($home, '\\', '/'), '/');
  16722. }
  16723. }
  16724. <?php
  16725. namespace Composer\Filter\PlatformRequirementFilter;
  16726. use Composer\Repository\PlatformRepository;
  16727. final class IgnoreAllPlatformRequirementFilter implements PlatformRequirementFilterInterface
  16728. {
  16729. public function isIgnored($req)
  16730. {
  16731. return PlatformRepository::isPlatformPackage($req);
  16732. }
  16733. }
  16734. <?php
  16735. namespace Composer\Filter\PlatformRequirementFilter;
  16736. use Composer\Package\BasePackage;
  16737. use Composer\Pcre\Preg;
  16738. use Composer\Repository\PlatformRepository;
  16739. use Composer\Semver\Constraint\Constraint;
  16740. use Composer\Semver\Constraint\ConstraintInterface;
  16741. use Composer\Semver\Constraint\MatchAllConstraint;
  16742. use Composer\Semver\Constraint\MultiConstraint;
  16743. use Composer\Semver\Interval;
  16744. use Composer\Semver\Intervals;
  16745. final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFilterInterface
  16746. {
  16747. private $ignoreRegex;
  16748. private $ignoreUpperBoundRegex;
  16749. public function __construct(array $reqList)
  16750. {
  16751. $ignoreAll = $ignoreUpperBound = array();
  16752. foreach ($reqList as $req) {
  16753. if (substr($req, -1) === '+') {
  16754. $ignoreUpperBound[] = substr($req, 0, -1);
  16755. } else {
  16756. $ignoreAll[] = $req;
  16757. }
  16758. }
  16759. $this->ignoreRegex = BasePackage::packageNamesToRegexp($ignoreAll);
  16760. $this->ignoreUpperBoundRegex = BasePackage::packageNamesToRegexp($ignoreUpperBound);
  16761. }
  16762. public function isIgnored($req)
  16763. {
  16764. if (!PlatformRepository::isPlatformPackage($req)) {
  16765. return false;
  16766. }
  16767. return Preg::isMatch($this->ignoreRegex, $req);
  16768. }
  16769. public function filterConstraint($req, ConstraintInterface $constraint)
  16770. {
  16771. if (!PlatformRepository::isPlatformPackage($req)) {
  16772. return $constraint;
  16773. }
  16774. if (!Preg::isMatch($this->ignoreUpperBoundRegex, $req)) {
  16775. return $constraint;
  16776. }
  16777. if (Preg::isMatch($this->ignoreRegex, $req)) {
  16778. return new MatchAllConstraint;
  16779. }
  16780. $intervals = Intervals::get($constraint);
  16781. $last = end($intervals['numeric']);
  16782. if ($last !== false && (string) $last->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  16783. $constraint = new MultiConstraint(array($constraint, new Constraint('>=', $last->getEnd()->getVersion())), false);
  16784. }
  16785. return $constraint;
  16786. }
  16787. }
  16788. <?php
  16789. namespace Composer\Filter\PlatformRequirementFilter;
  16790. final class IgnoreNothingPlatformRequirementFilter implements PlatformRequirementFilterInterface
  16791. {
  16792. public function isIgnored($req)
  16793. {
  16794. return false;
  16795. }
  16796. }
  16797. <?php
  16798. namespace Composer\Filter\PlatformRequirementFilter;
  16799. final class PlatformRequirementFilterFactory
  16800. {
  16801. public static function fromBoolOrList($boolOrList)
  16802. {
  16803. if (is_bool($boolOrList)) {
  16804. return $boolOrList ? self::ignoreAll() : self::ignoreNothing();
  16805. }
  16806. if (is_array($boolOrList)) {
  16807. return new IgnoreListPlatformRequirementFilter($boolOrList);
  16808. }
  16809. throw new \InvalidArgumentException(
  16810. sprintf(
  16811. 'PlatformRequirementFilter: Unknown $boolOrList parameter %s. Please report at https://github.com/composer/composer/issues/new.',
  16812. gettype($boolOrList)
  16813. )
  16814. );
  16815. }
  16816. public static function ignoreAll()
  16817. {
  16818. return new IgnoreAllPlatformRequirementFilter();
  16819. }
  16820. public static function ignoreNothing()
  16821. {
  16822. return new IgnoreNothingPlatformRequirementFilter();
  16823. }
  16824. }
  16825. <?php
  16826. namespace Composer\Filter\PlatformRequirementFilter;
  16827. interface PlatformRequirementFilterInterface
  16828. {
  16829. public function isIgnored($req);
  16830. }
  16831. <?php
  16832. namespace Composer\IO;
  16833. use Composer\Config;
  16834. use Composer\Pcre\Preg;
  16835. use Composer\Util\ProcessExecutor;
  16836. use Psr\Log\LogLevel;
  16837. abstract class BaseIO implements IOInterface
  16838. {
  16839. protected $authentications = array();
  16840. public function getAuthentications()
  16841. {
  16842. return $this->authentications;
  16843. }
  16844. public function resetAuthentications()
  16845. {
  16846. $this->authentications = array();
  16847. }
  16848. public function hasAuthentication($repositoryName)
  16849. {
  16850. return isset($this->authentications[$repositoryName]);
  16851. }
  16852. public function getAuthentication($repositoryName)
  16853. {
  16854. if (isset($this->authentications[$repositoryName])) {
  16855. return $this->authentications[$repositoryName];
  16856. }
  16857. return array('username' => null, 'password' => null);
  16858. }
  16859. public function setAuthentication($repositoryName, $username, $password = null)
  16860. {
  16861. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  16862. }
  16863. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  16864. {
  16865. $this->write($messages, $newline, $verbosity);
  16866. }
  16867. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  16868. {
  16869. $this->writeError($messages, $newline, $verbosity);
  16870. }
  16871. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  16872. {
  16873. if ($this->hasAuthentication($repositoryName)) {
  16874. $auth = $this->getAuthentication($repositoryName);
  16875. if ($auth['username'] === $username && $auth['password'] === $password) {
  16876. return;
  16877. }
  16878. $this->writeError(
  16879. sprintf(
  16880. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  16881. $repositoryName
  16882. )
  16883. );
  16884. }
  16885. $this->setAuthentication($repositoryName, $username, $password);
  16886. }
  16887. public function loadConfiguration(Config $config)
  16888. {
  16889. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  16890. $githubOauth = $config->get('github-oauth') ?: array();
  16891. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  16892. $gitlabToken = $config->get('gitlab-token') ?: array();
  16893. $httpBasic = $config->get('http-basic') ?: array();
  16894. $bearerToken = $config->get('bearer') ?: array();
  16895. foreach ($bitbucketOauth as $domain => $cred) {
  16896. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  16897. }
  16898. foreach ($githubOauth as $domain => $token) {
  16899. if (!Preg::isMatch('{^[.A-Za-z0-9_]+$}', $token)) {
  16900. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  16901. }
  16902. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  16903. }
  16904. foreach ($gitlabOauth as $domain => $token) {
  16905. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  16906. }
  16907. foreach ($gitlabToken as $domain => $token) {
  16908. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  16909. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  16910. $this->checkAndSetAuthentication($domain, $username, $password);
  16911. }
  16912. foreach ($httpBasic as $domain => $cred) {
  16913. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  16914. }
  16915. foreach ($bearerToken as $domain => $token) {
  16916. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  16917. }
  16918. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  16919. }
  16920. public function emergency($message, array $context = array())
  16921. {
  16922. $this->log(LogLevel::EMERGENCY, $message, $context);
  16923. }
  16924. public function alert($message, array $context = array())
  16925. {
  16926. $this->log(LogLevel::ALERT, $message, $context);
  16927. }
  16928. public function critical($message, array $context = array())
  16929. {
  16930. $this->log(LogLevel::CRITICAL, $message, $context);
  16931. }
  16932. public function error($message, array $context = array())
  16933. {
  16934. $this->log(LogLevel::ERROR, $message, $context);
  16935. }
  16936. public function warning($message, array $context = array())
  16937. {
  16938. $this->log(LogLevel::WARNING, $message, $context);
  16939. }
  16940. public function notice($message, array $context = array())
  16941. {
  16942. $this->log(LogLevel::NOTICE, $message, $context);
  16943. }
  16944. public function info($message, array $context = array())
  16945. {
  16946. $this->log(LogLevel::INFO, $message, $context);
  16947. }
  16948. public function debug($message, array $context = array())
  16949. {
  16950. $this->log(LogLevel::DEBUG, $message, $context);
  16951. }
  16952. public function log($level, $message, array $context = array())
  16953. {
  16954. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  16955. $this->writeError('<error>'.$message.'</error>');
  16956. } elseif ($level === LogLevel::WARNING) {
  16957. $this->writeError('<warning>'.$message.'</warning>');
  16958. } elseif ($level === LogLevel::NOTICE) {
  16959. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  16960. } elseif ($level === LogLevel::INFO) {
  16961. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  16962. } else {
  16963. $this->writeError($message, true, self::DEBUG);
  16964. }
  16965. }
  16966. }
  16967. <?php
  16968. namespace Composer\IO;
  16969. use Composer\Pcre\Preg;
  16970. use Symfony\Component\Console\Helper\QuestionHelper;
  16971. use Symfony\Component\Console\Output\StreamOutput;
  16972. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  16973. use Symfony\Component\Console\Input\StreamableInputInterface;
  16974. use Symfony\Component\Console\Input\StringInput;
  16975. use Symfony\Component\Console\Helper\HelperSet;
  16976. class BufferIO extends ConsoleIO
  16977. {
  16978. protected $input;
  16979. protected $output;
  16980. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  16981. {
  16982. $input = new StringInput($input);
  16983. $input->setInteractive(false);
  16984. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  16985. parent::__construct($input, $output, new HelperSet(array(
  16986. new QuestionHelper(),
  16987. )));
  16988. }
  16989. public function getOutput()
  16990. {
  16991. fseek($this->output->getStream(), 0);
  16992. $output = stream_get_contents($this->output->getStream());
  16993. $output = Preg::replaceCallback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  16994. $pre = strip_tags($matches[1]);
  16995. if (strlen($pre) === strlen($matches[2])) {
  16996. return '';
  16997. }
  16998. return rtrim($matches[1])."\n";
  16999. }, $output);
  17000. return $output;
  17001. }
  17002. public function setUserInputs(array $inputs)
  17003. {
  17004. if (!$this->input instanceof StreamableInputInterface) {
  17005. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  17006. }
  17007. $this->input->setStream($this->createStream($inputs));
  17008. $this->input->setInteractive(true);
  17009. }
  17010. private function createStream(array $inputs)
  17011. {
  17012. $stream = fopen('php://memory', 'r+');
  17013. foreach ($inputs as $input) {
  17014. fwrite($stream, $input.PHP_EOL);
  17015. }
  17016. rewind($stream);
  17017. return $stream;
  17018. }
  17019. }
  17020. <?php
  17021. namespace Composer\IO;
  17022. use Composer\Question\StrictConfirmationQuestion;
  17023. use Symfony\Component\Console\Helper\HelperSet;
  17024. use Symfony\Component\Console\Helper\ProgressBar;
  17025. use Symfony\Component\Console\Input\InputInterface;
  17026. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  17027. use Symfony\Component\Console\Output\OutputInterface;
  17028. use Symfony\Component\Console\Question\ChoiceQuestion;
  17029. use Symfony\Component\Console\Question\Question;
  17030. class ConsoleIO extends BaseIO
  17031. {
  17032. protected $input;
  17033. protected $output;
  17034. protected $helperSet;
  17035. protected $lastMessage = '';
  17036. protected $lastMessageErr = '';
  17037. private $startTime;
  17038. private $verbosityMap;
  17039. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  17040. {
  17041. $this->input = $input;
  17042. $this->output = $output;
  17043. $this->helperSet = $helperSet;
  17044. $this->verbosityMap = array(
  17045. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  17046. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  17047. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  17048. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  17049. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  17050. );
  17051. }
  17052. public function enableDebugging($startTime)
  17053. {
  17054. $this->startTime = $startTime;
  17055. }
  17056. public function isInteractive()
  17057. {
  17058. return $this->input->isInteractive();
  17059. }
  17060. public function isDecorated()
  17061. {
  17062. return $this->output->isDecorated();
  17063. }
  17064. public function isVerbose()
  17065. {
  17066. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  17067. }
  17068. public function isVeryVerbose()
  17069. {
  17070. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  17071. }
  17072. public function isDebug()
  17073. {
  17074. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  17075. }
  17076. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  17077. {
  17078. $this->doWrite($messages, $newline, false, $verbosity);
  17079. }
  17080. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  17081. {
  17082. $this->doWrite($messages, $newline, true, $verbosity);
  17083. }
  17084. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  17085. {
  17086. $this->doWrite($messages, $newline, false, $verbosity, true);
  17087. }
  17088. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  17089. {
  17090. $this->doWrite($messages, $newline, true, $verbosity, true);
  17091. }
  17092. private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
  17093. {
  17094. $sfVerbosity = $this->verbosityMap[$verbosity];
  17095. if ($sfVerbosity > $this->output->getVerbosity()) {
  17096. return;
  17097. }
  17098. if ($raw) {
  17099. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  17100. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  17101. } else {
  17102. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  17103. }
  17104. }
  17105. if (null !== $this->startTime) {
  17106. $memoryUsage = memory_get_usage() / 1024 / 1024;
  17107. $timeSpent = microtime(true) - $this->startTime;
  17108. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  17109. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  17110. }, (array) $messages);
  17111. }
  17112. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  17113. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  17114. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  17115. return;
  17116. }
  17117. $this->output->write($messages, $newline, $sfVerbosity);
  17118. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  17119. }
  17120. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  17121. {
  17122. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  17123. }
  17124. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  17125. {
  17126. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  17127. }
  17128. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  17129. {
  17130. $messages = implode($newline ? "\n" : '', (array) $messages);
  17131. if (!isset($size)) {
  17132. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  17133. }
  17134. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  17135. $this->doWrite($messages, false, $stderr, $verbosity);
  17136. $fill = $size - strlen(strip_tags($messages));
  17137. if ($fill > 0) {
  17138. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  17139. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  17140. }
  17141. if ($newline) {
  17142. $this->doWrite('', true, $stderr, $verbosity);
  17143. }
  17144. if ($stderr) {
  17145. $this->lastMessageErr = $messages;
  17146. } else {
  17147. $this->lastMessage = $messages;
  17148. }
  17149. }
  17150. public function getProgressBar($max = 0)
  17151. {
  17152. return new ProgressBar($this->getErrorOutput(), $max);
  17153. }
  17154. public function ask($question, $default = null)
  17155. {
  17156. $helper = $this->helperSet->get('question');
  17157. $question = new Question($question, $default);
  17158. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17159. }
  17160. public function askConfirmation($question, $default = true)
  17161. {
  17162. $helper = $this->helperSet->get('question');
  17163. $question = new StrictConfirmationQuestion($question, $default);
  17164. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17165. }
  17166. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  17167. {
  17168. $helper = $this->helperSet->get('question');
  17169. $question = new Question($question, $default);
  17170. $question->setValidator($validator);
  17171. $question->setMaxAttempts($attempts);
  17172. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17173. }
  17174. public function askAndHideAnswer($question)
  17175. {
  17176. $helper = $this->helperSet->get('question');
  17177. $question = new Question($question);
  17178. $question->setHidden(true);
  17179. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  17180. }
  17181. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  17182. {
  17183. $helper = $this->helperSet->get('question');
  17184. $question = new ChoiceQuestion($question, $choices, $default);
  17185. $question->setMaxAttempts($attempts ?: null);
  17186. $question->setErrorMessage($errorMessage);
  17187. $question->setMultiselect($multiselect);
  17188. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  17189. if (!is_array($result)) {
  17190. return (string) array_search($result, $choices, true);
  17191. }
  17192. $results = array();
  17193. foreach ($choices as $index => $choice) {
  17194. if (in_array($choice, $result, true)) {
  17195. $results[] = (string) $index;
  17196. }
  17197. }
  17198. return $results;
  17199. }
  17200. private function getErrorOutput()
  17201. {
  17202. if ($this->output instanceof ConsoleOutputInterface) {
  17203. return $this->output->getErrorOutput();
  17204. }
  17205. return $this->output;
  17206. }
  17207. }
  17208. <?php
  17209. namespace Composer\IO;
  17210. use Composer\Config;
  17211. use Psr\Log\LoggerInterface;
  17212. interface IOInterface extends LoggerInterface
  17213. {
  17214. const QUIET = 1;
  17215. const NORMAL = 2;
  17216. const VERBOSE = 4;
  17217. const VERY_VERBOSE = 8;
  17218. const DEBUG = 16;
  17219. public function isInteractive();
  17220. public function isVerbose();
  17221. public function isVeryVerbose();
  17222. public function isDebug();
  17223. public function isDecorated();
  17224. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  17225. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  17226. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
  17227. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
  17228. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  17229. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  17230. public function ask($question, $default = null);
  17231. public function askConfirmation($question, $default = true);
  17232. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  17233. public function askAndHideAnswer($question);
  17234. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  17235. public function getAuthentications();
  17236. public function hasAuthentication($repositoryName);
  17237. public function getAuthentication($repositoryName);
  17238. public function setAuthentication($repositoryName, $username, $password = null);
  17239. public function loadConfiguration(Config $config);
  17240. }
  17241. <?php
  17242. namespace Composer\IO;
  17243. class NullIO extends BaseIO
  17244. {
  17245. public function isInteractive()
  17246. {
  17247. return false;
  17248. }
  17249. public function isVerbose()
  17250. {
  17251. return false;
  17252. }
  17253. public function isVeryVerbose()
  17254. {
  17255. return false;
  17256. }
  17257. public function isDebug()
  17258. {
  17259. return false;
  17260. }
  17261. public function isDecorated()
  17262. {
  17263. return false;
  17264. }
  17265. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  17266. {
  17267. }
  17268. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  17269. {
  17270. }
  17271. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  17272. {
  17273. }
  17274. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  17275. {
  17276. }
  17277. public function ask($question, $default = null)
  17278. {
  17279. return $default;
  17280. }
  17281. public function askConfirmation($question, $default = true)
  17282. {
  17283. return $default;
  17284. }
  17285. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  17286. {
  17287. return $default;
  17288. }
  17289. public function askAndHideAnswer($question)
  17290. {
  17291. return null;
  17292. }
  17293. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  17294. {
  17295. return $default;
  17296. }
  17297. }
  17298. <?php
  17299. namespace Composer;
  17300. use Composer\Autoload\AutoloadGenerator;
  17301. use Composer\Console\GithubActionError;
  17302. use Composer\DependencyResolver\DefaultPolicy;
  17303. use Composer\DependencyResolver\LocalRepoTransaction;
  17304. use Composer\DependencyResolver\LockTransaction;
  17305. use Composer\DependencyResolver\Operation\UpdateOperation;
  17306. use Composer\DependencyResolver\Operation\InstallOperation;
  17307. use Composer\DependencyResolver\Operation\UninstallOperation;
  17308. use Composer\DependencyResolver\PoolOptimizer;
  17309. use Composer\DependencyResolver\Pool;
  17310. use Composer\DependencyResolver\Request;
  17311. use Composer\DependencyResolver\Solver;
  17312. use Composer\DependencyResolver\SolverProblemsException;
  17313. use Composer\DependencyResolver\PolicyInterface;
  17314. use Composer\Downloader\DownloadManager;
  17315. use Composer\EventDispatcher\EventDispatcher;
  17316. use Composer\Filter\PlatformRequirementFilter\IgnoreListPlatformRequirementFilter;
  17317. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  17318. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  17319. use Composer\Installer\InstallationManager;
  17320. use Composer\Installer\InstallerEvents;
  17321. use Composer\Installer\SuggestedPackagesReporter;
  17322. use Composer\IO\IOInterface;
  17323. use Composer\Package\AliasPackage;
  17324. use Composer\Package\RootAliasPackage;
  17325. use Composer\Package\BasePackage;
  17326. use Composer\Package\CompletePackage;
  17327. use Composer\Package\CompletePackageInterface;
  17328. use Composer\Package\Link;
  17329. use Composer\Package\Loader\ArrayLoader;
  17330. use Composer\Package\Dumper\ArrayDumper;
  17331. use Composer\Package\Version\VersionParser;
  17332. use Composer\Package\Package;
  17333. use Composer\Repository\ArrayRepository;
  17334. use Composer\Repository\RepositorySet;
  17335. use Composer\Repository\CompositeRepository;
  17336. use Composer\Semver\Constraint\Constraint;
  17337. use Composer\Package\Locker;
  17338. use Composer\Package\RootPackageInterface;
  17339. use Composer\Repository\InstalledArrayRepository;
  17340. use Composer\Repository\InstalledRepositoryInterface;
  17341. use Composer\Repository\InstalledRepository;
  17342. use Composer\Repository\RootPackageRepository;
  17343. use Composer\Repository\PlatformRepository;
  17344. use Composer\Repository\RepositoryInterface;
  17345. use Composer\Repository\RepositoryManager;
  17346. use Composer\Repository\LockArrayRepository;
  17347. use Composer\Script\ScriptEvents;
  17348. use Composer\Util\Platform;
  17349. class Installer
  17350. {
  17351. const ERROR_NONE = 0;
  17352. const ERROR_GENERIC_FAILURE = 1;
  17353. const ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE = 3;
  17354. const ERROR_LOCK_FILE_INVALID = 4;
  17355. const ERROR_DEPENDENCY_RESOLUTION_FAILED = 2;
  17356. protected $io;
  17357. protected $config;
  17358. protected $package;
  17359. protected $fixedRootPackage;
  17360. protected $downloadManager;
  17361. protected $repositoryManager;
  17362. protected $locker;
  17363. protected $installationManager;
  17364. protected $eventDispatcher;
  17365. protected $autoloadGenerator;
  17366. protected $preferSource = false;
  17367. protected $preferDist = false;
  17368. protected $optimizeAutoloader = false;
  17369. protected $classMapAuthoritative = false;
  17370. protected $apcuAutoloader = false;
  17371. protected $apcuAutoloaderPrefix = null;
  17372. protected $devMode = false;
  17373. protected $dryRun = false;
  17374. protected $verbose = false;
  17375. protected $update = false;
  17376. protected $install = true;
  17377. protected $dumpAutoloader = true;
  17378. protected $runScripts = true;
  17379. protected $preferStable = false;
  17380. protected $preferLowest = false;
  17381. protected $writeLock;
  17382. protected $executeOperations = true;
  17383. protected $updateMirrors = false;
  17384. protected $updateAllowList = null;
  17385. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  17386. protected $suggestedPackagesReporter;
  17387. protected $platformRequirementFilter;
  17388. protected $additionalFixedRepository;
  17389. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  17390. {
  17391. $this->io = $io;
  17392. $this->config = $config;
  17393. $this->package = $package;
  17394. $this->downloadManager = $downloadManager;
  17395. $this->repositoryManager = $repositoryManager;
  17396. $this->locker = $locker;
  17397. $this->installationManager = $installationManager;
  17398. $this->eventDispatcher = $eventDispatcher;
  17399. $this->autoloadGenerator = $autoloadGenerator;
  17400. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  17401. $this->platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  17402. $this->writeLock = $config->get('lock');
  17403. }
  17404. public function run()
  17405. {
  17406. gc_collect_cycles();
  17407. gc_disable();
  17408. if ($this->updateAllowList && $this->updateMirrors) {
  17409. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  17410. }
  17411. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  17412. if (!$this->update && !$this->locker->isLocked()) {
  17413. $this->io->writeError('<warning>No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.</warning>');
  17414. $this->update = true;
  17415. }
  17416. if ($this->dryRun) {
  17417. $this->verbose = true;
  17418. $this->runScripts = false;
  17419. $this->executeOperations = false;
  17420. $this->writeLock = false;
  17421. $this->dumpAutoloader = false;
  17422. $this->mockLocalRepositories($this->repositoryManager);
  17423. }
  17424. if ($this->update && !$this->install) {
  17425. $this->dumpAutoloader = false;
  17426. }
  17427. if ($this->runScripts) {
  17428. Platform::putEnv('COMPOSER_DEV_MODE', $this->devMode ? '1' : '0');
  17429. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  17430. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  17431. }
  17432. $this->downloadManager->setPreferSource($this->preferSource);
  17433. $this->downloadManager->setPreferDist($this->preferDist);
  17434. $localRepo = $this->repositoryManager->getLocalRepository();
  17435. try {
  17436. if ($this->update) {
  17437. $res = $this->doUpdate($localRepo, $this->install);
  17438. } else {
  17439. $res = $this->doInstall($localRepo);
  17440. }
  17441. if ($res !== 0) {
  17442. return $res;
  17443. }
  17444. } catch (\Exception $e) {
  17445. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  17446. $this->installationManager->notifyInstalls($this->io);
  17447. }
  17448. throw $e;
  17449. }
  17450. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  17451. $this->installationManager->notifyInstalls($this->io);
  17452. }
  17453. if ($this->update) {
  17454. $installedRepo = new InstalledRepository(array(
  17455. $this->locker->getLockedRepository($this->devMode),
  17456. $this->createPlatformRepo(false),
  17457. new RootPackageRepository(clone $this->package),
  17458. ));
  17459. if ($isFreshInstall) {
  17460. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  17461. }
  17462. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  17463. }
  17464. $lockedRepository = $this->locker->getLockedRepository(true);
  17465. foreach ($lockedRepository->getPackages() as $package) {
  17466. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  17467. continue;
  17468. }
  17469. $replacement = is_string($package->getReplacementPackage())
  17470. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  17471. : 'No replacement was suggested';
  17472. $this->io->writeError(
  17473. sprintf(
  17474. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  17475. $package->getPrettyName(),
  17476. $replacement
  17477. )
  17478. );
  17479. }
  17480. if ($this->dumpAutoloader) {
  17481. if ($this->optimizeAutoloader) {
  17482. $this->io->writeError('<info>Generating optimized autoload files</info>');
  17483. } else {
  17484. $this->io->writeError('<info>Generating autoload files</info>');
  17485. }
  17486. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  17487. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  17488. $this->autoloadGenerator->setRunScripts($this->runScripts);
  17489. $this->autoloadGenerator->setPlatformRequirementFilter($this->platformRequirementFilter);
  17490. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  17491. }
  17492. if ($this->install && $this->executeOperations) {
  17493. foreach ($localRepo->getPackages() as $package) {
  17494. $this->installationManager->ensureBinariesPresence($package);
  17495. }
  17496. }
  17497. $fundingCount = 0;
  17498. foreach ($localRepo->getPackages() as $package) {
  17499. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  17500. $fundingCount++;
  17501. }
  17502. }
  17503. if ($fundingCount > 0) {
  17504. $this->io->writeError(array(
  17505. sprintf(
  17506. "<info>%d package%s you are using %s looking for funding.</info>",
  17507. $fundingCount,
  17508. 1 === $fundingCount ? '' : 's',
  17509. 1 === $fundingCount ? 'is' : 'are'
  17510. ),
  17511. '<info>Use the `composer fund` command to find out more!</info>',
  17512. ));
  17513. }
  17514. if ($this->runScripts) {
  17515. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  17516. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  17517. }
  17518. if (!defined('HHVM_VERSION')) {
  17519. gc_enable();
  17520. }
  17521. return 0;
  17522. }
  17523. protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
  17524. {
  17525. $platformRepo = $this->createPlatformRepo(true);
  17526. $aliases = $this->getRootAliases(true);
  17527. $lockedRepository = null;
  17528. try {
  17529. if ($this->locker->isLocked()) {
  17530. $lockedRepository = $this->locker->getLockedRepository(true);
  17531. }
  17532. } catch (\Seld\JsonLint\ParsingException $e) {
  17533. if ($this->updateAllowList || $this->updateMirrors) {
  17534. throw $e;
  17535. }
  17536. }
  17537. if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
  17538. $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);
  17539. return self::ERROR_NO_LOCK_FILE_FOR_PARTIAL_UPDATE;
  17540. }
  17541. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  17542. $policy = $this->createPolicy(true);
  17543. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  17544. $repositories = $this->repositoryManager->getRepositories();
  17545. foreach ($repositories as $repository) {
  17546. $repositorySet->addRepository($repository);
  17547. }
  17548. if ($lockedRepository) {
  17549. $repositorySet->addRepository($lockedRepository);
  17550. }
  17551. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  17552. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  17553. if ($this->updateAllowList) {
  17554. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  17555. }
  17556. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher, $this->createPoolOptimizer($policy));
  17557. $this->io->writeError('<info>Updating dependencies</info>');
  17558. $solver = new Solver($policy, $pool, $this->io);
  17559. try {
  17560. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  17561. $ruleSetSize = $solver->getRuleSetSize();
  17562. $solver = null;
  17563. } catch (SolverProblemsException $e) {
  17564. $err = 'Your requirements could not be resolved to an installable set of packages.';
  17565. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  17566. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  17567. $this->io->writeError($prettyProblem);
  17568. if (!$this->devMode) {
  17569. $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);
  17570. }
  17571. $ghe = new GithubActionError($this->io);
  17572. $ghe->emit($err."\n".$prettyProblem);
  17573. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  17574. }
  17575. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  17576. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  17577. $pool = null;
  17578. if (!$lockTransaction->getOperations()) {
  17579. $this->io->writeError('Nothing to modify in lock file');
  17580. }
  17581. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  17582. if ($exitCode !== 0) {
  17583. return $exitCode;
  17584. }
  17585. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  17586. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  17587. $installsUpdates = $uninstalls = array();
  17588. if ($lockTransaction->getOperations()) {
  17589. $installNames = $updateNames = $uninstallNames = array();
  17590. foreach ($lockTransaction->getOperations() as $operation) {
  17591. if ($operation instanceof InstallOperation) {
  17592. $installsUpdates[] = $operation;
  17593. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  17594. } elseif ($operation instanceof UpdateOperation) {
  17595. if ($this->updateMirrors
  17596. && $operation->getInitialPackage()->getName() == $operation->getTargetPackage()->getName()
  17597. && $operation->getInitialPackage()->getVersion() == $operation->getTargetPackage()->getVersion()
  17598. ) {
  17599. continue;
  17600. }
  17601. $installsUpdates[] = $operation;
  17602. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  17603. } elseif ($operation instanceof UninstallOperation) {
  17604. $uninstalls[] = $operation;
  17605. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  17606. }
  17607. }
  17608. $this->io->writeError(sprintf(
  17609. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  17610. count($installNames),
  17611. 1 === count($installNames) ? '' : 's',
  17612. count($updateNames),
  17613. 1 === count($updateNames) ? '' : 's',
  17614. count($uninstalls),
  17615. 1 === count($uninstalls) ? '' : 's'
  17616. ));
  17617. if ($installNames) {
  17618. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  17619. }
  17620. if ($updateNames) {
  17621. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  17622. }
  17623. if ($uninstalls) {
  17624. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  17625. }
  17626. }
  17627. $sortByName = function ($a, $b) {
  17628. if ($a instanceof UpdateOperation) {
  17629. $a = $a->getTargetPackage()->getName();
  17630. } else {
  17631. $a = $a->getPackage()->getName();
  17632. }
  17633. if ($b instanceof UpdateOperation) {
  17634. $b = $b->getTargetPackage()->getName();
  17635. } else {
  17636. $b = $b->getPackage()->getName();
  17637. }
  17638. return strcmp($a, $b);
  17639. };
  17640. usort($uninstalls, $sortByName);
  17641. usort($installsUpdates, $sortByName);
  17642. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  17643. if ($operation instanceof InstallOperation) {
  17644. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  17645. }
  17646. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  17647. $this->io->writeError(' - ' . $operation->show(true));
  17648. }
  17649. }
  17650. $updatedLock = $this->locker->setLockData(
  17651. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  17652. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  17653. $platformReqs,
  17654. $platformDevReqs,
  17655. $lockTransaction->getAliases($aliases),
  17656. $this->package->getMinimumStability(),
  17657. $this->package->getStabilityFlags(),
  17658. $this->preferStable || $this->package->getPreferStable(),
  17659. $this->preferLowest,
  17660. $this->config->get('platform') ?: array(),
  17661. $this->writeLock && $this->executeOperations
  17662. );
  17663. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  17664. $this->io->writeError('<info>Writing lock file</info>');
  17665. }
  17666. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  17667. $vendorDir = $this->config->get('vendor-dir');
  17668. if (is_dir($vendorDir)) {
  17669. @touch($vendorDir);
  17670. }
  17671. }
  17672. if ($doInstall) {
  17673. return $this->doInstall($localRepo, true);
  17674. }
  17675. return 0;
  17676. }
  17677. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null)
  17678. {
  17679. if (!$this->package->getDevRequires()) {
  17680. return 0;
  17681. }
  17682. $resultRepo = new ArrayRepository(array());
  17683. $loader = new ArrayLoader(null, true);
  17684. $dumper = new ArrayDumper();
  17685. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  17686. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  17687. }
  17688. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  17689. $repositorySet->addRepository($resultRepo);
  17690. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  17691. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  17692. $pool = $repositorySet->createPoolWithAllPackages();
  17693. $solver = new Solver($policy, $pool, $this->io);
  17694. try {
  17695. $nonDevLockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  17696. $solver = null;
  17697. } catch (SolverProblemsException $e) {
  17698. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  17699. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  17700. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  17701. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  17702. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  17703. $this->io->writeError($prettyProblem);
  17704. $ghe = new GithubActionError($this->io);
  17705. $ghe->emit($err."\n".$prettyProblem);
  17706. return $e->getCode();
  17707. }
  17708. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  17709. return 0;
  17710. }
  17711. protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false)
  17712. {
  17713. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  17714. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  17715. if (!$alreadySolved) {
  17716. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  17717. $platformRepo = $this->createPlatformRepo(false);
  17718. $policy = $this->createPolicy(false);
  17719. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  17720. $repositorySet->addRepository($lockedRepository);
  17721. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  17722. if (!$this->locker->isFresh()) {
  17723. $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);
  17724. }
  17725. foreach ($lockedRepository->getPackages() as $package) {
  17726. $request->fixLockedPackage($package);
  17727. }
  17728. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  17729. $request->requireName($link->getTarget(), $link->getConstraint());
  17730. }
  17731. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  17732. $solver = new Solver($policy, $pool, $this->io);
  17733. try {
  17734. $lockTransaction = $solver->solve($request, $this->platformRequirementFilter);
  17735. $solver = null;
  17736. if (0 !== count($lockTransaction->getOperations())) {
  17737. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  17738. return self::ERROR_LOCK_FILE_INVALID;
  17739. }
  17740. } catch (SolverProblemsException $e) {
  17741. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  17742. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  17743. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  17744. $this->io->writeError($prettyProblem);
  17745. $ghe = new GithubActionError($this->io);
  17746. $ghe->emit($err."\n".$prettyProblem);
  17747. return max(self::ERROR_GENERIC_FAILURE, $e->getCode());
  17748. }
  17749. }
  17750. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  17751. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  17752. if (!$localRepoTransaction->getOperations()) {
  17753. $this->io->writeError('Nothing to install, update or remove');
  17754. }
  17755. if ($localRepoTransaction->getOperations()) {
  17756. $installs = $updates = $uninstalls = array();
  17757. foreach ($localRepoTransaction->getOperations() as $operation) {
  17758. if ($operation instanceof InstallOperation) {
  17759. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  17760. } elseif ($operation instanceof UpdateOperation) {
  17761. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  17762. } elseif ($operation instanceof UninstallOperation) {
  17763. $uninstalls[] = $operation->getPackage()->getPrettyName();
  17764. }
  17765. }
  17766. $this->io->writeError(sprintf(
  17767. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  17768. count($installs),
  17769. 1 === count($installs) ? '' : 's',
  17770. count($updates),
  17771. 1 === count($updates) ? '' : 's',
  17772. count($uninstalls),
  17773. 1 === count($uninstalls) ? '' : 's'
  17774. ));
  17775. if ($installs) {
  17776. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  17777. }
  17778. if ($updates) {
  17779. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  17780. }
  17781. if ($uninstalls) {
  17782. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  17783. }
  17784. }
  17785. if ($this->executeOperations) {
  17786. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  17787. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  17788. } else {
  17789. foreach ($localRepoTransaction->getOperations() as $operation) {
  17790. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  17791. $this->io->writeError(' - ' . $operation->show(false));
  17792. }
  17793. }
  17794. }
  17795. return 0;
  17796. }
  17797. protected function createPlatformRepo($forUpdate)
  17798. {
  17799. if ($forUpdate) {
  17800. $platformOverrides = $this->config->get('platform') ?: array();
  17801. } else {
  17802. $platformOverrides = $this->locker->getPlatformOverrides();
  17803. }
  17804. return new PlatformRepository(array(), $platformOverrides);
  17805. }
  17806. private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
  17807. {
  17808. if ($forUpdate) {
  17809. $minimumStability = $this->package->getMinimumStability();
  17810. $stabilityFlags = $this->package->getStabilityFlags();
  17811. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  17812. } else {
  17813. $minimumStability = $this->locker->getMinimumStability();
  17814. $stabilityFlags = $this->locker->getStabilityFlags();
  17815. $requires = array();
  17816. foreach ($lockedRepository->getPackages() as $package) {
  17817. $constraint = new Constraint('=', $package->getVersion());
  17818. $constraint->setPrettyString($package->getPrettyVersion());
  17819. $requires[$package->getName()] = $constraint;
  17820. }
  17821. }
  17822. $rootRequires = array();
  17823. foreach ($requires as $req => $constraint) {
  17824. if ($constraint instanceof Link) {
  17825. $constraint = $constraint->getConstraint();
  17826. }
  17827. if ($this->platformRequirementFilter->isIgnored($req)) {
  17828. continue;
  17829. } elseif ($this->platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
  17830. $constraint = $this->platformRequirementFilter->filterConstraint($req, $constraint);
  17831. }
  17832. $rootRequires[$req] = $constraint;
  17833. }
  17834. $this->fixedRootPackage = clone $this->package;
  17835. $this->fixedRootPackage->setRequires(array());
  17836. $this->fixedRootPackage->setDevRequires(array());
  17837. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  17838. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  17839. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  17840. $repositorySet->addRepository($platformRepo);
  17841. if ($this->additionalFixedRepository) {
  17842. $additionalFixedRepositories = $this->additionalFixedRepository;
  17843. if ($additionalFixedRepositories instanceof CompositeRepository) {
  17844. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  17845. } else {
  17846. $additionalFixedRepositories = array($additionalFixedRepositories);
  17847. }
  17848. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  17849. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  17850. $repositorySet->allowInstalledRepositories();
  17851. break;
  17852. }
  17853. }
  17854. $repositorySet->addRepository($this->additionalFixedRepository);
  17855. }
  17856. return $repositorySet;
  17857. }
  17858. private function createPolicy($forUpdate)
  17859. {
  17860. $preferStable = null;
  17861. $preferLowest = null;
  17862. if (!$forUpdate) {
  17863. $preferStable = $this->locker->getPreferStable();
  17864. $preferLowest = $this->locker->getPreferLowest();
  17865. }
  17866. if (null === $preferStable) {
  17867. $preferStable = $this->preferStable || $this->package->getPreferStable();
  17868. }
  17869. if (null === $preferLowest) {
  17870. $preferLowest = $this->preferLowest;
  17871. }
  17872. return new DefaultPolicy($preferStable, $preferLowest);
  17873. }
  17874. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null)
  17875. {
  17876. $request = new Request($lockedRepository);
  17877. $request->fixPackage($rootPackage);
  17878. if ($rootPackage instanceof RootAliasPackage) {
  17879. $request->fixPackage($rootPackage->getAliasOf());
  17880. }
  17881. $fixedPackages = $platformRepo->getPackages();
  17882. if ($this->additionalFixedRepository) {
  17883. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  17884. }
  17885. $provided = $rootPackage->getProvides();
  17886. foreach ($fixedPackages as $package) {
  17887. if ($package->getRepository() !== $platformRepo
  17888. || !isset($provided[$package->getName()])
  17889. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  17890. ) {
  17891. $request->fixPackage($package);
  17892. }
  17893. }
  17894. return $request;
  17895. }
  17896. private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true)
  17897. {
  17898. if ($this->updateMirrors) {
  17899. $excludedPackages = array();
  17900. if (!$includeDevRequires) {
  17901. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  17902. }
  17903. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  17904. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  17905. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  17906. }
  17907. }
  17908. } else {
  17909. $links = $this->package->getRequires();
  17910. if ($includeDevRequires) {
  17911. $links = array_merge($links, $this->package->getDevRequires());
  17912. }
  17913. foreach ($links as $link) {
  17914. $request->requireName($link->getTarget(), $link->getConstraint());
  17915. }
  17916. }
  17917. }
  17918. private function getRootAliases($forUpdate)
  17919. {
  17920. if ($forUpdate) {
  17921. $aliases = $this->package->getAliases();
  17922. } else {
  17923. $aliases = $this->locker->getAliases();
  17924. }
  17925. return $aliases;
  17926. }
  17927. private function extractPlatformRequirements(array $links)
  17928. {
  17929. $platformReqs = array();
  17930. foreach ($links as $link) {
  17931. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  17932. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  17933. }
  17934. }
  17935. return $platformReqs;
  17936. }
  17937. private function mockLocalRepositories(RepositoryManager $rm)
  17938. {
  17939. $packages = array();
  17940. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  17941. $packages[(string) $package] = clone $package;
  17942. }
  17943. foreach ($packages as $key => $package) {
  17944. if ($package instanceof AliasPackage) {
  17945. $alias = (string) $package->getAliasOf();
  17946. $className = get_class($package);
  17947. $packages[$key] = new $className($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  17948. }
  17949. }
  17950. $rm->setLocalRepository(
  17951. new InstalledArrayRepository($packages)
  17952. );
  17953. }
  17954. private function createPoolOptimizer(PolicyInterface $policy)
  17955. {
  17956. if ('0' === Platform::getEnv('COMPOSER_POOL_OPTIMIZER')) {
  17957. $this->io->write('Pool Optimizer was disabled for debugging purposes.', true, IOInterface::DEBUG);
  17958. return null;
  17959. }
  17960. return new PoolOptimizer($policy);
  17961. }
  17962. public static function create(IOInterface $io, Composer $composer)
  17963. {
  17964. return new static(
  17965. $io,
  17966. $composer->getConfig(),
  17967. $composer->getPackage(),
  17968. $composer->getDownloadManager(),
  17969. $composer->getRepositoryManager(),
  17970. $composer->getLocker(),
  17971. $composer->getInstallationManager(),
  17972. $composer->getEventDispatcher(),
  17973. $composer->getAutoloadGenerator()
  17974. );
  17975. }
  17976. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository)
  17977. {
  17978. $this->additionalFixedRepository = $additionalFixedRepository;
  17979. return $this;
  17980. }
  17981. public function setDryRun($dryRun = true)
  17982. {
  17983. $this->dryRun = (bool) $dryRun;
  17984. return $this;
  17985. }
  17986. public function isDryRun()
  17987. {
  17988. return $this->dryRun;
  17989. }
  17990. public function setPreferSource($preferSource = true)
  17991. {
  17992. $this->preferSource = (bool) $preferSource;
  17993. return $this;
  17994. }
  17995. public function setPreferDist($preferDist = true)
  17996. {
  17997. $this->preferDist = (bool) $preferDist;
  17998. return $this;
  17999. }
  18000. public function setOptimizeAutoloader($optimizeAutoloader)
  18001. {
  18002. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  18003. if (!$this->optimizeAutoloader) {
  18004. $this->setClassMapAuthoritative(false);
  18005. }
  18006. return $this;
  18007. }
  18008. public function setClassMapAuthoritative($classMapAuthoritative)
  18009. {
  18010. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  18011. if ($this->classMapAuthoritative) {
  18012. $this->setOptimizeAutoloader(true);
  18013. }
  18014. return $this;
  18015. }
  18016. public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
  18017. {
  18018. $this->apcuAutoloader = $apcuAutoloader;
  18019. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  18020. return $this;
  18021. }
  18022. public function setUpdate($update)
  18023. {
  18024. $this->update = (bool) $update;
  18025. return $this;
  18026. }
  18027. public function setInstall($install)
  18028. {
  18029. $this->install = (bool) $install;
  18030. return $this;
  18031. }
  18032. public function setDevMode($devMode = true)
  18033. {
  18034. $this->devMode = (bool) $devMode;
  18035. return $this;
  18036. }
  18037. public function setDumpAutoloader($dumpAutoloader = true)
  18038. {
  18039. $this->dumpAutoloader = (bool) $dumpAutoloader;
  18040. return $this;
  18041. }
  18042. public function setRunScripts($runScripts = true)
  18043. {
  18044. $this->runScripts = (bool) $runScripts;
  18045. return $this;
  18046. }
  18047. public function setConfig(Config $config)
  18048. {
  18049. $this->config = $config;
  18050. return $this;
  18051. }
  18052. public function setVerbose($verbose = true)
  18053. {
  18054. $this->verbose = (bool) $verbose;
  18055. return $this;
  18056. }
  18057. public function isVerbose()
  18058. {
  18059. return $this->verbose;
  18060. }
  18061. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  18062. {
  18063. trigger_error('Installer::setIgnorePlatformRequirements is deprecated since Composer 2.2, use setPlatformRequirementFilter instead.', E_USER_DEPRECATED);
  18064. return $this->setPlatformRequirementFilter(PlatformRequirementFilterFactory::fromBoolOrList($ignorePlatformReqs));
  18065. }
  18066. public function setPlatformRequirementFilter(PlatformRequirementFilterInterface $platformRequirementFilter)
  18067. {
  18068. $this->platformRequirementFilter = $platformRequirementFilter;
  18069. return $this;
  18070. }
  18071. public function setUpdateMirrors($updateMirrors)
  18072. {
  18073. $this->updateMirrors = $updateMirrors;
  18074. return $this;
  18075. }
  18076. public function setUpdateAllowList(array $packages)
  18077. {
  18078. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  18079. return $this;
  18080. }
  18081. public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  18082. {
  18083. 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)) {
  18084. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  18085. }
  18086. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  18087. return $this;
  18088. }
  18089. public function setPreferStable($preferStable = true)
  18090. {
  18091. $this->preferStable = (bool) $preferStable;
  18092. return $this;
  18093. }
  18094. public function setPreferLowest($preferLowest = true)
  18095. {
  18096. $this->preferLowest = (bool) $preferLowest;
  18097. return $this;
  18098. }
  18099. public function setWriteLock($writeLock = true)
  18100. {
  18101. $this->writeLock = (bool) $writeLock;
  18102. return $this;
  18103. }
  18104. public function setExecuteOperations($executeOperations = true)
  18105. {
  18106. $this->executeOperations = (bool) $executeOperations;
  18107. return $this;
  18108. }
  18109. public function disablePlugins()
  18110. {
  18111. $this->installationManager->disablePlugins();
  18112. return $this;
  18113. }
  18114. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  18115. {
  18116. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  18117. return $this;
  18118. }
  18119. }
  18120. <?php
  18121. namespace Composer\Installer;
  18122. use Composer\IO\IOInterface;
  18123. use Composer\Package\PackageInterface;
  18124. use Composer\Pcre\Preg;
  18125. use Composer\Util\Filesystem;
  18126. use Composer\Util\Platform;
  18127. use Composer\Util\ProcessExecutor;
  18128. use Composer\Util\Silencer;
  18129. class BinaryInstaller
  18130. {
  18131. protected $binDir;
  18132. protected $binCompat;
  18133. protected $io;
  18134. protected $filesystem;
  18135. private $vendorDir;
  18136. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null, $vendorDir = null)
  18137. {
  18138. $this->binDir = $binDir;
  18139. $this->binCompat = $binCompat;
  18140. $this->io = $io;
  18141. $this->filesystem = $filesystem ?: new Filesystem();
  18142. $this->vendorDir = $vendorDir;
  18143. }
  18144. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  18145. {
  18146. $binaries = $this->getBinaries($package);
  18147. if (!$binaries) {
  18148. return;
  18149. }
  18150. Platform::workaroundFilesystemIssues();
  18151. foreach ($binaries as $bin) {
  18152. $binPath = $installPath.'/'.$bin;
  18153. if (!file_exists($binPath)) {
  18154. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  18155. continue;
  18156. }
  18157. if (is_dir($binPath)) {
  18158. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': found a directory at that path</warning>');
  18159. continue;
  18160. }
  18161. if (!$this->filesystem->isAbsolutePath($binPath)) {
  18162. $binPath = realpath($binPath);
  18163. }
  18164. $this->initializeBinDir();
  18165. $link = $this->binDir.'/'.basename($bin);
  18166. if (file_exists($link)) {
  18167. if (!is_link($link)) {
  18168. if ($warnOnOverwrite) {
  18169. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  18170. }
  18171. continue;
  18172. }
  18173. if (realpath($link) === realpath($binPath)) {
  18174. $this->filesystem->unlink($link);
  18175. }
  18176. }
  18177. $binCompat = $this->binCompat;
  18178. if ($binCompat === "auto" && (Platform::isWindows() || Platform::isWindowsSubsystemForLinux())) {
  18179. $binCompat = 'full';
  18180. }
  18181. if ($binCompat === "full") {
  18182. $this->installFullBinaries($binPath, $link, $bin, $package);
  18183. } else {
  18184. $this->installUnixyProxyBinaries($binPath, $link);
  18185. }
  18186. Silencer::call('chmod', $binPath, 0777 & ~umask());
  18187. }
  18188. }
  18189. public function removeBinaries(PackageInterface $package)
  18190. {
  18191. $this->initializeBinDir();
  18192. $binaries = $this->getBinaries($package);
  18193. if (!$binaries) {
  18194. return;
  18195. }
  18196. foreach ($binaries as $bin) {
  18197. $link = $this->binDir.'/'.basename($bin);
  18198. if (is_link($link) || file_exists($link)) {
  18199. $this->filesystem->unlink($link);
  18200. }
  18201. if (is_file($link.'.bat')) {
  18202. $this->filesystem->unlink($link.'.bat');
  18203. }
  18204. }
  18205. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  18206. Silencer::call('rmdir', $this->binDir);
  18207. }
  18208. }
  18209. public static function determineBinaryCaller($bin)
  18210. {
  18211. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  18212. return 'call';
  18213. }
  18214. $handle = fopen($bin, 'r');
  18215. $line = fgets($handle);
  18216. fclose($handle);
  18217. if (Preg::isMatch('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  18218. return trim($match[1]);
  18219. }
  18220. return 'php';
  18221. }
  18222. protected function getBinaries(PackageInterface $package)
  18223. {
  18224. return $package->getBinaries();
  18225. }
  18226. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  18227. {
  18228. if ('.bat' !== substr($binPath, -4)) {
  18229. $this->installUnixyProxyBinaries($binPath, $link);
  18230. $link .= '.bat';
  18231. if (file_exists($link)) {
  18232. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  18233. }
  18234. }
  18235. if (!file_exists($link)) {
  18236. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  18237. Silencer::call('chmod', $link, 0777 & ~umask());
  18238. }
  18239. }
  18240. protected function installUnixyProxyBinaries($binPath, $link)
  18241. {
  18242. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  18243. Silencer::call('chmod', $link, 0777 & ~umask());
  18244. }
  18245. protected function initializeBinDir()
  18246. {
  18247. $this->filesystem->ensureDirectoryExists($this->binDir);
  18248. $this->binDir = realpath($this->binDir);
  18249. }
  18250. protected function generateWindowsProxyCode($bin, $link)
  18251. {
  18252. $binPath = $this->filesystem->findShortestPath($link, $bin);
  18253. $caller = self::determineBinaryCaller($bin);
  18254. if ($caller === 'php') {
  18255. return "@ECHO OFF\r\n".
  18256. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  18257. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape(basename($link, '.bat')), '"\'')."\r\n".
  18258. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  18259. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  18260. }
  18261. return "@ECHO OFF\r\n".
  18262. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  18263. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  18264. "SET COMPOSER_RUNTIME_BIN_DIR=%~dp0\r\n".
  18265. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  18266. }
  18267. protected function generateUnixyProxyCode($bin, $link)
  18268. {
  18269. $binPath = $this->filesystem->findShortestPath($link, $bin);
  18270. $binDir = ProcessExecutor::escape(dirname($binPath));
  18271. $binFile = basename($binPath);
  18272. $binContents = file_get_contents($bin);
  18273. if (Preg::isMatch('{^(#!.*\r?\n)?[\r\n\t ]*<\?php}', $binContents, $match)) {
  18274. $proxyCode = empty($match[1]) ? '#!/usr/bin/env php' : trim($match[1]);
  18275. $binPathExported = $this->filesystem->findShortestPathCode($link, $bin, false, true);
  18276. $streamProxyCode = $streamHint = '';
  18277. $globalsCode = '$GLOBALS[\'_composer_bin_dir\'] = __DIR__;'."\n";
  18278. $phpunitHack1 = $phpunitHack2 = '';
  18279. if ($this->vendorDir) {
  18280. $globalsCode .= '$GLOBALS[\'_composer_autoload_path\'] = ' . $this->filesystem->findShortestPathCode($link, $this->vendorDir . '/autoload.php', false, true).";\n";
  18281. }
  18282. if ($this->filesystem->normalizePath($bin) === $this->filesystem->normalizePath($this->vendorDir.'/phpunit/phpunit/phpunit')) {
  18283. $globalsCode .= '$GLOBALS[\'__PHPUNIT_ISOLATION_EXCLUDE_LIST\'] = $GLOBALS[\'__PHPUNIT_ISOLATION_BLACKLIST\'] = array(realpath('.$binPathExported.'));'."\n";
  18284. $phpunitHack1 = "'phpvfscomposer://'.";
  18285. $phpunitHack2 = '
  18286. $data = str_replace(\'__DIR__\', var_export(dirname($this->realpath), true), $data);
  18287. $data = str_replace(\'__FILE__\', var_export($this->realpath, true), $data);';
  18288. }
  18289. if (trim($match[0]) !== '<?php') {
  18290. $streamHint = ' using a stream wrapper to prevent the shebang from being output on PHP<8'."\n *";
  18291. $streamProxyCode = <<<STREAMPROXY
  18292. if (PHP_VERSION_ID < 80000) {
  18293. if (!class_exists('Composer\BinProxyWrapper')) {
  18294. /**
  18295. * @internal
  18296. */
  18297. final class BinProxyWrapper
  18298. {
  18299. private \$handle;
  18300. private \$position;
  18301. private \$realpath;
  18302. public function stream_open(\$path, \$mode, \$options, &\$opened_path)
  18303. {
  18304. // get rid of phpvfscomposer:// prefix for __FILE__ & __DIR__ resolution
  18305. \$opened_path = substr(\$path, 17);
  18306. \$this->realpath = realpath(\$opened_path) ?: \$opened_path;
  18307. \$opened_path = $phpunitHack1\$this->realpath;
  18308. \$this->handle = fopen(\$this->realpath, \$mode);
  18309. \$this->position = 0;
  18310. return (bool) \$this->handle;
  18311. }
  18312. public function stream_read(\$count)
  18313. {
  18314. \$data = fread(\$this->handle, \$count);
  18315. if (\$this->position === 0) {
  18316. \$data = preg_replace('{^#!.*\\r?\\n}', '', \$data);
  18317. }$phpunitHack2
  18318. \$this->position += strlen(\$data);
  18319. return \$data;
  18320. }
  18321. public function stream_cast(\$castAs)
  18322. {
  18323. return \$this->handle;
  18324. }
  18325. public function stream_close()
  18326. {
  18327. fclose(\$this->handle);
  18328. }
  18329. public function stream_lock(\$operation)
  18330. {
  18331. return \$operation ? flock(\$this->handle, \$operation) : true;
  18332. }
  18333. public function stream_seek(\$offset, \$whence)
  18334. {
  18335. if (0 === fseek(\$this->handle, \$offset, \$whence)) {
  18336. \$this->position = ftell(\$this->handle);
  18337. return true;
  18338. }
  18339. return false;
  18340. }
  18341. public function stream_tell()
  18342. {
  18343. return \$this->position;
  18344. }
  18345. public function stream_eof()
  18346. {
  18347. return feof(\$this->handle);
  18348. }
  18349. public function stream_stat()
  18350. {
  18351. return array();
  18352. }
  18353. public function stream_set_option(\$option, \$arg1, \$arg2)
  18354. {
  18355. return true;
  18356. }
  18357. public function url_stat(\$path, \$flags)
  18358. {
  18359. \$path = substr(\$path, 17);
  18360. if (file_exists(\$path)) {
  18361. return stat(\$path);
  18362. }
  18363. return false;
  18364. }
  18365. }
  18366. }
  18367. if (function_exists('stream_wrapper_register') && stream_wrapper_register('phpvfscomposer', 'Composer\BinProxyWrapper')) {
  18368. include("phpvfscomposer://" . $binPathExported);
  18369. exit(0);
  18370. }
  18371. }
  18372. STREAMPROXY;
  18373. }
  18374. return $proxyCode . "\n" . <<<PROXY
  18375. <?php
  18376. /**
  18377. * Proxy PHP file generated by Composer
  18378. *
  18379. * This file includes the referenced bin path ($binPath)
  18380. *$streamHint
  18381. * @generated
  18382. */
  18383. namespace Composer;
  18384. $globalsCode
  18385. $streamProxyCode
  18386. include $binPathExported;
  18387. PROXY;
  18388. }
  18389. return <<<PROXY
  18390. #!/usr/bin/env sh
  18391. # Support bash to support `source` with fallback on $0 if this does not run with bash
  18392. # https://stackoverflow.com/a/35006505/6512
  18393. selfArg="\$BASH_SOURCE"
  18394. if [ -z "\$selfArg" ]; then
  18395. selfArg="\$0"
  18396. fi
  18397. self=\$(realpath \$selfArg 2> /dev/null)
  18398. if [ -z "\$self" ]; then
  18399. self="\$selfArg"
  18400. fi
  18401. dir=\$(cd "\${self%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  18402. if [ -d /proc/cygdrive ]; then
  18403. case \$(which php) in
  18404. \$(readlink -n /proc/cygdrive)/*)
  18405. # We are in Cygwin using Windows php, so the path must be translated
  18406. dir=\$(cygpath -m "\$dir");
  18407. ;;
  18408. esac
  18409. fi
  18410. export COMPOSER_RUNTIME_BIN_DIR=\$(cd "\${self%[/\\\\]*}" > /dev/null; pwd)
  18411. # If bash is sourcing this file, we have to source the target as well
  18412. bashSource="\$BASH_SOURCE"
  18413. if [ -n "\$bashSource" ]; then
  18414. if [ "\$bashSource" != "\$0" ]; then
  18415. source "\${dir}/$binFile" "\$@"
  18416. return
  18417. fi
  18418. fi
  18419. "\${dir}/$binFile" "\$@"
  18420. PROXY;
  18421. }
  18422. }
  18423. <?php
  18424. namespace Composer\Installer;
  18425. use Composer\Package\PackageInterface;
  18426. interface BinaryPresenceInterface
  18427. {
  18428. public function ensureBinariesPresence(PackageInterface $package);
  18429. }
  18430. <?php
  18431. namespace Composer\Installer;
  18432. use Composer\IO\IOInterface;
  18433. use Composer\IO\ConsoleIO;
  18434. use Composer\Package\PackageInterface;
  18435. use Composer\Package\AliasPackage;
  18436. use Composer\Repository\InstalledRepositoryInterface;
  18437. use Composer\DependencyResolver\Operation\OperationInterface;
  18438. use Composer\DependencyResolver\Operation\InstallOperation;
  18439. use Composer\DependencyResolver\Operation\UpdateOperation;
  18440. use Composer\DependencyResolver\Operation\UninstallOperation;
  18441. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  18442. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  18443. use Composer\Downloader\FileDownloader;
  18444. use Composer\EventDispatcher\EventDispatcher;
  18445. use Composer\Util\Loop;
  18446. use Composer\Util\Platform;
  18447. use React\Promise\PromiseInterface;
  18448. class InstallationManager
  18449. {
  18450. private $installers = array();
  18451. private $cache = array();
  18452. private $notifiablePackages = array();
  18453. private $loop;
  18454. private $io;
  18455. private $eventDispatcher;
  18456. private $outputProgress;
  18457. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  18458. {
  18459. $this->loop = $loop;
  18460. $this->io = $io;
  18461. $this->eventDispatcher = $eventDispatcher;
  18462. }
  18463. public function reset()
  18464. {
  18465. $this->notifiablePackages = array();
  18466. FileDownloader::$downloadMetadata = array();
  18467. }
  18468. public function addInstaller(InstallerInterface $installer)
  18469. {
  18470. array_unshift($this->installers, $installer);
  18471. $this->cache = array();
  18472. }
  18473. public function removeInstaller(InstallerInterface $installer)
  18474. {
  18475. if (false !== ($key = array_search($installer, $this->installers, true))) {
  18476. array_splice($this->installers, $key, 1);
  18477. $this->cache = array();
  18478. }
  18479. }
  18480. public function disablePlugins()
  18481. {
  18482. foreach ($this->installers as $i => $installer) {
  18483. if (!$installer instanceof PluginInstaller) {
  18484. continue;
  18485. }
  18486. unset($this->installers[$i]);
  18487. }
  18488. }
  18489. public function getInstaller($type)
  18490. {
  18491. $type = strtolower($type);
  18492. if (isset($this->cache[$type])) {
  18493. return $this->cache[$type];
  18494. }
  18495. foreach ($this->installers as $installer) {
  18496. if ($installer->supports($type)) {
  18497. return $this->cache[$type] = $installer;
  18498. }
  18499. }
  18500. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  18501. }
  18502. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  18503. {
  18504. if ($package instanceof AliasPackage) {
  18505. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  18506. }
  18507. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  18508. }
  18509. public function ensureBinariesPresence(PackageInterface $package)
  18510. {
  18511. try {
  18512. $installer = $this->getInstaller($package->getType());
  18513. } catch (\InvalidArgumentException $e) {
  18514. return;
  18515. }
  18516. if ($installer instanceof BinaryPresenceInterface) {
  18517. $installer->ensureBinariesPresence($package);
  18518. }
  18519. }
  18520. public function execute(InstalledRepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
  18521. {
  18522. $cleanupPromises = array();
  18523. $loop = $this->loop;
  18524. $io = $this->io;
  18525. $runCleanup = function () use (&$cleanupPromises, $loop) {
  18526. $promises = array();
  18527. $loop->abortJobs();
  18528. foreach ($cleanupPromises as $cleanup) {
  18529. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup) {
  18530. $promise = $cleanup();
  18531. if (!$promise instanceof PromiseInterface) {
  18532. $resolve();
  18533. } else {
  18534. $promise->then(function () use ($resolve) {
  18535. $resolve();
  18536. });
  18537. }
  18538. });
  18539. }
  18540. if (!empty($promises)) {
  18541. $loop->wait($promises);
  18542. }
  18543. };
  18544. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  18545. $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli';
  18546. $prevHandler = null;
  18547. $windowsHandler = null;
  18548. if ($handleInterruptsUnix) {
  18549. pcntl_async_signals(true);
  18550. $prevHandler = pcntl_signal_get_handler(SIGINT);
  18551. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io) {
  18552. $io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);
  18553. $runCleanup();
  18554. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  18555. call_user_func($prevHandler, $sig);
  18556. }
  18557. exit(130);
  18558. });
  18559. }
  18560. if ($handleInterruptsWindows) {
  18561. $windowsHandler = function ($event) use ($runCleanup, $io) {
  18562. if ($event !== PHP_WINDOWS_EVENT_CTRL_C) {
  18563. return;
  18564. }
  18565. $io->writeError('Received CTRL+C, aborting', true, IOInterface::DEBUG);
  18566. $runCleanup();
  18567. exit(130);
  18568. };
  18569. sapi_windows_set_ctrl_handler($windowsHandler);
  18570. }
  18571. try {
  18572. $batches = array();
  18573. $batch = array();
  18574. foreach ($operations as $index => $operation) {
  18575. if ($operation instanceof UpdateOperation || $operation instanceof InstallOperation) {
  18576. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  18577. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  18578. if ($batch) {
  18579. $batches[] = $batch;
  18580. }
  18581. $batches[] = array($index => $operation);
  18582. $batch = array();
  18583. continue;
  18584. }
  18585. }
  18586. $batch[$index] = $operation;
  18587. }
  18588. if ($batch) {
  18589. $batches[] = $batch;
  18590. }
  18591. foreach ($batches as $batch) {
  18592. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  18593. }
  18594. } catch (\Exception $e) {
  18595. $runCleanup();
  18596. if ($handleInterruptsUnix) {
  18597. pcntl_signal(SIGINT, $prevHandler);
  18598. }
  18599. if ($handleInterruptsWindows) {
  18600. sapi_windows_set_ctrl_handler($windowsHandler, false);
  18601. }
  18602. throw $e;
  18603. }
  18604. if ($handleInterruptsUnix) {
  18605. pcntl_signal(SIGINT, $prevHandler);
  18606. }
  18607. if ($handleInterruptsWindows) {
  18608. sapi_windows_set_ctrl_handler($windowsHandler, false);
  18609. }
  18610. $repo->write($devMode, $this);
  18611. }
  18612. private function downloadAndExecuteBatch(InstalledRepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
  18613. {
  18614. $promises = array();
  18615. foreach ($operations as $index => $operation) {
  18616. $opType = $operation->getOperationType();
  18617. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  18618. continue;
  18619. }
  18620. if ($opType === 'update') {
  18621. $package = $operation->getTargetPackage();
  18622. $initialPackage = $operation->getInitialPackage();
  18623. } else {
  18624. $package = $operation->getPackage();
  18625. $initialPackage = null;
  18626. }
  18627. $installer = $this->getInstaller($package->getType());
  18628. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  18629. if (!$package->getInstallationSource()) {
  18630. return;
  18631. }
  18632. return $installer->cleanup($opType, $package, $initialPackage);
  18633. };
  18634. if ($opType !== 'uninstall') {
  18635. $promise = $installer->download($package, $initialPackage);
  18636. if ($promise) {
  18637. $promises[] = $promise;
  18638. }
  18639. }
  18640. }
  18641. if (count($promises)) {
  18642. $this->waitOnPromises($promises);
  18643. }
  18644. $batches = array();
  18645. $batch = array();
  18646. foreach ($operations as $index => $operation) {
  18647. if ($operation instanceof InstallOperation || $operation instanceof UpdateOperation) {
  18648. $package = $operation instanceof UpdateOperation ? $operation->getTargetPackage() : $operation->getPackage();
  18649. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  18650. if ($batch) {
  18651. $batches[] = $batch;
  18652. }
  18653. $batches[] = array($index => $operation);
  18654. $batch = array();
  18655. continue;
  18656. }
  18657. }
  18658. $batch[$index] = $operation;
  18659. }
  18660. if ($batch) {
  18661. $batches[] = $batch;
  18662. }
  18663. foreach ($batches as $batch) {
  18664. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  18665. }
  18666. }
  18667. private function executeBatch(InstalledRepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
  18668. {
  18669. $promises = array();
  18670. $postExecCallbacks = array();
  18671. foreach ($operations as $index => $operation) {
  18672. $opType = $operation->getOperationType();
  18673. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  18674. if ($this->io->isDebug()) {
  18675. $this->io->writeError(' - ' . $operation->show(false));
  18676. }
  18677. $this->$opType($repo, $operation);
  18678. continue;
  18679. }
  18680. if ($opType === 'update') {
  18681. $package = $operation->getTargetPackage();
  18682. $initialPackage = $operation->getInitialPackage();
  18683. } else {
  18684. $package = $operation->getPackage();
  18685. $initialPackage = null;
  18686. }
  18687. $installer = $this->getInstaller($package->getType());
  18688. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  18689. if (defined($event) && $runScripts && $this->eventDispatcher) {
  18690. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  18691. }
  18692. $dispatcher = $this->eventDispatcher;
  18693. $installManager = $this;
  18694. $io = $this->io;
  18695. $promise = $installer->prepare($opType, $package, $initialPackage);
  18696. if (!$promise instanceof PromiseInterface) {
  18697. $promise = \React\Promise\resolve();
  18698. }
  18699. $promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
  18700. return $installManager->$opType($repo, $operation);
  18701. })->then($cleanupPromises[$index])
  18702. ->then(function () use ($installManager, $devMode, $repo) {
  18703. $repo->write($devMode, $installManager);
  18704. }, function ($e) use ($opType, $package, $io) {
  18705. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  18706. throw $e;
  18707. });
  18708. $postExecCallbacks[] = function () use ($opType, $runScripts, $dispatcher, $devMode, $repo, $allOperations, $operation) {
  18709. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  18710. if (defined($event) && $runScripts && $dispatcher) {
  18711. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  18712. }
  18713. };
  18714. $promises[] = $promise;
  18715. }
  18716. if (count($promises)) {
  18717. $this->waitOnPromises($promises);
  18718. }
  18719. Platform::workaroundFilesystemIssues();
  18720. foreach ($postExecCallbacks as $cb) {
  18721. $cb();
  18722. }
  18723. }
  18724. private function waitOnPromises(array $promises)
  18725. {
  18726. $progress = null;
  18727. if (
  18728. $this->outputProgress
  18729. && $this->io instanceof ConsoleIO
  18730. && !Platform::getEnv('CI')
  18731. && !$this->io->isDebug()
  18732. && count($promises) > 1
  18733. ) {
  18734. $progress = $this->io->getProgressBar();
  18735. }
  18736. $this->loop->wait($promises, $progress);
  18737. if ($progress) {
  18738. $progress->clear();
  18739. if (!$this->io->isDecorated()) {
  18740. $this->io->writeError('');
  18741. }
  18742. }
  18743. }
  18744. public function install(InstalledRepositoryInterface $repo, InstallOperation $operation)
  18745. {
  18746. $package = $operation->getPackage();
  18747. $installer = $this->getInstaller($package->getType());
  18748. $promise = $installer->install($repo, $package);
  18749. $this->markForNotification($package);
  18750. return $promise;
  18751. }
  18752. public function update(InstalledRepositoryInterface $repo, UpdateOperation $operation)
  18753. {
  18754. $initial = $operation->getInitialPackage();
  18755. $target = $operation->getTargetPackage();
  18756. $initialType = $initial->getType();
  18757. $targetType = $target->getType();
  18758. if ($initialType === $targetType) {
  18759. $installer = $this->getInstaller($initialType);
  18760. $promise = $installer->update($repo, $initial, $target);
  18761. $this->markForNotification($target);
  18762. } else {
  18763. $promise = $this->getInstaller($initialType)->uninstall($repo, $initial);
  18764. if (!$promise instanceof PromiseInterface) {
  18765. $promise = \React\Promise\resolve();
  18766. }
  18767. $installer = $this->getInstaller($targetType);
  18768. $promise = $promise->then(function () use ($installer, $repo, $target) {
  18769. return $installer->install($repo, $target);
  18770. });
  18771. }
  18772. return $promise;
  18773. }
  18774. public function uninstall(InstalledRepositoryInterface $repo, UninstallOperation $operation)
  18775. {
  18776. $package = $operation->getPackage();
  18777. $installer = $this->getInstaller($package->getType());
  18778. return $installer->uninstall($repo, $package);
  18779. }
  18780. public function markAliasInstalled(InstalledRepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  18781. {
  18782. $package = $operation->getPackage();
  18783. if (!$repo->hasPackage($package)) {
  18784. $repo->addPackage(clone $package);
  18785. }
  18786. }
  18787. public function markAliasUninstalled(InstalledRepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  18788. {
  18789. $package = $operation->getPackage();
  18790. $repo->removePackage($package);
  18791. }
  18792. public function getInstallPath(PackageInterface $package)
  18793. {
  18794. $installer = $this->getInstaller($package->getType());
  18795. return $installer->getInstallPath($package);
  18796. }
  18797. public function setOutputProgress($outputProgress)
  18798. {
  18799. $this->outputProgress = $outputProgress;
  18800. }
  18801. public function notifyInstalls(IOInterface $io)
  18802. {
  18803. $promises = array();
  18804. try {
  18805. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  18806. if (strpos($repoUrl, '%package%')) {
  18807. foreach ($packages as $package) {
  18808. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  18809. $params = array(
  18810. 'version' => $package->getPrettyVersion(),
  18811. 'version_normalized' => $package->getVersion(),
  18812. );
  18813. $opts = array(
  18814. 'retry-auth-failure' => false,
  18815. 'http' => array(
  18816. 'method' => 'POST',
  18817. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  18818. 'content' => http_build_query($params, '', '&'),
  18819. 'timeout' => 3,
  18820. ),
  18821. );
  18822. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  18823. }
  18824. continue;
  18825. }
  18826. $postData = array('downloads' => array());
  18827. foreach ($packages as $package) {
  18828. $packageNotification = array(
  18829. 'name' => $package->getPrettyName(),
  18830. 'version' => $package->getVersion(),
  18831. );
  18832. if (strpos($repoUrl, 'packagist.org/') !== false) {
  18833. if (isset(FileDownloader::$downloadMetadata[$package->getName()])) {
  18834. $packageNotification['downloaded'] = FileDownloader::$downloadMetadata[$package->getName()];
  18835. } else {
  18836. $packageNotification['downloaded'] = false;
  18837. }
  18838. }
  18839. $postData['downloads'][] = $packageNotification;
  18840. }
  18841. $opts = array(
  18842. 'retry-auth-failure' => false,
  18843. 'http' => array(
  18844. 'method' => 'POST',
  18845. 'header' => array('Content-Type: application/json'),
  18846. 'content' => json_encode($postData),
  18847. 'timeout' => 6,
  18848. ),
  18849. );
  18850. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  18851. }
  18852. $this->loop->wait($promises);
  18853. } catch (\Exception $e) {
  18854. }
  18855. $this->reset();
  18856. }
  18857. private function markForNotification(PackageInterface $package)
  18858. {
  18859. if ($package->getNotificationUrl()) {
  18860. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  18861. }
  18862. }
  18863. }
  18864. <?php
  18865. namespace Composer\Installer;
  18866. use Composer\Composer;
  18867. use Composer\DependencyResolver\Transaction;
  18868. use Composer\EventDispatcher\Event;
  18869. use Composer\IO\IOInterface;
  18870. class InstallerEvent extends Event
  18871. {
  18872. private $composer;
  18873. private $io;
  18874. private $devMode;
  18875. private $executeOperations;
  18876. private $transaction;
  18877. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
  18878. {
  18879. parent::__construct($eventName);
  18880. $this->composer = $composer;
  18881. $this->io = $io;
  18882. $this->devMode = $devMode;
  18883. $this->executeOperations = $executeOperations;
  18884. $this->transaction = $transaction;
  18885. }
  18886. public function getComposer()
  18887. {
  18888. return $this->composer;
  18889. }
  18890. public function getIO()
  18891. {
  18892. return $this->io;
  18893. }
  18894. public function isDevMode()
  18895. {
  18896. return $this->devMode;
  18897. }
  18898. public function isExecutingOperations()
  18899. {
  18900. return $this->executeOperations;
  18901. }
  18902. public function getTransaction()
  18903. {
  18904. return $this->transaction;
  18905. }
  18906. }
  18907. <?php
  18908. namespace Composer\Installer;
  18909. class InstallerEvents
  18910. {
  18911. const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  18912. }
  18913. <?php
  18914. namespace Composer\Installer;
  18915. use Composer\Package\PackageInterface;
  18916. use Composer\Repository\InstalledRepositoryInterface;
  18917. use InvalidArgumentException;
  18918. use React\Promise\PromiseInterface;
  18919. interface InstallerInterface
  18920. {
  18921. public function supports($packageType);
  18922. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  18923. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  18924. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
  18925. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  18926. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  18927. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  18928. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
  18929. public function getInstallPath(PackageInterface $package);
  18930. }
  18931. <?php
  18932. namespace Composer\Installer;
  18933. use Composer\Composer;
  18934. use Composer\IO\IOInterface;
  18935. use Composer\Pcre\Preg;
  18936. use Composer\Repository\InstalledRepositoryInterface;
  18937. use Composer\Package\PackageInterface;
  18938. use Composer\Util\Filesystem;
  18939. use Composer\Util\Silencer;
  18940. use Composer\Util\Platform;
  18941. use React\Promise\PromiseInterface;
  18942. use Composer\Downloader\DownloadManager;
  18943. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  18944. {
  18945. protected $composer;
  18946. protected $vendorDir;
  18947. protected $downloadManager;
  18948. protected $io;
  18949. protected $type;
  18950. protected $filesystem;
  18951. protected $binaryInstaller;
  18952. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  18953. {
  18954. $this->composer = $composer;
  18955. $this->downloadManager = $composer->getDownloadManager();
  18956. $this->io = $io;
  18957. $this->type = $type;
  18958. $this->filesystem = $filesystem ?: new Filesystem();
  18959. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  18960. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem, $this->vendorDir);
  18961. }
  18962. public function supports($packageType)
  18963. {
  18964. return $packageType === $this->type || null === $this->type;
  18965. }
  18966. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  18967. {
  18968. if (!$repo->hasPackage($package)) {
  18969. return false;
  18970. }
  18971. $installPath = $this->getInstallPath($package);
  18972. if (Filesystem::isReadable($installPath)) {
  18973. return true;
  18974. }
  18975. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  18976. }
  18977. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  18978. {
  18979. $this->initializeVendorDir();
  18980. $downloadPath = $this->getInstallPath($package);
  18981. return $this->downloadManager->download($package, $downloadPath, $prevPackage);
  18982. }
  18983. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18984. {
  18985. $this->initializeVendorDir();
  18986. $downloadPath = $this->getInstallPath($package);
  18987. return $this->downloadManager->prepare($type, $package, $downloadPath, $prevPackage);
  18988. }
  18989. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  18990. {
  18991. $this->initializeVendorDir();
  18992. $downloadPath = $this->getInstallPath($package);
  18993. return $this->downloadManager->cleanup($type, $package, $downloadPath, $prevPackage);
  18994. }
  18995. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  18996. {
  18997. $this->initializeVendorDir();
  18998. $downloadPath = $this->getInstallPath($package);
  18999. if (!Filesystem::isReadable($downloadPath) && $repo->hasPackage($package)) {
  19000. $this->binaryInstaller->removeBinaries($package);
  19001. }
  19002. $promise = $this->installCode($package);
  19003. if (!$promise instanceof PromiseInterface) {
  19004. $promise = \React\Promise\resolve();
  19005. }
  19006. $binaryInstaller = $this->binaryInstaller;
  19007. $installPath = $this->getInstallPath($package);
  19008. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
  19009. $binaryInstaller->installBinaries($package, $installPath);
  19010. if (!$repo->hasPackage($package)) {
  19011. $repo->addPackage(clone $package);
  19012. }
  19013. });
  19014. }
  19015. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19016. {
  19017. if (!$repo->hasPackage($initial)) {
  19018. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  19019. }
  19020. $this->initializeVendorDir();
  19021. $this->binaryInstaller->removeBinaries($initial);
  19022. $promise = $this->updateCode($initial, $target);
  19023. if (!$promise instanceof PromiseInterface) {
  19024. $promise = \React\Promise\resolve();
  19025. }
  19026. $binaryInstaller = $this->binaryInstaller;
  19027. $installPath = $this->getInstallPath($target);
  19028. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
  19029. $binaryInstaller->installBinaries($target, $installPath);
  19030. $repo->removePackage($initial);
  19031. if (!$repo->hasPackage($target)) {
  19032. $repo->addPackage(clone $target);
  19033. }
  19034. });
  19035. }
  19036. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19037. {
  19038. if (!$repo->hasPackage($package)) {
  19039. throw new \InvalidArgumentException('Package is not installed: '.$package);
  19040. }
  19041. $promise = $this->removeCode($package);
  19042. if (!$promise instanceof PromiseInterface) {
  19043. $promise = \React\Promise\resolve();
  19044. }
  19045. $binaryInstaller = $this->binaryInstaller;
  19046. $downloadPath = $this->getPackageBasePath($package);
  19047. $filesystem = $this->filesystem;
  19048. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
  19049. $binaryInstaller->removeBinaries($package);
  19050. $repo->removePackage($package);
  19051. if (strpos($package->getName(), '/')) {
  19052. $packageVendorDir = dirname($downloadPath);
  19053. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  19054. Silencer::call('rmdir', $packageVendorDir);
  19055. }
  19056. }
  19057. });
  19058. }
  19059. public function getInstallPath(PackageInterface $package)
  19060. {
  19061. $this->initializeVendorDir();
  19062. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  19063. $targetDir = $package->getTargetDir();
  19064. return $basePath . ($targetDir ? '/'.$targetDir : '');
  19065. }
  19066. public function ensureBinariesPresence(PackageInterface $package)
  19067. {
  19068. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  19069. }
  19070. protected function getPackageBasePath(PackageInterface $package)
  19071. {
  19072. $installPath = $this->getInstallPath($package);
  19073. $targetDir = $package->getTargetDir();
  19074. if ($targetDir) {
  19075. return Preg::replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  19076. }
  19077. return $installPath;
  19078. }
  19079. protected function installCode(PackageInterface $package)
  19080. {
  19081. $downloadPath = $this->getInstallPath($package);
  19082. return $this->downloadManager->install($package, $downloadPath);
  19083. }
  19084. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  19085. {
  19086. $initialDownloadPath = $this->getInstallPath($initial);
  19087. $targetDownloadPath = $this->getInstallPath($target);
  19088. if ($targetDownloadPath !== $initialDownloadPath) {
  19089. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  19090. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  19091. ) {
  19092. $promise = $this->removeCode($initial);
  19093. if (!$promise instanceof PromiseInterface) {
  19094. $promise = \React\Promise\resolve();
  19095. }
  19096. $self = $this;
  19097. return $promise->then(function () use ($self, $target) {
  19098. $reflMethod = new \ReflectionMethod($self, 'installCode');
  19099. $reflMethod->setAccessible(true);
  19100. return $reflMethod->invoke($self, $target);
  19101. });
  19102. }
  19103. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  19104. }
  19105. return $this->downloadManager->update($initial, $target, $targetDownloadPath);
  19106. }
  19107. protected function removeCode(PackageInterface $package)
  19108. {
  19109. $downloadPath = $this->getPackageBasePath($package);
  19110. return $this->downloadManager->remove($package, $downloadPath);
  19111. }
  19112. protected function initializeVendorDir()
  19113. {
  19114. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  19115. $this->vendorDir = realpath($this->vendorDir);
  19116. }
  19117. }
  19118. <?php
  19119. namespace Composer\Installer;
  19120. use Composer\Repository\InstalledRepositoryInterface;
  19121. use Composer\Package\PackageInterface;
  19122. use Composer\IO\IOInterface;
  19123. use Composer\DependencyResolver\Operation\UpdateOperation;
  19124. use Composer\DependencyResolver\Operation\InstallOperation;
  19125. use Composer\DependencyResolver\Operation\UninstallOperation;
  19126. class MetapackageInstaller implements InstallerInterface
  19127. {
  19128. private $io;
  19129. public function __construct(IOInterface $io)
  19130. {
  19131. $this->io = $io;
  19132. }
  19133. public function supports($packageType)
  19134. {
  19135. return $packageType === 'metapackage';
  19136. }
  19137. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  19138. {
  19139. return $repo->hasPackage($package);
  19140. }
  19141. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19142. {
  19143. return \React\Promise\resolve();
  19144. }
  19145. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19146. {
  19147. return \React\Promise\resolve();
  19148. }
  19149. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19150. {
  19151. return \React\Promise\resolve();
  19152. }
  19153. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19154. {
  19155. $this->io->writeError(" - " . InstallOperation::format($package));
  19156. $repo->addPackage(clone $package);
  19157. return \React\Promise\resolve();
  19158. }
  19159. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19160. {
  19161. if (!$repo->hasPackage($initial)) {
  19162. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  19163. }
  19164. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  19165. $repo->removePackage($initial);
  19166. $repo->addPackage(clone $target);
  19167. return \React\Promise\resolve();
  19168. }
  19169. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19170. {
  19171. if (!$repo->hasPackage($package)) {
  19172. throw new \InvalidArgumentException('Package is not installed: '.$package);
  19173. }
  19174. $this->io->writeError(" - " . UninstallOperation::format($package));
  19175. $repo->removePackage($package);
  19176. return \React\Promise\resolve();
  19177. }
  19178. public function getInstallPath(PackageInterface $package)
  19179. {
  19180. return '';
  19181. }
  19182. }
  19183. <?php
  19184. namespace Composer\Installer;
  19185. use Composer\Repository\InstalledRepositoryInterface;
  19186. use Composer\Package\PackageInterface;
  19187. class NoopInstaller implements InstallerInterface
  19188. {
  19189. public function supports($packageType)
  19190. {
  19191. return true;
  19192. }
  19193. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  19194. {
  19195. return $repo->hasPackage($package);
  19196. }
  19197. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19198. {
  19199. return \React\Promise\resolve();
  19200. }
  19201. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19202. {
  19203. return \React\Promise\resolve();
  19204. }
  19205. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19206. {
  19207. return \React\Promise\resolve();
  19208. }
  19209. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19210. {
  19211. if (!$repo->hasPackage($package)) {
  19212. $repo->addPackage(clone $package);
  19213. }
  19214. return \React\Promise\resolve();
  19215. }
  19216. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19217. {
  19218. if (!$repo->hasPackage($initial)) {
  19219. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  19220. }
  19221. $repo->removePackage($initial);
  19222. if (!$repo->hasPackage($target)) {
  19223. $repo->addPackage(clone $target);
  19224. }
  19225. return \React\Promise\resolve();
  19226. }
  19227. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19228. {
  19229. if (!$repo->hasPackage($package)) {
  19230. throw new \InvalidArgumentException('Package is not installed: '.$package);
  19231. }
  19232. $repo->removePackage($package);
  19233. return \React\Promise\resolve();
  19234. }
  19235. public function getInstallPath(PackageInterface $package)
  19236. {
  19237. $targetDir = $package->getTargetDir();
  19238. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  19239. }
  19240. }
  19241. <?php
  19242. namespace Composer\Installer;
  19243. use Composer\Composer;
  19244. use Composer\IO\IOInterface;
  19245. use Composer\DependencyResolver\Operation\OperationInterface;
  19246. use Composer\Repository\RepositoryInterface;
  19247. use Composer\EventDispatcher\Event;
  19248. class PackageEvent extends Event
  19249. {
  19250. private $composer;
  19251. private $io;
  19252. private $devMode;
  19253. private $localRepo;
  19254. private $operations;
  19255. private $operation;
  19256. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  19257. {
  19258. parent::__construct($eventName);
  19259. $this->composer = $composer;
  19260. $this->io = $io;
  19261. $this->devMode = $devMode;
  19262. $this->localRepo = $localRepo;
  19263. $this->operations = $operations;
  19264. $this->operation = $operation;
  19265. }
  19266. public function getComposer()
  19267. {
  19268. return $this->composer;
  19269. }
  19270. public function getIO()
  19271. {
  19272. return $this->io;
  19273. }
  19274. public function isDevMode()
  19275. {
  19276. return $this->devMode;
  19277. }
  19278. public function getLocalRepo()
  19279. {
  19280. return $this->localRepo;
  19281. }
  19282. public function getOperations()
  19283. {
  19284. return $this->operations;
  19285. }
  19286. public function getOperation()
  19287. {
  19288. return $this->operation;
  19289. }
  19290. }
  19291. <?php
  19292. namespace Composer\Installer;
  19293. class PackageEvents
  19294. {
  19295. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  19296. const POST_PACKAGE_INSTALL = 'post-package-install';
  19297. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  19298. const POST_PACKAGE_UPDATE = 'post-package-update';
  19299. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  19300. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  19301. }
  19302. <?php
  19303. namespace Composer\Installer;
  19304. use Composer\Composer;
  19305. use Composer\IO\IOInterface;
  19306. use Composer\Repository\InstalledRepositoryInterface;
  19307. use Composer\Package\PackageInterface;
  19308. use Composer\Util\Filesystem;
  19309. use Composer\Util\Platform;
  19310. use React\Promise\PromiseInterface;
  19311. class PluginInstaller extends LibraryInstaller
  19312. {
  19313. public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  19314. {
  19315. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  19316. }
  19317. public function supports($packageType)
  19318. {
  19319. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  19320. }
  19321. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19322. {
  19323. $extra = $package->getExtra();
  19324. if (empty($extra['class'])) {
  19325. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  19326. }
  19327. return parent::download($package, $prevPackage);
  19328. }
  19329. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19330. {
  19331. $promise = parent::install($repo, $package);
  19332. if (!$promise instanceof PromiseInterface) {
  19333. $promise = \React\Promise\resolve();
  19334. }
  19335. $pluginManager = $this->composer->getPluginManager();
  19336. $self = $this;
  19337. return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
  19338. try {
  19339. Platform::workaroundFilesystemIssues();
  19340. $pluginManager->registerPackage($package, true);
  19341. } catch (\Exception $e) {
  19342. $self->rollbackInstall($e, $repo, $package);
  19343. }
  19344. });
  19345. }
  19346. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19347. {
  19348. $promise = parent::update($repo, $initial, $target);
  19349. if (!$promise instanceof PromiseInterface) {
  19350. $promise = \React\Promise\resolve();
  19351. }
  19352. $pluginManager = $this->composer->getPluginManager();
  19353. $self = $this;
  19354. return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
  19355. try {
  19356. Platform::workaroundFilesystemIssues();
  19357. $pluginManager->deactivatePackage($initial);
  19358. $pluginManager->registerPackage($target, true);
  19359. } catch (\Exception $e) {
  19360. $self->rollbackInstall($e, $repo, $target);
  19361. }
  19362. });
  19363. }
  19364. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19365. {
  19366. $this->composer->getPluginManager()->uninstallPackage($package);
  19367. return parent::uninstall($repo, $package);
  19368. }
  19369. public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
  19370. {
  19371. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  19372. parent::uninstall($repo, $package);
  19373. throw $e;
  19374. }
  19375. }
  19376. <?php
  19377. namespace Composer\Installer;
  19378. use Composer\Package\PackageInterface;
  19379. use Composer\Downloader\DownloadManager;
  19380. use Composer\Repository\InstalledRepositoryInterface;
  19381. use Composer\Util\Filesystem;
  19382. class ProjectInstaller implements InstallerInterface
  19383. {
  19384. private $installPath;
  19385. private $downloadManager;
  19386. private $filesystem;
  19387. public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
  19388. {
  19389. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  19390. $this->downloadManager = $dm;
  19391. $this->filesystem = $fs;
  19392. }
  19393. public function supports($packageType)
  19394. {
  19395. return true;
  19396. }
  19397. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  19398. {
  19399. return false;
  19400. }
  19401. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  19402. {
  19403. $installPath = $this->installPath;
  19404. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  19405. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  19406. }
  19407. if (!is_dir($installPath)) {
  19408. mkdir($installPath, 0777, true);
  19409. }
  19410. return $this->downloadManager->download($package, $installPath, $prevPackage);
  19411. }
  19412. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19413. {
  19414. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  19415. }
  19416. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  19417. {
  19418. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  19419. }
  19420. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  19421. {
  19422. return $this->downloadManager->install($package, $this->installPath);
  19423. }
  19424. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  19425. {
  19426. throw new \InvalidArgumentException("not supported");
  19427. }
  19428. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  19429. {
  19430. throw new \InvalidArgumentException("not supported");
  19431. }
  19432. public function getInstallPath(PackageInterface $package)
  19433. {
  19434. return $this->installPath;
  19435. }
  19436. }
  19437. <?php
  19438. namespace Composer\Installer;
  19439. use Composer\IO\IOInterface;
  19440. use Composer\Package\PackageInterface;
  19441. use Composer\Pcre\Preg;
  19442. use Composer\Repository\InstalledRepository;
  19443. use Symfony\Component\Console\Formatter\OutputFormatter;
  19444. class SuggestedPackagesReporter
  19445. {
  19446. const MODE_LIST = 1;
  19447. const MODE_BY_PACKAGE = 2;
  19448. const MODE_BY_SUGGESTION = 4;
  19449. protected $suggestedPackages = array();
  19450. private $io;
  19451. public function __construct(IOInterface $io)
  19452. {
  19453. $this->io = $io;
  19454. }
  19455. public function getPackages()
  19456. {
  19457. return $this->suggestedPackages;
  19458. }
  19459. public function addPackage($source, $target, $reason)
  19460. {
  19461. $this->suggestedPackages[] = array(
  19462. 'source' => $source,
  19463. 'target' => $target,
  19464. 'reason' => $reason,
  19465. );
  19466. return $this;
  19467. }
  19468. public function addSuggestionsFromPackage(PackageInterface $package)
  19469. {
  19470. $source = $package->getPrettyName();
  19471. foreach ($package->getSuggests() as $target => $reason) {
  19472. $this->addPackage(
  19473. $source,
  19474. $target,
  19475. $reason
  19476. );
  19477. }
  19478. return $this;
  19479. }
  19480. public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  19481. {
  19482. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  19483. $suggesters = array();
  19484. $suggested = array();
  19485. foreach ($suggestedPackages as $suggestion) {
  19486. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  19487. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  19488. }
  19489. ksort($suggesters);
  19490. ksort($suggested);
  19491. if ($mode & self::MODE_LIST) {
  19492. foreach (array_keys($suggested) as $name) {
  19493. $this->io->write(sprintf('<info>%s</info>', $name));
  19494. }
  19495. return;
  19496. }
  19497. if ($mode & self::MODE_BY_PACKAGE) {
  19498. foreach ($suggesters as $suggester => $suggestions) {
  19499. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  19500. foreach ($suggestions as $suggestion => $reason) {
  19501. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  19502. }
  19503. $this->io->write('');
  19504. }
  19505. }
  19506. if ($mode & self::MODE_BY_SUGGESTION) {
  19507. if ($mode & self::MODE_BY_PACKAGE) {
  19508. $this->io->write(str_repeat('-', 78));
  19509. }
  19510. foreach ($suggested as $suggestion => $suggesters) {
  19511. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  19512. foreach ($suggesters as $suggester => $reason) {
  19513. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  19514. }
  19515. $this->io->write('');
  19516. }
  19517. }
  19518. if ($onlyDependentsOf) {
  19519. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  19520. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  19521. if ($diff) {
  19522. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  19523. }
  19524. }
  19525. }
  19526. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  19527. {
  19528. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  19529. if ($suggestedPackages) {
  19530. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  19531. }
  19532. }
  19533. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  19534. {
  19535. $suggestedPackages = $this->getPackages();
  19536. $installedNames = array();
  19537. if (null !== $installedRepo && !empty($suggestedPackages)) {
  19538. foreach ($installedRepo->getPackages() as $package) {
  19539. $installedNames = array_merge(
  19540. $installedNames,
  19541. $package->getNames()
  19542. );
  19543. }
  19544. }
  19545. $sourceFilter = array();
  19546. if ($onlyDependentsOf) {
  19547. $sourceFilter = array_map(function ($link) {
  19548. return $link->getTarget();
  19549. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  19550. $sourceFilter[] = $onlyDependentsOf->getName();
  19551. }
  19552. $suggestions = array();
  19553. foreach ($suggestedPackages as $suggestion) {
  19554. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  19555. continue;
  19556. }
  19557. $suggestions[] = $suggestion;
  19558. }
  19559. return $suggestions;
  19560. }
  19561. private function escapeOutput($string)
  19562. {
  19563. return OutputFormatter::escape(
  19564. $this->removeControlCharacters($string)
  19565. );
  19566. }
  19567. private function removeControlCharacters($string)
  19568. {
  19569. return Preg::replace(
  19570. '/[[:cntrl:]]/',
  19571. '',
  19572. str_replace("\n", ' ', $string)
  19573. );
  19574. }
  19575. }
  19576. <?php
  19577. namespace Composer\Json;
  19578. use Composer\Pcre\Preg;
  19579. use JsonSchema\Validator;
  19580. use Seld\JsonLint\JsonParser;
  19581. use Seld\JsonLint\ParsingException;
  19582. use Composer\Util\HttpDownloader;
  19583. use Composer\IO\IOInterface;
  19584. use Composer\Downloader\TransportException;
  19585. class JsonFile
  19586. {
  19587. const LAX_SCHEMA = 1;
  19588. const STRICT_SCHEMA = 2;
  19589. const JSON_UNESCAPED_SLASHES = 64;
  19590. const JSON_PRETTY_PRINT = 128;
  19591. const JSON_UNESCAPED_UNICODE = 256;
  19592. const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
  19593. private $path;
  19594. private $httpDownloader;
  19595. private $io;
  19596. public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  19597. {
  19598. $this->path = $path;
  19599. if (null === $httpDownloader && Preg::isMatch('{^https?://}i', $path)) {
  19600. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  19601. }
  19602. $this->httpDownloader = $httpDownloader;
  19603. $this->io = $io;
  19604. }
  19605. public function getPath()
  19606. {
  19607. return $this->path;
  19608. }
  19609. public function exists()
  19610. {
  19611. return is_file($this->path);
  19612. }
  19613. public function read()
  19614. {
  19615. try {
  19616. if ($this->httpDownloader) {
  19617. $json = $this->httpDownloader->get($this->path)->getBody();
  19618. } else {
  19619. if ($this->io && $this->io->isDebug()) {
  19620. $realpathInfo = '';
  19621. $realpath = realpath($this->path);
  19622. if (false !== $realpath && $realpath !== $this->path) {
  19623. $realpathInfo = ' (' . $realpath . ')';
  19624. }
  19625. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  19626. }
  19627. $json = file_get_contents($this->path);
  19628. }
  19629. } catch (TransportException $e) {
  19630. throw new \RuntimeException($e->getMessage(), 0, $e);
  19631. } catch (\Exception $e) {
  19632. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  19633. }
  19634. return static::parseJson($json, $this->path);
  19635. }
  19636. public function write(array $hash, $options = 448)
  19637. {
  19638. if ($this->path === 'php://memory') {
  19639. file_put_contents($this->path, static::encode($hash, $options));
  19640. return;
  19641. }
  19642. $dir = dirname($this->path);
  19643. if (!is_dir($dir)) {
  19644. if (file_exists($dir)) {
  19645. throw new \UnexpectedValueException(
  19646. realpath($dir).' exists and is not a directory.'
  19647. );
  19648. }
  19649. if (!@mkdir($dir, 0777, true)) {
  19650. throw new \UnexpectedValueException(
  19651. $dir.' does not exist and could not be created.'
  19652. );
  19653. }
  19654. }
  19655. $retries = 3;
  19656. while ($retries--) {
  19657. try {
  19658. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  19659. break;
  19660. } catch (\Exception $e) {
  19661. if ($retries > 0) {
  19662. usleep(500000);
  19663. continue;
  19664. }
  19665. throw $e;
  19666. }
  19667. }
  19668. }
  19669. private function filePutContentsIfModified($path, $content)
  19670. {
  19671. $currentContent = @file_get_contents($path);
  19672. if (!$currentContent || ($currentContent != $content)) {
  19673. return file_put_contents($path, $content);
  19674. }
  19675. return 0;
  19676. }
  19677. public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
  19678. {
  19679. $content = file_get_contents($this->path);
  19680. $data = json_decode($content);
  19681. if (null === $data && 'null' !== $content) {
  19682. self::validateSyntax($content, $this->path);
  19683. }
  19684. $isComposerSchemaFile = false;
  19685. if (null === $schemaFile) {
  19686. $isComposerSchemaFile = true;
  19687. $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
  19688. }
  19689. if (false === strpos($schemaFile, '://')) {
  19690. $schemaFile = 'file://' . $schemaFile;
  19691. }
  19692. $schemaData = (object) array('$ref' => $schemaFile);
  19693. if ($schema === self::LAX_SCHEMA) {
  19694. $schemaData->additionalProperties = true;
  19695. $schemaData->required = array();
  19696. } elseif ($schema === self::STRICT_SCHEMA && $isComposerSchemaFile) {
  19697. $schemaData->additionalProperties = false;
  19698. $schemaData->required = array('name', 'description');
  19699. }
  19700. $validator = new Validator();
  19701. $validator->check($data, $schemaData);
  19702. if (!$validator->isValid()) {
  19703. $errors = array();
  19704. foreach ((array) $validator->getErrors() as $error) {
  19705. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  19706. }
  19707. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  19708. }
  19709. return true;
  19710. }
  19711. public static function encode($data, $options = 448)
  19712. {
  19713. if (PHP_VERSION_ID >= 50400) {
  19714. $json = json_encode($data, $options);
  19715. if (false === $json) {
  19716. self::throwEncodeError(json_last_error());
  19717. }
  19718. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  19719. $json = Preg::replace('/\[\s+\]/', '[]', $json);
  19720. $json = Preg::replace('/\{\s+\}/', '{}', $json);
  19721. }
  19722. return $json;
  19723. }
  19724. $json = json_encode($data);
  19725. if (false === $json) {
  19726. self::throwEncodeError(json_last_error());
  19727. }
  19728. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  19729. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  19730. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  19731. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  19732. return $json;
  19733. }
  19734. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  19735. }
  19736. private static function throwEncodeError($code)
  19737. {
  19738. switch ($code) {
  19739. case JSON_ERROR_DEPTH:
  19740. $msg = 'Maximum stack depth exceeded';
  19741. break;
  19742. case JSON_ERROR_STATE_MISMATCH:
  19743. $msg = 'Underflow or the modes mismatch';
  19744. break;
  19745. case JSON_ERROR_CTRL_CHAR:
  19746. $msg = 'Unexpected control character found';
  19747. break;
  19748. case JSON_ERROR_UTF8:
  19749. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  19750. break;
  19751. default:
  19752. $msg = 'Unknown error';
  19753. }
  19754. throw new \RuntimeException('JSON encoding failed: '.$msg);
  19755. }
  19756. public static function parseJson($json, $file = null)
  19757. {
  19758. if (null === $json) {
  19759. return null;
  19760. }
  19761. $data = json_decode($json, true);
  19762. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  19763. self::validateSyntax($json, $file);
  19764. }
  19765. return $data;
  19766. }
  19767. protected static function validateSyntax($json, $file = null)
  19768. {
  19769. $parser = new JsonParser();
  19770. $result = $parser->lint($json);
  19771. if (null === $result) {
  19772. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  19773. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  19774. }
  19775. return true;
  19776. }
  19777. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  19778. }
  19779. }
  19780. <?php
  19781. namespace Composer\Json;
  19782. use Composer\Pcre\Preg;
  19783. class JsonFormatter
  19784. {
  19785. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  19786. {
  19787. $result = '';
  19788. $pos = 0;
  19789. $strLen = strlen($json);
  19790. $indentStr = ' ';
  19791. $newLine = "\n";
  19792. $outOfQuotes = true;
  19793. $buffer = '';
  19794. $noescape = true;
  19795. for ($i = 0; $i < $strLen; $i++) {
  19796. $char = substr($json, $i, 1);
  19797. if ('"' === $char && $noescape) {
  19798. $outOfQuotes = !$outOfQuotes;
  19799. }
  19800. if (!$outOfQuotes) {
  19801. $buffer .= $char;
  19802. $noescape = '\\' === $char ? !$noescape : true;
  19803. continue;
  19804. }
  19805. if ('' !== $buffer) {
  19806. if ($unescapeSlashes) {
  19807. $buffer = str_replace('\\/', '/', $buffer);
  19808. }
  19809. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  19810. $buffer = Preg::replaceCallback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  19811. $l = strlen($match[1]);
  19812. if ($l % 2) {
  19813. $code = hexdec($match[2]);
  19814. if (0xD800 <= $code && 0xDFFF >= $code) {
  19815. return $match[0];
  19816. }
  19817. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  19818. pack('H*', $match[2]),
  19819. 'UTF-8',
  19820. 'UCS-2BE'
  19821. );
  19822. }
  19823. return $match[0];
  19824. }, $buffer);
  19825. }
  19826. $result .= $buffer.$char;
  19827. $buffer = '';
  19828. continue;
  19829. }
  19830. if (':' === $char) {
  19831. $char .= ' ';
  19832. } elseif ('}' === $char || ']' === $char) {
  19833. $pos--;
  19834. $prevChar = substr($json, $i - 1, 1);
  19835. if ('{' !== $prevChar && '[' !== $prevChar) {
  19836. $result .= $newLine;
  19837. for ($j = 0; $j < $pos; $j++) {
  19838. $result .= $indentStr;
  19839. }
  19840. } else {
  19841. $result = rtrim($result);
  19842. }
  19843. }
  19844. $result .= $char;
  19845. if (',' === $char || '{' === $char || '[' === $char) {
  19846. $result .= $newLine;
  19847. if ('{' === $char || '[' === $char) {
  19848. $pos++;
  19849. }
  19850. for ($j = 0; $j < $pos; $j++) {
  19851. $result .= $indentStr;
  19852. }
  19853. }
  19854. }
  19855. return $result;
  19856. }
  19857. }
  19858. <?php
  19859. namespace Composer\Json;
  19860. use Composer\Pcre\Preg;
  19861. use Composer\Repository\PlatformRepository;
  19862. class JsonManipulator
  19863. {
  19864. private static $DEFINES = '(?(DEFINE)
  19865. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? )
  19866. (?<boolean> true | false | null )
  19867. (?<string> " ([^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  19868. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  19869. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  19870. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  19871. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  19872. )';
  19873. private $contents;
  19874. private $newline;
  19875. private $indent;
  19876. public function __construct($contents)
  19877. {
  19878. $contents = trim($contents);
  19879. if ($contents === '') {
  19880. $contents = '{}';
  19881. }
  19882. if (!Preg::isMatch('#^\{(.*)\}$#s', $contents)) {
  19883. throw new \InvalidArgumentException('The json file must be an object ({})');
  19884. }
  19885. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  19886. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  19887. $this->detectIndenting();
  19888. }
  19889. public function getContents()
  19890. {
  19891. return $this->contents . $this->newline;
  19892. }
  19893. public function addLink($type, $package, $constraint, $sortPackages = false)
  19894. {
  19895. $decoded = JsonFile::parseJson($this->contents);
  19896. if (!isset($decoded[$type])) {
  19897. return $this->addMainKey($type, array($package => $constraint));
  19898. }
  19899. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  19900. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  19901. if (!Preg::isMatch($regex, $this->contents, $matches)) {
  19902. return false;
  19903. }
  19904. $links = $matches['value'];
  19905. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  19906. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  19907. if (Preg::isMatch($regex, $links, $packageMatches)) {
  19908. $existingPackage = $packageMatches['package'];
  19909. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  19910. $links = Preg::replaceCallback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  19911. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  19912. }, $links);
  19913. } else {
  19914. if (Preg::isMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  19915. $links = Preg::replace(
  19916. '{'.preg_quote($match[1]).'$}',
  19917. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  19918. $links
  19919. );
  19920. } else {
  19921. $links = '{' . $this->newline .
  19922. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  19923. $this->indent . '}';
  19924. }
  19925. }
  19926. if (true === $sortPackages) {
  19927. $requirements = json_decode($links, true);
  19928. $this->sortPackages($requirements);
  19929. $links = $this->format($requirements);
  19930. }
  19931. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  19932. return true;
  19933. }
  19934. private function sortPackages(array &$packages = array())
  19935. {
  19936. $prefix = function ($requirement) {
  19937. if (PlatformRepository::isPlatformPackage($requirement)) {
  19938. return Preg::replace(
  19939. array(
  19940. '/^php/',
  19941. '/^hhvm/',
  19942. '/^ext/',
  19943. '/^lib/',
  19944. '/^\D/',
  19945. ),
  19946. array(
  19947. '0-$0',
  19948. '1-$0',
  19949. '2-$0',
  19950. '3-$0',
  19951. '4-$0',
  19952. ),
  19953. $requirement
  19954. );
  19955. }
  19956. return '5-'.$requirement;
  19957. };
  19958. uksort($packages, function ($a, $b) use ($prefix) {
  19959. return strnatcmp($prefix($a), $prefix($b));
  19960. });
  19961. }
  19962. public function addRepository($name, $config, $append = true)
  19963. {
  19964. return $this->addSubNode('repositories', $name, $config, $append);
  19965. }
  19966. public function removeRepository($name)
  19967. {
  19968. return $this->removeSubNode('repositories', $name);
  19969. }
  19970. public function addConfigSetting($name, $value)
  19971. {
  19972. return $this->addSubNode('config', $name, $value);
  19973. }
  19974. public function removeConfigSetting($name)
  19975. {
  19976. return $this->removeSubNode('config', $name);
  19977. }
  19978. public function addProperty($name, $value)
  19979. {
  19980. if (strpos($name, 'suggest.') === 0) {
  19981. return $this->addSubNode('suggest', substr($name, 8), $value);
  19982. }
  19983. if (strpos($name, 'extra.') === 0) {
  19984. return $this->addSubNode('extra', substr($name, 6), $value);
  19985. }
  19986. if (strpos($name, 'scripts.') === 0) {
  19987. return $this->addSubNode('scripts', substr($name, 8), $value);
  19988. }
  19989. return $this->addMainKey($name, $value);
  19990. }
  19991. public function removeProperty($name)
  19992. {
  19993. if (strpos($name, 'suggest.') === 0) {
  19994. return $this->removeSubNode('suggest', substr($name, 8));
  19995. }
  19996. if (strpos($name, 'extra.') === 0) {
  19997. return $this->removeSubNode('extra', substr($name, 6));
  19998. }
  19999. if (strpos($name, 'scripts.') === 0) {
  20000. return $this->removeSubNode('scripts', substr($name, 8));
  20001. }
  20002. return $this->removeMainKey($name);
  20003. }
  20004. public function addSubNode($mainNode, $name, $value, $append = true)
  20005. {
  20006. $decoded = JsonFile::parseJson($this->contents);
  20007. $subName = null;
  20008. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  20009. list($name, $subName) = explode('.', $name, 2);
  20010. }
  20011. if (!isset($decoded[$mainNode])) {
  20012. if ($subName !== null) {
  20013. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  20014. } else {
  20015. $this->addMainKey($mainNode, array($name => $value));
  20016. }
  20017. return true;
  20018. }
  20019. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  20020. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  20021. try {
  20022. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  20023. return false;
  20024. }
  20025. } catch (\RuntimeException $e) {
  20026. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  20027. return false;
  20028. }
  20029. throw $e;
  20030. }
  20031. $children = $match['content'];
  20032. if (!@json_decode($children)) {
  20033. return false;
  20034. }
  20035. $that = $this;
  20036. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  20037. if (Preg::isMatch($childRegex, $children, $matches)) {
  20038. $children = Preg::replaceCallback($childRegex, function ($matches) use ($subName, $value, $that) {
  20039. if ($subName !== null) {
  20040. $curVal = json_decode($matches['content'], true);
  20041. if (!is_array($curVal)) {
  20042. $curVal = array();
  20043. }
  20044. $curVal[$subName] = $value;
  20045. $value = $curVal;
  20046. }
  20047. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  20048. }, $children);
  20049. } else {
  20050. Preg::match('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  20051. $whitespace = '';
  20052. if (!empty($match['trailingspace'])) {
  20053. $whitespace = $match['trailingspace'];
  20054. }
  20055. if (!empty($match['content'])) {
  20056. if ($subName !== null) {
  20057. $value = array($subName => $value);
  20058. }
  20059. if ($append) {
  20060. $children = Preg::replace(
  20061. '#'.$whitespace.'}$#',
  20062. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  20063. $children
  20064. );
  20065. } else {
  20066. $whitespace = '';
  20067. if (!empty($match['leadingspace'])) {
  20068. $whitespace = $match['leadingspace'];
  20069. }
  20070. $children = Preg::replace(
  20071. '#^{'.$whitespace.'#',
  20072. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  20073. $children
  20074. );
  20075. }
  20076. } else {
  20077. if ($subName !== null) {
  20078. $value = array($subName => $value);
  20079. }
  20080. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  20081. }
  20082. }
  20083. $this->contents = Preg::replaceCallback($nodeRegex, function ($m) use ($children) {
  20084. return $m['start'] . $children . $m['end'];
  20085. }, $this->contents);
  20086. return true;
  20087. }
  20088. public function removeSubNode($mainNode, $name)
  20089. {
  20090. $decoded = JsonFile::parseJson($this->contents);
  20091. if (empty($decoded[$mainNode])) {
  20092. return true;
  20093. }
  20094. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  20095. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  20096. try {
  20097. if (!Preg::isMatch($nodeRegex, $this->contents, $match)) {
  20098. return false;
  20099. }
  20100. } catch (\RuntimeException $e) {
  20101. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  20102. return false;
  20103. }
  20104. throw $e;
  20105. }
  20106. $children = $match['content'];
  20107. if (!@json_decode($children, true)) {
  20108. return false;
  20109. }
  20110. $subName = null;
  20111. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  20112. list($name, $subName) = explode('.', $name, 2);
  20113. }
  20114. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  20115. return true;
  20116. }
  20117. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  20118. if (Preg::isMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  20119. if (Preg::isMatchAll('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  20120. $bestMatch = '';
  20121. foreach ($matches[0] as $match) {
  20122. if (strlen($bestMatch) < strlen($match)) {
  20123. $bestMatch = $match;
  20124. }
  20125. }
  20126. $childrenClean = Preg::replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  20127. if (1 !== $count) {
  20128. $childrenClean = Preg::replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  20129. if (1 !== $count) {
  20130. return false;
  20131. }
  20132. }
  20133. }
  20134. } else {
  20135. $childrenClean = $children;
  20136. }
  20137. if (!isset($childrenClean)) {
  20138. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  20139. }
  20140. Preg::match('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  20141. if (empty($match['content'])) {
  20142. $newline = $this->newline;
  20143. $indent = $this->indent;
  20144. $this->contents = Preg::replaceCallback($nodeRegex, function ($matches) use ($indent, $newline) {
  20145. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  20146. }, $this->contents);
  20147. if ($subName !== null) {
  20148. $curVal = json_decode($children, true);
  20149. unset($curVal[$name][$subName]);
  20150. $this->addSubNode($mainNode, $name, $curVal[$name]);
  20151. }
  20152. return true;
  20153. }
  20154. $that = $this;
  20155. $this->contents = Preg::replaceCallback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  20156. if ($subName !== null) {
  20157. $curVal = json_decode($matches['content'], true);
  20158. unset($curVal[$name][$subName]);
  20159. $childrenClean = $that->format($curVal);
  20160. }
  20161. return $matches['start'] . $childrenClean . $matches['end'];
  20162. }, $this->contents);
  20163. return true;
  20164. }
  20165. public function addMainKey($key, $content)
  20166. {
  20167. $decoded = JsonFile::parseJson($this->contents);
  20168. $content = $this->format($content);
  20169. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  20170. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  20171. if (isset($decoded[$key]) && Preg::isMatch($regex, $this->contents, $matches)) {
  20172. if (!@json_decode('{'.$matches['key'].'}')) {
  20173. return false;
  20174. }
  20175. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  20176. return true;
  20177. }
  20178. if (Preg::isMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  20179. $this->contents = Preg::replace(
  20180. '#'.$match[1].'\}$#',
  20181. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  20182. $this->contents
  20183. );
  20184. return true;
  20185. }
  20186. $this->contents = Preg::replace(
  20187. '#\}$#',
  20188. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  20189. $this->contents
  20190. );
  20191. return true;
  20192. }
  20193. public function removeMainKey($key)
  20194. {
  20195. $decoded = JsonFile::parseJson($this->contents);
  20196. if (!array_key_exists($key, $decoded)) {
  20197. return true;
  20198. }
  20199. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  20200. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  20201. if (Preg::isMatch($regex, $this->contents, $matches)) {
  20202. if (!@json_decode('{'.$matches['removal'].'}')) {
  20203. return false;
  20204. }
  20205. if (Preg::isMatch('#,\s*$#', $matches['start']) && Preg::isMatch('#^\}$#', $matches['end'])) {
  20206. $matches['start'] = rtrim(Preg::replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  20207. }
  20208. $this->contents = $matches['start'] . $matches['end'];
  20209. if (Preg::isMatch('#^\{\s*\}\s*$#', $this->contents)) {
  20210. $this->contents = "{\n}";
  20211. }
  20212. return true;
  20213. }
  20214. return false;
  20215. }
  20216. public function removeMainKeyIfEmpty($key)
  20217. {
  20218. $decoded = JsonFile::parseJson($this->contents);
  20219. if (!array_key_exists($key, $decoded)) {
  20220. return true;
  20221. }
  20222. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  20223. return $this->removeMainKey($key);
  20224. }
  20225. return true;
  20226. }
  20227. public function format($data, $depth = 0)
  20228. {
  20229. if (is_array($data)) {
  20230. reset($data);
  20231. if (is_numeric(key($data))) {
  20232. foreach ($data as $key => $val) {
  20233. $data[$key] = $this->format($val, $depth + 1);
  20234. }
  20235. return '['.implode(', ', $data).']';
  20236. }
  20237. $out = '{' . $this->newline;
  20238. $elems = array();
  20239. foreach ($data as $key => $val) {
  20240. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  20241. }
  20242. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  20243. }
  20244. return JsonFile::encode($data);
  20245. }
  20246. protected function detectIndenting()
  20247. {
  20248. if (Preg::isMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  20249. $this->indent = $match[1];
  20250. } else {
  20251. $this->indent = ' ';
  20252. }
  20253. }
  20254. }
  20255. <?php
  20256. namespace Composer\Json;
  20257. use Exception;
  20258. class JsonValidationException extends Exception
  20259. {
  20260. protected $errors;
  20261. public function __construct($message, $errors = array(), Exception $previous = null)
  20262. {
  20263. $this->errors = $errors;
  20264. parent::__construct((string) $message, 0, $previous);
  20265. }
  20266. public function getErrors()
  20267. {
  20268. return $this->errors;
  20269. }
  20270. }
  20271. <?php
  20272. namespace Composer\Package;
  20273. use Composer\Semver\Constraint\Constraint;
  20274. use Composer\Package\Version\VersionParser;
  20275. class AliasPackage extends BasePackage
  20276. {
  20277. protected $version;
  20278. protected $prettyVersion;
  20279. protected $dev;
  20280. protected $rootPackageAlias = false;
  20281. protected $stability;
  20282. protected $hasSelfVersionRequires = false;
  20283. protected $aliasOf;
  20284. protected $requires;
  20285. protected $devRequires;
  20286. protected $conflicts;
  20287. protected $provides;
  20288. protected $replaces;
  20289. public function __construct(BasePackage $aliasOf, $version, $prettyVersion)
  20290. {
  20291. parent::__construct($aliasOf->getName());
  20292. $this->version = $version;
  20293. $this->prettyVersion = $prettyVersion;
  20294. $this->aliasOf = $aliasOf;
  20295. $this->stability = VersionParser::parseStability($version);
  20296. $this->dev = $this->stability === 'dev';
  20297. foreach (Link::$TYPES as $type) {
  20298. $links = $aliasOf->{'get' . ucfirst($type)}();
  20299. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  20300. }
  20301. }
  20302. public function getAliasOf()
  20303. {
  20304. return $this->aliasOf;
  20305. }
  20306. public function getVersion()
  20307. {
  20308. return $this->version;
  20309. }
  20310. public function getStability()
  20311. {
  20312. return $this->stability;
  20313. }
  20314. public function getPrettyVersion()
  20315. {
  20316. return $this->prettyVersion;
  20317. }
  20318. public function isDev()
  20319. {
  20320. return $this->dev;
  20321. }
  20322. public function getRequires()
  20323. {
  20324. return $this->requires;
  20325. }
  20326. public function getConflicts()
  20327. {
  20328. return $this->conflicts;
  20329. }
  20330. public function getProvides()
  20331. {
  20332. return $this->provides;
  20333. }
  20334. public function getReplaces()
  20335. {
  20336. return $this->replaces;
  20337. }
  20338. public function getDevRequires()
  20339. {
  20340. return $this->devRequires;
  20341. }
  20342. public function setRootPackageAlias($value)
  20343. {
  20344. return $this->rootPackageAlias = $value;
  20345. }
  20346. public function isRootPackageAlias()
  20347. {
  20348. return $this->rootPackageAlias;
  20349. }
  20350. protected function replaceSelfVersionDependencies(array $links, $linkType)
  20351. {
  20352. $prettyVersion = $this->prettyVersion;
  20353. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  20354. $prettyVersion = $this->aliasOf->getPrettyVersion();
  20355. }
  20356. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  20357. $newLinks = array();
  20358. foreach ($links as $link) {
  20359. if ('self.version' === $link->getPrettyConstraint()) {
  20360. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  20361. $constraint->setPrettyString($prettyVersion);
  20362. }
  20363. }
  20364. $links = array_merge($links, $newLinks);
  20365. } else {
  20366. foreach ($links as $index => $link) {
  20367. if ('self.version' === $link->getPrettyConstraint()) {
  20368. if ($linkType === Link::TYPE_REQUIRE) {
  20369. $this->hasSelfVersionRequires = true;
  20370. }
  20371. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  20372. $constraint->setPrettyString($prettyVersion);
  20373. }
  20374. }
  20375. }
  20376. return $links;
  20377. }
  20378. public function hasSelfVersionRequires()
  20379. {
  20380. return $this->hasSelfVersionRequires;
  20381. }
  20382. public function __toString()
  20383. {
  20384. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  20385. }
  20386. public function getType()
  20387. {
  20388. return $this->aliasOf->getType();
  20389. }
  20390. public function getTargetDir()
  20391. {
  20392. return $this->aliasOf->getTargetDir();
  20393. }
  20394. public function getExtra()
  20395. {
  20396. return $this->aliasOf->getExtra();
  20397. }
  20398. public function setInstallationSource($type)
  20399. {
  20400. $this->aliasOf->setInstallationSource($type);
  20401. }
  20402. public function getInstallationSource()
  20403. {
  20404. return $this->aliasOf->getInstallationSource();
  20405. }
  20406. public function getSourceType()
  20407. {
  20408. return $this->aliasOf->getSourceType();
  20409. }
  20410. public function getSourceUrl()
  20411. {
  20412. return $this->aliasOf->getSourceUrl();
  20413. }
  20414. public function getSourceUrls()
  20415. {
  20416. return $this->aliasOf->getSourceUrls();
  20417. }
  20418. public function getSourceReference()
  20419. {
  20420. return $this->aliasOf->getSourceReference();
  20421. }
  20422. public function setSourceReference($reference)
  20423. {
  20424. $this->aliasOf->setSourceReference($reference);
  20425. }
  20426. public function setSourceMirrors($mirrors)
  20427. {
  20428. $this->aliasOf->setSourceMirrors($mirrors);
  20429. }
  20430. public function getSourceMirrors()
  20431. {
  20432. return $this->aliasOf->getSourceMirrors();
  20433. }
  20434. public function getDistType()
  20435. {
  20436. return $this->aliasOf->getDistType();
  20437. }
  20438. public function getDistUrl()
  20439. {
  20440. return $this->aliasOf->getDistUrl();
  20441. }
  20442. public function getDistUrls()
  20443. {
  20444. return $this->aliasOf->getDistUrls();
  20445. }
  20446. public function getDistReference()
  20447. {
  20448. return $this->aliasOf->getDistReference();
  20449. }
  20450. public function setDistReference($reference)
  20451. {
  20452. $this->aliasOf->setDistReference($reference);
  20453. }
  20454. public function getDistSha1Checksum()
  20455. {
  20456. return $this->aliasOf->getDistSha1Checksum();
  20457. }
  20458. public function setTransportOptions(array $options)
  20459. {
  20460. $this->aliasOf->setTransportOptions($options);
  20461. }
  20462. public function getTransportOptions()
  20463. {
  20464. return $this->aliasOf->getTransportOptions();
  20465. }
  20466. public function setDistMirrors($mirrors)
  20467. {
  20468. $this->aliasOf->setDistMirrors($mirrors);
  20469. }
  20470. public function getDistMirrors()
  20471. {
  20472. return $this->aliasOf->getDistMirrors();
  20473. }
  20474. public function getAutoload()
  20475. {
  20476. return $this->aliasOf->getAutoload();
  20477. }
  20478. public function getDevAutoload()
  20479. {
  20480. return $this->aliasOf->getDevAutoload();
  20481. }
  20482. public function getIncludePaths()
  20483. {
  20484. return $this->aliasOf->getIncludePaths();
  20485. }
  20486. public function getReleaseDate()
  20487. {
  20488. return $this->aliasOf->getReleaseDate();
  20489. }
  20490. public function getBinaries()
  20491. {
  20492. return $this->aliasOf->getBinaries();
  20493. }
  20494. public function getSuggests()
  20495. {
  20496. return $this->aliasOf->getSuggests();
  20497. }
  20498. public function getNotificationUrl()
  20499. {
  20500. return $this->aliasOf->getNotificationUrl();
  20501. }
  20502. public function isDefaultBranch()
  20503. {
  20504. return $this->aliasOf->isDefaultBranch();
  20505. }
  20506. public function setDistUrl($url)
  20507. {
  20508. $this->aliasOf->setDistUrl($url);
  20509. }
  20510. public function setDistType($type)
  20511. {
  20512. $this->aliasOf->setDistType($type);
  20513. }
  20514. public function setSourceDistReferences($reference)
  20515. {
  20516. $this->aliasOf->setSourceDistReferences($reference);
  20517. }
  20518. }
  20519. <?php
  20520. namespace Composer\Package\Archiver;
  20521. use FilterIterator;
  20522. use PharData;
  20523. class ArchivableFilesFilter extends FilterIterator
  20524. {
  20525. private $dirs = array();
  20526. #[\ReturnTypeWillChange]
  20527. public function accept()
  20528. {
  20529. $file = $this->getInnerIterator()->current();
  20530. if ($file->isDir()) {
  20531. $this->dirs[] = (string) $file;
  20532. return false;
  20533. }
  20534. return true;
  20535. }
  20536. public function addEmptyDir(PharData $phar, $sources)
  20537. {
  20538. foreach ($this->dirs as $filepath) {
  20539. $localname = str_replace($sources . "/", '', $filepath);
  20540. $phar->addEmptyDir($localname);
  20541. }
  20542. }
  20543. }
  20544. <?php
  20545. namespace Composer\Package\Archiver;
  20546. use Composer\Pcre\Preg;
  20547. use Composer\Util\Filesystem;
  20548. use FilesystemIterator;
  20549. use Symfony\Component\Finder\Finder;
  20550. use Symfony\Component\Finder\SplFileInfo;
  20551. class ArchivableFilesFinder extends \FilterIterator
  20552. {
  20553. protected $finder;
  20554. public function __construct($sources, array $excludes, $ignoreFilters = false)
  20555. {
  20556. $fs = new Filesystem();
  20557. $sources = $fs->normalizePath(realpath($sources));
  20558. if ($ignoreFilters) {
  20559. $filters = array();
  20560. } else {
  20561. $filters = array(
  20562. new GitExcludeFilter($sources),
  20563. new ComposerExcludeFilter($sources, $excludes),
  20564. );
  20565. }
  20566. $this->finder = new Finder();
  20567. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  20568. if ($file->isLink() && strpos($file->getRealPath(), $sources) !== 0) {
  20569. return false;
  20570. }
  20571. $relativePath = Preg::replace(
  20572. '#^'.preg_quote($sources, '#').'#',
  20573. '',
  20574. $fs->normalizePath($file->getRealPath())
  20575. );
  20576. $exclude = false;
  20577. foreach ($filters as $filter) {
  20578. $exclude = $filter->filter($relativePath, $exclude);
  20579. }
  20580. return !$exclude;
  20581. };
  20582. if (method_exists($filter, 'bindTo')) {
  20583. $filter = $filter->bindTo(null);
  20584. }
  20585. $this->finder
  20586. ->in($sources)
  20587. ->filter($filter)
  20588. ->ignoreVCS(true)
  20589. ->ignoreDotFiles(false)
  20590. ->sortByName();
  20591. parent::__construct($this->finder->getIterator());
  20592. }
  20593. #[\ReturnTypeWillChange]
  20594. public function accept()
  20595. {
  20596. $current = $this->getInnerIterator()->current();
  20597. if (!$current->isDir()) {
  20598. return true;
  20599. }
  20600. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  20601. return !$iterator->valid();
  20602. }
  20603. }
  20604. <?php
  20605. namespace Composer\Package\Archiver;
  20606. use Composer\Downloader\DownloadManager;
  20607. use Composer\Package\RootPackageInterface;
  20608. use Composer\Pcre\Preg;
  20609. use Composer\Util\Filesystem;
  20610. use Composer\Util\Loop;
  20611. use Composer\Util\SyncHelper;
  20612. use Composer\Json\JsonFile;
  20613. use Composer\Package\CompletePackageInterface;
  20614. class ArchiveManager
  20615. {
  20616. protected $downloadManager;
  20617. protected $loop;
  20618. protected $archivers = array();
  20619. protected $overwriteFiles = true;
  20620. public function __construct(DownloadManager $downloadManager, Loop $loop)
  20621. {
  20622. $this->downloadManager = $downloadManager;
  20623. $this->loop = $loop;
  20624. }
  20625. public function addArchiver(ArchiverInterface $archiver)
  20626. {
  20627. $this->archivers[] = $archiver;
  20628. }
  20629. public function setOverwriteFiles($overwriteFiles)
  20630. {
  20631. $this->overwriteFiles = $overwriteFiles;
  20632. return $this;
  20633. }
  20634. public function getPackageFilename(CompletePackageInterface $package)
  20635. {
  20636. if ($package->getArchiveName()) {
  20637. $baseName = $package->getArchiveName();
  20638. } else {
  20639. $baseName = Preg::replace('#[^a-z0-9-_]#i', '-', $package->getName());
  20640. }
  20641. $nameParts = array($baseName);
  20642. if (null !== $package->getDistReference() && Preg::isMatch('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  20643. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  20644. } else {
  20645. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  20646. }
  20647. if ($package->getSourceReference()) {
  20648. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  20649. }
  20650. $name = implode('-', array_filter($nameParts, function ($p) {
  20651. return !empty($p);
  20652. }));
  20653. return str_replace('/', '-', $name);
  20654. }
  20655. public function archive(CompletePackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  20656. {
  20657. if (empty($format)) {
  20658. throw new \InvalidArgumentException('Format must be specified');
  20659. }
  20660. $usableArchiver = null;
  20661. foreach ($this->archivers as $archiver) {
  20662. if ($archiver->supports($format, $package->getSourceType())) {
  20663. $usableArchiver = $archiver;
  20664. break;
  20665. }
  20666. }
  20667. if (null === $usableArchiver) {
  20668. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  20669. }
  20670. $filesystem = new Filesystem();
  20671. if ($package instanceof RootPackageInterface) {
  20672. $sourcePath = realpath('.');
  20673. } else {
  20674. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  20675. $filesystem->ensureDirectoryExists($sourcePath);
  20676. try {
  20677. $promise = $this->downloadManager->download($package, $sourcePath);
  20678. SyncHelper::await($this->loop, $promise);
  20679. $promise = $this->downloadManager->install($package, $sourcePath);
  20680. SyncHelper::await($this->loop, $promise);
  20681. } catch (\Exception $e) {
  20682. $filesystem->removeDirectory($sourcePath);
  20683. throw $e;
  20684. }
  20685. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  20686. $jsonFile = new JsonFile($composerJsonPath);
  20687. $jsonData = $jsonFile->read();
  20688. if (!empty($jsonData['archive']['name'])) {
  20689. $package->setArchiveName($jsonData['archive']['name']);
  20690. }
  20691. if (!empty($jsonData['archive']['exclude'])) {
  20692. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  20693. }
  20694. }
  20695. }
  20696. if (null === $fileName) {
  20697. $packageName = $this->getPackageFilename($package);
  20698. } else {
  20699. $packageName = $fileName;
  20700. }
  20701. $filesystem->ensureDirectoryExists($targetDir);
  20702. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  20703. $filesystem->ensureDirectoryExists(dirname($target));
  20704. if (!$this->overwriteFiles && file_exists($target)) {
  20705. return $target;
  20706. }
  20707. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  20708. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  20709. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  20710. $filesystem->rename($archivePath, $target);
  20711. if (!$package instanceof RootPackageInterface) {
  20712. $filesystem->removeDirectory($sourcePath);
  20713. }
  20714. $filesystem->remove($tempTarget);
  20715. return $target;
  20716. }
  20717. }
  20718. <?php
  20719. namespace Composer\Package\Archiver;
  20720. interface ArchiverInterface
  20721. {
  20722. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  20723. public function supports($format, $sourceType);
  20724. }
  20725. <?php
  20726. namespace Composer\Package\Archiver;
  20727. use Composer\Pcre\Preg;
  20728. use Symfony\Component\Finder;
  20729. abstract class BaseExcludeFilter
  20730. {
  20731. protected $sourcePath;
  20732. protected $excludePatterns;
  20733. public function __construct($sourcePath)
  20734. {
  20735. $this->sourcePath = $sourcePath;
  20736. $this->excludePatterns = array();
  20737. }
  20738. public function filter($relativePath, $exclude)
  20739. {
  20740. foreach ($this->excludePatterns as $patternData) {
  20741. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  20742. if ($stripLeadingSlash) {
  20743. $path = substr($relativePath, 1);
  20744. } else {
  20745. $path = $relativePath;
  20746. }
  20747. try {
  20748. if (Preg::isMatch($pattern, $path)) {
  20749. $exclude = !$negate;
  20750. }
  20751. } catch (\RuntimeException $e) {
  20752. }
  20753. }
  20754. return $exclude;
  20755. }
  20756. protected function parseLines(array $lines, $lineParser)
  20757. {
  20758. return array_filter(
  20759. array_map(
  20760. function ($line) use ($lineParser) {
  20761. $line = trim($line);
  20762. if (!$line || 0 === strpos($line, '#')) {
  20763. return null;
  20764. }
  20765. return call_user_func($lineParser, $line);
  20766. },
  20767. $lines
  20768. ),
  20769. function ($pattern) {
  20770. return $pattern !== null;
  20771. }
  20772. );
  20773. }
  20774. protected function generatePatterns($rules)
  20775. {
  20776. $patterns = array();
  20777. foreach ($rules as $rule) {
  20778. $patterns[] = $this->generatePattern($rule);
  20779. }
  20780. return $patterns;
  20781. }
  20782. protected function generatePattern($rule)
  20783. {
  20784. $negate = false;
  20785. $pattern = '';
  20786. if ($rule !== '' && $rule[0] === '!') {
  20787. $negate = true;
  20788. $rule = ltrim($rule, '!');
  20789. }
  20790. $firstSlashPosition = strpos($rule, '/');
  20791. if (0 === $firstSlashPosition) {
  20792. $pattern = '^/';
  20793. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  20794. $pattern = '/';
  20795. }
  20796. $rule = trim($rule, '/');
  20797. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  20798. return array('{'.$pattern.$rule.'(?=$|/)}', $negate, false);
  20799. }
  20800. }
  20801. <?php
  20802. namespace Composer\Package\Archiver;
  20803. class ComposerExcludeFilter extends BaseExcludeFilter
  20804. {
  20805. public function __construct($sourcePath, array $excludeRules)
  20806. {
  20807. parent::__construct($sourcePath);
  20808. $this->excludePatterns = $this->generatePatterns($excludeRules);
  20809. }
  20810. }
  20811. <?php
  20812. namespace Composer\Package\Archiver;
  20813. use Composer\Pcre\Preg;
  20814. class GitExcludeFilter extends BaseExcludeFilter
  20815. {
  20816. public function __construct($sourcePath)
  20817. {
  20818. parent::__construct($sourcePath);
  20819. if (file_exists($sourcePath.'/.gitattributes')) {
  20820. $this->excludePatterns = array_merge(
  20821. $this->excludePatterns,
  20822. $this->parseLines(
  20823. file($sourcePath.'/.gitattributes'),
  20824. array($this, 'parseGitAttributesLine')
  20825. )
  20826. );
  20827. }
  20828. }
  20829. public function parseGitAttributesLine($line)
  20830. {
  20831. $parts = Preg::split('#\s+#', $line);
  20832. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  20833. return $this->generatePattern($parts[0]);
  20834. }
  20835. if (count($parts) == 2 && $parts[1] === '-export-ignore') {
  20836. return $this->generatePattern('!'.$parts[0]);
  20837. }
  20838. return null;
  20839. }
  20840. }
  20841. <?php
  20842. namespace Composer\Package\Archiver;
  20843. class PharArchiver implements ArchiverInterface
  20844. {
  20845. protected static $formats = array(
  20846. 'zip' => \Phar::ZIP,
  20847. 'tar' => \Phar::TAR,
  20848. 'tar.gz' => \Phar::TAR,
  20849. 'tar.bz2' => \Phar::TAR,
  20850. );
  20851. protected static $compressFormats = array(
  20852. 'tar.gz' => \Phar::GZ,
  20853. 'tar.bz2' => \Phar::BZ2,
  20854. );
  20855. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  20856. {
  20857. $sources = realpath($sources);
  20858. if (file_exists($target)) {
  20859. unlink($target);
  20860. }
  20861. try {
  20862. $filename = substr($target, 0, strrpos($target, $format) - 1);
  20863. if (isset(static::$compressFormats[$format])) {
  20864. $target = $filename . '.tar';
  20865. }
  20866. $phar = new \PharData(
  20867. $target,
  20868. \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO,
  20869. '',
  20870. static::$formats[$format]
  20871. );
  20872. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  20873. $filesOnly = new ArchivableFilesFilter($files);
  20874. $phar->buildFromIterator($filesOnly, $sources);
  20875. $filesOnly->addEmptyDir($phar, $sources);
  20876. if (isset(static::$compressFormats[$format])) {
  20877. if (!$phar->canCompress(static::$compressFormats[$format])) {
  20878. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  20879. }
  20880. unlink($target);
  20881. $phar->compress(static::$compressFormats[$format]);
  20882. $target = $filename . '.' . $format;
  20883. }
  20884. return $target;
  20885. } catch (\UnexpectedValueException $e) {
  20886. $message = sprintf(
  20887. "Could not create archive '%s' from '%s': %s",
  20888. $target,
  20889. $sources,
  20890. $e->getMessage()
  20891. );
  20892. throw new \RuntimeException($message, $e->getCode(), $e);
  20893. }
  20894. }
  20895. public function supports($format, $sourceType)
  20896. {
  20897. return isset(static::$formats[$format]);
  20898. }
  20899. }
  20900. <?php
  20901. namespace Composer\Package\Archiver;
  20902. use ZipArchive;
  20903. use Composer\Util\Filesystem;
  20904. class ZipArchiver implements ArchiverInterface
  20905. {
  20906. protected static $formats = array(
  20907. 'zip' => true,
  20908. );
  20909. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  20910. {
  20911. $fs = new Filesystem();
  20912. $sources = $fs->normalizePath($sources);
  20913. $zip = new ZipArchive();
  20914. $res = $zip->open($target, ZipArchive::CREATE);
  20915. if ($res === true) {
  20916. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  20917. foreach ($files as $file) {
  20918. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  20919. $localname = $filepath;
  20920. if (strpos($localname, $sources . '/') === 0) {
  20921. $localname = substr($localname, strlen($sources . '/'));
  20922. }
  20923. if ($file->isDir()) {
  20924. $zip->addEmptyDir($localname);
  20925. } else {
  20926. $zip->addFile($filepath, $localname);
  20927. }
  20928. if (PHP_VERSION_ID >= 50600 && method_exists($zip, 'setExternalAttributesName')) {
  20929. $perms = fileperms($filepath);
  20930. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  20931. }
  20932. }
  20933. if ($zip->close()) {
  20934. return $target;
  20935. }
  20936. }
  20937. $message = sprintf(
  20938. "Could not create archive '%s' from '%s': %s",
  20939. $target,
  20940. $sources,
  20941. $zip->getStatusString()
  20942. );
  20943. throw new \RuntimeException($message);
  20944. }
  20945. public function supports($format, $sourceType)
  20946. {
  20947. return isset(static::$formats[$format]) && $this->compressionAvailable();
  20948. }
  20949. private function compressionAvailable()
  20950. {
  20951. return class_exists('ZipArchive');
  20952. }
  20953. }
  20954. <?php
  20955. namespace Composer\Package;
  20956. use Composer\Repository\RepositoryInterface;
  20957. use Composer\Repository\PlatformRepository;
  20958. abstract class BasePackage implements PackageInterface
  20959. {
  20960. public static $supportedLinkTypes = array(
  20961. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  20962. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  20963. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  20964. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  20965. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  20966. );
  20967. const STABILITY_STABLE = 0;
  20968. const STABILITY_RC = 5;
  20969. const STABILITY_BETA = 10;
  20970. const STABILITY_ALPHA = 15;
  20971. const STABILITY_DEV = 20;
  20972. public static $stabilities = array(
  20973. 'stable' => self::STABILITY_STABLE,
  20974. 'RC' => self::STABILITY_RC,
  20975. 'beta' => self::STABILITY_BETA,
  20976. 'alpha' => self::STABILITY_ALPHA,
  20977. 'dev' => self::STABILITY_DEV,
  20978. );
  20979. public $id;
  20980. protected $name;
  20981. protected $prettyName;
  20982. protected $repository = null;
  20983. public function __construct($name)
  20984. {
  20985. $this->prettyName = $name;
  20986. $this->name = strtolower($name);
  20987. $this->id = -1;
  20988. }
  20989. public function getName()
  20990. {
  20991. return $this->name;
  20992. }
  20993. public function getPrettyName()
  20994. {
  20995. return $this->prettyName;
  20996. }
  20997. public function getNames($provides = true)
  20998. {
  20999. $names = array(
  21000. $this->getName() => true,
  21001. );
  21002. if ($provides) {
  21003. foreach ($this->getProvides() as $link) {
  21004. $names[$link->getTarget()] = true;
  21005. }
  21006. }
  21007. foreach ($this->getReplaces() as $link) {
  21008. $names[$link->getTarget()] = true;
  21009. }
  21010. return array_keys($names);
  21011. }
  21012. public function setId($id)
  21013. {
  21014. $this->id = $id;
  21015. }
  21016. public function getId()
  21017. {
  21018. return $this->id;
  21019. }
  21020. public function setRepository(RepositoryInterface $repository)
  21021. {
  21022. if ($this->repository && $repository !== $this->repository) {
  21023. throw new \LogicException('A package can only be added to one repository');
  21024. }
  21025. $this->repository = $repository;
  21026. }
  21027. public function getRepository()
  21028. {
  21029. return $this->repository;
  21030. }
  21031. public function isPlatform()
  21032. {
  21033. return $this->getRepository() instanceof PlatformRepository;
  21034. }
  21035. public function getUniqueName()
  21036. {
  21037. return $this->getName().'-'.$this->getVersion();
  21038. }
  21039. public function equals(PackageInterface $package)
  21040. {
  21041. $self = $this;
  21042. if ($this instanceof AliasPackage) {
  21043. $self = $this->getAliasOf();
  21044. }
  21045. if ($package instanceof AliasPackage) {
  21046. $package = $package->getAliasOf();
  21047. }
  21048. return $package === $self;
  21049. }
  21050. public function __toString()
  21051. {
  21052. return $this->getUniqueName();
  21053. }
  21054. public function getPrettyString()
  21055. {
  21056. return $this->getPrettyName().' '.$this->getPrettyVersion();
  21057. }
  21058. public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
  21059. {
  21060. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  21061. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  21062. ) {
  21063. return $this->getPrettyVersion();
  21064. }
  21065. switch ($displayMode) {
  21066. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  21067. case PackageInterface::DISPLAY_SOURCE_REF:
  21068. $reference = $this->getSourceReference();
  21069. break;
  21070. case PackageInterface::DISPLAY_DIST_REF:
  21071. $reference = $this->getDistReference();
  21072. break;
  21073. default:
  21074. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  21075. }
  21076. if (null === $reference) {
  21077. return $this->getPrettyVersion();
  21078. }
  21079. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  21080. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  21081. }
  21082. return $this->getPrettyVersion() . ' ' . $reference;
  21083. }
  21084. public function getStabilityPriority()
  21085. {
  21086. return self::$stabilities[$this->getStability()];
  21087. }
  21088. public function __clone()
  21089. {
  21090. $this->repository = null;
  21091. $this->id = -1;
  21092. }
  21093. public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
  21094. {
  21095. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  21096. return sprintf($wrap, $cleanedAllowPattern);
  21097. }
  21098. public static function packageNamesToRegexp(array $packageNames, $wrap = '{^(?:%s)$}iD')
  21099. {
  21100. $packageNames = array_map(
  21101. function ($packageName) {
  21102. return BasePackage::packageNameToRegexp($packageName, '%s');
  21103. },
  21104. $packageNames
  21105. );
  21106. return sprintf($wrap, implode('|', $packageNames));
  21107. }
  21108. }
  21109. <?php
  21110. namespace Composer\Package\Comparer;
  21111. class Comparer
  21112. {
  21113. private $source;
  21114. private $update;
  21115. private $changed;
  21116. public function setSource($source)
  21117. {
  21118. $this->source = $source;
  21119. }
  21120. public function setUpdate($update)
  21121. {
  21122. $this->update = $update;
  21123. }
  21124. public function getChanged($toString = false, $explicated = false)
  21125. {
  21126. $changed = $this->changed;
  21127. if (!count($changed)) {
  21128. return false;
  21129. }
  21130. if ($explicated) {
  21131. foreach ($changed as $sectionKey => $itemSection) {
  21132. foreach ($itemSection as $itemKey => $item) {
  21133. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  21134. }
  21135. }
  21136. }
  21137. if ($toString) {
  21138. $strings = array();
  21139. foreach ($changed as $sectionKey => $itemSection) {
  21140. foreach ($itemSection as $itemKey => $item) {
  21141. $strings[] = $item."\r\n";
  21142. }
  21143. }
  21144. $changed = implode("\r\n", $strings);
  21145. }
  21146. return $changed;
  21147. }
  21148. public function doCompare()
  21149. {
  21150. $source = array();
  21151. $destination = array();
  21152. $this->changed = array();
  21153. $currentDirectory = getcwd();
  21154. chdir($this->source);
  21155. $source = $this->doTree('.', $source);
  21156. if (!is_array($source)) {
  21157. return;
  21158. }
  21159. chdir($currentDirectory);
  21160. chdir($this->update);
  21161. $destination = $this->doTree('.', $destination);
  21162. if (!is_array($destination)) {
  21163. exit;
  21164. }
  21165. chdir($currentDirectory);
  21166. foreach ($source as $dir => $value) {
  21167. foreach ($value as $file => $hash) {
  21168. if (isset($destination[$dir][$file])) {
  21169. if ($hash !== $destination[$dir][$file]) {
  21170. $this->changed['changed'][] = $dir.'/'.$file;
  21171. }
  21172. } else {
  21173. $this->changed['removed'][] = $dir.'/'.$file;
  21174. }
  21175. }
  21176. }
  21177. foreach ($destination as $dir => $value) {
  21178. foreach ($value as $file => $hash) {
  21179. if (!isset($source[$dir][$file])) {
  21180. $this->changed['added'][] = $dir.'/'.$file;
  21181. }
  21182. }
  21183. }
  21184. }
  21185. private function doTree($dir, &$array)
  21186. {
  21187. if ($dh = opendir($dir)) {
  21188. while ($file = readdir($dh)) {
  21189. if ($file !== '.' && $file !== '..') {
  21190. if (is_link($dir.'/'.$file)) {
  21191. $array[$dir][$file] = readlink($dir.'/'.$file);
  21192. } elseif (is_dir($dir.'/'.$file)) {
  21193. if (!count($array)) {
  21194. $array[0] = 'Temp';
  21195. }
  21196. if (!$this->doTree($dir.'/'.$file, $array)) {
  21197. return false;
  21198. }
  21199. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  21200. $array[$dir][$file] = md5_file($dir.'/'.$file);
  21201. }
  21202. }
  21203. }
  21204. if (count($array) > 1 && isset($array['0'])) {
  21205. unset($array['0']);
  21206. }
  21207. return $array;
  21208. }
  21209. return false;
  21210. }
  21211. }
  21212. <?php
  21213. namespace Composer\Package;
  21214. class CompleteAliasPackage extends AliasPackage implements CompletePackageInterface
  21215. {
  21216. protected $aliasOf;
  21217. public function __construct(CompletePackage $aliasOf, $version, $prettyVersion)
  21218. {
  21219. parent::__construct($aliasOf, $version, $prettyVersion);
  21220. }
  21221. public function getAliasOf()
  21222. {
  21223. return $this->aliasOf;
  21224. }
  21225. public function getScripts()
  21226. {
  21227. return $this->aliasOf->getScripts();
  21228. }
  21229. public function setScripts(array $scripts)
  21230. {
  21231. $this->aliasOf->setScripts($scripts);
  21232. }
  21233. public function getRepositories()
  21234. {
  21235. return $this->aliasOf->getRepositories();
  21236. }
  21237. public function setRepositories(array $repositories)
  21238. {
  21239. $this->aliasOf->setRepositories($repositories);
  21240. }
  21241. public function getLicense()
  21242. {
  21243. return $this->aliasOf->getLicense();
  21244. }
  21245. public function setLicense(array $license)
  21246. {
  21247. $this->aliasOf->setLicense($license);
  21248. }
  21249. public function getKeywords()
  21250. {
  21251. return $this->aliasOf->getKeywords();
  21252. }
  21253. public function setKeywords(array $keywords)
  21254. {
  21255. $this->aliasOf->setKeywords($keywords);
  21256. }
  21257. public function getDescription()
  21258. {
  21259. return $this->aliasOf->getDescription();
  21260. }
  21261. public function setDescription($description)
  21262. {
  21263. $this->aliasOf->setDescription($description);
  21264. }
  21265. public function getHomepage()
  21266. {
  21267. return $this->aliasOf->getHomepage();
  21268. }
  21269. public function setHomepage($homepage)
  21270. {
  21271. $this->aliasOf->setHomepage($homepage);
  21272. }
  21273. public function getAuthors()
  21274. {
  21275. return $this->aliasOf->getAuthors();
  21276. }
  21277. public function setAuthors(array $authors)
  21278. {
  21279. $this->aliasOf->setAuthors($authors);
  21280. }
  21281. public function getSupport()
  21282. {
  21283. return $this->aliasOf->getSupport();
  21284. }
  21285. public function setSupport(array $support)
  21286. {
  21287. $this->aliasOf->setSupport($support);
  21288. }
  21289. public function getFunding()
  21290. {
  21291. return $this->aliasOf->getFunding();
  21292. }
  21293. public function setFunding(array $funding)
  21294. {
  21295. $this->aliasOf->setFunding($funding);
  21296. }
  21297. public function isAbandoned()
  21298. {
  21299. return $this->aliasOf->isAbandoned();
  21300. }
  21301. public function getReplacementPackage()
  21302. {
  21303. return $this->aliasOf->getReplacementPackage();
  21304. }
  21305. public function setAbandoned($abandoned)
  21306. {
  21307. $this->aliasOf->setAbandoned($abandoned);
  21308. }
  21309. public function getArchiveName()
  21310. {
  21311. return $this->aliasOf->getArchiveName();
  21312. }
  21313. public function setArchiveName($name)
  21314. {
  21315. $this->aliasOf->setArchiveName($name);
  21316. }
  21317. public function getArchiveExcludes()
  21318. {
  21319. return $this->aliasOf->getArchiveExcludes();
  21320. }
  21321. public function setArchiveExcludes(array $excludes)
  21322. {
  21323. $this->aliasOf->setArchiveExcludes($excludes);
  21324. }
  21325. }
  21326. <?php
  21327. namespace Composer\Package;
  21328. class CompletePackage extends Package implements CompletePackageInterface
  21329. {
  21330. protected $repositories = array();
  21331. protected $license = array();
  21332. protected $keywords = array();
  21333. protected $authors = array();
  21334. protected $description = null;
  21335. protected $homepage = null;
  21336. protected $scripts = array();
  21337. protected $support = array();
  21338. protected $funding = array();
  21339. protected $abandoned = false;
  21340. protected $archiveName = null;
  21341. protected $archiveExcludes = array();
  21342. public function setScripts(array $scripts)
  21343. {
  21344. $this->scripts = $scripts;
  21345. }
  21346. public function getScripts()
  21347. {
  21348. return $this->scripts;
  21349. }
  21350. public function setRepositories(array $repositories)
  21351. {
  21352. $this->repositories = $repositories;
  21353. }
  21354. public function getRepositories()
  21355. {
  21356. return $this->repositories;
  21357. }
  21358. public function setLicense(array $license)
  21359. {
  21360. $this->license = $license;
  21361. }
  21362. public function getLicense()
  21363. {
  21364. return $this->license;
  21365. }
  21366. public function setKeywords(array $keywords)
  21367. {
  21368. $this->keywords = $keywords;
  21369. }
  21370. public function getKeywords()
  21371. {
  21372. return $this->keywords;
  21373. }
  21374. public function setAuthors(array $authors)
  21375. {
  21376. $this->authors = $authors;
  21377. }
  21378. public function getAuthors()
  21379. {
  21380. return $this->authors;
  21381. }
  21382. public function setDescription($description)
  21383. {
  21384. $this->description = $description;
  21385. }
  21386. public function getDescription()
  21387. {
  21388. return $this->description;
  21389. }
  21390. public function setHomepage($homepage)
  21391. {
  21392. $this->homepage = $homepage;
  21393. }
  21394. public function getHomepage()
  21395. {
  21396. return $this->homepage;
  21397. }
  21398. public function setSupport(array $support)
  21399. {
  21400. $this->support = $support;
  21401. }
  21402. public function getSupport()
  21403. {
  21404. return $this->support;
  21405. }
  21406. public function setFunding(array $funding)
  21407. {
  21408. $this->funding = $funding;
  21409. }
  21410. public function getFunding()
  21411. {
  21412. return $this->funding;
  21413. }
  21414. public function isAbandoned()
  21415. {
  21416. return (bool) $this->abandoned;
  21417. }
  21418. public function setAbandoned($abandoned)
  21419. {
  21420. $this->abandoned = $abandoned;
  21421. }
  21422. public function getReplacementPackage()
  21423. {
  21424. return \is_string($this->abandoned) ? $this->abandoned : null;
  21425. }
  21426. public function setArchiveName($name)
  21427. {
  21428. $this->archiveName = $name;
  21429. }
  21430. public function getArchiveName()
  21431. {
  21432. return $this->archiveName;
  21433. }
  21434. public function setArchiveExcludes(array $excludes)
  21435. {
  21436. $this->archiveExcludes = $excludes;
  21437. }
  21438. public function getArchiveExcludes()
  21439. {
  21440. return $this->archiveExcludes;
  21441. }
  21442. }
  21443. <?php
  21444. namespace Composer\Package;
  21445. interface CompletePackageInterface extends PackageInterface
  21446. {
  21447. public function getScripts();
  21448. public function setScripts(array $scripts);
  21449. public function getRepositories();
  21450. public function setRepositories(array $repositories);
  21451. public function getLicense();
  21452. public function setLicense(array $license);
  21453. public function getKeywords();
  21454. public function setKeywords(array $keywords);
  21455. public function getDescription();
  21456. public function setDescription($description);
  21457. public function getHomepage();
  21458. public function setHomepage($homepage);
  21459. public function getAuthors();
  21460. public function setAuthors(array $authors);
  21461. public function getSupport();
  21462. public function setSupport(array $support);
  21463. public function getFunding();
  21464. public function setFunding(array $funding);
  21465. public function isAbandoned();
  21466. public function getReplacementPackage();
  21467. public function setAbandoned($abandoned);
  21468. public function getArchiveName();
  21469. public function setArchiveName($name);
  21470. public function getArchiveExcludes();
  21471. public function setArchiveExcludes(array $excludes);
  21472. }
  21473. <?php
  21474. namespace Composer\Package\Dumper;
  21475. use Composer\Package\BasePackage;
  21476. use Composer\Package\PackageInterface;
  21477. use Composer\Package\CompletePackageInterface;
  21478. use Composer\Package\RootPackageInterface;
  21479. class ArrayDumper
  21480. {
  21481. public function dump(PackageInterface $package)
  21482. {
  21483. $keys = array(
  21484. 'binaries' => 'bin',
  21485. 'type',
  21486. 'extra',
  21487. 'installationSource' => 'installation-source',
  21488. 'autoload',
  21489. 'devAutoload' => 'autoload-dev',
  21490. 'notificationUrl' => 'notification-url',
  21491. 'includePaths' => 'include-path',
  21492. );
  21493. $data = array();
  21494. $data['name'] = $package->getPrettyName();
  21495. $data['version'] = $package->getPrettyVersion();
  21496. $data['version_normalized'] = $package->getVersion();
  21497. if ($package->getTargetDir()) {
  21498. $data['target-dir'] = $package->getTargetDir();
  21499. }
  21500. if ($package->getSourceType()) {
  21501. $data['source']['type'] = $package->getSourceType();
  21502. $data['source']['url'] = $package->getSourceUrl();
  21503. if (null !== ($value = $package->getSourceReference())) {
  21504. $data['source']['reference'] = $value;
  21505. }
  21506. if ($mirrors = $package->getSourceMirrors()) {
  21507. $data['source']['mirrors'] = $mirrors;
  21508. }
  21509. }
  21510. if ($package->getDistType()) {
  21511. $data['dist']['type'] = $package->getDistType();
  21512. $data['dist']['url'] = $package->getDistUrl();
  21513. if (null !== ($value = $package->getDistReference())) {
  21514. $data['dist']['reference'] = $value;
  21515. }
  21516. if (null !== ($value = $package->getDistSha1Checksum())) {
  21517. $data['dist']['shasum'] = $value;
  21518. }
  21519. if ($mirrors = $package->getDistMirrors()) {
  21520. $data['dist']['mirrors'] = $mirrors;
  21521. }
  21522. }
  21523. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  21524. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  21525. foreach ($links as $link) {
  21526. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  21527. }
  21528. ksort($data[$type]);
  21529. }
  21530. }
  21531. if ($packages = $package->getSuggests()) {
  21532. ksort($packages);
  21533. $data['suggest'] = $packages;
  21534. }
  21535. if ($package->getReleaseDate()) {
  21536. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  21537. }
  21538. if ($package->isDefaultBranch()) {
  21539. $data['default-branch'] = true;
  21540. }
  21541. $data = $this->dumpValues($package, $keys, $data);
  21542. if ($package instanceof CompletePackageInterface) {
  21543. if ($package->getArchiveName()) {
  21544. $data['archive']['name'] = $package->getArchiveName();
  21545. }
  21546. if ($package->getArchiveExcludes()) {
  21547. $data['archive']['exclude'] = $package->getArchiveExcludes();
  21548. }
  21549. $keys = array(
  21550. 'scripts',
  21551. 'license',
  21552. 'authors',
  21553. 'description',
  21554. 'homepage',
  21555. 'keywords',
  21556. 'repositories',
  21557. 'support',
  21558. 'funding',
  21559. );
  21560. $data = $this->dumpValues($package, $keys, $data);
  21561. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  21562. sort($data['keywords']);
  21563. }
  21564. if ($package->isAbandoned()) {
  21565. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  21566. }
  21567. }
  21568. if ($package instanceof RootPackageInterface) {
  21569. $minimumStability = $package->getMinimumStability();
  21570. if ($minimumStability) {
  21571. $data['minimum-stability'] = $minimumStability;
  21572. }
  21573. }
  21574. if (\count($package->getTransportOptions()) > 0) {
  21575. $data['transport-options'] = $package->getTransportOptions();
  21576. }
  21577. return $data;
  21578. }
  21579. private function dumpValues(PackageInterface $package, array $keys, array $data)
  21580. {
  21581. foreach ($keys as $method => $key) {
  21582. if (is_numeric($method)) {
  21583. $method = $key;
  21584. }
  21585. $getter = 'get'.ucfirst($method);
  21586. $value = $package->$getter();
  21587. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  21588. $data[$key] = $value;
  21589. }
  21590. }
  21591. return $data;
  21592. }
  21593. }
  21594. <?php
  21595. namespace Composer\Package;
  21596. use Composer\Semver\Constraint\ConstraintInterface;
  21597. class Link
  21598. {
  21599. const TYPE_REQUIRE = 'requires';
  21600. const TYPE_DEV_REQUIRE = 'devRequires';
  21601. const TYPE_PROVIDE = 'provides';
  21602. const TYPE_CONFLICT = 'conflicts';
  21603. const TYPE_REPLACE = 'replaces';
  21604. const TYPE_DOES_NOT_REQUIRE = 'does not require';
  21605. const TYPE_UNKNOWN = 'relates to';
  21606. public static $TYPES = array(
  21607. self::TYPE_REQUIRE,
  21608. self::TYPE_DEV_REQUIRE,
  21609. self::TYPE_PROVIDE,
  21610. self::TYPE_CONFLICT,
  21611. self::TYPE_REPLACE,
  21612. );
  21613. protected $source;
  21614. protected $target;
  21615. protected $constraint;
  21616. protected $description;
  21617. protected $prettyConstraint;
  21618. public function __construct(
  21619. $source,
  21620. $target,
  21621. ConstraintInterface $constraint,
  21622. $description = self::TYPE_UNKNOWN,
  21623. $prettyConstraint = null
  21624. ) {
  21625. $this->source = strtolower($source);
  21626. $this->target = strtolower($target);
  21627. $this->constraint = $constraint;
  21628. $this->description = self::TYPE_DEV_REQUIRE === $description ? 'requires (for development)' : $description;
  21629. $this->prettyConstraint = $prettyConstraint;
  21630. }
  21631. public function getDescription()
  21632. {
  21633. return $this->description;
  21634. }
  21635. public function getSource()
  21636. {
  21637. return $this->source;
  21638. }
  21639. public function getTarget()
  21640. {
  21641. return $this->target;
  21642. }
  21643. public function getConstraint()
  21644. {
  21645. return $this->constraint;
  21646. }
  21647. public function getPrettyConstraint()
  21648. {
  21649. if (null === $this->prettyConstraint) {
  21650. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  21651. }
  21652. return $this->prettyConstraint;
  21653. }
  21654. public function __toString()
  21655. {
  21656. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  21657. }
  21658. public function getPrettyString(PackageInterface $sourcePackage)
  21659. {
  21660. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.' '.$this->constraint->getPrettyString();
  21661. }
  21662. }
  21663. <?php
  21664. namespace Composer\Package\Loader;
  21665. use Composer\Package\BasePackage;
  21666. use Composer\Package\CompleteAliasPackage;
  21667. use Composer\Package\CompletePackage;
  21668. use Composer\Package\RootPackage;
  21669. use Composer\Package\PackageInterface;
  21670. use Composer\Package\CompletePackageInterface;
  21671. use Composer\Package\Link;
  21672. use Composer\Package\RootAliasPackage;
  21673. use Composer\Package\Version\VersionParser;
  21674. use Composer\Pcre\Preg;
  21675. class ArrayLoader implements LoaderInterface
  21676. {
  21677. protected $versionParser;
  21678. protected $loadOptions;
  21679. public function __construct(VersionParser $parser = null, $loadOptions = false)
  21680. {
  21681. if (!$parser) {
  21682. $parser = new VersionParser;
  21683. }
  21684. $this->versionParser = $parser;
  21685. $this->loadOptions = $loadOptions;
  21686. }
  21687. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  21688. {
  21689. if ($class !== 'Composer\Package\CompletePackage' && $class !== 'Composer\Package\RootPackage') {
  21690. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  21691. }
  21692. $package = $this->createObject($config, $class);
  21693. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  21694. if (isset($config[$type])) {
  21695. $method = 'set'.ucfirst($opts['method']);
  21696. $package->{$method}(
  21697. $this->parseLinks(
  21698. $package->getName(),
  21699. $package->getPrettyVersion(),
  21700. $opts['method'],
  21701. $config[$type]
  21702. )
  21703. );
  21704. }
  21705. }
  21706. $package = $this->configureObject($package, $config);
  21707. return $package;
  21708. }
  21709. public function loadPackages(array $versions)
  21710. {
  21711. $packages = array();
  21712. $linkCache = array();
  21713. foreach ($versions as $version) {
  21714. $package = $this->createObject($version, 'Composer\Package\CompletePackage');
  21715. $this->configureCachedLinks($linkCache, $package, $version);
  21716. $package = $this->configureObject($package, $version);
  21717. $packages[] = $package;
  21718. }
  21719. return $packages;
  21720. }
  21721. private function createObject(array $config, $class)
  21722. {
  21723. if (!isset($config['name'])) {
  21724. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  21725. }
  21726. if (!isset($config['version']) || !is_scalar($config['version'])) {
  21727. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  21728. }
  21729. if (!is_string($config['version'])) {
  21730. $config['version'] = (string) $config['version'];
  21731. }
  21732. if (isset($config['version_normalized']) && is_string($config['version_normalized'])) {
  21733. $version = $config['version_normalized'];
  21734. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  21735. $version = $this->versionParser->normalize($config['version']);
  21736. }
  21737. } else {
  21738. $version = $this->versionParser->normalize($config['version']);
  21739. }
  21740. return new $class($config['name'], $version, $config['version']);
  21741. }
  21742. private function configureObject(PackageInterface $package, array $config)
  21743. {
  21744. if (!$package instanceof CompletePackage) {
  21745. throw new \LogicException('ArrayLoader expects instances of the Composer\Package\CompletePackage class to function correctly');
  21746. }
  21747. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  21748. if (isset($config['target-dir'])) {
  21749. $package->setTargetDir($config['target-dir']);
  21750. }
  21751. if (isset($config['extra']) && \is_array($config['extra'])) {
  21752. $package->setExtra($config['extra']);
  21753. }
  21754. if (isset($config['bin'])) {
  21755. if (!\is_array($config['bin'])) {
  21756. $config['bin'] = array($config['bin']);
  21757. }
  21758. foreach ($config['bin'] as $key => $bin) {
  21759. $config['bin'][$key] = ltrim($bin, '/');
  21760. }
  21761. $package->setBinaries($config['bin']);
  21762. }
  21763. if (isset($config['installation-source'])) {
  21764. $package->setInstallationSource($config['installation-source']);
  21765. }
  21766. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  21767. $package->setIsDefaultBranch(true);
  21768. }
  21769. if (isset($config['source'])) {
  21770. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  21771. throw new \UnexpectedValueException(sprintf(
  21772. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  21773. $config['name'],
  21774. json_encode($config['source'])
  21775. ));
  21776. }
  21777. $package->setSourceType($config['source']['type']);
  21778. $package->setSourceUrl($config['source']['url']);
  21779. $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
  21780. if (isset($config['source']['mirrors'])) {
  21781. $package->setSourceMirrors($config['source']['mirrors']);
  21782. }
  21783. }
  21784. if (isset($config['dist'])) {
  21785. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  21786. throw new \UnexpectedValueException(sprintf(
  21787. "Package %s's dist key should be specified as ".
  21788. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  21789. $config['name'],
  21790. json_encode($config['dist'])
  21791. ));
  21792. }
  21793. $package->setDistType($config['dist']['type']);
  21794. $package->setDistUrl($config['dist']['url']);
  21795. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  21796. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  21797. if (isset($config['dist']['mirrors'])) {
  21798. $package->setDistMirrors($config['dist']['mirrors']);
  21799. }
  21800. }
  21801. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  21802. foreach ($config['suggest'] as $target => $reason) {
  21803. if ('self.version' === trim($reason)) {
  21804. $config['suggest'][$target] = $package->getPrettyVersion();
  21805. }
  21806. }
  21807. $package->setSuggests($config['suggest']);
  21808. }
  21809. if (isset($config['autoload'])) {
  21810. $package->setAutoload($config['autoload']);
  21811. }
  21812. if (isset($config['autoload-dev'])) {
  21813. $package->setDevAutoload($config['autoload-dev']);
  21814. }
  21815. if (isset($config['include-path'])) {
  21816. $package->setIncludePaths($config['include-path']);
  21817. }
  21818. if (!empty($config['time'])) {
  21819. $time = Preg::isMatch('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  21820. try {
  21821. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  21822. $package->setReleaseDate($date);
  21823. } catch (\Exception $e) {
  21824. }
  21825. }
  21826. if (!empty($config['notification-url'])) {
  21827. $package->setNotificationUrl($config['notification-url']);
  21828. }
  21829. if ($package instanceof CompletePackageInterface) {
  21830. if (!empty($config['archive']['name'])) {
  21831. $package->setArchiveName($config['archive']['name']);
  21832. }
  21833. if (!empty($config['archive']['exclude'])) {
  21834. $package->setArchiveExcludes($config['archive']['exclude']);
  21835. }
  21836. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  21837. foreach ($config['scripts'] as $event => $listeners) {
  21838. $config['scripts'][$event] = (array) $listeners;
  21839. }
  21840. foreach (array('composer', 'php', 'putenv') as $reserved) {
  21841. if (isset($config['scripts'][$reserved])) {
  21842. trigger_error('The `'.$reserved.'` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  21843. }
  21844. }
  21845. $package->setScripts($config['scripts']);
  21846. }
  21847. if (!empty($config['description']) && \is_string($config['description'])) {
  21848. $package->setDescription($config['description']);
  21849. }
  21850. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  21851. $package->setHomepage($config['homepage']);
  21852. }
  21853. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  21854. $package->setKeywords($config['keywords']);
  21855. }
  21856. if (!empty($config['license'])) {
  21857. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  21858. }
  21859. if (!empty($config['authors']) && \is_array($config['authors'])) {
  21860. $package->setAuthors($config['authors']);
  21861. }
  21862. if (isset($config['support'])) {
  21863. $package->setSupport($config['support']);
  21864. }
  21865. if (!empty($config['funding']) && \is_array($config['funding'])) {
  21866. $package->setFunding($config['funding']);
  21867. }
  21868. if (isset($config['abandoned'])) {
  21869. $package->setAbandoned($config['abandoned']);
  21870. }
  21871. }
  21872. if ($this->loadOptions && isset($config['transport-options'])) {
  21873. $package->setTransportOptions($config['transport-options']);
  21874. }
  21875. if ($aliasNormalized = $this->getBranchAlias($config)) {
  21876. $prettyAlias = Preg::replace('{(\.9{7})+}', '.x', $aliasNormalized);
  21877. if ($package instanceof RootPackage) {
  21878. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  21879. }
  21880. return new CompleteAliasPackage($package, $aliasNormalized, $prettyAlias);
  21881. }
  21882. return $package;
  21883. }
  21884. private function configureCachedLinks(&$linkCache, $package, array $config)
  21885. {
  21886. $name = $package->getName();
  21887. $prettyVersion = $package->getPrettyVersion();
  21888. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  21889. if (isset($config[$type])) {
  21890. $method = 'set'.ucfirst($opts['method']);
  21891. $links = array();
  21892. foreach ($config[$type] as $prettyTarget => $constraint) {
  21893. $target = strtolower($prettyTarget);
  21894. if ($target === $name) {
  21895. continue;
  21896. }
  21897. if ($constraint === 'self.version') {
  21898. $links[$target] = $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint);
  21899. } else {
  21900. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  21901. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['method'], $target, $constraint));
  21902. }
  21903. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  21904. $links[$target] = $link;
  21905. }
  21906. }
  21907. $package->{$method}($links);
  21908. }
  21909. }
  21910. }
  21911. public function parseLinks($source, $sourceVersion, $description, $links)
  21912. {
  21913. $res = array();
  21914. foreach ($links as $target => $constraint) {
  21915. $target = strtolower($target);
  21916. $res[$target] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  21917. }
  21918. return $res;
  21919. }
  21920. private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
  21921. {
  21922. if (!\is_string($prettyConstraint)) {
  21923. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  21924. }
  21925. if ('self.version' === $prettyConstraint) {
  21926. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  21927. } else {
  21928. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  21929. }
  21930. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  21931. }
  21932. public function getBranchAlias(array $config)
  21933. {
  21934. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  21935. return null;
  21936. }
  21937. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  21938. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  21939. if ('-dev' !== substr($targetBranch, -4)) {
  21940. continue;
  21941. }
  21942. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  21943. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  21944. } else {
  21945. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  21946. }
  21947. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  21948. continue;
  21949. }
  21950. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  21951. continue;
  21952. }
  21953. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  21954. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  21955. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  21956. ) {
  21957. continue;
  21958. }
  21959. return $validatedTargetBranch;
  21960. }
  21961. }
  21962. if (
  21963. isset($config['default-branch'])
  21964. && $config['default-branch'] === true
  21965. && false === $this->versionParser->parseNumericAliasPrefix($config['version'])
  21966. ) {
  21967. return VersionParser::DEFAULT_BRANCH_ALIAS;
  21968. }
  21969. return null;
  21970. }
  21971. }
  21972. <?php
  21973. namespace Composer\Package\Loader;
  21974. class InvalidPackageException extends \Exception
  21975. {
  21976. private $errors;
  21977. private $warnings;
  21978. private $data;
  21979. public function __construct(array $errors, array $warnings, array $data)
  21980. {
  21981. $this->errors = $errors;
  21982. $this->warnings = $warnings;
  21983. $this->data = $data;
  21984. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  21985. }
  21986. public function getData()
  21987. {
  21988. return $this->data;
  21989. }
  21990. public function getErrors()
  21991. {
  21992. return $this->errors;
  21993. }
  21994. public function getWarnings()
  21995. {
  21996. return $this->warnings;
  21997. }
  21998. }
  21999. <?php
  22000. namespace Composer\Package\Loader;
  22001. use Composer\Json\JsonFile;
  22002. use Composer\Package\CompletePackage;
  22003. use Composer\Package\CompleteAliasPackage;
  22004. class JsonLoader
  22005. {
  22006. private $loader;
  22007. public function __construct(LoaderInterface $loader)
  22008. {
  22009. $this->loader = $loader;
  22010. }
  22011. public function load($json)
  22012. {
  22013. if ($json instanceof JsonFile) {
  22014. $config = $json->read();
  22015. } elseif (file_exists($json)) {
  22016. $config = JsonFile::parseJson(file_get_contents($json), $json);
  22017. } elseif (is_string($json)) {
  22018. $config = JsonFile::parseJson($json);
  22019. } else {
  22020. throw new \InvalidArgumentException(sprintf(
  22021. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  22022. gettype($json)
  22023. ));
  22024. }
  22025. return $this->loader->load($config);
  22026. }
  22027. }
  22028. <?php
  22029. namespace Composer\Package\Loader;
  22030. use Composer\Package\CompletePackageInterface;
  22031. use Composer\Package\CompletePackage;
  22032. use Composer\Package\CompleteAliasPackage;
  22033. use Composer\Package\RootAliasPackage;
  22034. use Composer\Package\RootPackage;
  22035. interface LoaderInterface
  22036. {
  22037. public function load(array $config, $class = 'Composer\Package\CompletePackage');
  22038. }
  22039. <?php
  22040. namespace Composer\Package\Loader;
  22041. use Composer\Package\BasePackage;
  22042. use Composer\Config;
  22043. use Composer\IO\IOInterface;
  22044. use Composer\Package\RootAliasPackage;
  22045. use Composer\Pcre\Preg;
  22046. use Composer\Repository\RepositoryFactory;
  22047. use Composer\Package\Version\VersionGuesser;
  22048. use Composer\Package\Version\VersionParser;
  22049. use Composer\Package\RootPackage;
  22050. use Composer\Repository\RepositoryManager;
  22051. use Composer\Util\Platform;
  22052. use Composer\Util\ProcessExecutor;
  22053. class RootPackageLoader extends ArrayLoader
  22054. {
  22055. private $manager;
  22056. private $config;
  22057. private $versionGuesser;
  22058. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  22059. {
  22060. parent::__construct($parser);
  22061. $this->manager = $manager;
  22062. $this->config = $config;
  22063. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  22064. }
  22065. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  22066. {
  22067. if ($class !== 'Composer\Package\RootPackage') {
  22068. trigger_error('The $class arg is deprecated, please reach out to Composer maintainers ASAP if you still need this.', E_USER_DEPRECATED);
  22069. }
  22070. if (!isset($config['name'])) {
  22071. $config['name'] = '__root__';
  22072. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  22073. throw new \RuntimeException('Your package name '.$err);
  22074. }
  22075. $autoVersioned = false;
  22076. if (!isset($config['version'])) {
  22077. $commit = null;
  22078. if (Platform::getEnv('COMPOSER_ROOT_VERSION')) {
  22079. $config['version'] = Platform::getEnv('COMPOSER_ROOT_VERSION');
  22080. } else {
  22081. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  22082. if ($versionData) {
  22083. $config['version'] = $versionData['pretty_version'];
  22084. $config['version_normalized'] = $versionData['version'];
  22085. $commit = $versionData['commit'];
  22086. }
  22087. }
  22088. if (!isset($config['version'])) {
  22089. $config['version'] = '1.0.0';
  22090. $autoVersioned = true;
  22091. }
  22092. if ($commit) {
  22093. $config['source'] = array(
  22094. 'type' => '',
  22095. 'url' => '',
  22096. 'reference' => $commit,
  22097. );
  22098. $config['dist'] = array(
  22099. 'type' => '',
  22100. 'url' => '',
  22101. 'reference' => $commit,
  22102. );
  22103. }
  22104. }
  22105. $package = parent::load($config, $class);
  22106. if ($package instanceof RootAliasPackage) {
  22107. $realPackage = $package->getAliasOf();
  22108. } else {
  22109. $realPackage = $package;
  22110. }
  22111. if (!$realPackage instanceof RootPackage) {
  22112. throw new \LogicException('Expecting a Composer\Package\RootPackage at this point');
  22113. }
  22114. if ($autoVersioned) {
  22115. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  22116. }
  22117. if (isset($config['minimum-stability'])) {
  22118. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  22119. }
  22120. $aliases = array();
  22121. $stabilityFlags = array();
  22122. $references = array();
  22123. foreach (array('require', 'require-dev') as $linkType) {
  22124. if (isset($config[$linkType])) {
  22125. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  22126. $method = 'get'.ucfirst($linkInfo['method']);
  22127. $links = array();
  22128. foreach ($realPackage->$method() as $link) {
  22129. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  22130. }
  22131. $aliases = $this->extractAliases($links, $aliases);
  22132. $stabilityFlags = self::extractStabilityFlags($links, $realPackage->getMinimumStability(), $stabilityFlags);
  22133. $references = self::extractReferences($links, $references);
  22134. if (isset($links[$config['name']])) {
  22135. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  22136. 'Did you accidentally name your root package after an external package?', $config['name']));
  22137. }
  22138. }
  22139. }
  22140. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  22141. if (isset($config[$linkType])) {
  22142. foreach ($config[$linkType] as $linkName => $constraint) {
  22143. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  22144. throw new \RuntimeException($linkType.'.'.$err);
  22145. }
  22146. }
  22147. }
  22148. }
  22149. $realPackage->setAliases($aliases);
  22150. $realPackage->setStabilityFlags($stabilityFlags);
  22151. $realPackage->setReferences($references);
  22152. if (isset($config['prefer-stable'])) {
  22153. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  22154. }
  22155. if (isset($config['config'])) {
  22156. $realPackage->setConfig($config['config']);
  22157. }
  22158. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  22159. foreach ($repos as $repo) {
  22160. $this->manager->addRepository($repo);
  22161. }
  22162. $realPackage->setRepositories($this->config->getRepositories());
  22163. return $package;
  22164. }
  22165. private function extractAliases(array $requires, array $aliases)
  22166. {
  22167. foreach ($requires as $reqName => $reqVersion) {
  22168. if (Preg::isMatch('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  22169. $aliases[] = array(
  22170. 'package' => strtolower($reqName),
  22171. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  22172. 'alias' => $match[2],
  22173. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  22174. );
  22175. } elseif (strpos($reqVersion, ' as ') !== false) {
  22176. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  22177. }
  22178. }
  22179. return $aliases;
  22180. }
  22181. public static function extractStabilityFlags(array $requires, $minimumStability, array $stabilityFlags)
  22182. {
  22183. $stabilities = BasePackage::$stabilities;
  22184. $minimumStability = $stabilities[$minimumStability];
  22185. foreach ($requires as $reqName => $reqVersion) {
  22186. $constraints = array();
  22187. $orSplit = Preg::split('{\s*\|\|?\s*}', trim($reqVersion));
  22188. foreach ($orSplit as $orConstraint) {
  22189. $andSplit = Preg::split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  22190. foreach ($andSplit as $andConstraint) {
  22191. $constraints[] = $andConstraint;
  22192. }
  22193. }
  22194. $match = false;
  22195. foreach ($constraints as $constraint) {
  22196. if (Preg::isMatch('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  22197. $name = strtolower($reqName);
  22198. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  22199. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  22200. continue;
  22201. }
  22202. $stabilityFlags[$name] = $stability;
  22203. $match = true;
  22204. }
  22205. }
  22206. if ($match) {
  22207. continue;
  22208. }
  22209. foreach ($constraints as $constraint) {
  22210. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  22211. if (Preg::isMatch('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  22212. $name = strtolower($reqName);
  22213. $stability = $stabilities[$stabilityName];
  22214. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  22215. continue;
  22216. }
  22217. $stabilityFlags[$name] = $stability;
  22218. }
  22219. }
  22220. }
  22221. return $stabilityFlags;
  22222. }
  22223. public static function extractReferences(array $requires, array $references)
  22224. {
  22225. foreach ($requires as $reqName => $reqVersion) {
  22226. $reqVersion = Preg::replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  22227. if (Preg::isMatch('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  22228. $name = strtolower($reqName);
  22229. $references[$name] = $match[1];
  22230. }
  22231. }
  22232. return $references;
  22233. }
  22234. }
  22235. <?php
  22236. namespace Composer\Package\Loader;
  22237. use Composer\Package\BasePackage;
  22238. use Composer\Pcre\Preg;
  22239. use Composer\Semver\Constraint\Constraint;
  22240. use Composer\Package\Version\VersionParser;
  22241. use Composer\Repository\PlatformRepository;
  22242. use Composer\Spdx\SpdxLicenses;
  22243. class ValidatingArrayLoader implements LoaderInterface
  22244. {
  22245. const CHECK_ALL = 3;
  22246. const CHECK_UNBOUND_CONSTRAINTS = 1;
  22247. const CHECK_STRICT_CONSTRAINTS = 2;
  22248. private $loader;
  22249. private $versionParser;
  22250. private $errors;
  22251. private $warnings;
  22252. private $config;
  22253. private $flags;
  22254. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  22255. {
  22256. $this->loader = $loader;
  22257. $this->versionParser = $parser ?: new VersionParser();
  22258. $this->flags = $flags;
  22259. if ($strictName !== true) {
  22260. trigger_error('$strictName must be set to true in ValidatingArrayLoader\'s constructor as of 2.2, and it will be removed in 3.0', E_USER_DEPRECATED);
  22261. }
  22262. }
  22263. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  22264. {
  22265. $this->errors = array();
  22266. $this->warnings = array();
  22267. $this->config = $config;
  22268. $this->validateString('name', true);
  22269. if ($err = self::hasPackageNamingError($config['name'])) {
  22270. $this->errors[] = 'name : '.$err;
  22271. }
  22272. if (!empty($this->config['version'])) {
  22273. if (!is_scalar($this->config['version'])) {
  22274. $this->validateString('version');
  22275. } else {
  22276. if (!is_string($this->config['version'])) {
  22277. $this->config['version'] = (string) $this->config['version'];
  22278. }
  22279. try {
  22280. $this->versionParser->normalize($this->config['version']);
  22281. } catch (\Exception $e) {
  22282. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  22283. unset($this->config['version']);
  22284. }
  22285. }
  22286. }
  22287. if (!empty($this->config['config']['platform'])) {
  22288. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  22289. if (false === $platform) {
  22290. continue;
  22291. }
  22292. if (!is_string($platform)) {
  22293. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.gettype($platform).' '.var_export($platform, true).'): expected string or false';
  22294. continue;
  22295. }
  22296. try {
  22297. $this->versionParser->normalize($platform);
  22298. } catch (\Exception $e) {
  22299. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  22300. }
  22301. }
  22302. }
  22303. $this->validateRegex('type', '[A-Za-z0-9-]+');
  22304. $this->validateString('target-dir');
  22305. $this->validateArray('extra');
  22306. if (isset($this->config['bin'])) {
  22307. if (is_string($this->config['bin'])) {
  22308. $this->validateString('bin');
  22309. } else {
  22310. $this->validateFlatArray('bin');
  22311. }
  22312. }
  22313. $this->validateArray('scripts');
  22314. $this->validateString('description');
  22315. $this->validateUrl('homepage');
  22316. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  22317. $releaseDate = null;
  22318. $this->validateString('time');
  22319. if (!empty($this->config['time'])) {
  22320. try {
  22321. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  22322. } catch (\Exception $e) {
  22323. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  22324. unset($this->config['time']);
  22325. }
  22326. }
  22327. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  22328. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  22329. $licenses = (array) $this->config['license'];
  22330. $licenseValidator = new SpdxLicenses();
  22331. foreach ($licenses as $license) {
  22332. if ('proprietary' === $license) {
  22333. continue;
  22334. }
  22335. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  22336. if (!$licenseValidator->validate($licenseToValidate)) {
  22337. if ($licenseValidator->validate(trim($licenseToValidate))) {
  22338. $this->warnings[] = sprintf(
  22339. 'License %s must not contain extra spaces, make sure to trim it.',
  22340. json_encode($license)
  22341. );
  22342. } else {
  22343. $this->warnings[] = sprintf(
  22344. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  22345. 'If the software is closed-source, you may use "proprietary" as license.',
  22346. json_encode($license)
  22347. );
  22348. }
  22349. }
  22350. }
  22351. }
  22352. }
  22353. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  22354. foreach ($this->config['authors'] as $key => $author) {
  22355. if (!is_array($author)) {
  22356. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  22357. unset($this->config['authors'][$key]);
  22358. continue;
  22359. }
  22360. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  22361. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  22362. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  22363. unset($this->config['authors'][$key][$authorData]);
  22364. }
  22365. }
  22366. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  22367. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  22368. unset($this->config['authors'][$key]['homepage']);
  22369. }
  22370. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  22371. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  22372. unset($this->config['authors'][$key]['email']);
  22373. }
  22374. if (empty($this->config['authors'][$key])) {
  22375. unset($this->config['authors'][$key]);
  22376. }
  22377. }
  22378. if (empty($this->config['authors'])) {
  22379. unset($this->config['authors']);
  22380. }
  22381. }
  22382. if ($this->validateArray('support') && !empty($this->config['support'])) {
  22383. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  22384. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  22385. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  22386. unset($this->config['support'][$key]);
  22387. }
  22388. }
  22389. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  22390. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  22391. unset($this->config['support']['email']);
  22392. }
  22393. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc', 'ircs'))) {
  22394. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> or ircs:// URL';
  22395. unset($this->config['support']['irc']);
  22396. }
  22397. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  22398. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  22399. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  22400. unset($this->config['support'][$key]);
  22401. }
  22402. }
  22403. if (empty($this->config['support'])) {
  22404. unset($this->config['support']);
  22405. }
  22406. }
  22407. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  22408. foreach ($this->config['funding'] as $key => $fundingOption) {
  22409. if (!is_array($fundingOption)) {
  22410. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  22411. unset($this->config['funding'][$key]);
  22412. continue;
  22413. }
  22414. foreach (array('type', 'url') as $fundingData) {
  22415. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  22416. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  22417. unset($this->config['funding'][$key][$fundingData]);
  22418. }
  22419. }
  22420. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  22421. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  22422. unset($this->config['funding'][$key]['url']);
  22423. }
  22424. if (empty($this->config['funding'][$key])) {
  22425. unset($this->config['funding'][$key]);
  22426. }
  22427. }
  22428. if (empty($this->config['funding'])) {
  22429. unset($this->config['funding']);
  22430. }
  22431. }
  22432. $unboundConstraint = new Constraint('=', '10000000-dev');
  22433. $stableConstraint = new Constraint('=', '1.0.0');
  22434. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  22435. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  22436. foreach ($this->config[$linkType] as $package => $constraint) {
  22437. if (0 === strcasecmp($package, $this->config['name'])) {
  22438. $this->errors[] = $linkType.'.'.$package.' : a package cannot set a '.$linkType.' on itself';
  22439. unset($this->config[$linkType][$package]);
  22440. continue;
  22441. }
  22442. if ($err = self::hasPackageNamingError($package, true)) {
  22443. $this->errors[] = $linkType.'.'.$err;
  22444. } elseif (!Preg::isMatch('{^[A-Za-z0-9_./-]+$}', $package)) {
  22445. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  22446. }
  22447. if (!is_string($constraint)) {
  22448. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  22449. unset($this->config[$linkType][$package]);
  22450. } elseif ('self.version' !== $constraint) {
  22451. try {
  22452. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  22453. } catch (\Exception $e) {
  22454. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  22455. unset($this->config[$linkType][$package]);
  22456. continue;
  22457. }
  22458. if (
  22459. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  22460. && 'require' === $linkType
  22461. && $linkConstraint->matches($unboundConstraint)
  22462. && !PlatformRepository::isPlatformPackage($package)
  22463. ) {
  22464. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  22465. } elseif (
  22466. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  22467. && 'require' === $linkType
  22468. && strpos($linkConstraint, '=') === 0
  22469. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  22470. ) {
  22471. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  22472. }
  22473. }
  22474. if ($linkType === 'conflict' && isset($this->config['replace']) && $keys = array_intersect_key($this->config['replace'], $this->config['conflict'])) {
  22475. $this->errors[] = $linkType.'.'.$package.' : you cannot conflict with a package that is also replaced, as replace already creates an implicit conflict rule';
  22476. unset($this->config[$linkType][$package]);
  22477. }
  22478. }
  22479. }
  22480. }
  22481. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  22482. foreach ($this->config['suggest'] as $package => $description) {
  22483. if (!is_string($description)) {
  22484. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  22485. unset($this->config['suggest'][$package]);
  22486. }
  22487. }
  22488. }
  22489. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  22490. if (!isset(BasePackage::$stabilities[strtolower($this->config['minimum-stability'])]) && $this->config['minimum-stability'] !== 'RC') {
  22491. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  22492. unset($this->config['minimum-stability']);
  22493. }
  22494. }
  22495. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  22496. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  22497. foreach ($this->config['autoload'] as $type => $typeConfig) {
  22498. if (!in_array($type, $types)) {
  22499. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  22500. unset($this->config['autoload'][$type]);
  22501. }
  22502. if ($type === 'psr-4') {
  22503. foreach ($typeConfig as $namespace => $dirs) {
  22504. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  22505. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  22506. }
  22507. }
  22508. }
  22509. }
  22510. }
  22511. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  22512. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  22513. unset($this->config['autoload']['psr-4']);
  22514. }
  22515. foreach (array('source', 'dist') as $srcType) {
  22516. if ($this->validateArray($srcType) && !empty($this->config[$srcType])) {
  22517. if (!isset($this->config[$srcType]['type'])) {
  22518. $this->errors[] = $srcType . '.type : must be present';
  22519. }
  22520. if (!isset($this->config[$srcType]['url'])) {
  22521. $this->errors[] = $srcType . '.url : must be present';
  22522. }
  22523. if ($srcType === 'source' && !isset($this->config[$srcType]['reference'])) {
  22524. $this->errors[] = $srcType . '.reference : must be present';
  22525. }
  22526. if (!is_string($this->config[$srcType]['type'])) {
  22527. $this->errors[] = $srcType . '.type : should be a string, '.gettype($this->config[$srcType]['type']).' given';
  22528. }
  22529. if (!is_string($this->config[$srcType]['url'])) {
  22530. $this->errors[] = $srcType . '.url : should be a string, '.gettype($this->config[$srcType]['url']).' given';
  22531. }
  22532. if (isset($this->config[$srcType]['reference']) && !is_string($this->config[$srcType]['reference']) && !is_int($this->config[$srcType]['reference'])) {
  22533. $this->errors[] = $srcType . '.reference : should be a string or int, '.gettype($this->config[$srcType]['reference']).' given';
  22534. }
  22535. if (isset($this->config[$srcType]['reference']) && Preg::isMatch('{^\s*-}', (string) $this->config[$srcType]['reference'])) {
  22536. $this->errors[] = $srcType . '.reference : must not start with a "-", "'.$this->config[$srcType]['reference'].'" given';
  22537. }
  22538. if (Preg::isMatch('{^\s*-}', $this->config[$srcType]['url'])) {
  22539. $this->errors[] = $srcType . '.url : must not start with a "-", "'.$this->config[$srcType]['url'].'" given';
  22540. }
  22541. }
  22542. }
  22543. $this->validateFlatArray('include-path');
  22544. $this->validateArray('transport-options');
  22545. if (isset($this->config['extra']['branch-alias'])) {
  22546. if (!is_array($this->config['extra']['branch-alias'])) {
  22547. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  22548. } else {
  22549. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  22550. if (!is_string($targetBranch)) {
  22551. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.json_encode($targetBranch).') must be a string, "'.gettype($targetBranch).'" received.';
  22552. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22553. continue;
  22554. }
  22555. if ('-dev' !== substr($targetBranch, -4)) {
  22556. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  22557. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22558. continue;
  22559. }
  22560. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  22561. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  22562. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  22563. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22564. continue;
  22565. }
  22566. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  22567. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  22568. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  22569. ) {
  22570. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  22571. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  22572. }
  22573. }
  22574. }
  22575. }
  22576. if ($this->errors) {
  22577. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  22578. }
  22579. $package = $this->loader->load($this->config, $class);
  22580. $this->config = array();
  22581. return $package;
  22582. }
  22583. public function getWarnings()
  22584. {
  22585. return $this->warnings;
  22586. }
  22587. public function getErrors()
  22588. {
  22589. return $this->errors;
  22590. }
  22591. public static function hasPackageNamingError($name, $isLink = false)
  22592. {
  22593. if (PlatformRepository::isPlatformPackage($name)) {
  22594. return null;
  22595. }
  22596. if (!Preg::isMatch('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  22597. 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]+)*$".';
  22598. }
  22599. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  22600. $bits = explode('/', strtolower($name));
  22601. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  22602. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  22603. }
  22604. if (Preg::isMatch('{\.json$}', $name)) {
  22605. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  22606. }
  22607. if (Preg::isMatch('{[A-Z]}', $name)) {
  22608. if ($isLink) {
  22609. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  22610. }
  22611. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  22612. $suggestName = strtolower($suggestName);
  22613. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  22614. }
  22615. return null;
  22616. }
  22617. private function validateRegex($property, $regex, $mandatory = false)
  22618. {
  22619. if (!$this->validateString($property, $mandatory)) {
  22620. return false;
  22621. }
  22622. if (!Preg::isMatch('{^'.$regex.'$}u', $this->config[$property])) {
  22623. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  22624. if ($mandatory) {
  22625. $this->errors[] = $message;
  22626. } else {
  22627. $this->warnings[] = $message;
  22628. }
  22629. unset($this->config[$property]);
  22630. return false;
  22631. }
  22632. return true;
  22633. }
  22634. private function validateString($property, $mandatory = false)
  22635. {
  22636. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  22637. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  22638. unset($this->config[$property]);
  22639. return false;
  22640. }
  22641. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  22642. if ($mandatory) {
  22643. $this->errors[] = $property.' : must be present';
  22644. }
  22645. unset($this->config[$property]);
  22646. return false;
  22647. }
  22648. return true;
  22649. }
  22650. private function validateArray($property, $mandatory = false)
  22651. {
  22652. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  22653. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  22654. unset($this->config[$property]);
  22655. return false;
  22656. }
  22657. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  22658. if ($mandatory) {
  22659. $this->errors[] = $property.' : must be present and contain at least one element';
  22660. }
  22661. unset($this->config[$property]);
  22662. return false;
  22663. }
  22664. return true;
  22665. }
  22666. private function validateFlatArray($property, $regex = null, $mandatory = false)
  22667. {
  22668. if (!$this->validateArray($property, $mandatory)) {
  22669. return false;
  22670. }
  22671. $pass = true;
  22672. foreach ($this->config[$property] as $key => $value) {
  22673. if (!is_string($value) && !is_numeric($value)) {
  22674. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  22675. unset($this->config[$property][$key]);
  22676. $pass = false;
  22677. continue;
  22678. }
  22679. if ($regex && !Preg::isMatch('{^'.$regex.'$}u', $value)) {
  22680. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  22681. unset($this->config[$property][$key]);
  22682. $pass = false;
  22683. }
  22684. }
  22685. return $pass;
  22686. }
  22687. private function validateUrl($property, $mandatory = false)
  22688. {
  22689. if (!$this->validateString($property, $mandatory)) {
  22690. return false;
  22691. }
  22692. if (!$this->filterUrl($this->config[$property])) {
  22693. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  22694. unset($this->config[$property]);
  22695. return false;
  22696. }
  22697. return true;
  22698. }
  22699. private function filterUrl($value, array $schemes = array('http', 'https'))
  22700. {
  22701. if ($value === '') {
  22702. return true;
  22703. }
  22704. $bits = parse_url($value);
  22705. if (empty($bits['scheme']) || empty($bits['host'])) {
  22706. return false;
  22707. }
  22708. if (!in_array($bits['scheme'], $schemes, true)) {
  22709. return false;
  22710. }
  22711. return true;
  22712. }
  22713. }
  22714. <?php
  22715. namespace Composer\Package;
  22716. use Composer\Json\JsonFile;
  22717. use Composer\Installer\InstallationManager;
  22718. use Composer\Pcre\Preg;
  22719. use Composer\Repository\LockArrayRepository;
  22720. use Composer\Util\ProcessExecutor;
  22721. use Composer\Package\Dumper\ArrayDumper;
  22722. use Composer\Package\Loader\ArrayLoader;
  22723. use Composer\Package\Version\VersionParser;
  22724. use Composer\Plugin\PluginInterface;
  22725. use Composer\Util\Git as GitUtil;
  22726. use Composer\IO\IOInterface;
  22727. use Seld\JsonLint\ParsingException;
  22728. class Locker
  22729. {
  22730. private $lockFile;
  22731. private $installationManager;
  22732. private $hash;
  22733. private $contentHash;
  22734. private $loader;
  22735. private $dumper;
  22736. private $process;
  22737. private $lockDataCache = null;
  22738. private $virtualFileWritten = false;
  22739. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents, ProcessExecutor $process = null)
  22740. {
  22741. $this->lockFile = $lockFile;
  22742. $this->installationManager = $installationManager;
  22743. $this->hash = md5($composerFileContents);
  22744. $this->contentHash = self::getContentHash($composerFileContents);
  22745. $this->loader = new ArrayLoader(null, true);
  22746. $this->dumper = new ArrayDumper();
  22747. $this->process = $process ?: new ProcessExecutor($io);
  22748. }
  22749. public static function getContentHash($composerFileContents)
  22750. {
  22751. $content = json_decode($composerFileContents, true);
  22752. $relevantKeys = array(
  22753. 'name',
  22754. 'version',
  22755. 'require',
  22756. 'require-dev',
  22757. 'conflict',
  22758. 'replace',
  22759. 'provide',
  22760. 'minimum-stability',
  22761. 'prefer-stable',
  22762. 'repositories',
  22763. 'extra',
  22764. );
  22765. $relevantContent = array();
  22766. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  22767. $relevantContent[$key] = $content[$key];
  22768. }
  22769. if (isset($content['config']['platform'])) {
  22770. $relevantContent['config']['platform'] = $content['config']['platform'];
  22771. }
  22772. ksort($relevantContent);
  22773. return md5(json_encode($relevantContent));
  22774. }
  22775. public function isLocked()
  22776. {
  22777. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  22778. return false;
  22779. }
  22780. $data = $this->getLockData();
  22781. return isset($data['packages']);
  22782. }
  22783. public function isFresh()
  22784. {
  22785. $lock = $this->lockFile->read();
  22786. if (!empty($lock['content-hash'])) {
  22787. return $this->contentHash === $lock['content-hash'];
  22788. }
  22789. if (!empty($lock['hash'])) {
  22790. return $this->hash === $lock['hash'];
  22791. }
  22792. return false;
  22793. }
  22794. public function getLockedRepository($withDevReqs = false)
  22795. {
  22796. $lockData = $this->getLockData();
  22797. $packages = new LockArrayRepository();
  22798. $lockedPackages = $lockData['packages'];
  22799. if ($withDevReqs) {
  22800. if (isset($lockData['packages-dev'])) {
  22801. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  22802. } else {
  22803. 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.');
  22804. }
  22805. }
  22806. if (empty($lockedPackages)) {
  22807. return $packages;
  22808. }
  22809. if (isset($lockedPackages[0]['name'])) {
  22810. $packageByName = array();
  22811. foreach ($lockedPackages as $info) {
  22812. $package = $this->loader->load($info);
  22813. $packages->addPackage($package);
  22814. $packageByName[$package->getName()] = $package;
  22815. if ($package instanceof AliasPackage) {
  22816. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  22817. }
  22818. }
  22819. if (isset($lockData['aliases'])) {
  22820. foreach ($lockData['aliases'] as $alias) {
  22821. if (isset($packageByName[$alias['package']])) {
  22822. $aliasPkg = new CompleteAliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  22823. $aliasPkg->setRootPackageAlias(true);
  22824. $packages->addPackage($aliasPkg);
  22825. }
  22826. }
  22827. }
  22828. return $packages;
  22829. }
  22830. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  22831. }
  22832. public function getDevPackageNames()
  22833. {
  22834. $names = array();
  22835. $lockData = $this->getLockData();
  22836. if (isset($lockData['packages-dev'])) {
  22837. foreach ($lockData['packages-dev'] as $package) {
  22838. $names[] = strtolower($package['name']);
  22839. }
  22840. }
  22841. return $names;
  22842. }
  22843. public function getPlatformRequirements($withDevReqs = false)
  22844. {
  22845. $lockData = $this->getLockData();
  22846. $requirements = array();
  22847. if (!empty($lockData['platform'])) {
  22848. $requirements = $this->loader->parseLinks(
  22849. '__root__',
  22850. '1.0.0',
  22851. Link::TYPE_REQUIRE,
  22852. isset($lockData['platform']) ? $lockData['platform'] : array()
  22853. );
  22854. }
  22855. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  22856. $devRequirements = $this->loader->parseLinks(
  22857. '__root__',
  22858. '1.0.0',
  22859. Link::TYPE_REQUIRE,
  22860. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  22861. );
  22862. $requirements = array_merge($requirements, $devRequirements);
  22863. }
  22864. return $requirements;
  22865. }
  22866. public function getMinimumStability()
  22867. {
  22868. $lockData = $this->getLockData();
  22869. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  22870. }
  22871. public function getStabilityFlags()
  22872. {
  22873. $lockData = $this->getLockData();
  22874. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  22875. }
  22876. public function getPreferStable()
  22877. {
  22878. $lockData = $this->getLockData();
  22879. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  22880. }
  22881. public function getPreferLowest()
  22882. {
  22883. $lockData = $this->getLockData();
  22884. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  22885. }
  22886. public function getPlatformOverrides()
  22887. {
  22888. $lockData = $this->getLockData();
  22889. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  22890. }
  22891. public function getAliases()
  22892. {
  22893. $lockData = $this->getLockData();
  22894. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  22895. }
  22896. public function getLockData()
  22897. {
  22898. if (null !== $this->lockDataCache) {
  22899. return $this->lockDataCache;
  22900. }
  22901. if (!$this->lockFile->exists()) {
  22902. throw new \LogicException('No lockfile found. Unable to read locked packages');
  22903. }
  22904. return $this->lockDataCache = $this->lockFile->read();
  22905. }
  22906. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
  22907. {
  22908. $aliases = array_map(function ($alias) {
  22909. if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  22910. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  22911. }
  22912. return $alias;
  22913. }, $aliases);
  22914. $lock = array(
  22915. '_readme' => array('This file locks the dependencies of your project to a known state',
  22916. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  22917. 'This file is @gener'.'ated automatically', ),
  22918. 'content-hash' => $this->contentHash,
  22919. 'packages' => null,
  22920. 'packages-dev' => null,
  22921. 'aliases' => $aliases,
  22922. 'minimum-stability' => $minimumStability,
  22923. 'stability-flags' => $stabilityFlags,
  22924. 'prefer-stable' => $preferStable,
  22925. 'prefer-lowest' => $preferLowest,
  22926. );
  22927. $lock['packages'] = $this->lockPackages($packages);
  22928. if (null !== $devPackages) {
  22929. $lock['packages-dev'] = $this->lockPackages($devPackages);
  22930. }
  22931. $lock['platform'] = $platformReqs;
  22932. $lock['platform-dev'] = $platformDevReqs;
  22933. if ($platformOverrides) {
  22934. $lock['platform-overrides'] = $platformOverrides;
  22935. }
  22936. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  22937. try {
  22938. $isLocked = $this->isLocked();
  22939. } catch (ParsingException $e) {
  22940. $isLocked = false;
  22941. }
  22942. if (!$isLocked || $lock !== $this->getLockData()) {
  22943. if ($write) {
  22944. $this->lockFile->write($lock);
  22945. $this->lockDataCache = null;
  22946. $this->virtualFileWritten = false;
  22947. } else {
  22948. $this->virtualFileWritten = true;
  22949. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT));
  22950. }
  22951. return true;
  22952. }
  22953. return false;
  22954. }
  22955. private function lockPackages(array $packages)
  22956. {
  22957. $locked = array();
  22958. foreach ($packages as $package) {
  22959. if ($package instanceof AliasPackage) {
  22960. continue;
  22961. }
  22962. $name = $package->getPrettyName();
  22963. $version = $package->getPrettyVersion();
  22964. if (!$name || !$version) {
  22965. throw new \LogicException(sprintf(
  22966. 'Package "%s" has no version or name and can not be locked',
  22967. $package
  22968. ));
  22969. }
  22970. $spec = $this->dumper->dump($package);
  22971. unset($spec['version_normalized']);
  22972. $time = isset($spec['time']) ? $spec['time'] : null;
  22973. unset($spec['time']);
  22974. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  22975. $time = $this->getPackageTime($package) ?: $time;
  22976. }
  22977. if (null !== $time) {
  22978. $spec['time'] = $time;
  22979. }
  22980. unset($spec['installation-source']);
  22981. $locked[] = $spec;
  22982. }
  22983. usort($locked, function ($a, $b) {
  22984. $comparison = strcmp($a['name'], $b['name']);
  22985. if (0 !== $comparison) {
  22986. return $comparison;
  22987. }
  22988. return strcmp($a['version'], $b['version']);
  22989. });
  22990. return $locked;
  22991. }
  22992. private function getPackageTime(PackageInterface $package)
  22993. {
  22994. if (!function_exists('proc_open')) {
  22995. return null;
  22996. }
  22997. $path = realpath($this->installationManager->getInstallPath($package));
  22998. $sourceType = $package->getSourceType();
  22999. $datetime = null;
  23000. if ($path && in_array($sourceType, array('git', 'hg'))) {
  23001. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  23002. switch ($sourceType) {
  23003. case 'git':
  23004. GitUtil::cleanEnv();
  23005. if (0 === $this->process->execute('git log -n1 --pretty=%ct '.ProcessExecutor::escape($sourceRef).GitUtil::getNoShowSignatureFlag($this->process), $output, $path) && Preg::isMatch('{^\s*\d+\s*$}', $output)) {
  23006. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  23007. }
  23008. break;
  23009. case 'hg':
  23010. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && Preg::isMatch('{^\s*(\d+)\s*}', $output, $match)) {
  23011. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  23012. }
  23013. break;
  23014. }
  23015. }
  23016. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  23017. }
  23018. }
  23019. <?php
  23020. namespace Composer\Package;
  23021. use Composer\Package\Version\VersionParser;
  23022. use Composer\Pcre\Preg;
  23023. use Composer\Util\ComposerMirror;
  23024. class Package extends BasePackage
  23025. {
  23026. protected $type;
  23027. protected $targetDir;
  23028. protected $installationSource;
  23029. protected $sourceType;
  23030. protected $sourceUrl;
  23031. protected $sourceReference;
  23032. protected $sourceMirrors;
  23033. protected $distType;
  23034. protected $distUrl;
  23035. protected $distReference;
  23036. protected $distSha1Checksum;
  23037. protected $distMirrors;
  23038. protected $version;
  23039. protected $prettyVersion;
  23040. protected $releaseDate;
  23041. protected $extra = array();
  23042. protected $binaries = array();
  23043. protected $dev;
  23044. protected $stability;
  23045. protected $notificationUrl;
  23046. protected $requires = array();
  23047. protected $conflicts = array();
  23048. protected $provides = array();
  23049. protected $replaces = array();
  23050. protected $devRequires = array();
  23051. protected $suggests = array();
  23052. protected $autoload = array();
  23053. protected $devAutoload = array();
  23054. protected $includePaths = array();
  23055. protected $isDefaultBranch = false;
  23056. protected $transportOptions = array();
  23057. public function __construct($name, $version, $prettyVersion)
  23058. {
  23059. parent::__construct($name);
  23060. $this->version = $version;
  23061. $this->prettyVersion = $prettyVersion;
  23062. $this->stability = VersionParser::parseStability($version);
  23063. $this->dev = $this->stability === 'dev';
  23064. }
  23065. public function isDev()
  23066. {
  23067. return $this->dev;
  23068. }
  23069. public function setType($type)
  23070. {
  23071. $this->type = $type;
  23072. }
  23073. public function getType()
  23074. {
  23075. return $this->type ?: 'library';
  23076. }
  23077. public function getStability()
  23078. {
  23079. return $this->stability;
  23080. }
  23081. public function setTargetDir($targetDir)
  23082. {
  23083. $this->targetDir = $targetDir;
  23084. }
  23085. public function getTargetDir()
  23086. {
  23087. if (null === $this->targetDir) {
  23088. return null;
  23089. }
  23090. return ltrim(Preg::replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  23091. }
  23092. public function setExtra(array $extra)
  23093. {
  23094. $this->extra = $extra;
  23095. }
  23096. public function getExtra()
  23097. {
  23098. return $this->extra;
  23099. }
  23100. public function setBinaries(array $binaries)
  23101. {
  23102. $this->binaries = $binaries;
  23103. }
  23104. public function getBinaries()
  23105. {
  23106. return $this->binaries;
  23107. }
  23108. public function setInstallationSource($type)
  23109. {
  23110. $this->installationSource = $type;
  23111. }
  23112. public function getInstallationSource()
  23113. {
  23114. return $this->installationSource;
  23115. }
  23116. public function setSourceType($type)
  23117. {
  23118. $this->sourceType = $type;
  23119. }
  23120. public function getSourceType()
  23121. {
  23122. return $this->sourceType;
  23123. }
  23124. public function setSourceUrl($url)
  23125. {
  23126. $this->sourceUrl = $url;
  23127. }
  23128. public function getSourceUrl()
  23129. {
  23130. return $this->sourceUrl;
  23131. }
  23132. public function setSourceReference($reference)
  23133. {
  23134. $this->sourceReference = $reference;
  23135. }
  23136. public function getSourceReference()
  23137. {
  23138. return $this->sourceReference;
  23139. }
  23140. public function setSourceMirrors($mirrors)
  23141. {
  23142. $this->sourceMirrors = $mirrors;
  23143. }
  23144. public function getSourceMirrors()
  23145. {
  23146. return $this->sourceMirrors;
  23147. }
  23148. public function getSourceUrls()
  23149. {
  23150. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  23151. }
  23152. public function setDistType($type)
  23153. {
  23154. $this->distType = $type;
  23155. }
  23156. public function getDistType()
  23157. {
  23158. return $this->distType;
  23159. }
  23160. public function setDistUrl($url)
  23161. {
  23162. $this->distUrl = $url;
  23163. }
  23164. public function getDistUrl()
  23165. {
  23166. return $this->distUrl;
  23167. }
  23168. public function setDistReference($reference)
  23169. {
  23170. $this->distReference = $reference;
  23171. }
  23172. public function getDistReference()
  23173. {
  23174. return $this->distReference;
  23175. }
  23176. public function setDistSha1Checksum($sha1checksum)
  23177. {
  23178. $this->distSha1Checksum = $sha1checksum;
  23179. }
  23180. public function getDistSha1Checksum()
  23181. {
  23182. return $this->distSha1Checksum;
  23183. }
  23184. public function setDistMirrors($mirrors)
  23185. {
  23186. $this->distMirrors = $mirrors;
  23187. }
  23188. public function getDistMirrors()
  23189. {
  23190. return $this->distMirrors;
  23191. }
  23192. public function getDistUrls()
  23193. {
  23194. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  23195. }
  23196. public function getTransportOptions()
  23197. {
  23198. return $this->transportOptions;
  23199. }
  23200. public function setTransportOptions(array $options)
  23201. {
  23202. $this->transportOptions = $options;
  23203. }
  23204. public function getVersion()
  23205. {
  23206. return $this->version;
  23207. }
  23208. public function getPrettyVersion()
  23209. {
  23210. return $this->prettyVersion;
  23211. }
  23212. public function setReleaseDate(\DateTime $releaseDate)
  23213. {
  23214. $this->releaseDate = $releaseDate;
  23215. }
  23216. public function getReleaseDate()
  23217. {
  23218. return $this->releaseDate;
  23219. }
  23220. public function setRequires(array $requires)
  23221. {
  23222. if (isset($requires[0])) {
  23223. $requires = $this->convertLinksToMap($requires, 'setRequires');
  23224. }
  23225. $this->requires = $requires;
  23226. }
  23227. public function getRequires()
  23228. {
  23229. return $this->requires;
  23230. }
  23231. public function setConflicts(array $conflicts)
  23232. {
  23233. if (isset($conflicts[0])) {
  23234. $conflicts = $this->convertLinksToMap($conflicts, 'setConflicts');
  23235. }
  23236. $this->conflicts = $conflicts;
  23237. }
  23238. public function getConflicts()
  23239. {
  23240. return $this->conflicts;
  23241. }
  23242. public function setProvides(array $provides)
  23243. {
  23244. if (isset($provides[0])) {
  23245. $provides = $this->convertLinksToMap($provides, 'setProvides');
  23246. }
  23247. $this->provides = $provides;
  23248. }
  23249. public function getProvides()
  23250. {
  23251. return $this->provides;
  23252. }
  23253. public function setReplaces(array $replaces)
  23254. {
  23255. if (isset($replaces[0])) {
  23256. $replaces = $this->convertLinksToMap($replaces, 'setReplaces');
  23257. }
  23258. $this->replaces = $replaces;
  23259. }
  23260. public function getReplaces()
  23261. {
  23262. return $this->replaces;
  23263. }
  23264. public function setDevRequires(array $devRequires)
  23265. {
  23266. if (isset($devRequires[0])) {
  23267. $devRequires = $this->convertLinksToMap($devRequires, 'setDevRequires');
  23268. }
  23269. $this->devRequires = $devRequires;
  23270. }
  23271. public function getDevRequires()
  23272. {
  23273. return $this->devRequires;
  23274. }
  23275. public function setSuggests(array $suggests)
  23276. {
  23277. $this->suggests = $suggests;
  23278. }
  23279. public function getSuggests()
  23280. {
  23281. return $this->suggests;
  23282. }
  23283. public function setAutoload(array $autoload)
  23284. {
  23285. $this->autoload = $autoload;
  23286. }
  23287. public function getAutoload()
  23288. {
  23289. return $this->autoload;
  23290. }
  23291. public function setDevAutoload(array $devAutoload)
  23292. {
  23293. $this->devAutoload = $devAutoload;
  23294. }
  23295. public function getDevAutoload()
  23296. {
  23297. return $this->devAutoload;
  23298. }
  23299. public function setIncludePaths(array $includePaths)
  23300. {
  23301. $this->includePaths = $includePaths;
  23302. }
  23303. public function getIncludePaths()
  23304. {
  23305. return $this->includePaths;
  23306. }
  23307. public function setNotificationUrl($notificationUrl)
  23308. {
  23309. $this->notificationUrl = $notificationUrl;
  23310. }
  23311. public function getNotificationUrl()
  23312. {
  23313. return $this->notificationUrl;
  23314. }
  23315. public function setIsDefaultBranch($defaultBranch)
  23316. {
  23317. $this->isDefaultBranch = $defaultBranch;
  23318. }
  23319. public function isDefaultBranch()
  23320. {
  23321. return $this->isDefaultBranch;
  23322. }
  23323. public function setSourceDistReferences($reference)
  23324. {
  23325. $this->setSourceReference($reference);
  23326. if (
  23327. $this->getDistUrl() !== null
  23328. && Preg::isMatch('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())
  23329. ) {
  23330. $this->setDistReference($reference);
  23331. $this->setDistUrl(Preg::replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  23332. } elseif ($this->getDistReference()) {
  23333. $this->setDistReference($reference);
  23334. }
  23335. }
  23336. public function replaceVersion($version, $prettyVersion)
  23337. {
  23338. $this->version = $version;
  23339. $this->prettyVersion = $prettyVersion;
  23340. $this->stability = VersionParser::parseStability($version);
  23341. $this->dev = $this->stability === 'dev';
  23342. }
  23343. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  23344. {
  23345. if (!$url) {
  23346. return array();
  23347. }
  23348. if ($urlType === 'dist' && false !== strpos($url, '%')) {
  23349. $url = ComposerMirror::processUrl($url, $this->name, $this->version, $ref, $type, $this->prettyVersion);
  23350. }
  23351. $urls = array($url);
  23352. if ($mirrors) {
  23353. foreach ($mirrors as $mirror) {
  23354. if ($urlType === 'dist') {
  23355. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type, $this->prettyVersion);
  23356. } elseif ($urlType === 'source' && $type === 'git') {
  23357. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  23358. } elseif ($urlType === 'source' && $type === 'hg') {
  23359. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  23360. } else {
  23361. continue;
  23362. }
  23363. if (!\in_array($mirrorUrl, $urls)) {
  23364. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  23365. $func($urls, $mirrorUrl);
  23366. }
  23367. }
  23368. }
  23369. return $urls;
  23370. }
  23371. private function convertLinksToMap(array $links, $source)
  23372. {
  23373. trigger_error('Package::'.$source.' must be called with a map of lowercased package name => Link object, got a indexed array, this is deprecated and you should fix your usage.');
  23374. $newLinks = array();
  23375. foreach ($links as $link) {
  23376. $newLinks[$link->getTarget()] = $link;
  23377. }
  23378. return $newLinks;
  23379. }
  23380. }
  23381. <?php
  23382. namespace Composer\Package;
  23383. use Composer\Repository\RepositoryInterface;
  23384. interface PackageInterface
  23385. {
  23386. const DISPLAY_SOURCE_REF_IF_DEV = 0;
  23387. const DISPLAY_SOURCE_REF = 1;
  23388. const DISPLAY_DIST_REF = 2;
  23389. public function getName();
  23390. public function getPrettyName();
  23391. public function getNames($provides = true);
  23392. public function setId($id);
  23393. public function getId();
  23394. public function isDev();
  23395. public function getType();
  23396. public function getTargetDir();
  23397. public function getExtra();
  23398. public function setInstallationSource($type);
  23399. public function getInstallationSource();
  23400. public function getSourceType();
  23401. public function getSourceUrl();
  23402. public function getSourceUrls();
  23403. public function getSourceReference();
  23404. public function getSourceMirrors();
  23405. public function setSourceMirrors($mirrors);
  23406. public function getDistType();
  23407. public function getDistUrl();
  23408. public function getDistUrls();
  23409. public function getDistReference();
  23410. public function getDistSha1Checksum();
  23411. public function getDistMirrors();
  23412. public function setDistMirrors($mirrors);
  23413. public function getVersion();
  23414. public function getPrettyVersion();
  23415. public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
  23416. public function getReleaseDate();
  23417. public function getStability();
  23418. public function getRequires();
  23419. public function getConflicts();
  23420. public function getProvides();
  23421. public function getReplaces();
  23422. public function getDevRequires();
  23423. public function getSuggests();
  23424. public function getAutoload();
  23425. public function getDevAutoload();
  23426. public function getIncludePaths();
  23427. public function setRepository(RepositoryInterface $repository);
  23428. public function getRepository();
  23429. public function getBinaries();
  23430. public function getUniqueName();
  23431. public function getNotificationUrl();
  23432. public function __toString();
  23433. public function getPrettyString();
  23434. public function isDefaultBranch();
  23435. public function getTransportOptions();
  23436. public function setTransportOptions(array $options);
  23437. public function setSourceReference($reference);
  23438. public function setDistUrl($url);
  23439. public function setDistType($type);
  23440. public function setDistReference($reference);
  23441. public function setSourceDistReferences($reference);
  23442. }
  23443. <?php
  23444. namespace Composer\Package;
  23445. class RootAliasPackage extends CompleteAliasPackage implements RootPackageInterface
  23446. {
  23447. protected $aliasOf;
  23448. public function __construct(RootPackage $aliasOf, $version, $prettyVersion)
  23449. {
  23450. parent::__construct($aliasOf, $version, $prettyVersion);
  23451. }
  23452. public function getAliasOf()
  23453. {
  23454. return $this->aliasOf;
  23455. }
  23456. public function getAliases()
  23457. {
  23458. return $this->aliasOf->getAliases();
  23459. }
  23460. public function getMinimumStability()
  23461. {
  23462. return $this->aliasOf->getMinimumStability();
  23463. }
  23464. public function getStabilityFlags()
  23465. {
  23466. return $this->aliasOf->getStabilityFlags();
  23467. }
  23468. public function getReferences()
  23469. {
  23470. return $this->aliasOf->getReferences();
  23471. }
  23472. public function getPreferStable()
  23473. {
  23474. return $this->aliasOf->getPreferStable();
  23475. }
  23476. public function getConfig()
  23477. {
  23478. return $this->aliasOf->getConfig();
  23479. }
  23480. public function setRequires(array $require)
  23481. {
  23482. $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
  23483. $this->aliasOf->setRequires($require);
  23484. }
  23485. public function setDevRequires(array $devRequire)
  23486. {
  23487. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
  23488. $this->aliasOf->setDevRequires($devRequire);
  23489. }
  23490. public function setConflicts(array $conflicts)
  23491. {
  23492. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  23493. $this->aliasOf->setConflicts($conflicts);
  23494. }
  23495. public function setProvides(array $provides)
  23496. {
  23497. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  23498. $this->aliasOf->setProvides($provides);
  23499. }
  23500. public function setReplaces(array $replaces)
  23501. {
  23502. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  23503. $this->aliasOf->setReplaces($replaces);
  23504. }
  23505. public function setAutoload(array $autoload)
  23506. {
  23507. $this->aliasOf->setAutoload($autoload);
  23508. }
  23509. public function setDevAutoload(array $devAutoload)
  23510. {
  23511. $this->aliasOf->setDevAutoload($devAutoload);
  23512. }
  23513. public function setStabilityFlags(array $stabilityFlags)
  23514. {
  23515. $this->aliasOf->setStabilityFlags($stabilityFlags);
  23516. }
  23517. public function setMinimumStability($minimumStability)
  23518. {
  23519. $this->aliasOf->setMinimumStability($minimumStability);
  23520. }
  23521. public function setPreferStable($preferStable)
  23522. {
  23523. $this->aliasOf->setPreferStable($preferStable);
  23524. }
  23525. public function setConfig(array $config)
  23526. {
  23527. $this->aliasOf->setConfig($config);
  23528. }
  23529. public function setReferences(array $references)
  23530. {
  23531. $this->aliasOf->setReferences($references);
  23532. }
  23533. public function setAliases(array $aliases)
  23534. {
  23535. $this->aliasOf->setAliases($aliases);
  23536. }
  23537. public function setSuggests(array $suggests)
  23538. {
  23539. $this->aliasOf->setSuggests($suggests);
  23540. }
  23541. public function setExtra(array $extra)
  23542. {
  23543. $this->aliasOf->setExtra($extra);
  23544. }
  23545. public function __clone()
  23546. {
  23547. parent::__clone();
  23548. $this->aliasOf = clone $this->aliasOf;
  23549. }
  23550. }
  23551. <?php
  23552. namespace Composer\Package;
  23553. class RootPackage extends CompletePackage implements RootPackageInterface
  23554. {
  23555. const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  23556. protected $minimumStability = 'stable';
  23557. protected $preferStable = false;
  23558. protected $stabilityFlags = array();
  23559. protected $config = array();
  23560. protected $references = array();
  23561. protected $aliases = array();
  23562. public function setMinimumStability($minimumStability)
  23563. {
  23564. $this->minimumStability = $minimumStability;
  23565. }
  23566. public function getMinimumStability()
  23567. {
  23568. return $this->minimumStability;
  23569. }
  23570. public function setStabilityFlags(array $stabilityFlags)
  23571. {
  23572. $this->stabilityFlags = $stabilityFlags;
  23573. }
  23574. public function getStabilityFlags()
  23575. {
  23576. return $this->stabilityFlags;
  23577. }
  23578. public function setPreferStable($preferStable)
  23579. {
  23580. $this->preferStable = $preferStable;
  23581. }
  23582. public function getPreferStable()
  23583. {
  23584. return $this->preferStable;
  23585. }
  23586. public function setConfig(array $config)
  23587. {
  23588. $this->config = $config;
  23589. }
  23590. public function getConfig()
  23591. {
  23592. return $this->config;
  23593. }
  23594. public function setReferences(array $references)
  23595. {
  23596. $this->references = $references;
  23597. }
  23598. public function getReferences()
  23599. {
  23600. return $this->references;
  23601. }
  23602. public function setAliases(array $aliases)
  23603. {
  23604. $this->aliases = $aliases;
  23605. }
  23606. public function getAliases()
  23607. {
  23608. return $this->aliases;
  23609. }
  23610. }
  23611. <?php
  23612. namespace Composer\Package;
  23613. interface RootPackageInterface extends CompletePackageInterface
  23614. {
  23615. public function getAliases();
  23616. public function getMinimumStability();
  23617. public function getStabilityFlags();
  23618. public function getReferences();
  23619. public function getPreferStable();
  23620. public function getConfig();
  23621. public function setRequires(array $requires);
  23622. public function setDevRequires(array $devRequires);
  23623. public function setConflicts(array $conflicts);
  23624. public function setProvides(array $provides);
  23625. public function setReplaces(array $replaces);
  23626. public function setRepositories(array $repositories);
  23627. public function setAutoload(array $autoload);
  23628. public function setDevAutoload(array $devAutoload);
  23629. public function setStabilityFlags(array $stabilityFlags);
  23630. public function setMinimumStability($minimumStability);
  23631. public function setPreferStable($preferStable);
  23632. public function setConfig(array $config);
  23633. public function setReferences(array $references);
  23634. public function setAliases(array $aliases);
  23635. public function setSuggests(array $suggests);
  23636. public function setExtra(array $extra);
  23637. }
  23638. <?php
  23639. namespace Composer\Package\Version;
  23640. use Composer\Package\BasePackage;
  23641. class StabilityFilter
  23642. {
  23643. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, array $names, $stability)
  23644. {
  23645. foreach ($names as $name) {
  23646. if (isset($stabilityFlags[$name])) {
  23647. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  23648. return true;
  23649. }
  23650. } elseif (isset($acceptableStabilities[$stability])) {
  23651. return true;
  23652. }
  23653. }
  23654. return false;
  23655. }
  23656. }
  23657. <?php
  23658. namespace Composer\Package\Version;
  23659. use Composer\Config;
  23660. use Composer\Pcre\Preg;
  23661. use Composer\Repository\Vcs\HgDriver;
  23662. use Composer\IO\NullIO;
  23663. use Composer\Semver\VersionParser as SemverVersionParser;
  23664. use Composer\Util\Git as GitUtil;
  23665. use Composer\Util\HttpDownloader;
  23666. use Composer\Util\ProcessExecutor;
  23667. use Composer\Util\Svn as SvnUtil;
  23668. class VersionGuesser
  23669. {
  23670. private $config;
  23671. private $process;
  23672. private $versionParser;
  23673. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  23674. {
  23675. $this->config = $config;
  23676. $this->process = $process;
  23677. $this->versionParser = $versionParser;
  23678. }
  23679. public function guessVersion(array $packageConfig, $path)
  23680. {
  23681. if (!function_exists('proc_open')) {
  23682. return null;
  23683. }
  23684. $versionData = $this->guessGitVersion($packageConfig, $path);
  23685. if (null !== $versionData && null !== $versionData['version']) {
  23686. return $this->postprocess($versionData);
  23687. }
  23688. $versionData = $this->guessHgVersion($packageConfig, $path);
  23689. if (null !== $versionData && null !== $versionData['version']) {
  23690. return $this->postprocess($versionData);
  23691. }
  23692. $versionData = $this->guessFossilVersion($path);
  23693. if (null !== $versionData && null !== $versionData['version']) {
  23694. return $this->postprocess($versionData);
  23695. }
  23696. $versionData = $this->guessSvnVersion($packageConfig, $path);
  23697. if (null !== $versionData && null !== $versionData['version']) {
  23698. return $this->postprocess($versionData);
  23699. }
  23700. return null;
  23701. }
  23702. private function postprocess(array $versionData)
  23703. {
  23704. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  23705. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  23706. }
  23707. if ('-dev' === substr($versionData['version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['version'])) {
  23708. $versionData['pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['version']);
  23709. }
  23710. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && Preg::isMatch('{\.9{7}}', $versionData['feature_version'])) {
  23711. $versionData['feature_pretty_version'] = Preg::replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  23712. }
  23713. return $versionData;
  23714. }
  23715. private function guessGitVersion(array $packageConfig, $path)
  23716. {
  23717. GitUtil::cleanEnv();
  23718. $commit = null;
  23719. $version = null;
  23720. $prettyVersion = null;
  23721. $featureVersion = null;
  23722. $featurePrettyVersion = null;
  23723. $isDetached = false;
  23724. if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
  23725. $branches = array();
  23726. $isFeatureBranch = false;
  23727. foreach ($this->process->splitLines($output) as $branch) {
  23728. if ($branch && Preg::isMatch('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  23729. if (
  23730. $match[1] === '(no branch)'
  23731. || strpos($match[1], '(detached ') === 0
  23732. || strpos($match[1], '(HEAD detached at') === 0
  23733. ) {
  23734. $version = 'dev-' . $match[2];
  23735. $prettyVersion = $version;
  23736. $isFeatureBranch = true;
  23737. $isDetached = true;
  23738. } else {
  23739. $version = $this->versionParser->normalizeBranch($match[1]);
  23740. $prettyVersion = 'dev-' . $match[1];
  23741. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  23742. }
  23743. if ($match[2]) {
  23744. $commit = $match[2];
  23745. }
  23746. }
  23747. if ($branch && !Preg::isMatch('{^ *.+/HEAD }', $branch)) {
  23748. if (Preg::isMatch('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  23749. $branches[] = $match[1];
  23750. }
  23751. }
  23752. }
  23753. if ($isFeatureBranch) {
  23754. $featureVersion = $version;
  23755. $featurePrettyVersion = $prettyVersion;
  23756. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  23757. $version = $result['version'];
  23758. $prettyVersion = $result['pretty_version'];
  23759. }
  23760. }
  23761. if (!$version || $isDetached) {
  23762. $result = $this->versionFromGitTags($path);
  23763. if ($result) {
  23764. $version = $result['version'];
  23765. $prettyVersion = $result['pretty_version'];
  23766. $featureVersion = null;
  23767. $featurePrettyVersion = null;
  23768. }
  23769. }
  23770. if (!$commit) {
  23771. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  23772. if (0 === $this->process->execute($command, $output, $path)) {
  23773. $commit = trim($output) ?: null;
  23774. }
  23775. }
  23776. if ($featureVersion) {
  23777. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  23778. }
  23779. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  23780. }
  23781. private function versionFromGitTags($path)
  23782. {
  23783. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  23784. try {
  23785. $version = $this->versionParser->normalize(trim($output));
  23786. return array('version' => $version, 'pretty_version' => trim($output));
  23787. } catch (\Exception $e) {
  23788. }
  23789. }
  23790. return null;
  23791. }
  23792. private function guessHgVersion(array $packageConfig, $path)
  23793. {
  23794. if (0 === $this->process->execute('hg branch', $output, $path)) {
  23795. $branch = trim($output);
  23796. $version = $this->versionParser->normalizeBranch($branch);
  23797. $isFeatureBranch = 0 === strpos($version, 'dev-');
  23798. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  23799. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  23800. }
  23801. if (!$isFeatureBranch) {
  23802. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  23803. }
  23804. $io = new NullIO();
  23805. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  23806. $branches = array_map('strval', array_keys($driver->getBranches()));
  23807. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  23808. $result['commit'] = '';
  23809. $result['feature_version'] = $version;
  23810. $result['feature_pretty_version'] = $version;
  23811. return $result;
  23812. }
  23813. return null;
  23814. }
  23815. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  23816. {
  23817. $prettyVersion = $version;
  23818. if (!isset($packageConfig['extra']['branch-alias'][$version])
  23819. || strpos(json_encode($packageConfig), '"self.version"')
  23820. ) {
  23821. $branch = Preg::replace('{^dev-}', '', $version);
  23822. $length = PHP_INT_MAX;
  23823. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  23824. return array('version' => $version, 'pretty_version' => $prettyVersion);
  23825. }
  23826. usort($branches, function ($a, $b) {
  23827. $aRemote = 0 === strpos($a, 'remotes/');
  23828. $bRemote = 0 === strpos($b, 'remotes/');
  23829. if ($aRemote !== $bRemote) {
  23830. return $aRemote ? 1 : -1;
  23831. }
  23832. return strnatcasecmp($b, $a);
  23833. });
  23834. foreach ($branches as $candidate) {
  23835. $candidateVersion = Preg::replace('{^remotes/\S+/}', '', $candidate);
  23836. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  23837. continue;
  23838. }
  23839. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  23840. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  23841. continue;
  23842. }
  23843. if (strlen($output) < $length) {
  23844. $length = strlen($output);
  23845. $version = $this->versionParser->normalizeBranch($candidateVersion);
  23846. $prettyVersion = 'dev-' . $candidateVersion;
  23847. if ($length === 0) {
  23848. break;
  23849. }
  23850. }
  23851. }
  23852. }
  23853. return array('version' => $version, 'pretty_version' => $prettyVersion);
  23854. }
  23855. private function isFeatureBranch(array $packageConfig, $branchName)
  23856. {
  23857. $nonFeatureBranches = '';
  23858. if (!empty($packageConfig['non-feature-branches'])) {
  23859. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  23860. }
  23861. return !Preg::isMatch('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  23862. }
  23863. private function guessFossilVersion($path)
  23864. {
  23865. $version = null;
  23866. $prettyVersion = null;
  23867. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  23868. $branch = trim($output);
  23869. $version = $this->versionParser->normalizeBranch($branch);
  23870. $prettyVersion = 'dev-' . $branch;
  23871. }
  23872. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  23873. try {
  23874. $version = $this->versionParser->normalize(trim($output));
  23875. $prettyVersion = trim($output);
  23876. } catch (\Exception $e) {
  23877. }
  23878. }
  23879. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  23880. }
  23881. private function guessSvnVersion(array $packageConfig, $path)
  23882. {
  23883. SvnUtil::cleanEnv();
  23884. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  23885. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  23886. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  23887. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  23888. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  23889. if (Preg::isMatch($urlPattern, $output, $matches)) {
  23890. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  23891. $version = $this->versionParser->normalizeBranch($matches[3]);
  23892. $prettyVersion = 'dev-' . $matches[3];
  23893. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  23894. }
  23895. $prettyVersion = trim($matches[1]);
  23896. if ($prettyVersion === 'trunk') {
  23897. $version = 'dev-trunk';
  23898. } else {
  23899. $version = $this->versionParser->normalize($prettyVersion);
  23900. }
  23901. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  23902. }
  23903. }
  23904. return null;
  23905. }
  23906. }
  23907. <?php
  23908. namespace Composer\Package\Version;
  23909. use Composer\Pcre\Preg;
  23910. use Composer\Repository\PlatformRepository;
  23911. use Composer\Semver\VersionParser as SemverVersionParser;
  23912. use Composer\Semver\Semver;
  23913. use Composer\Semver\Constraint\ConstraintInterface;
  23914. class VersionParser extends SemverVersionParser
  23915. {
  23916. const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  23917. private static $constraints = array();
  23918. public function parseConstraints($constraints)
  23919. {
  23920. if (!isset(self::$constraints[$constraints])) {
  23921. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  23922. }
  23923. return self::$constraints[$constraints];
  23924. }
  23925. public function parseNameVersionPairs(array $pairs)
  23926. {
  23927. $pairs = array_values($pairs);
  23928. $result = array();
  23929. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  23930. $pair = Preg::replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  23931. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !Preg::isMatch('{(?<=[a-z0-9_/-])\*|\*(?=[a-z0-9_/-])}i', $pairs[$i + 1]) && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  23932. $pair .= ' '.$pairs[$i + 1];
  23933. $i++;
  23934. }
  23935. if (strpos($pair, ' ')) {
  23936. list($name, $version) = explode(' ', $pair, 2);
  23937. $result[] = array('name' => $name, 'version' => $version);
  23938. } else {
  23939. $result[] = array('name' => $pair);
  23940. }
  23941. }
  23942. return $result;
  23943. }
  23944. public static function isUpgrade($normalizedFrom, $normalizedTo)
  23945. {
  23946. if ($normalizedFrom === $normalizedTo) {
  23947. return true;
  23948. }
  23949. if (in_array($normalizedFrom, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  23950. $normalizedFrom = VersionParser::DEFAULT_BRANCH_ALIAS;
  23951. }
  23952. if (in_array($normalizedTo, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  23953. $normalizedTo = VersionParser::DEFAULT_BRANCH_ALIAS;
  23954. }
  23955. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  23956. return true;
  23957. }
  23958. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  23959. return $sorted[0] === $normalizedFrom;
  23960. }
  23961. }
  23962. <?php
  23963. namespace Composer\Package\Version;
  23964. use Composer\Filter\PlatformRequirementFilter\IgnoreAllPlatformRequirementFilter;
  23965. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterFactory;
  23966. use Composer\Filter\PlatformRequirementFilter\PlatformRequirementFilterInterface;
  23967. use Composer\Package\BasePackage;
  23968. use Composer\Package\AliasPackage;
  23969. use Composer\Package\PackageInterface;
  23970. use Composer\Composer;
  23971. use Composer\Package\Loader\ArrayLoader;
  23972. use Composer\Package\Dumper\ArrayDumper;
  23973. use Composer\Pcre\Preg;
  23974. use Composer\Repository\RepositorySet;
  23975. use Composer\Repository\PlatformRepository;
  23976. use Composer\Semver\Constraint\Constraint;
  23977. use Composer\Semver\Constraint\ConstraintInterface;
  23978. class VersionSelector
  23979. {
  23980. private $repositorySet;
  23981. private $platformConstraints = array();
  23982. private $parser;
  23983. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  23984. {
  23985. $this->repositorySet = $repositorySet;
  23986. if ($platformRepo) {
  23987. foreach ($platformRepo->getPackages() as $package) {
  23988. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  23989. }
  23990. }
  23991. }
  23992. public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $platformRequirementFilter = null, $repoSetFlags = 0)
  23993. {
  23994. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  23995. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  23996. }
  23997. if (null === $platformRequirementFilter) {
  23998. $platformRequirementFilter = PlatformRequirementFilterFactory::ignoreNothing();
  23999. } elseif (!($platformRequirementFilter instanceof PlatformRequirementFilterInterface)) {
  24000. trigger_error('VersionSelector::findBestCandidate with ignored platform reqs as bool|array is deprecated since Composer 2.2, use an instance of PlatformRequirementFilterInterface instead.', E_USER_DEPRECATED);
  24001. $platformRequirementFilter = PlatformRequirementFilterFactory::fromBoolOrList($platformRequirementFilter);
  24002. }
  24003. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  24004. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  24005. if ($this->platformConstraints && !($platformRequirementFilter instanceof IgnoreAllPlatformRequirementFilter)) {
  24006. $platformConstraints = $this->platformConstraints;
  24007. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $platformRequirementFilter) {
  24008. $reqs = $pkg->getRequires();
  24009. foreach ($reqs as $name => $link) {
  24010. if (!$platformRequirementFilter->isIgnored($name)) {
  24011. if (isset($platformConstraints[$name])) {
  24012. foreach ($platformConstraints[$name] as $constraint) {
  24013. if ($link->getConstraint()->matches($constraint)) {
  24014. continue 2;
  24015. }
  24016. }
  24017. return false;
  24018. } elseif (PlatformRepository::isPlatformPackage($name)) {
  24019. return false;
  24020. }
  24021. }
  24022. }
  24023. return true;
  24024. });
  24025. }
  24026. if (!$candidates) {
  24027. return false;
  24028. }
  24029. $package = reset($candidates);
  24030. $minPriority = BasePackage::$stabilities[$preferredStability];
  24031. foreach ($candidates as $candidate) {
  24032. $candidatePriority = $candidate->getStabilityPriority();
  24033. $currentPriority = $package->getStabilityPriority();
  24034. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  24035. continue;
  24036. }
  24037. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  24038. $package = $candidate;
  24039. continue;
  24040. }
  24041. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  24042. $package = $candidate;
  24043. continue;
  24044. }
  24045. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  24046. $package = $candidate;
  24047. }
  24048. }
  24049. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  24050. $package = $package->getAliasOf();
  24051. }
  24052. return $package;
  24053. }
  24054. public function findRecommendedRequireVersion(PackageInterface $package)
  24055. {
  24056. if (0 === strpos($package->getName(), 'ext-')) {
  24057. $phpVersion = PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  24058. $extVersion = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  24059. if ($phpVersion === $extVersion) {
  24060. return '*';
  24061. }
  24062. }
  24063. $version = $package->getVersion();
  24064. if (!$package->isDev()) {
  24065. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  24066. }
  24067. $loader = new ArrayLoader($this->getParser());
  24068. $dumper = new ArrayDumper();
  24069. $extra = $loader->getBranchAlias($dumper->dump($package));
  24070. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  24071. $extra = Preg::replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  24072. if ($count) {
  24073. $extra = str_replace('.9999999', '.0', $extra);
  24074. return $this->transformVersion($extra, $extra, 'dev');
  24075. }
  24076. }
  24077. return $package->getPrettyVersion();
  24078. }
  24079. private function transformVersion($version, $prettyVersion, $stability)
  24080. {
  24081. $semanticVersionParts = explode('.', $version);
  24082. if (count($semanticVersionParts) == 4 && Preg::isMatch('{^0\D?}', $semanticVersionParts[3])) {
  24083. if ($semanticVersionParts[0] === '0') {
  24084. unset($semanticVersionParts[3]);
  24085. } else {
  24086. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  24087. }
  24088. $version = implode('.', $semanticVersionParts);
  24089. } else {
  24090. return $prettyVersion;
  24091. }
  24092. if ($stability != 'stable') {
  24093. $version .= '@'.$stability;
  24094. }
  24095. return '^' . $version;
  24096. }
  24097. private function getParser()
  24098. {
  24099. if ($this->parser === null) {
  24100. $this->parser = new VersionParser();
  24101. }
  24102. return $this->parser;
  24103. }
  24104. }
  24105. <?php
  24106. namespace Composer\Platform;
  24107. use Composer\Util\Platform;
  24108. use Composer\Util\ProcessExecutor;
  24109. use Symfony\Component\Process\ExecutableFinder;
  24110. class HhvmDetector
  24111. {
  24112. private static $hhvmVersion = null;
  24113. private $executableFinder;
  24114. private $processExecutor;
  24115. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  24116. {
  24117. $this->executableFinder = $executableFinder;
  24118. $this->processExecutor = $processExecutor;
  24119. }
  24120. public function reset()
  24121. {
  24122. self::$hhvmVersion = null;
  24123. }
  24124. public function getVersion()
  24125. {
  24126. if (null !== self::$hhvmVersion) {
  24127. return self::$hhvmVersion ?: null;
  24128. }
  24129. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  24130. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  24131. self::$hhvmVersion = false;
  24132. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  24133. $hhvmPath = $this->executableFinder->find('hhvm');
  24134. if ($hhvmPath !== null) {
  24135. $this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
  24136. $exitCode = $this->processExecutor->execute(
  24137. ProcessExecutor::escape($hhvmPath).
  24138. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  24139. self::$hhvmVersion
  24140. );
  24141. if ($exitCode !== 0) {
  24142. self::$hhvmVersion = false;
  24143. }
  24144. }
  24145. }
  24146. return self::$hhvmVersion ?: null;
  24147. }
  24148. }
  24149. <?php
  24150. namespace Composer\Platform;
  24151. class Runtime
  24152. {
  24153. public function hasConstant($constant, $class = null)
  24154. {
  24155. return defined(ltrim($class.'::'.$constant, ':'));
  24156. }
  24157. public function getConstant($constant, $class = null)
  24158. {
  24159. return constant(ltrim($class.'::'.$constant, ':'));
  24160. }
  24161. public function hasFunction($fn)
  24162. {
  24163. return function_exists($fn);
  24164. }
  24165. public function invoke($callable, array $arguments = array())
  24166. {
  24167. return call_user_func_array($callable, $arguments);
  24168. }
  24169. public function hasClass($class)
  24170. {
  24171. return class_exists($class, false);
  24172. }
  24173. public function construct($class, array $arguments = array())
  24174. {
  24175. if (empty($arguments)) {
  24176. return new $class;
  24177. }
  24178. $refl = new \ReflectionClass($class);
  24179. return $refl->newInstanceArgs($arguments);
  24180. }
  24181. public function getExtensions()
  24182. {
  24183. return get_loaded_extensions();
  24184. }
  24185. public function getExtensionVersion($extension)
  24186. {
  24187. return phpversion($extension);
  24188. }
  24189. public function getExtensionInfo($extension)
  24190. {
  24191. $reflector = new \ReflectionExtension($extension);
  24192. ob_start();
  24193. $reflector->info();
  24194. return ob_get_clean();
  24195. }
  24196. }
  24197. <?php
  24198. namespace Composer\Platform;
  24199. use Composer\Pcre\Preg;
  24200. class Version
  24201. {
  24202. public static function parseOpenssl($opensslVersion, &$isFips)
  24203. {
  24204. $isFips = false;
  24205. if (!Preg::isMatch('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?(?<garbage>-\w+)?$/', $opensslVersion, $matches)) {
  24206. return null;
  24207. }
  24208. $isFips = strpos($matches['suffix'], 'fips') !== false;
  24209. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  24210. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  24211. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  24212. }
  24213. public static function parseLibjpeg($libjpegVersion)
  24214. {
  24215. if (!Preg::isMatch('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  24216. return null;
  24217. }
  24218. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  24219. }
  24220. public static function parseZoneinfoVersion($zoneinfoVersion)
  24221. {
  24222. if (!Preg::isMatch('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  24223. return null;
  24224. }
  24225. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  24226. }
  24227. private static function convertAlphaVersionToIntVersion($alpha)
  24228. {
  24229. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  24230. }
  24231. public static function convertLibxpmVersionId($versionId)
  24232. {
  24233. return self::convertVersionId($versionId, 100);
  24234. }
  24235. public static function convertOpenldapVersionId($versionId)
  24236. {
  24237. return self::convertVersionId($versionId, 100);
  24238. }
  24239. private static function convertVersionId($versionId, $base)
  24240. {
  24241. return sprintf(
  24242. '%d.%d.%d',
  24243. $versionId / ($base * $base),
  24244. (int) ($versionId / $base) % $base,
  24245. $versionId % $base
  24246. );
  24247. }
  24248. }
  24249. <?php
  24250. namespace Composer\Plugin\Capability;
  24251. interface Capability
  24252. {
  24253. }
  24254. <?php
  24255. namespace Composer\Plugin\Capability;
  24256. interface CommandProvider extends Capability
  24257. {
  24258. public function getCommands();
  24259. }
  24260. <?php
  24261. namespace Composer\Plugin;
  24262. interface Capable
  24263. {
  24264. public function getCapabilities();
  24265. }
  24266. <?php
  24267. namespace Composer\Plugin;
  24268. use Composer\EventDispatcher\Event;
  24269. use Symfony\Component\Console\Input\InputInterface;
  24270. use Symfony\Component\Console\Output\OutputInterface;
  24271. class CommandEvent extends Event
  24272. {
  24273. private $commandName;
  24274. private $input;
  24275. private $output;
  24276. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  24277. {
  24278. parent::__construct($name, $args, $flags);
  24279. $this->commandName = $commandName;
  24280. $this->input = $input;
  24281. $this->output = $output;
  24282. }
  24283. public function getInput()
  24284. {
  24285. return $this->input;
  24286. }
  24287. public function getOutput()
  24288. {
  24289. return $this->output;
  24290. }
  24291. public function getCommandName()
  24292. {
  24293. return $this->commandName;
  24294. }
  24295. }
  24296. <?php
  24297. namespace Composer\Plugin;
  24298. class PluginEvents
  24299. {
  24300. const INIT = 'init';
  24301. const COMMAND = 'command';
  24302. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  24303. const POST_FILE_DOWNLOAD = 'post-file-download';
  24304. const PRE_COMMAND_RUN = 'pre-command-run';
  24305. const PRE_POOL_CREATE = 'pre-pool-create';
  24306. }
  24307. <?php
  24308. namespace Composer\Plugin;
  24309. use Composer\Composer;
  24310. use Composer\IO\IOInterface;
  24311. interface PluginInterface
  24312. {
  24313. const PLUGIN_API_VERSION = '2.2.0';
  24314. public function activate(Composer $composer, IOInterface $io);
  24315. public function deactivate(Composer $composer, IOInterface $io);
  24316. public function uninstall(Composer $composer, IOInterface $io);
  24317. }
  24318. <?php
  24319. namespace Composer\Plugin;
  24320. use Composer\Composer;
  24321. use Composer\EventDispatcher\EventSubscriberInterface;
  24322. use Composer\Installer\InstallerInterface;
  24323. use Composer\IO\IOInterface;
  24324. use Composer\Package\BasePackage;
  24325. use Composer\Package\CompletePackage;
  24326. use Composer\Package\Package;
  24327. use Composer\Package\Version\VersionParser;
  24328. use Composer\Pcre\Preg;
  24329. use Composer\Repository\RepositoryInterface;
  24330. use Composer\Repository\InstalledRepository;
  24331. use Composer\Repository\RootPackageRepository;
  24332. use Composer\Package\PackageInterface;
  24333. use Composer\Package\Link;
  24334. use Composer\Semver\Constraint\Constraint;
  24335. use Composer\Plugin\Capability\Capability;
  24336. use Composer\Util\PackageSorter;
  24337. class PluginManager
  24338. {
  24339. protected $composer;
  24340. protected $io;
  24341. protected $globalComposer;
  24342. protected $versionParser;
  24343. protected $disablePlugins = false;
  24344. protected $plugins = array();
  24345. protected $registeredPlugins = array();
  24346. private $allowPluginRules;
  24347. private $allowGlobalPluginRules;
  24348. private static $classCounter = 0;
  24349. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  24350. {
  24351. $this->io = $io;
  24352. $this->composer = $composer;
  24353. $this->globalComposer = $globalComposer;
  24354. $this->versionParser = new VersionParser();
  24355. $this->disablePlugins = $disablePlugins;
  24356. $this->allowPluginRules = $this->parseAllowedPlugins($composer->getConfig()->get('allow-plugins'));
  24357. $this->allowGlobalPluginRules = $this->parseAllowedPlugins($globalComposer !== null ? $globalComposer->getConfig()->get('allow-plugins') : false);
  24358. }
  24359. public function loadInstalledPlugins()
  24360. {
  24361. if ($this->disablePlugins) {
  24362. return;
  24363. }
  24364. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  24365. $globalRepo = $this->globalComposer !== null ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  24366. $this->loadRepository($repo, false);
  24367. if ($globalRepo) {
  24368. $this->loadRepository($globalRepo, true);
  24369. }
  24370. }
  24371. public function deactivateInstalledPlugins()
  24372. {
  24373. if ($this->disablePlugins) {
  24374. return;
  24375. }
  24376. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  24377. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  24378. $this->deactivateRepository($repo, false);
  24379. if ($globalRepo) {
  24380. $this->deactivateRepository($globalRepo, true);
  24381. }
  24382. }
  24383. public function getPlugins()
  24384. {
  24385. return $this->plugins;
  24386. }
  24387. public function getGlobalComposer()
  24388. {
  24389. return $this->globalComposer;
  24390. }
  24391. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false, $isGlobalPlugin = false)
  24392. {
  24393. if ($this->disablePlugins) {
  24394. return;
  24395. }
  24396. if (!$this->isPluginAllowed($package->getName(), $isGlobalPlugin)) {
  24397. $this->io->writeError('Skipped loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'as it is not in config.allow-plugins', true, IOInterface::DEBUG);
  24398. return;
  24399. }
  24400. if ($package->getType() === 'composer-plugin') {
  24401. $requiresComposer = null;
  24402. foreach ($package->getRequires() as $link) {
  24403. if ('composer-plugin-api' === $link->getTarget()) {
  24404. $requiresComposer = $link->getConstraint();
  24405. break;
  24406. }
  24407. }
  24408. if (!$requiresComposer) {
  24409. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  24410. }
  24411. $currentPluginApiVersion = $this->getPluginApiVersion();
  24412. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  24413. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  24414. $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>');
  24415. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  24416. $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>');
  24417. return;
  24418. }
  24419. if ($package->getName() === 'symfony/flex' && Preg::isMatch('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  24420. $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>');
  24421. return;
  24422. }
  24423. }
  24424. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  24425. if (isset($this->registeredPlugins[$package->getName()])) {
  24426. return;
  24427. }
  24428. $extra = $package->getExtra();
  24429. if (empty($extra['class'])) {
  24430. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  24431. }
  24432. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  24433. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  24434. $globalRepo = $this->globalComposer !== null ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  24435. $rootPackage = clone $this->composer->getPackage();
  24436. $rootPackageAutoloads = $rootPackage->getAutoload();
  24437. $rootPackageAutoloads['files'] = array();
  24438. $rootPackage->setAutoload($rootPackageAutoloads);
  24439. $rootPackageAutoloads = $rootPackage->getDevAutoload();
  24440. $rootPackageAutoloads['files'] = array();
  24441. $rootPackage->setDevAutoload($rootPackageAutoloads);
  24442. unset($rootPackageAutoloads);
  24443. $rootPackageRepo = new RootPackageRepository($rootPackage);
  24444. $installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo));
  24445. if ($globalRepo) {
  24446. $installedRepo->addRepository($globalRepo);
  24447. }
  24448. $autoloadPackages = array($package->getName() => $package);
  24449. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  24450. $generator = $this->composer->getAutoloadGenerator();
  24451. $autoloads = array(array($rootPackage, ''));
  24452. foreach ($autoloadPackages as $autoloadPackage) {
  24453. if ($autoloadPackage === $rootPackage) {
  24454. continue;
  24455. }
  24456. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  24457. $autoloads[] = array($autoloadPackage, $downloadPath);
  24458. }
  24459. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  24460. $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  24461. $classLoader->register(false);
  24462. foreach ($map['files'] as $fileIdentifier => $file) {
  24463. if ($fileIdentifier === '7e9bd612cc444b3eed788ebbe46263a0') {
  24464. continue;
  24465. }
  24466. \Composer\Autoload\composerRequire($fileIdentifier, $file);
  24467. }
  24468. foreach ($classes as $class) {
  24469. if (class_exists($class, false)) {
  24470. $class = trim($class, '\\');
  24471. $path = $classLoader->findFile($class);
  24472. $code = file_get_contents($path);
  24473. $separatorPos = strrpos($class, '\\');
  24474. $className = $class;
  24475. if ($separatorPos) {
  24476. $className = substr($class, $separatorPos + 1);
  24477. }
  24478. $code = Preg::replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  24479. $code = strtr($code, array(
  24480. '__FILE__' => var_export($path, true),
  24481. '__DIR__' => var_export(dirname($path), true),
  24482. '__CLASS__' => var_export($class, true),
  24483. ));
  24484. $code = Preg::replace('/^\s*<\?(php)?/i', '', $code, 1);
  24485. eval($code);
  24486. $class .= '_composer_tmp'.self::$classCounter;
  24487. self::$classCounter++;
  24488. }
  24489. if ($oldInstallerPlugin) {
  24490. if (!is_a($class, 'Composer\Installer\InstallerInterface', true)) {
  24491. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Installer\InstallerInterface');
  24492. }
  24493. $this->io->writeError('<warning>Loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'which is a legacy composer-installer built for Composer 1.x, it is likely to cause issues as you are running Composer 2.x.</warning>');
  24494. $installer = new $class($this->io, $this->composer);
  24495. $this->composer->getInstallationManager()->addInstaller($installer);
  24496. $this->registeredPlugins[$package->getName()] = $installer;
  24497. } elseif (class_exists($class)) {
  24498. if (!is_a($class, 'Composer\Plugin\PluginInterface', true)) {
  24499. throw new \RuntimeException('Could not activate plugin "'.$package->getName().'" as "'.$class.'" does not implement Composer\Plugin\PluginInterface');
  24500. }
  24501. $plugin = new $class();
  24502. $this->addPlugin($plugin, $isGlobalPlugin, $package);
  24503. $this->registeredPlugins[$package->getName()] = $plugin;
  24504. } elseif ($failOnMissingClasses) {
  24505. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  24506. }
  24507. }
  24508. }
  24509. public function deactivatePackage(PackageInterface $package)
  24510. {
  24511. if ($this->disablePlugins) {
  24512. return;
  24513. }
  24514. if (!isset($this->registeredPlugins[$package->getName()])) {
  24515. return;
  24516. }
  24517. $plugin = $this->registeredPlugins[$package->getName()];
  24518. unset($this->registeredPlugins[$package->getName()]);
  24519. if ($plugin instanceof InstallerInterface) {
  24520. $this->composer->getInstallationManager()->removeInstaller($plugin);
  24521. } else {
  24522. $this->removePlugin($plugin);
  24523. }
  24524. }
  24525. public function uninstallPackage(PackageInterface $package)
  24526. {
  24527. if ($this->disablePlugins) {
  24528. return;
  24529. }
  24530. if (!isset($this->registeredPlugins[$package->getName()])) {
  24531. return;
  24532. }
  24533. $plugin = $this->registeredPlugins[$package->getName()];
  24534. if ($plugin instanceof InstallerInterface) {
  24535. $this->deactivatePackage($package);
  24536. } else {
  24537. unset($this->registeredPlugins[$package->getName()]);
  24538. $this->removePlugin($plugin);
  24539. $this->uninstallPlugin($plugin);
  24540. }
  24541. }
  24542. protected function getPluginApiVersion()
  24543. {
  24544. return PluginInterface::PLUGIN_API_VERSION;
  24545. }
  24546. public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false, PackageInterface $sourcePackage = null)
  24547. {
  24548. if ($sourcePackage === null) {
  24549. trigger_error('Calling PluginManager::addPlugin without $sourcePackage is deprecated, if you are using this please get in touch with us to explain the use case', E_USER_DEPRECATED);
  24550. } elseif (!$this->isPluginAllowed($sourcePackage->getName(), $isGlobalPlugin)) {
  24551. $this->io->writeError('Skipped loading "'.get_class($plugin).' from '.$sourcePackage->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').' as it is not in config.allow-plugins', true, IOInterface::DEBUG);
  24552. return;
  24553. }
  24554. $details = array();
  24555. if ($sourcePackage) {
  24556. $details[] = 'from '.$sourcePackage->getName();
  24557. }
  24558. if ($isGlobalPlugin) {
  24559. $details[] = 'installed globally';
  24560. }
  24561. $this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
  24562. $this->plugins[] = $plugin;
  24563. $plugin->activate($this->composer, $this->io);
  24564. if ($plugin instanceof EventSubscriberInterface) {
  24565. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  24566. }
  24567. }
  24568. public function removePlugin(PluginInterface $plugin)
  24569. {
  24570. $index = array_search($plugin, $this->plugins, true);
  24571. if ($index === false) {
  24572. return;
  24573. }
  24574. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  24575. unset($this->plugins[$index]);
  24576. $plugin->deactivate($this->composer, $this->io);
  24577. $this->composer->getEventDispatcher()->removeListener($plugin);
  24578. }
  24579. public function uninstallPlugin(PluginInterface $plugin)
  24580. {
  24581. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  24582. $plugin->uninstall($this->composer, $this->io);
  24583. }
  24584. private function loadRepository(RepositoryInterface $repo, $isGlobalRepo)
  24585. {
  24586. $packages = $repo->getPackages();
  24587. $sortedPackages = PackageSorter::sortPackages($packages);
  24588. foreach ($sortedPackages as $package) {
  24589. if (!($package instanceof CompletePackage)) {
  24590. continue;
  24591. }
  24592. if ('composer-plugin' === $package->getType()) {
  24593. $this->registerPackage($package, false, $isGlobalRepo);
  24594. } elseif ('composer-installer' === $package->getType()) {
  24595. $this->registerPackage($package, false, $isGlobalRepo);
  24596. }
  24597. }
  24598. }
  24599. private function deactivateRepository(RepositoryInterface $repo, $isGlobalRepo)
  24600. {
  24601. $packages = $repo->getPackages();
  24602. $sortedPackages = array_reverse(PackageSorter::sortPackages($packages));
  24603. foreach ($sortedPackages as $package) {
  24604. if (!($package instanceof CompletePackage)) {
  24605. continue;
  24606. }
  24607. if ('composer-plugin' === $package->getType()) {
  24608. $this->deactivatePackage($package);
  24609. } elseif ('composer-installer' === $package->getType()) {
  24610. $this->deactivatePackage($package);
  24611. }
  24612. }
  24613. }
  24614. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
  24615. {
  24616. foreach ($package->getRequires() as $requireLink) {
  24617. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  24618. if (!isset($collected[$requiredPackage->getName()])) {
  24619. $collected[$requiredPackage->getName()] = $requiredPackage;
  24620. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  24621. }
  24622. }
  24623. }
  24624. return $collected;
  24625. }
  24626. private function getInstallPath(PackageInterface $package, $global = false)
  24627. {
  24628. if (!$global) {
  24629. return $this->composer->getInstallationManager()->getInstallPath($package);
  24630. }
  24631. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  24632. }
  24633. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  24634. {
  24635. if (!($plugin instanceof Capable)) {
  24636. return null;
  24637. }
  24638. $capabilities = (array) $plugin->getCapabilities();
  24639. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  24640. return trim($capabilities[$capability]);
  24641. }
  24642. if (
  24643. array_key_exists($capability, $capabilities)
  24644. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  24645. ) {
  24646. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], true));
  24647. }
  24648. return null;
  24649. }
  24650. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  24651. {
  24652. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  24653. if (!class_exists($capabilityClass)) {
  24654. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  24655. }
  24656. $ctorArgs['plugin'] = $plugin;
  24657. $capabilityObj = new $capabilityClass($ctorArgs);
  24658. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  24659. throw new \RuntimeException(
  24660. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  24661. );
  24662. }
  24663. return $capabilityObj;
  24664. }
  24665. return null;
  24666. }
  24667. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  24668. {
  24669. $capabilities = array();
  24670. foreach ($this->getPlugins() as $plugin) {
  24671. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  24672. $capabilities[] = $capability;
  24673. }
  24674. }
  24675. return $capabilities;
  24676. }
  24677. private function parseAllowedPlugins($allowPluginsConfig)
  24678. {
  24679. if (null === $allowPluginsConfig) {
  24680. return null;
  24681. }
  24682. if (true === $allowPluginsConfig) {
  24683. return array('{}' => true);
  24684. }
  24685. if (false === $allowPluginsConfig) {
  24686. return array('{^$}D' => false);
  24687. }
  24688. $rules = array();
  24689. foreach ($allowPluginsConfig as $pattern => $allow) {
  24690. $rules[BasePackage::packageNameToRegexp($pattern)] = $allow;
  24691. }
  24692. return $rules;
  24693. }
  24694. private function isPluginAllowed($package, $isGlobalPlugin)
  24695. {
  24696. static $warned = array();
  24697. $rules = $isGlobalPlugin ? $this->allowGlobalPluginRules : $this->allowPluginRules;
  24698. if ($rules === null) {
  24699. if (!$this->io->isInteractive()) {
  24700. if (!isset($warned['all'])) {
  24701. $this->io->writeError('<warning>For additional security you should declare the allow-plugins config with a list of packages names that are allowed to run code. See https://getcomposer.org/allow-plugins</warning>');
  24702. $this->io->writeError('<warning>You have until July 2022 to add the setting. Composer will then switch the default behavior to disallow all plugins.</warning>');
  24703. $warned['all'] = true;
  24704. }
  24705. return true;
  24706. }
  24707. $rules = array();
  24708. }
  24709. foreach ($rules as $pattern => $allow) {
  24710. if (Preg::isMatch($pattern, $package)) {
  24711. return $allow === true;
  24712. }
  24713. }
  24714. if ($package === 'composer/package-versions-deprecated') {
  24715. return false;
  24716. }
  24717. if (!isset($warned[$package])) {
  24718. if ($this->io->isInteractive()) {
  24719. $composer = $isGlobalPlugin && $this->globalComposer !== null ? $this->globalComposer : $this->composer;
  24720. $this->io->writeError('<warning>'.$package.($isGlobalPlugin ? ' (installed globally)' : '').' contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins</warning>');
  24721. while (true) {
  24722. switch ($answer = $this->io->ask('Do you trust "<info>'.$package.'</info>" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [<comment>y,n,d,?</comment>] ', '?')) {
  24723. case 'y':
  24724. case 'n':
  24725. case 'd':
  24726. $allow = $answer === 'y';
  24727. if ($isGlobalPlugin) {
  24728. $this->allowGlobalPluginRules[BasePackage::packageNameToRegexp($package)] = $allow;
  24729. } else {
  24730. $this->allowPluginRules[BasePackage::packageNameToRegexp($package)] = $allow;
  24731. }
  24732. if ($answer === 'y' || $answer === 'n') {
  24733. $composer->getConfig()->getConfigSource()->addConfigSetting('allow-plugins.'.$package, $allow);
  24734. }
  24735. return $allow;
  24736. case '?':
  24737. default:
  24738. $this->io->writeError(array(
  24739. 'y - add package to allow-plugins in composer.json and let it run immediately',
  24740. 'n - add package (as disallowed) to allow-plugins in composer.json to suppress further prompts',
  24741. 'd - discard this, do not change composer.json and do not allow the plugin to run',
  24742. '? - print help'
  24743. ));
  24744. break;
  24745. }
  24746. }
  24747. } else {
  24748. $this->io->writeError('<warning>'.$package.($isGlobalPlugin ? ' (installed globally)' : '').' contains a Composer plugin which is blocked by your allow-plugins config. You may add it to the list if you consider it safe. See https://getcomposer.org/allow-plugins</warning>');
  24749. $this->io->writeError('<warning>You can run "composer '.($isGlobalPlugin ? 'global ' : '').'config --no-plugins allow-plugins.'.$package.' [true|false]" to enable it (true) or keep it disabled and suppress this warning (false)</warning>');
  24750. }
  24751. $warned[$package] = true;
  24752. }
  24753. return false;
  24754. }
  24755. }
  24756. <?php
  24757. namespace Composer\Plugin;
  24758. use Composer\EventDispatcher\Event;
  24759. use Composer\Package\PackageInterface;
  24760. class PostFileDownloadEvent extends Event
  24761. {
  24762. private $fileName;
  24763. private $checksum;
  24764. private $url;
  24765. private $context;
  24766. private $type;
  24767. public function __construct($name, $fileName, $checksum, $url, $type, $context = null)
  24768. {
  24769. if ($context === null && $type instanceof PackageInterface) {
  24770. $context = $type;
  24771. $type = 'package';
  24772. trigger_error('PostFileDownloadEvent::__construct should receive a $type=package and the package object in $context since Composer 2.1.', E_USER_DEPRECATED);
  24773. }
  24774. parent::__construct($name);
  24775. $this->fileName = $fileName;
  24776. $this->checksum = $checksum;
  24777. $this->url = $url;
  24778. $this->context = $context;
  24779. $this->type = $type;
  24780. }
  24781. public function getFileName()
  24782. {
  24783. return $this->fileName;
  24784. }
  24785. public function getChecksum()
  24786. {
  24787. return $this->checksum;
  24788. }
  24789. public function getUrl()
  24790. {
  24791. return $this->url;
  24792. }
  24793. public function getContext()
  24794. {
  24795. return $this->context;
  24796. }
  24797. public function getPackage()
  24798. {
  24799. trigger_error('PostFileDownloadEvent::getPackage is deprecated since Composer 2.1, use getContext instead.', E_USER_DEPRECATED);
  24800. $context = $this->getContext();
  24801. return $context instanceof PackageInterface ? $context : null;
  24802. }
  24803. public function getType()
  24804. {
  24805. return $this->type;
  24806. }
  24807. }
  24808. <?php
  24809. namespace Composer\Plugin;
  24810. use Composer\EventDispatcher\Event;
  24811. use Symfony\Component\Console\Input\InputInterface;
  24812. class PreCommandRunEvent extends Event
  24813. {
  24814. private $input;
  24815. private $command;
  24816. public function __construct($name, InputInterface $input, $command)
  24817. {
  24818. parent::__construct($name);
  24819. $this->input = $input;
  24820. $this->command = $command;
  24821. }
  24822. public function getInput()
  24823. {
  24824. return $this->input;
  24825. }
  24826. public function getCommand()
  24827. {
  24828. return $this->command;
  24829. }
  24830. }
  24831. <?php
  24832. namespace Composer\Plugin;
  24833. use Composer\EventDispatcher\Event;
  24834. use Composer\Util\HttpDownloader;
  24835. class PreFileDownloadEvent extends Event
  24836. {
  24837. private $httpDownloader;
  24838. private $processedUrl;
  24839. private $customCacheKey;
  24840. private $type;
  24841. private $context;
  24842. private $transportOptions = array();
  24843. public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null)
  24844. {
  24845. parent::__construct($name);
  24846. $this->httpDownloader = $httpDownloader;
  24847. $this->processedUrl = $processedUrl;
  24848. $this->type = $type;
  24849. $this->context = $context;
  24850. }
  24851. public function getHttpDownloader()
  24852. {
  24853. return $this->httpDownloader;
  24854. }
  24855. public function getProcessedUrl()
  24856. {
  24857. return $this->processedUrl;
  24858. }
  24859. public function setProcessedUrl($processedUrl)
  24860. {
  24861. $this->processedUrl = $processedUrl;
  24862. }
  24863. public function getCustomCacheKey()
  24864. {
  24865. return $this->customCacheKey;
  24866. }
  24867. public function setCustomCacheKey($customCacheKey)
  24868. {
  24869. $this->customCacheKey = $customCacheKey;
  24870. }
  24871. public function getType()
  24872. {
  24873. return $this->type;
  24874. }
  24875. public function getContext()
  24876. {
  24877. return $this->context;
  24878. }
  24879. public function getTransportOptions()
  24880. {
  24881. return $this->transportOptions;
  24882. }
  24883. public function setTransportOptions(array $options)
  24884. {
  24885. $this->transportOptions = $options;
  24886. }
  24887. }
  24888. <?php
  24889. namespace Composer\Plugin;
  24890. use Composer\EventDispatcher\Event;
  24891. use Composer\Repository\RepositoryInterface;
  24892. use Composer\DependencyResolver\Request;
  24893. use Composer\Package\BasePackage;
  24894. class PrePoolCreateEvent extends Event
  24895. {
  24896. private $repositories;
  24897. private $request;
  24898. private $acceptableStabilities;
  24899. private $stabilityFlags;
  24900. private $rootAliases;
  24901. private $rootReferences;
  24902. private $packages;
  24903. private $unacceptableFixedPackages;
  24904. public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  24905. {
  24906. parent::__construct($name);
  24907. $this->repositories = $repositories;
  24908. $this->request = $request;
  24909. $this->acceptableStabilities = $acceptableStabilities;
  24910. $this->stabilityFlags = $stabilityFlags;
  24911. $this->rootAliases = $rootAliases;
  24912. $this->rootReferences = $rootReferences;
  24913. $this->packages = $packages;
  24914. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  24915. }
  24916. public function getRepositories()
  24917. {
  24918. return $this->repositories;
  24919. }
  24920. public function getRequest()
  24921. {
  24922. return $this->request;
  24923. }
  24924. public function getAcceptableStabilities()
  24925. {
  24926. return $this->acceptableStabilities;
  24927. }
  24928. public function getStabilityFlags()
  24929. {
  24930. return $this->stabilityFlags;
  24931. }
  24932. public function getRootAliases()
  24933. {
  24934. return $this->rootAliases;
  24935. }
  24936. public function getRootReferences()
  24937. {
  24938. return $this->rootReferences;
  24939. }
  24940. public function getPackages()
  24941. {
  24942. return $this->packages;
  24943. }
  24944. public function getUnacceptableFixedPackages()
  24945. {
  24946. return $this->unacceptableFixedPackages;
  24947. }
  24948. public function setPackages(array $packages)
  24949. {
  24950. $this->packages = $packages;
  24951. }
  24952. public function setUnacceptableFixedPackages(array $packages)
  24953. {
  24954. $this->unacceptableFixedPackages = $packages;
  24955. }
  24956. }
  24957. <?php
  24958. namespace Composer\Question;
  24959. use Composer\Pcre\Preg;
  24960. use Symfony\Component\Console\Exception\InvalidArgumentException;
  24961. use Symfony\Component\Console\Question\Question;
  24962. class StrictConfirmationQuestion extends Question
  24963. {
  24964. private $trueAnswerRegex;
  24965. private $falseAnswerRegex;
  24966. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  24967. {
  24968. parent::__construct($question, (bool) $default);
  24969. $this->trueAnswerRegex = $trueAnswerRegex;
  24970. $this->falseAnswerRegex = $falseAnswerRegex;
  24971. $this->setNormalizer($this->getDefaultNormalizer());
  24972. $this->setValidator($this->getDefaultValidator());
  24973. }
  24974. private function getDefaultNormalizer()
  24975. {
  24976. $default = $this->getDefault();
  24977. $trueRegex = $this->trueAnswerRegex;
  24978. $falseRegex = $this->falseAnswerRegex;
  24979. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  24980. if (is_bool($answer)) {
  24981. return $answer;
  24982. }
  24983. if (empty($answer) && !empty($default)) {
  24984. return $default;
  24985. }
  24986. if (Preg::isMatch($trueRegex, $answer)) {
  24987. return true;
  24988. }
  24989. if (Preg::isMatch($falseRegex, $answer)) {
  24990. return false;
  24991. }
  24992. return null;
  24993. };
  24994. }
  24995. private function getDefaultValidator()
  24996. {
  24997. return function ($answer) {
  24998. if (!is_bool($answer)) {
  24999. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  25000. }
  25001. return $answer;
  25002. };
  25003. }
  25004. }
  25005. <?php
  25006. namespace Composer\Repository;
  25007. use Composer\Package\AliasPackage;
  25008. use Composer\Package\BasePackage;
  25009. use Composer\Package\CompleteAliasPackage;
  25010. use Composer\Package\CompletePackage;
  25011. use Composer\Package\PackageInterface;
  25012. use Composer\Package\CompletePackageInterface;
  25013. use Composer\Package\Version\VersionParser;
  25014. use Composer\Package\Version\StabilityFilter;
  25015. use Composer\Pcre\Preg;
  25016. use Composer\Semver\Constraint\ConstraintInterface;
  25017. use Composer\Semver\Constraint\Constraint;
  25018. class ArrayRepository implements RepositoryInterface
  25019. {
  25020. protected $packages = null;
  25021. protected $packageMap = null;
  25022. public function __construct(array $packages = array())
  25023. {
  25024. foreach ($packages as $package) {
  25025. $this->addPackage($package);
  25026. }
  25027. }
  25028. public function getRepoName()
  25029. {
  25030. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  25031. }
  25032. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  25033. {
  25034. $packages = $this->getPackages();
  25035. $result = array();
  25036. $namesFound = array();
  25037. foreach ($packages as $package) {
  25038. if (array_key_exists($package->getName(), $packageMap)) {
  25039. if (
  25040. (!$packageMap[$package->getName()] || $packageMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  25041. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  25042. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  25043. ) {
  25044. $result[spl_object_hash($package)] = $package;
  25045. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  25046. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  25047. }
  25048. }
  25049. $namesFound[$package->getName()] = true;
  25050. }
  25051. }
  25052. foreach ($packages as $package) {
  25053. if ($package instanceof AliasPackage) {
  25054. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  25055. $result[spl_object_hash($package)] = $package;
  25056. }
  25057. }
  25058. }
  25059. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  25060. }
  25061. public function findPackage($name, $constraint)
  25062. {
  25063. $name = strtolower($name);
  25064. if (!$constraint instanceof ConstraintInterface) {
  25065. $versionParser = new VersionParser();
  25066. $constraint = $versionParser->parseConstraints($constraint);
  25067. }
  25068. foreach ($this->getPackages() as $package) {
  25069. if ($name === $package->getName()) {
  25070. $pkgConstraint = new Constraint('==', $package->getVersion());
  25071. if ($constraint->matches($pkgConstraint)) {
  25072. return $package;
  25073. }
  25074. }
  25075. }
  25076. return null;
  25077. }
  25078. public function findPackages($name, $constraint = null)
  25079. {
  25080. $name = strtolower($name);
  25081. $packages = array();
  25082. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  25083. $versionParser = new VersionParser();
  25084. $constraint = $versionParser->parseConstraints($constraint);
  25085. }
  25086. foreach ($this->getPackages() as $package) {
  25087. if ($name === $package->getName()) {
  25088. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  25089. $packages[] = $package;
  25090. }
  25091. }
  25092. }
  25093. return $packages;
  25094. }
  25095. public function search($query, $mode = 0, $type = null)
  25096. {
  25097. if ($mode === self::SEARCH_FULLTEXT) {
  25098. $regex = '{(?:'.implode('|', Preg::split('{\s+}', preg_quote($query))).')}i';
  25099. } else {
  25100. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  25101. }
  25102. $matches = array();
  25103. foreach ($this->getPackages() as $package) {
  25104. $name = $package->getName();
  25105. if ($mode === self::SEARCH_VENDOR) {
  25106. list($name) = explode('/', $name);
  25107. }
  25108. if (isset($matches[$name])) {
  25109. continue;
  25110. }
  25111. if (null !== $type && $package->getType() !== $type) {
  25112. continue;
  25113. }
  25114. if (Preg::isMatch($regex, $name)
  25115. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && Preg::isMatch($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  25116. ) {
  25117. if ($mode === self::SEARCH_VENDOR) {
  25118. $matches[$name] = array(
  25119. 'name' => $name,
  25120. 'description' => null,
  25121. );
  25122. } else {
  25123. $matches[$name] = array(
  25124. 'name' => $package->getPrettyName(),
  25125. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  25126. );
  25127. if ($package instanceof CompletePackageInterface && $package->isAbandoned()) {
  25128. $matches[$name]['abandoned'] = $package->getReplacementPackage() ?: true;
  25129. }
  25130. }
  25131. }
  25132. }
  25133. return array_values($matches);
  25134. }
  25135. public function hasPackage(PackageInterface $package)
  25136. {
  25137. if ($this->packageMap === null) {
  25138. $this->packageMap = array();
  25139. foreach ($this->getPackages() as $repoPackage) {
  25140. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  25141. }
  25142. }
  25143. return isset($this->packageMap[$package->getUniqueName()]);
  25144. }
  25145. public function addPackage(PackageInterface $package)
  25146. {
  25147. if (!$package instanceof BasePackage) {
  25148. throw new \InvalidArgumentException('Only subclasses of BasePackage are supported');
  25149. }
  25150. if (null === $this->packages) {
  25151. $this->initialize();
  25152. }
  25153. $package->setRepository($this);
  25154. $this->packages[] = $package;
  25155. if ($package instanceof AliasPackage) {
  25156. $aliasedPackage = $package->getAliasOf();
  25157. if (null === $aliasedPackage->getRepository()) {
  25158. $this->addPackage($aliasedPackage);
  25159. }
  25160. }
  25161. $this->packageMap = null;
  25162. }
  25163. public function getProviders($packageName)
  25164. {
  25165. $result = array();
  25166. foreach ($this->getPackages() as $candidate) {
  25167. if (isset($result[$candidate->getName()])) {
  25168. continue;
  25169. }
  25170. foreach ($candidate->getProvides() as $link) {
  25171. if ($packageName === $link->getTarget()) {
  25172. $result[$candidate->getName()] = array(
  25173. 'name' => $candidate->getName(),
  25174. 'description' => $candidate instanceof CompletePackageInterface ? $candidate->getDescription() : null,
  25175. 'type' => $candidate->getType(),
  25176. );
  25177. continue 2;
  25178. }
  25179. }
  25180. }
  25181. return $result;
  25182. }
  25183. protected function createAliasPackage(BasePackage $package, $alias, $prettyAlias)
  25184. {
  25185. while ($package instanceof AliasPackage) {
  25186. $package = $package->getAliasOf();
  25187. }
  25188. if ($package instanceof CompletePackage) {
  25189. return new CompleteAliasPackage($package, $alias, $prettyAlias);
  25190. }
  25191. return new AliasPackage($package, $alias, $prettyAlias);
  25192. }
  25193. public function removePackage(PackageInterface $package)
  25194. {
  25195. $packageId = $package->getUniqueName();
  25196. foreach ($this->getPackages() as $key => $repoPackage) {
  25197. if ($packageId === $repoPackage->getUniqueName()) {
  25198. array_splice($this->packages, $key, 1);
  25199. $this->packageMap = null;
  25200. return;
  25201. }
  25202. }
  25203. }
  25204. public function getPackages()
  25205. {
  25206. if (null === $this->packages) {
  25207. $this->initialize();
  25208. }
  25209. if (null === $this->packages) {
  25210. throw new \LogicException('initialize failed to initialize the packages array');
  25211. }
  25212. return $this->packages;
  25213. }
  25214. #[\ReturnTypeWillChange]
  25215. public function count()
  25216. {
  25217. if (null === $this->packages) {
  25218. $this->initialize();
  25219. }
  25220. return count($this->packages);
  25221. }
  25222. protected function initialize()
  25223. {
  25224. $this->packages = array();
  25225. }
  25226. }
  25227. <?php
  25228. namespace Composer\Repository;
  25229. use Composer\IO\IOInterface;
  25230. use Composer\Json\JsonFile;
  25231. use Composer\Package\BasePackage;
  25232. use Composer\Package\Loader\ArrayLoader;
  25233. use Composer\Package\Loader\LoaderInterface;
  25234. use Composer\Util\Tar;
  25235. use Composer\Util\Zip;
  25236. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  25237. {
  25238. protected $loader;
  25239. protected $lookup;
  25240. protected $repoConfig;
  25241. private $io;
  25242. public function __construct(array $repoConfig, IOInterface $io)
  25243. {
  25244. parent::__construct();
  25245. if (!extension_loaded('zip')) {
  25246. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  25247. }
  25248. $this->loader = new ArrayLoader();
  25249. $this->lookup = $repoConfig['url'];
  25250. $this->io = $io;
  25251. $this->repoConfig = $repoConfig;
  25252. }
  25253. public function getRepoName()
  25254. {
  25255. return 'artifact repo ('.$this->lookup.')';
  25256. }
  25257. public function getRepoConfig()
  25258. {
  25259. return $this->repoConfig;
  25260. }
  25261. protected function initialize()
  25262. {
  25263. parent::initialize();
  25264. $this->scanDirectory($this->lookup);
  25265. }
  25266. private function scanDirectory($path)
  25267. {
  25268. $io = $this->io;
  25269. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  25270. $iterator = new \RecursiveIteratorIterator($directory);
  25271. $regex = new \RegexIterator($iterator, '/^.+\.(zip|tar|gz|tgz)$/i');
  25272. foreach ($regex as $file) {
  25273. if (!$file->isFile()) {
  25274. continue;
  25275. }
  25276. $package = $this->getComposerInformation($file);
  25277. if (!$package) {
  25278. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  25279. continue;
  25280. }
  25281. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  25282. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  25283. $this->addPackage($package);
  25284. }
  25285. }
  25286. private function getComposerInformation(\SplFileInfo $file)
  25287. {
  25288. $json = null;
  25289. $fileType = null;
  25290. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  25291. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  25292. $fileType = 'tar';
  25293. } elseif ($fileExtension === 'zip') {
  25294. $fileType = 'zip';
  25295. } else {
  25296. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  25297. }
  25298. try {
  25299. if ($fileType === 'tar') {
  25300. $json = Tar::getComposerJson($file->getPathname());
  25301. } else {
  25302. $json = Zip::getComposerJson($file->getPathname());
  25303. }
  25304. } catch (\Exception $exception) {
  25305. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  25306. }
  25307. if (null === $json) {
  25308. return null;
  25309. }
  25310. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  25311. $package['dist'] = array(
  25312. 'type' => $fileType,
  25313. 'url' => strtr($file->getPathname(), '\\', '/'),
  25314. 'shasum' => sha1_file($file->getRealPath()),
  25315. );
  25316. try {
  25317. $package = $this->loader->load($package);
  25318. } catch (\UnexpectedValueException $e) {
  25319. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  25320. }
  25321. return $package;
  25322. }
  25323. }
  25324. <?php
  25325. namespace Composer\Repository;
  25326. use Composer\Package\BasePackage;
  25327. use Composer\Package\Loader\ArrayLoader;
  25328. use Composer\Package\PackageInterface;
  25329. use Composer\Package\AliasPackage;
  25330. use Composer\Package\CompletePackage;
  25331. use Composer\Package\CompleteAliasPackage;
  25332. use Composer\Package\Version\VersionParser;
  25333. use Composer\Package\Version\StabilityFilter;
  25334. use Composer\Json\JsonFile;
  25335. use Composer\Cache;
  25336. use Composer\Config;
  25337. use Composer\IO\IOInterface;
  25338. use Composer\Pcre\Preg;
  25339. use Composer\Plugin\PostFileDownloadEvent;
  25340. use Composer\Semver\CompilingMatcher;
  25341. use Composer\Util\HttpDownloader;
  25342. use Composer\Util\Loop;
  25343. use Composer\Plugin\PluginEvents;
  25344. use Composer\Plugin\PreFileDownloadEvent;
  25345. use Composer\EventDispatcher\EventDispatcher;
  25346. use Composer\Downloader\TransportException;
  25347. use Composer\Semver\Constraint\ConstraintInterface;
  25348. use Composer\Semver\Constraint\Constraint;
  25349. use Composer\Semver\Constraint\MatchAllConstraint;
  25350. use Composer\Util\Http\Response;
  25351. use Composer\MetadataMinifier\MetadataMinifier;
  25352. use Composer\Util\Url;
  25353. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  25354. {
  25355. private $repoConfig;
  25356. private $options;
  25357. private $url;
  25358. private $baseUrl;
  25359. private $io;
  25360. private $httpDownloader;
  25361. private $loop;
  25362. protected $cache;
  25363. protected $notifyUrl = null;
  25364. protected $searchUrl = null;
  25365. protected $providersApiUrl = null;
  25366. protected $hasProviders = false;
  25367. protected $providersUrl = null;
  25368. protected $listUrl = null;
  25369. protected $hasAvailablePackageList = false;
  25370. protected $availablePackages = null;
  25371. protected $availablePackagePatterns = null;
  25372. protected $lazyProvidersUrl = null;
  25373. protected $providerListing;
  25374. protected $loader;
  25375. private $allowSslDowngrade = false;
  25376. private $eventDispatcher;
  25377. private $sourceMirrors;
  25378. private $distMirrors;
  25379. private $degradedMode = false;
  25380. private $rootData;
  25381. private $hasPartialPackages = false;
  25382. private $partialPackagesByName = null;
  25383. public $freshMetadataUrls = array();
  25384. public $packagesNotFoundCache = array();
  25385. public $versionParser;
  25386. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  25387. {
  25388. parent::__construct();
  25389. if (!Preg::isMatch('{^[\w.]+\??://}', $repoConfig['url'])) {
  25390. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  25391. }
  25392. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  25393. if (strpos($repoConfig['url'], 'https?') === 0) {
  25394. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  25395. }
  25396. $urlBits = parse_url($repoConfig['url']);
  25397. if ($urlBits === false || empty($urlBits['scheme'])) {
  25398. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  25399. }
  25400. if (!isset($repoConfig['options'])) {
  25401. $repoConfig['options'] = array();
  25402. }
  25403. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  25404. $this->allowSslDowngrade = true;
  25405. }
  25406. $this->options = $repoConfig['options'];
  25407. $this->url = $repoConfig['url'];
  25408. if (Preg::isMatch('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  25409. $this->url = $match['proto'].'://repo.packagist.org';
  25410. }
  25411. $this->baseUrl = rtrim(Preg::replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  25412. $this->io = $io;
  25413. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  25414. $this->cache->setReadOnly($config->get('cache-read-only'));
  25415. $this->versionParser = new VersionParser();
  25416. $this->loader = new ArrayLoader($this->versionParser);
  25417. $this->httpDownloader = $httpDownloader;
  25418. $this->eventDispatcher = $eventDispatcher;
  25419. $this->repoConfig = $repoConfig;
  25420. $this->loop = new Loop($this->httpDownloader);
  25421. }
  25422. public function getRepoName()
  25423. {
  25424. return 'composer repo ('.Url::sanitize($this->url).')';
  25425. }
  25426. public function getRepoConfig()
  25427. {
  25428. return $this->repoConfig;
  25429. }
  25430. public function findPackage($name, $constraint)
  25431. {
  25432. $hasProviders = $this->hasProviders();
  25433. $name = strtolower($name);
  25434. if (!$constraint instanceof ConstraintInterface) {
  25435. $constraint = $this->versionParser->parseConstraints($constraint);
  25436. }
  25437. if ($this->lazyProvidersUrl) {
  25438. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  25439. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  25440. }
  25441. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  25442. return null;
  25443. }
  25444. $packages = $this->loadAsyncPackages(array($name => $constraint));
  25445. return reset($packages['packages']);
  25446. }
  25447. if ($hasProviders) {
  25448. foreach ($this->getProviderNames() as $providerName) {
  25449. if ($name === $providerName) {
  25450. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  25451. }
  25452. }
  25453. return null;
  25454. }
  25455. return parent::findPackage($name, $constraint);
  25456. }
  25457. public function findPackages($name, $constraint = null)
  25458. {
  25459. $hasProviders = $this->hasProviders();
  25460. $name = strtolower($name);
  25461. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  25462. $constraint = $this->versionParser->parseConstraints($constraint);
  25463. }
  25464. if ($this->lazyProvidersUrl) {
  25465. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  25466. return $this->filterPackages($this->whatProvides($name), $constraint);
  25467. }
  25468. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  25469. return array();
  25470. }
  25471. $result = $this->loadAsyncPackages(array($name => $constraint));
  25472. return $result['packages'];
  25473. }
  25474. if ($hasProviders) {
  25475. foreach ($this->getProviderNames() as $providerName) {
  25476. if ($name === $providerName) {
  25477. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  25478. }
  25479. }
  25480. return array();
  25481. }
  25482. return parent::findPackages($name, $constraint);
  25483. }
  25484. private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
  25485. {
  25486. if (null === $constraint) {
  25487. if ($returnFirstMatch) {
  25488. return reset($packages);
  25489. }
  25490. return $packages;
  25491. }
  25492. $filteredPackages = array();
  25493. foreach ($packages as $package) {
  25494. $pkgConstraint = new Constraint('==', $package->getVersion());
  25495. if ($constraint->matches($pkgConstraint)) {
  25496. if ($returnFirstMatch) {
  25497. return $package;
  25498. }
  25499. $filteredPackages[] = $package;
  25500. }
  25501. }
  25502. if ($returnFirstMatch) {
  25503. return null;
  25504. }
  25505. return $filteredPackages;
  25506. }
  25507. public function getPackages()
  25508. {
  25509. $hasProviders = $this->hasProviders();
  25510. if ($this->lazyProvidersUrl) {
  25511. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  25512. $packageMap = array();
  25513. foreach ($this->availablePackages as $name) {
  25514. $packageMap[$name] = new MatchAllConstraint();
  25515. }
  25516. $result = $this->loadAsyncPackages($packageMap);
  25517. return array_values($result['packages']);
  25518. }
  25519. if ($this->hasPartialPackages()) {
  25520. if (!is_array($this->partialPackagesByName)) {
  25521. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  25522. }
  25523. return $this->createPackages($this->partialPackagesByName, 'packages.json inline packages');
  25524. }
  25525. 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.');
  25526. }
  25527. if ($hasProviders) {
  25528. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  25529. }
  25530. return parent::getPackages();
  25531. }
  25532. public function getPackageNames($packageFilter = null)
  25533. {
  25534. $hasProviders = $this->hasProviders();
  25535. $filterResults =
  25536. function (array $results) {
  25537. return $results;
  25538. }
  25539. ;
  25540. if (null !== $packageFilter && '' !== $packageFilter) {
  25541. $packageFilterRegex = BasePackage::packageNameToRegexp($packageFilter);
  25542. $filterResults =
  25543. function (array $results) use ($packageFilterRegex) {
  25544. return Preg::grep($packageFilterRegex, $results);
  25545. }
  25546. ;
  25547. }
  25548. if ($this->lazyProvidersUrl) {
  25549. if (is_array($this->availablePackages)) {
  25550. return $filterResults(array_keys($this->availablePackages));
  25551. }
  25552. if ($this->listUrl) {
  25553. return $this->loadPackageList($packageFilter);
  25554. }
  25555. if ($this->hasPartialPackages() && $this->partialPackagesByName !== null) {
  25556. return $filterResults(array_keys($this->partialPackagesByName));
  25557. }
  25558. return array();
  25559. }
  25560. if ($hasProviders) {
  25561. return $filterResults($this->getProviderNames());
  25562. }
  25563. $names = array();
  25564. foreach ($this->getPackages() as $package) {
  25565. $names[] = $package->getPrettyName();
  25566. }
  25567. return $filterResults($names);
  25568. }
  25569. private function getVendorNames()
  25570. {
  25571. $cacheKey = 'vendor-list.txt';
  25572. $cacheAge = $this->cache->getAge($cacheKey);
  25573. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  25574. $cachedData = explode("\n", $cachedData);
  25575. return $cachedData;
  25576. }
  25577. $names = $this->getPackageNames();
  25578. $uniques = array();
  25579. foreach ($names as $name) {
  25580. $uniques[substr($name, 0, strpos($name, '/'))] = true;
  25581. }
  25582. $vendors = array_keys($uniques);
  25583. if (!$this->cache->isReadOnly()) {
  25584. $this->cache->write($cacheKey, implode("\n", $vendors));
  25585. }
  25586. return $vendors;
  25587. }
  25588. private function loadPackageList($packageFilter = null)
  25589. {
  25590. if (null === $this->listUrl) {
  25591. throw new \LogicException('Make sure to call loadRootServerFile before loadPackageList');
  25592. }
  25593. $url = $this->listUrl;
  25594. if (is_string($packageFilter) && $packageFilter !== '') {
  25595. $url .= '?filter='.urlencode($packageFilter);
  25596. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  25597. return $result['packageNames'];
  25598. }
  25599. $cacheKey = 'package-list.txt';
  25600. $cacheAge = $this->cache->getAge($cacheKey);
  25601. if (false !== $cacheAge && $cacheAge < 600 && ($cachedData = $this->cache->read($cacheKey)) !== false) {
  25602. $cachedData = explode("\n", $cachedData);
  25603. return $cachedData;
  25604. }
  25605. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  25606. if (!$this->cache->isReadOnly()) {
  25607. $this->cache->write($cacheKey, implode("\n", $result['packageNames']));
  25608. }
  25609. return $result['packageNames'];
  25610. }
  25611. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  25612. {
  25613. $hasProviders = $this->hasProviders();
  25614. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  25615. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25616. }
  25617. $packages = array();
  25618. $namesFound = array();
  25619. if ($hasProviders || $this->hasPartialPackages()) {
  25620. foreach ($packageNameMap as $name => $constraint) {
  25621. $matches = array();
  25622. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  25623. continue;
  25624. }
  25625. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25626. foreach ($candidates as $candidate) {
  25627. if ($candidate->getName() !== $name) {
  25628. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  25629. }
  25630. $namesFound[$name] = true;
  25631. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  25632. $matches[spl_object_hash($candidate)] = $candidate;
  25633. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  25634. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  25635. }
  25636. }
  25637. }
  25638. foreach ($candidates as $candidate) {
  25639. if ($candidate instanceof AliasPackage) {
  25640. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  25641. $matches[spl_object_hash($candidate)] = $candidate;
  25642. }
  25643. }
  25644. }
  25645. $packages = array_merge($packages, $matches);
  25646. unset($packageNameMap[$name]);
  25647. }
  25648. }
  25649. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  25650. if ($this->hasAvailablePackageList) {
  25651. foreach ($packageNameMap as $name => $constraint) {
  25652. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  25653. unset($packageNameMap[$name]);
  25654. }
  25655. }
  25656. }
  25657. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  25658. $packages = array_merge($packages, $result['packages']);
  25659. $namesFound = array_merge($namesFound, $result['namesFound']);
  25660. }
  25661. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  25662. }
  25663. public function search($query, $mode = 0, $type = null)
  25664. {
  25665. $this->loadRootServerFile(600);
  25666. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  25667. $url = str_replace(array('%query%', '%type%'), array(urlencode($query), $type), $this->searchUrl);
  25668. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  25669. if (empty($search['results'])) {
  25670. return array();
  25671. }
  25672. $results = array();
  25673. foreach ($search['results'] as $result) {
  25674. if (!empty($result['virtual'])) {
  25675. continue;
  25676. }
  25677. $results[] = $result;
  25678. }
  25679. return $results;
  25680. }
  25681. if ($mode === self::SEARCH_VENDOR) {
  25682. $results = array();
  25683. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  25684. $vendorNames = $this->getVendorNames();
  25685. foreach (Preg::grep($regex, $vendorNames) as $name) {
  25686. $results[] = array('name' => $name, 'description' => '');
  25687. }
  25688. return $results;
  25689. }
  25690. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  25691. if (Preg::isMatch('{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i', $query, $match) && $this->listUrl !== null) {
  25692. $url = $this->listUrl . '?vendor='.urlencode($match['vendor']).'&filter='.urlencode($match['query'].'*');
  25693. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  25694. $results = array();
  25695. foreach ($result['packageNames'] as $name) {
  25696. $results[] = array('name' => $name, 'description' => '');
  25697. }
  25698. return $results;
  25699. }
  25700. $results = array();
  25701. $regex = '{(?:'.implode('|', Preg::split('{\s+}', $query)).')}i';
  25702. $packageNames = $this->getPackageNames();
  25703. foreach (Preg::grep($regex, $packageNames) as $name) {
  25704. $results[] = array('name' => $name, 'description' => '');
  25705. }
  25706. return $results;
  25707. }
  25708. return parent::search($query, $mode);
  25709. }
  25710. public function getProviders($packageName)
  25711. {
  25712. $this->loadRootServerFile();
  25713. $result = array();
  25714. if ($this->providersApiUrl) {
  25715. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  25716. foreach ($apiResult['providers'] as $provider) {
  25717. $result[$provider['name']] = $provider;
  25718. }
  25719. return $result;
  25720. }
  25721. if ($this->hasPartialPackages()) {
  25722. if (!is_array($this->partialPackagesByName)) {
  25723. throw new \LogicException('hasPartialPackages failed to initialize $this->partialPackagesByName');
  25724. }
  25725. foreach ($this->partialPackagesByName as $versions) {
  25726. foreach ($versions as $candidate) {
  25727. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  25728. continue;
  25729. }
  25730. $result[$candidate['name']] = array(
  25731. 'name' => $candidate['name'],
  25732. 'description' => isset($candidate['description']) ? $candidate['description'] : '',
  25733. 'type' => isset($candidate['type']) ? $candidate['type'] : '',
  25734. );
  25735. }
  25736. }
  25737. }
  25738. if ($this->packages) {
  25739. $result = array_merge($result, parent::getProviders($packageName));
  25740. }
  25741. return $result;
  25742. }
  25743. private function getProviderNames()
  25744. {
  25745. $this->loadRootServerFile();
  25746. if (null === $this->providerListing) {
  25747. $this->loadProviderListings($this->loadRootServerFile());
  25748. }
  25749. if ($this->lazyProvidersUrl) {
  25750. return array();
  25751. }
  25752. if ($this->providersUrl) {
  25753. return array_keys($this->providerListing);
  25754. }
  25755. return array();
  25756. }
  25757. protected function configurePackageTransportOptions(PackageInterface $package)
  25758. {
  25759. foreach ($package->getDistUrls() as $url) {
  25760. if (strpos($url, $this->baseUrl) === 0) {
  25761. $package->setTransportOptions($this->options);
  25762. return;
  25763. }
  25764. }
  25765. }
  25766. private function hasProviders()
  25767. {
  25768. $this->loadRootServerFile();
  25769. return $this->hasProviders;
  25770. }
  25771. private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  25772. {
  25773. $packagesSource = null;
  25774. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  25775. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  25776. return array();
  25777. }
  25778. if (null === $this->providerListing) {
  25779. $this->loadProviderListings($this->loadRootServerFile());
  25780. }
  25781. $useLastModifiedCheck = false;
  25782. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  25783. $hash = null;
  25784. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  25785. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  25786. $useLastModifiedCheck = true;
  25787. } elseif ($this->providersUrl) {
  25788. if (!isset($this->providerListing[$name])) {
  25789. return array();
  25790. }
  25791. $hash = $this->providerListing[$name]['sha256'];
  25792. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  25793. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  25794. } else {
  25795. return array();
  25796. }
  25797. $packages = null;
  25798. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  25799. $packages = json_decode($this->cache->read($cacheKey), true);
  25800. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  25801. } elseif ($useLastModifiedCheck) {
  25802. if ($contents = $this->cache->read($cacheKey)) {
  25803. $contents = json_decode($contents, true);
  25804. if (isset($alreadyLoaded[$name])) {
  25805. $packages = $contents;
  25806. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  25807. } elseif (isset($contents['last-modified'])) {
  25808. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  25809. $packages = true === $response ? $contents : $response;
  25810. $packagesSource = true === $response ? 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')' : 'downloaded file ('.Url::sanitize($url).')';
  25811. }
  25812. }
  25813. }
  25814. if (!$packages) {
  25815. try {
  25816. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  25817. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  25818. } catch (TransportException $e) {
  25819. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  25820. $packages = array('packages' => array());
  25821. $packagesSource = 'not-found file ('.Url::sanitize($url).')';
  25822. if ($e->getStatusCode() === 499) {
  25823. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  25824. }
  25825. } else {
  25826. throw $e;
  25827. }
  25828. }
  25829. }
  25830. $loadingPartialPackage = false;
  25831. } else {
  25832. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  25833. $packagesSource = 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')';
  25834. $loadingPartialPackage = true;
  25835. }
  25836. $result = array();
  25837. $versionsToLoad = array();
  25838. foreach ($packages['packages'] as $versions) {
  25839. foreach ($versions as $version) {
  25840. $normalizedName = strtolower($version['name']);
  25841. if ($normalizedName !== $name) {
  25842. continue;
  25843. }
  25844. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  25845. continue;
  25846. }
  25847. if (!isset($versionsToLoad[$version['uid']])) {
  25848. if (!isset($version['version_normalized'])) {
  25849. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  25850. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  25851. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  25852. }
  25853. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  25854. continue;
  25855. }
  25856. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  25857. $versionsToLoad[$version['uid']] = $version;
  25858. }
  25859. }
  25860. }
  25861. }
  25862. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  25863. $uids = array_keys($versionsToLoad);
  25864. foreach ($loadedPackages as $index => $package) {
  25865. $package->setRepository($this);
  25866. $uid = $uids[$index];
  25867. if ($package instanceof AliasPackage) {
  25868. $aliased = $package->getAliasOf();
  25869. $aliased->setRepository($this);
  25870. $result[$uid] = $aliased;
  25871. $result[$uid.'-alias'] = $package;
  25872. } else {
  25873. $result[$uid] = $package;
  25874. }
  25875. }
  25876. return $result;
  25877. }
  25878. protected function initialize()
  25879. {
  25880. parent::initialize();
  25881. $repoData = $this->loadDataFromServer();
  25882. foreach ($this->createPackages($repoData, 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')') as $package) {
  25883. $this->addPackage($package);
  25884. }
  25885. }
  25886. public function addPackage(PackageInterface $package)
  25887. {
  25888. parent::addPackage($package);
  25889. $this->configurePackageTransportOptions($package);
  25890. }
  25891. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  25892. {
  25893. $this->loadRootServerFile();
  25894. $packages = array();
  25895. $namesFound = array();
  25896. $promises = array();
  25897. $repo = $this;
  25898. if (!$this->lazyProvidersUrl) {
  25899. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  25900. }
  25901. foreach ($packageNames as $name => $constraint) {
  25902. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  25903. $packageNames[$name.'~dev'] = $constraint;
  25904. }
  25905. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  25906. unset($packageNames[$name]);
  25907. }
  25908. }
  25909. foreach ($packageNames as $name => $constraint) {
  25910. $name = strtolower($name);
  25911. $realName = Preg::replace('{~dev$}', '', $name);
  25912. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  25913. continue;
  25914. }
  25915. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  25916. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  25917. $lastModified = null;
  25918. if ($contents = $this->cache->read($cacheKey)) {
  25919. $contents = json_decode($contents, true);
  25920. $lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
  25921. }
  25922. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  25923. ->then(function ($response) use (&$packages, &$namesFound, $url, $cacheKey, $contents, $realName, $constraint, $repo, $acceptableStabilities, $stabilityFlags, $alreadyLoaded) {
  25924. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  25925. if (true === $response) {
  25926. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  25927. $response = $contents;
  25928. }
  25929. if (!isset($response['packages'][$realName])) {
  25930. return;
  25931. }
  25932. $versions = $response['packages'][$realName];
  25933. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  25934. $versions = MetadataMinifier::expand($versions);
  25935. }
  25936. $namesFound[$realName] = true;
  25937. $versionsToLoad = array();
  25938. foreach ($versions as $version) {
  25939. if (!isset($version['version_normalized'])) {
  25940. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  25941. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  25942. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  25943. }
  25944. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  25945. continue;
  25946. }
  25947. if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  25948. $versionsToLoad[] = $version;
  25949. }
  25950. }
  25951. $loadedPackages = $repo->createPackages($versionsToLoad, $packagesSource);
  25952. foreach ($loadedPackages as $package) {
  25953. $package->setRepository($repo);
  25954. $packages[spl_object_hash($package)] = $package;
  25955. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  25956. $package->getAliasOf()->setRepository($repo);
  25957. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  25958. }
  25959. }
  25960. });
  25961. }
  25962. $this->loop->wait($promises);
  25963. return array('namesFound' => $namesFound, 'packages' => $packages);
  25964. }
  25965. public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
  25966. {
  25967. $versions = array($versionData['version_normalized']);
  25968. if ($alias = $this->loader->getBranchAlias($versionData)) {
  25969. $versions[] = $alias;
  25970. }
  25971. foreach ($versions as $version) {
  25972. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  25973. continue;
  25974. }
  25975. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  25976. continue;
  25977. }
  25978. return true;
  25979. }
  25980. return false;
  25981. }
  25982. private function getPackagesJsonUrl()
  25983. {
  25984. $jsonUrlParts = parse_url($this->url);
  25985. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  25986. return $this->url;
  25987. }
  25988. return $this->url . '/packages.json';
  25989. }
  25990. protected function loadRootServerFile($rootMaxAge = null)
  25991. {
  25992. if (null !== $this->rootData) {
  25993. return $this->rootData;
  25994. }
  25995. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  25996. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  25997. }
  25998. if ($cachedData = $this->cache->read('packages.json')) {
  25999. $cachedData = json_decode($cachedData, true);
  26000. if ($rootMaxAge !== null && ($age = $this->cache->getAge('packages.json')) !== false && $age <= $rootMaxAge) {
  26001. $data = $cachedData;
  26002. } elseif (isset($cachedData['last-modified'])) {
  26003. $response = $this->fetchFileIfLastModified($this->getPackagesJsonUrl(), 'packages.json', $cachedData['last-modified']);
  26004. $data = true === $response ? $cachedData : $response;
  26005. }
  26006. }
  26007. if (!isset($data)) {
  26008. $data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json', null, true);
  26009. }
  26010. if (!empty($data['notify-batch'])) {
  26011. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  26012. } elseif (!empty($data['notify'])) {
  26013. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  26014. }
  26015. if (!empty($data['search'])) {
  26016. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  26017. }
  26018. if (!empty($data['mirrors'])) {
  26019. foreach ($data['mirrors'] as $mirror) {
  26020. if (!empty($mirror['git-url'])) {
  26021. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  26022. }
  26023. if (!empty($mirror['hg-url'])) {
  26024. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  26025. }
  26026. if (!empty($mirror['dist-url'])) {
  26027. $this->distMirrors[] = array(
  26028. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  26029. 'preferred' => !empty($mirror['preferred']),
  26030. );
  26031. }
  26032. }
  26033. }
  26034. if (!empty($data['providers-lazy-url'])) {
  26035. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  26036. $this->hasProviders = true;
  26037. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  26038. }
  26039. if (!empty($data['metadata-url'])) {
  26040. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  26041. $this->providersUrl = null;
  26042. $this->hasProviders = false;
  26043. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  26044. $this->allowSslDowngrade = false;
  26045. if (!empty($data['available-packages'])) {
  26046. $availPackages = array_map('strtolower', $data['available-packages']);
  26047. $this->availablePackages = array_combine($availPackages, $availPackages);
  26048. $this->hasAvailablePackageList = true;
  26049. }
  26050. if (!empty($data['available-package-patterns'])) {
  26051. $this->availablePackagePatterns = array_map(function ($pattern) {
  26052. return BasePackage::packageNameToRegexp($pattern);
  26053. }, $data['available-package-patterns']);
  26054. $this->hasAvailablePackageList = true;
  26055. }
  26056. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  26057. }
  26058. if ($this->allowSslDowngrade) {
  26059. $this->url = str_replace('https://', 'http://', $this->url);
  26060. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  26061. }
  26062. if (!empty($data['providers-url'])) {
  26063. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  26064. $this->hasProviders = true;
  26065. }
  26066. if (!empty($data['list'])) {
  26067. $this->listUrl = $this->canonicalizeUrl($data['list']);
  26068. }
  26069. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  26070. $this->hasProviders = true;
  26071. }
  26072. if (!empty($data['providers-api'])) {
  26073. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  26074. }
  26075. return $this->rootData = $data;
  26076. }
  26077. private function canonicalizeUrl($url)
  26078. {
  26079. if ('/' === $url[0]) {
  26080. if (Preg::isMatch('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  26081. return $matches[0] . $url;
  26082. }
  26083. return $this->url;
  26084. }
  26085. return $url;
  26086. }
  26087. private function loadDataFromServer()
  26088. {
  26089. $data = $this->loadRootServerFile();
  26090. return $this->loadIncludes($data);
  26091. }
  26092. private function hasPartialPackages()
  26093. {
  26094. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  26095. $this->initializePartialPackages();
  26096. }
  26097. return $this->hasPartialPackages;
  26098. }
  26099. private function loadProviderListings($data)
  26100. {
  26101. if (isset($data['providers'])) {
  26102. if (!is_array($this->providerListing)) {
  26103. $this->providerListing = array();
  26104. }
  26105. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  26106. }
  26107. if ($this->providersUrl && isset($data['provider-includes'])) {
  26108. $includes = $data['provider-includes'];
  26109. foreach ($includes as $include => $metadata) {
  26110. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  26111. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  26112. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  26113. $includedData = json_decode($this->cache->read($cacheKey), true);
  26114. } else {
  26115. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  26116. }
  26117. $this->loadProviderListings($includedData);
  26118. }
  26119. }
  26120. }
  26121. private function loadIncludes($data)
  26122. {
  26123. $packages = array();
  26124. if (!isset($data['packages']) && !isset($data['includes'])) {
  26125. foreach ($data as $pkg) {
  26126. if (isset($pkg['versions']) && is_array($pkg['versions'])) {
  26127. foreach ($pkg['versions'] as $metadata) {
  26128. $packages[] = $metadata;
  26129. }
  26130. }
  26131. }
  26132. return $packages;
  26133. }
  26134. if (isset($data['packages'])) {
  26135. foreach ($data['packages'] as $package => $versions) {
  26136. foreach ($versions as $version => $metadata) {
  26137. $packages[] = $metadata;
  26138. }
  26139. }
  26140. }
  26141. if (isset($data['includes'])) {
  26142. foreach ($data['includes'] as $include => $metadata) {
  26143. if (isset($metadata['sha1']) && $this->cache->sha1((string) $include) === $metadata['sha1']) {
  26144. $includedData = json_decode($this->cache->read((string) $include), true);
  26145. } else {
  26146. $includedData = $this->fetchFile($include);
  26147. }
  26148. $packages = array_merge($packages, $this->loadIncludes($includedData));
  26149. }
  26150. }
  26151. return $packages;
  26152. }
  26153. public function createPackages(array $packages, $source = null)
  26154. {
  26155. if (!$packages) {
  26156. return array();
  26157. }
  26158. try {
  26159. foreach ($packages as &$data) {
  26160. if (!isset($data['notification-url'])) {
  26161. $data['notification-url'] = $this->notifyUrl;
  26162. }
  26163. }
  26164. $packageInstances = $this->loader->loadPackages($packages);
  26165. foreach ($packageInstances as $package) {
  26166. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  26167. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  26168. }
  26169. $package->setDistMirrors($this->distMirrors);
  26170. $this->configurePackageTransportOptions($package);
  26171. }
  26172. return $packageInstances;
  26173. } catch (\Exception $e) {
  26174. throw new \RuntimeException('Could not load packages '.(isset($packages[0]['name']) ? $packages[0]['name'] : json_encode($packages)).' in '.$this->getRepoName().($source ? ' from '.$source : '').': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
  26175. }
  26176. }
  26177. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  26178. {
  26179. if (null === $cacheKey) {
  26180. $cacheKey = $filename;
  26181. $filename = $this->baseUrl.'/'.$filename;
  26182. }
  26183. if (($pos = strpos($filename, '$')) && Preg::isMatch('{^https?://}i', $filename)) {
  26184. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  26185. }
  26186. $retries = 3;
  26187. while ($retries--) {
  26188. try {
  26189. $options = $this->options;
  26190. if ($this->eventDispatcher) {
  26191. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  26192. $preFileDownloadEvent->setTransportOptions($this->options);
  26193. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  26194. $filename = $preFileDownloadEvent->getProcessedUrl();
  26195. $options = $preFileDownloadEvent->getTransportOptions();
  26196. }
  26197. $response = $this->httpDownloader->get($filename, $options);
  26198. $json = (string) $response->getBody();
  26199. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  26200. if ($this->allowSslDowngrade) {
  26201. $this->url = str_replace('http://', 'https://', $this->url);
  26202. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  26203. $filename = str_replace('http://', 'https://', $filename);
  26204. }
  26205. if ($retries > 0) {
  26206. usleep(100000);
  26207. continue;
  26208. }
  26209. 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.');
  26210. }
  26211. if ($this->eventDispatcher) {
  26212. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, $sha256, $filename, 'metadata', array('response' => $response, 'repository' => $this));
  26213. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  26214. }
  26215. $data = $response->decodeJson();
  26216. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  26217. if ($cacheKey && !$this->cache->isReadOnly()) {
  26218. if ($storeLastModifiedTime) {
  26219. $lastModifiedDate = $response->getHeader('last-modified');
  26220. if ($lastModifiedDate) {
  26221. $data['last-modified'] = $lastModifiedDate;
  26222. $json = JsonFile::encode($data, 0);
  26223. }
  26224. }
  26225. $this->cache->write($cacheKey, $json);
  26226. }
  26227. $response->collect();
  26228. break;
  26229. } catch (\Exception $e) {
  26230. if ($e instanceof \LogicException) {
  26231. throw $e;
  26232. }
  26233. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  26234. throw $e;
  26235. }
  26236. if ($e instanceof RepositorySecurityException) {
  26237. throw $e;
  26238. }
  26239. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  26240. if (!$this->degradedMode) {
  26241. $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>');
  26242. }
  26243. $this->degradedMode = true;
  26244. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  26245. break;
  26246. }
  26247. throw $e;
  26248. }
  26249. }
  26250. if (!isset($data)) {
  26251. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  26252. }
  26253. return $data;
  26254. }
  26255. private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  26256. {
  26257. try {
  26258. $options = $this->options;
  26259. if ($this->eventDispatcher) {
  26260. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  26261. $preFileDownloadEvent->setTransportOptions($this->options);
  26262. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  26263. $filename = $preFileDownloadEvent->getProcessedUrl();
  26264. $options = $preFileDownloadEvent->getTransportOptions();
  26265. }
  26266. if (isset($options['http']['header'])) {
  26267. $options['http']['header'] = (array) $options['http']['header'];
  26268. }
  26269. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  26270. $response = $this->httpDownloader->get($filename, $options);
  26271. $json = (string) $response->getBody();
  26272. if ($json === '' && $response->getStatusCode() === 304) {
  26273. return true;
  26274. }
  26275. if ($this->eventDispatcher) {
  26276. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', array('response' => $response, 'repository' => $this));
  26277. $this->eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  26278. }
  26279. $data = $response->decodeJson();
  26280. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  26281. $lastModifiedDate = $response->getHeader('last-modified');
  26282. $response->collect();
  26283. if ($lastModifiedDate) {
  26284. $data['last-modified'] = $lastModifiedDate;
  26285. $json = JsonFile::encode($data, 0);
  26286. }
  26287. if (!$this->cache->isReadOnly()) {
  26288. $this->cache->write($cacheKey, $json);
  26289. }
  26290. return $data;
  26291. } catch (\Exception $e) {
  26292. if ($e instanceof \LogicException) {
  26293. throw $e;
  26294. }
  26295. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  26296. throw $e;
  26297. }
  26298. if (!$this->degradedMode) {
  26299. $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>');
  26300. }
  26301. $this->degradedMode = true;
  26302. return true;
  26303. }
  26304. }
  26305. private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
  26306. {
  26307. if (isset($this->packagesNotFoundCache[$filename])) {
  26308. return \React\Promise\resolve(array('packages' => array()));
  26309. }
  26310. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  26311. return \React\Promise\resolve(true);
  26312. }
  26313. $httpDownloader = $this->httpDownloader;
  26314. $options = $this->options;
  26315. if ($this->eventDispatcher) {
  26316. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata', array('repository' => $this));
  26317. $preFileDownloadEvent->setTransportOptions($this->options);
  26318. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  26319. $filename = $preFileDownloadEvent->getProcessedUrl();
  26320. $options = $preFileDownloadEvent->getTransportOptions();
  26321. }
  26322. if ($lastModifiedTime) {
  26323. if (isset($options['http']['header'])) {
  26324. $options['http']['header'] = (array) $options['http']['header'];
  26325. }
  26326. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  26327. }
  26328. $io = $this->io;
  26329. $url = $this->url;
  26330. $cache = $this->cache;
  26331. $degradedMode = &$this->degradedMode;
  26332. $eventDispatcher = $this->eventDispatcher;
  26333. $repo = $this;
  26334. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $eventDispatcher, $repo) {
  26335. if ($response->getStatusCode() === 404) {
  26336. $repo->packagesNotFoundCache[$filename] = true;
  26337. return array('packages' => array());
  26338. }
  26339. $json = (string) $response->getBody();
  26340. if ($json === '' && $response->getStatusCode() === 304) {
  26341. $repo->freshMetadataUrls[$filename] = true;
  26342. return true;
  26343. }
  26344. if ($eventDispatcher) {
  26345. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, null, null, $filename, 'metadata', array('response' => $response, 'repository' => $repo));
  26346. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  26347. }
  26348. $data = $response->decodeJson();
  26349. HttpDownloader::outputWarnings($io, $url, $data);
  26350. $lastModifiedDate = $response->getHeader('last-modified');
  26351. $response->collect();
  26352. if ($lastModifiedDate) {
  26353. $data['last-modified'] = $lastModifiedDate;
  26354. $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE);
  26355. }
  26356. if (!$cache->isReadOnly()) {
  26357. $cache->write($cacheKey, $json);
  26358. }
  26359. $repo->freshMetadataUrls[$filename] = true;
  26360. return $data;
  26361. };
  26362. $reject = function ($e) use ($filename, $accept, $io, $url, &$degradedMode, $repo, $lastModifiedTime) {
  26363. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  26364. $repo->packagesNotFoundCache[$filename] = true;
  26365. return false;
  26366. }
  26367. if (!$degradedMode) {
  26368. $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>');
  26369. }
  26370. $degradedMode = true;
  26371. if ($lastModifiedTime) {
  26372. return $accept(new Response(array('url' => $url), 304, array(), ''));
  26373. }
  26374. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  26375. return $accept(new Response(array('url' => $url), 404, array(), ''));
  26376. }
  26377. throw $e;
  26378. };
  26379. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  26380. }
  26381. private function initializePartialPackages()
  26382. {
  26383. $rootData = $this->loadRootServerFile();
  26384. $this->partialPackagesByName = array();
  26385. foreach ($rootData['packages'] as $package => $versions) {
  26386. foreach ($versions as $version) {
  26387. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  26388. }
  26389. }
  26390. $this->rootData = true;
  26391. }
  26392. protected function lazyProvidersRepoContains($name)
  26393. {
  26394. if (!$this->hasAvailablePackageList) {
  26395. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  26396. }
  26397. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  26398. return true;
  26399. }
  26400. if (is_array($this->availablePackagePatterns)) {
  26401. foreach ($this->availablePackagePatterns as $providerRegex) {
  26402. if (Preg::isMatch($providerRegex, $name)) {
  26403. return true;
  26404. }
  26405. }
  26406. }
  26407. return false;
  26408. }
  26409. }
  26410. <?php
  26411. namespace Composer\Repository;
  26412. use Composer\Package\PackageInterface;
  26413. class CompositeRepository implements RepositoryInterface
  26414. {
  26415. private $repositories;
  26416. public function __construct(array $repositories)
  26417. {
  26418. $this->repositories = array();
  26419. foreach ($repositories as $repo) {
  26420. $this->addRepository($repo);
  26421. }
  26422. }
  26423. public function getRepoName()
  26424. {
  26425. return 'composite repo ('.implode(', ', array_map(function ($repo) {
  26426. return $repo->getRepoName();
  26427. }, $this->repositories)).')';
  26428. }
  26429. public function getRepositories()
  26430. {
  26431. return $this->repositories;
  26432. }
  26433. public function hasPackage(PackageInterface $package)
  26434. {
  26435. foreach ($this->repositories as $repository) {
  26436. if ($repository->hasPackage($package)) {
  26437. return true;
  26438. }
  26439. }
  26440. return false;
  26441. }
  26442. public function findPackage($name, $constraint)
  26443. {
  26444. foreach ($this->repositories as $repository) {
  26445. $package = $repository->findPackage($name, $constraint);
  26446. if (null !== $package) {
  26447. return $package;
  26448. }
  26449. }
  26450. return null;
  26451. }
  26452. public function findPackages($name, $constraint = null)
  26453. {
  26454. $packages = array();
  26455. foreach ($this->repositories as $repository) {
  26456. $packages[] = $repository->findPackages($name, $constraint);
  26457. }
  26458. return $packages ? call_user_func_array('array_merge', $packages) : array();
  26459. }
  26460. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  26461. {
  26462. $packages = array();
  26463. $namesFound = array();
  26464. foreach ($this->repositories as $repository) {
  26465. $result = $repository->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  26466. $packages[] = $result['packages'];
  26467. $namesFound[] = $result['namesFound'];
  26468. }
  26469. return array(
  26470. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  26471. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  26472. );
  26473. }
  26474. public function search($query, $mode = 0, $type = null)
  26475. {
  26476. $matches = array();
  26477. foreach ($this->repositories as $repository) {
  26478. $matches[] = $repository->search($query, $mode, $type);
  26479. }
  26480. return $matches ? call_user_func_array('array_merge', $matches) : array();
  26481. }
  26482. public function getPackages()
  26483. {
  26484. $packages = array();
  26485. foreach ($this->repositories as $repository) {
  26486. $packages[] = $repository->getPackages();
  26487. }
  26488. return $packages ? call_user_func_array('array_merge', $packages) : array();
  26489. }
  26490. public function getProviders($packageName)
  26491. {
  26492. $results = array();
  26493. foreach ($this->repositories as $repository) {
  26494. $results[] = $repository->getProviders($packageName);
  26495. }
  26496. return $results ? call_user_func_array('array_merge', $results) : array();
  26497. }
  26498. public function removePackage(PackageInterface $package)
  26499. {
  26500. foreach ($this->repositories as $repository) {
  26501. if ($repository instanceof WritableRepositoryInterface) {
  26502. $repository->removePackage($package);
  26503. }
  26504. }
  26505. }
  26506. #[\ReturnTypeWillChange]
  26507. public function count()
  26508. {
  26509. $total = 0;
  26510. foreach ($this->repositories as $repository) {
  26511. $total += $repository->count();
  26512. }
  26513. return $total;
  26514. }
  26515. public function addRepository(RepositoryInterface $repository)
  26516. {
  26517. if ($repository instanceof self) {
  26518. foreach ($repository->getRepositories() as $repo) {
  26519. $this->addRepository($repo);
  26520. }
  26521. } else {
  26522. $this->repositories[] = $repository;
  26523. }
  26524. }
  26525. }
  26526. <?php
  26527. namespace Composer\Repository;
  26528. interface ConfigurableRepositoryInterface
  26529. {
  26530. public function getRepoConfig();
  26531. }
  26532. <?php
  26533. namespace Composer\Repository;
  26534. use Composer\Json\JsonFile;
  26535. use Composer\Package\Loader\ArrayLoader;
  26536. use Composer\Package\RootPackageInterface;
  26537. use Composer\Package\AliasPackage;
  26538. use Composer\Package\Dumper\ArrayDumper;
  26539. use Composer\Installer\InstallationManager;
  26540. use Composer\Util\Filesystem;
  26541. class FilesystemRepository extends WritableArrayRepository
  26542. {
  26543. protected $file;
  26544. private $dumpVersions;
  26545. private $rootPackage;
  26546. private $filesystem;
  26547. private $devMode = null;
  26548. public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null, Filesystem $filesystem = null)
  26549. {
  26550. parent::__construct();
  26551. $this->file = $repositoryFile;
  26552. $this->dumpVersions = $dumpVersions;
  26553. $this->rootPackage = $rootPackage;
  26554. $this->filesystem = $filesystem ?: new Filesystem;
  26555. if ($dumpVersions && !$rootPackage) {
  26556. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  26557. }
  26558. }
  26559. public function getDevMode()
  26560. {
  26561. return $this->devMode;
  26562. }
  26563. protected function initialize()
  26564. {
  26565. parent::initialize();
  26566. if (!$this->file->exists()) {
  26567. return;
  26568. }
  26569. try {
  26570. $data = $this->file->read();
  26571. if (isset($data['packages'])) {
  26572. $packages = $data['packages'];
  26573. } else {
  26574. $packages = $data;
  26575. }
  26576. if (isset($data['dev-package-names'])) {
  26577. $this->setDevPackageNames($data['dev-package-names']);
  26578. }
  26579. if (isset($data['dev'])) {
  26580. $this->devMode = $data['dev'];
  26581. }
  26582. if (!is_array($packages)) {
  26583. throw new \UnexpectedValueException('Could not parse package list from the repository');
  26584. }
  26585. } catch (\Exception $e) {
  26586. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  26587. }
  26588. $loader = new ArrayLoader(null, true);
  26589. foreach ($packages as $packageData) {
  26590. $package = $loader->load($packageData);
  26591. $this->addPackage($package);
  26592. }
  26593. }
  26594. public function reload()
  26595. {
  26596. $this->packages = null;
  26597. $this->initialize();
  26598. }
  26599. public function write($devMode, InstallationManager $installationManager)
  26600. {
  26601. $data = array('packages' => array(), 'dev' => $devMode, 'dev-package-names' => array());
  26602. $dumper = new ArrayDumper();
  26603. $repoDir = dirname($this->file->getPath());
  26604. $this->filesystem->ensureDirectoryExists($repoDir);
  26605. $repoDir = $this->filesystem->normalizePath(realpath($repoDir));
  26606. $installPaths = array();
  26607. foreach ($this->getCanonicalPackages() as $package) {
  26608. $pkgArray = $dumper->dump($package);
  26609. $path = $installationManager->getInstallPath($package);
  26610. $installPath = null;
  26611. if ('' !== $path && null !== $path) {
  26612. $normalizedPath = $this->filesystem->normalizePath($this->filesystem->isAbsolutePath($path) ? $path : getcwd() . '/' . $path);
  26613. $installPath = $this->filesystem->findShortestPath($repoDir, $normalizedPath, true);
  26614. }
  26615. $installPaths[$package->getName()] = $installPath;
  26616. $pkgArray['install-path'] = $installPath;
  26617. $data['packages'][] = $pkgArray;
  26618. if (in_array($package->getName(), $this->devPackageNames, true)) {
  26619. $data['dev-package-names'][] = $package->getName();
  26620. }
  26621. }
  26622. sort($data['dev-package-names']);
  26623. usort($data['packages'], function ($a, $b) {
  26624. return strcmp($a['name'], $b['name']);
  26625. });
  26626. $this->file->write($data);
  26627. if ($this->dumpVersions) {
  26628. $versions = $this->generateInstalledVersions($installationManager, $installPaths, $devMode, $repoDir);
  26629. $this->filesystem->filePutContentsIfModified($repoDir.'/installed.php', '<?php return ' . $this->dumpToPhpCode($versions) . ';'."\n");
  26630. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  26631. $this->filesystem->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  26632. \Composer\InstalledVersions::reload($versions);
  26633. }
  26634. }
  26635. private function dumpToPhpCode(array $array = array(), $level = 0)
  26636. {
  26637. $lines = "array(\n";
  26638. $level++;
  26639. foreach ($array as $key => $value) {
  26640. $lines .= str_repeat(' ', $level);
  26641. $lines .= is_int($key) ? $key . ' => ' : '\'' . $key . '\' => ';
  26642. if (is_array($value)) {
  26643. if (!empty($value)) {
  26644. $lines .= $this->dumpToPhpCode($value, $level);
  26645. } else {
  26646. $lines .= "array(),\n";
  26647. }
  26648. } elseif ($key === 'install_path' && is_string($value)) {
  26649. if ($this->filesystem->isAbsolutePath($value)) {
  26650. $lines .= var_export($value, true) . ",\n";
  26651. } else {
  26652. $lines .= "__DIR__ . " . var_export('/' . $value, true) . ",\n";
  26653. }
  26654. } else {
  26655. $lines .= var_export($value, true) . ",\n";
  26656. }
  26657. }
  26658. $lines .= str_repeat(' ', $level - 1) . ')' . ($level - 1 == 0 ? '' : ",\n");
  26659. return $lines;
  26660. }
  26661. private function generateInstalledVersions(InstallationManager $installationManager, array $installPaths, $devMode, $repoDir)
  26662. {
  26663. if (!$this->dumpVersions) {
  26664. return null;
  26665. }
  26666. $devPackages = array_flip($this->devPackageNames);
  26667. $versions = array('versions' => array());
  26668. $packages = $this->getPackages();
  26669. $packages[] = $rootPackage = $this->rootPackage;
  26670. while ($rootPackage instanceof AliasPackage) {
  26671. $rootPackage = $rootPackage->getAliasOf();
  26672. $packages[] = $rootPackage;
  26673. }
  26674. foreach ($packages as $package) {
  26675. if ($package instanceof AliasPackage) {
  26676. continue;
  26677. }
  26678. $reference = null;
  26679. if ($package->getInstallationSource()) {
  26680. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  26681. }
  26682. if (null === $reference) {
  26683. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  26684. }
  26685. if ($package instanceof RootPackageInterface) {
  26686. $to = $this->filesystem->normalizePath(realpath(getcwd()));
  26687. $installPath = $this->filesystem->findShortestPath($repoDir, $to, true);
  26688. } else {
  26689. $installPath = $installPaths[$package->getName()];
  26690. }
  26691. $versions['versions'][$package->getName()] = array(
  26692. 'pretty_version' => $package->getPrettyVersion(),
  26693. 'version' => $package->getVersion(),
  26694. 'type' => $package->getType(),
  26695. 'install_path' => $installPath,
  26696. 'aliases' => array(),
  26697. 'reference' => $reference,
  26698. 'dev_requirement' => isset($devPackages[$package->getName()]),
  26699. );
  26700. if ($package instanceof RootPackageInterface) {
  26701. $versions['root'] = $versions['versions'][$package->getName()];
  26702. unset($versions['root']['dev_requirement']);
  26703. $versions['root']['name'] = $package->getName();
  26704. $versions['root']['dev'] = $devMode;
  26705. }
  26706. }
  26707. foreach ($packages as $package) {
  26708. $isDevPackage = isset($devPackages[$package->getName()]);
  26709. foreach ($package->getReplaces() as $replace) {
  26710. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  26711. continue;
  26712. }
  26713. if (!isset($versions['versions'][$replace->getTarget()]['dev_requirement'])) {
  26714. $versions['versions'][$replace->getTarget()]['dev_requirement'] = $isDevPackage;
  26715. } elseif (!$isDevPackage) {
  26716. $versions['versions'][$replace->getTarget()]['dev_requirement'] = false;
  26717. }
  26718. $replaced = $replace->getPrettyConstraint();
  26719. if ($replaced === 'self.version') {
  26720. $replaced = $package->getPrettyVersion();
  26721. }
  26722. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  26723. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  26724. }
  26725. }
  26726. foreach ($package->getProvides() as $provide) {
  26727. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  26728. continue;
  26729. }
  26730. if (!isset($versions['versions'][$provide->getTarget()]['dev_requirement'])) {
  26731. $versions['versions'][$provide->getTarget()]['dev_requirement'] = $isDevPackage;
  26732. } elseif (!$isDevPackage) {
  26733. $versions['versions'][$provide->getTarget()]['dev_requirement'] = false;
  26734. }
  26735. $provided = $provide->getPrettyConstraint();
  26736. if ($provided === 'self.version') {
  26737. $provided = $package->getPrettyVersion();
  26738. }
  26739. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  26740. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  26741. }
  26742. }
  26743. }
  26744. foreach ($packages as $package) {
  26745. if (!$package instanceof AliasPackage) {
  26746. continue;
  26747. }
  26748. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  26749. if ($package instanceof RootPackageInterface) {
  26750. $versions['root']['aliases'][] = $package->getPrettyVersion();
  26751. }
  26752. }
  26753. ksort($versions['versions']);
  26754. ksort($versions);
  26755. return $versions;
  26756. }
  26757. }
  26758. <?php
  26759. namespace Composer\Repository;
  26760. use Composer\Package\PackageInterface;
  26761. use Composer\Package\BasePackage;
  26762. use Composer\Pcre\Preg;
  26763. class FilterRepository implements RepositoryInterface
  26764. {
  26765. private $only = null;
  26766. private $exclude = null;
  26767. private $canonical = true;
  26768. private $repo;
  26769. public function __construct(RepositoryInterface $repo, array $options)
  26770. {
  26771. if (isset($options['only'])) {
  26772. if (!is_array($options['only'])) {
  26773. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  26774. }
  26775. $this->only = BasePackage::packageNamesToRegexp($options['only']);
  26776. }
  26777. if (isset($options['exclude'])) {
  26778. if (!is_array($options['exclude'])) {
  26779. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  26780. }
  26781. $this->exclude = BasePackage::packageNamesToRegexp($options['exclude']);
  26782. }
  26783. if ($this->exclude && $this->only) {
  26784. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  26785. }
  26786. if (isset($options['canonical'])) {
  26787. if (!is_bool($options['canonical'])) {
  26788. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  26789. }
  26790. $this->canonical = $options['canonical'];
  26791. }
  26792. $this->repo = $repo;
  26793. }
  26794. public function getRepoName()
  26795. {
  26796. return $this->repo->getRepoName();
  26797. }
  26798. public function getRepository()
  26799. {
  26800. return $this->repo;
  26801. }
  26802. public function hasPackage(PackageInterface $package)
  26803. {
  26804. return $this->repo->hasPackage($package);
  26805. }
  26806. public function findPackage($name, $constraint)
  26807. {
  26808. if (!$this->isAllowed($name)) {
  26809. return null;
  26810. }
  26811. return $this->repo->findPackage($name, $constraint);
  26812. }
  26813. public function findPackages($name, $constraint = null)
  26814. {
  26815. if (!$this->isAllowed($name)) {
  26816. return array();
  26817. }
  26818. return $this->repo->findPackages($name, $constraint);
  26819. }
  26820. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  26821. {
  26822. foreach ($packageMap as $name => $constraint) {
  26823. if (!$this->isAllowed($name)) {
  26824. unset($packageMap[$name]);
  26825. }
  26826. }
  26827. if (!$packageMap) {
  26828. return array('namesFound' => array(), 'packages' => array());
  26829. }
  26830. $result = $this->repo->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  26831. if (!$this->canonical) {
  26832. $result['namesFound'] = array();
  26833. }
  26834. return $result;
  26835. }
  26836. public function search($query, $mode = 0, $type = null)
  26837. {
  26838. $result = array();
  26839. foreach ($this->repo->search($query, $mode, $type) as $package) {
  26840. if ($this->isAllowed($package['name'])) {
  26841. $result[] = $package;
  26842. }
  26843. }
  26844. return $result;
  26845. }
  26846. public function getPackages()
  26847. {
  26848. $result = array();
  26849. foreach ($this->repo->getPackages() as $package) {
  26850. if ($this->isAllowed($package->getName())) {
  26851. $result[] = $package;
  26852. }
  26853. }
  26854. return $result;
  26855. }
  26856. public function getProviders($packageName)
  26857. {
  26858. $result = array();
  26859. foreach ($this->repo->getProviders($packageName) as $name => $provider) {
  26860. if ($this->isAllowed($provider['name'])) {
  26861. $result[$name] = $provider;
  26862. }
  26863. }
  26864. return $result;
  26865. }
  26866. #[\ReturnTypeWillChange]
  26867. public function count()
  26868. {
  26869. if ($this->repo->count() > 0) {
  26870. return count($this->getPackages());
  26871. }
  26872. return 0;
  26873. }
  26874. private function isAllowed($name)
  26875. {
  26876. if (!$this->only && !$this->exclude) {
  26877. return true;
  26878. }
  26879. if ($this->only) {
  26880. return Preg::isMatch($this->only, $name);
  26881. }
  26882. if ($this->exclude === null) {
  26883. return true;
  26884. }
  26885. return !Preg::isMatch($this->exclude, $name);
  26886. }
  26887. }
  26888. <?php
  26889. namespace Composer\Repository;
  26890. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  26891. {
  26892. public function getRepoName()
  26893. {
  26894. return 'installed '.parent::getRepoName();
  26895. }
  26896. public function isFresh()
  26897. {
  26898. return $this->count() === 0;
  26899. }
  26900. }
  26901. <?php
  26902. namespace Composer\Repository;
  26903. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  26904. {
  26905. public function getRepoName()
  26906. {
  26907. return 'installed '.parent::getRepoName();
  26908. }
  26909. public function isFresh()
  26910. {
  26911. return !$this->file->exists();
  26912. }
  26913. }
  26914. <?php
  26915. namespace Composer\Repository;
  26916. use Composer\Package\BasePackage;
  26917. use Composer\Package\PackageInterface;
  26918. use Composer\Package\Version\VersionParser;
  26919. use Composer\Semver\Constraint\ConstraintInterface;
  26920. use Composer\Semver\Constraint\Constraint;
  26921. use Composer\Semver\Constraint\MatchAllConstraint;
  26922. use Composer\Package\RootPackageInterface;
  26923. use Composer\Package\Link;
  26924. class InstalledRepository extends CompositeRepository
  26925. {
  26926. public function findPackagesWithReplacersAndProviders($name, $constraint = null)
  26927. {
  26928. $name = strtolower($name);
  26929. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  26930. $versionParser = new VersionParser();
  26931. $constraint = $versionParser->parseConstraints($constraint);
  26932. }
  26933. $matches = array();
  26934. foreach ($this->getRepositories() as $repo) {
  26935. foreach ($repo->getPackages() as $candidate) {
  26936. if ($name === $candidate->getName()) {
  26937. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  26938. $matches[] = $candidate;
  26939. }
  26940. continue;
  26941. }
  26942. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  26943. if (
  26944. $name === $link->getTarget()
  26945. && ($constraint === null || $constraint->matches($link->getConstraint()))
  26946. ) {
  26947. $matches[] = $candidate;
  26948. continue 2;
  26949. }
  26950. }
  26951. }
  26952. }
  26953. return $matches;
  26954. }
  26955. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  26956. {
  26957. $needles = array_map('strtolower', (array) $needle);
  26958. $results = array();
  26959. if (null === $packagesFound) {
  26960. $packagesFound = $needles;
  26961. }
  26962. $rootPackage = null;
  26963. foreach ($this->getPackages() as $package) {
  26964. if ($package instanceof RootPackageInterface) {
  26965. $rootPackage = $package;
  26966. break;
  26967. }
  26968. }
  26969. foreach ($this->getPackages() as $package) {
  26970. $links = $package->getRequires();
  26971. $packagesInTree = $packagesFound;
  26972. if (!$invert) {
  26973. $links += $package->getReplaces();
  26974. foreach ($package->getReplaces() as $link) {
  26975. foreach ($needles as $needle) {
  26976. if ($link->getSource() === $needle) {
  26977. if ($constraint === null || ($link->getConstraint()->matches($constraint) === true)) {
  26978. if (in_array($link->getTarget(), $packagesInTree)) {
  26979. $results[] = array($package, $link, false);
  26980. continue;
  26981. }
  26982. $packagesInTree[] = $link->getTarget();
  26983. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  26984. $results[] = array($package, $link, $dependents);
  26985. $needles[] = $link->getTarget();
  26986. }
  26987. }
  26988. }
  26989. }
  26990. }
  26991. if ($package instanceof RootPackageInterface) {
  26992. $links += $package->getDevRequires();
  26993. }
  26994. foreach ($links as $link) {
  26995. foreach ($needles as $needle) {
  26996. if ($link->getTarget() === $needle) {
  26997. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  26998. if (in_array($link->getSource(), $packagesInTree)) {
  26999. $results[] = array($package, $link, false);
  27000. continue;
  27001. }
  27002. $packagesInTree[] = $link->getSource();
  27003. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  27004. $results[] = array($package, $link, $dependents);
  27005. }
  27006. }
  27007. }
  27008. }
  27009. if ($invert && in_array($package->getName(), $needles)) {
  27010. foreach ($package->getConflicts() as $link) {
  27011. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  27012. $version = new Constraint('=', $pkg->getVersion());
  27013. if ($link->getConstraint()->matches($version) === $invert) {
  27014. $results[] = array($package, $link, false);
  27015. }
  27016. }
  27017. }
  27018. }
  27019. foreach ($package->getConflicts() as $link) {
  27020. if (in_array($link->getTarget(), $needles)) {
  27021. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  27022. $version = new Constraint('=', $pkg->getVersion());
  27023. if ($link->getConstraint()->matches($version) === $invert) {
  27024. $results[] = array($package, $link, false);
  27025. }
  27026. }
  27027. }
  27028. }
  27029. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  27030. foreach ($package->getRequires() as $link) {
  27031. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  27032. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  27033. continue;
  27034. }
  27035. $platformPkg = $this->findPackage($link->getTarget(), '*');
  27036. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  27037. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  27038. continue;
  27039. }
  27040. foreach ($this->getPackages() as $pkg) {
  27041. if (!in_array($link->getTarget(), $pkg->getNames())) {
  27042. continue;
  27043. }
  27044. $version = new Constraint('=', $pkg->getVersion());
  27045. if ($link->getTarget() !== $pkg->getName()) {
  27046. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  27047. if ($link->getTarget() === $prov->getTarget()) {
  27048. $version = $prov->getConstraint();
  27049. break;
  27050. }
  27051. }
  27052. }
  27053. if (!$link->getConstraint()->matches($version)) {
  27054. if ($rootPackage) {
  27055. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  27056. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  27057. $results[] = array($package, $link, false);
  27058. $results[] = array($rootPackage, $rootReq, false);
  27059. continue 3;
  27060. }
  27061. }
  27062. $results[] = array($package, $link, false);
  27063. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_DOES_NOT_REQUIRE, 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  27064. } else {
  27065. $results[] = array($package, $link, false);
  27066. }
  27067. }
  27068. continue 2;
  27069. }
  27070. }
  27071. }
  27072. }
  27073. ksort($results);
  27074. return $results;
  27075. }
  27076. public function getRepoName()
  27077. {
  27078. return 'installed repo ('.implode(', ', array_map(function ($repo) {
  27079. return $repo->getRepoName();
  27080. }, $this->getRepositories())).')';
  27081. }
  27082. public function addRepository(RepositoryInterface $repository)
  27083. {
  27084. if (
  27085. $repository instanceof LockArrayRepository
  27086. || $repository instanceof InstalledRepositoryInterface
  27087. || $repository instanceof RootPackageRepository
  27088. || $repository instanceof PlatformRepository
  27089. ) {
  27090. parent::addRepository($repository);
  27091. return;
  27092. }
  27093. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  27094. }
  27095. }
  27096. <?php
  27097. namespace Composer\Repository;
  27098. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  27099. {
  27100. public function getDevMode();
  27101. public function isFresh();
  27102. }
  27103. <?php
  27104. namespace Composer\Repository;
  27105. class InvalidRepositoryException extends \Exception
  27106. {
  27107. }
  27108. <?php
  27109. namespace Composer\Repository;
  27110. class LockArrayRepository extends ArrayRepository
  27111. {
  27112. public function getRepoName()
  27113. {
  27114. return 'lock repo';
  27115. }
  27116. }
  27117. <?php
  27118. namespace Composer\Repository;
  27119. use Composer\Package\Loader\ArrayLoader;
  27120. use Composer\Package\Loader\ValidatingArrayLoader;
  27121. use Composer\Pcre\Preg;
  27122. class PackageRepository extends ArrayRepository
  27123. {
  27124. private $config;
  27125. public function __construct(array $config)
  27126. {
  27127. parent::__construct();
  27128. $this->config = $config['package'];
  27129. if (!is_numeric(key($this->config))) {
  27130. $this->config = array($this->config);
  27131. }
  27132. }
  27133. protected function initialize()
  27134. {
  27135. parent::initialize();
  27136. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), true);
  27137. foreach ($this->config as $package) {
  27138. try {
  27139. $package = $loader->load($package);
  27140. } catch (\Exception $e) {
  27141. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  27142. }
  27143. $this->addPackage($package);
  27144. }
  27145. }
  27146. public function getRepoName()
  27147. {
  27148. return Preg::replace('{^array }', 'package ', parent::getRepoName());
  27149. }
  27150. }
  27151. <?php
  27152. namespace Composer\Repository;
  27153. use Composer\Config;
  27154. use Composer\IO\IOInterface;
  27155. use Composer\Json\JsonFile;
  27156. use Composer\Package\CompleteAliasPackage;
  27157. use Composer\Package\CompletePackage;
  27158. use Composer\Package\Loader\ArrayLoader;
  27159. use Composer\Package\Version\VersionGuesser;
  27160. use Composer\Package\Version\VersionParser;
  27161. use Composer\Pcre\Preg;
  27162. use Composer\Util\Platform;
  27163. use Composer\Util\ProcessExecutor;
  27164. use Composer\Util\Filesystem;
  27165. use Composer\Util\Url;
  27166. use Composer\Util\Git as GitUtil;
  27167. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27168. {
  27169. private $loader;
  27170. private $versionGuesser;
  27171. private $url;
  27172. private $repoConfig;
  27173. private $process;
  27174. private $options;
  27175. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  27176. {
  27177. if (!isset($repoConfig['url'])) {
  27178. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  27179. }
  27180. $this->loader = new ArrayLoader(null, true);
  27181. $this->url = Platform::expandPath($repoConfig['url']);
  27182. $this->process = new ProcessExecutor($io);
  27183. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  27184. $this->repoConfig = $repoConfig;
  27185. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  27186. if (!isset($this->options['relative'])) {
  27187. $filesystem = new Filesystem();
  27188. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  27189. }
  27190. parent::__construct();
  27191. }
  27192. public function getRepoName()
  27193. {
  27194. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  27195. }
  27196. public function getRepoConfig()
  27197. {
  27198. return $this->repoConfig;
  27199. }
  27200. protected function initialize()
  27201. {
  27202. parent::initialize();
  27203. $urlMatches = $this->getUrlMatches();
  27204. if (empty($urlMatches)) {
  27205. if (Preg::isMatch('{[*{}]}', $this->url)) {
  27206. $url = $this->url;
  27207. while (Preg::isMatch('{[*{}]}', $url)) {
  27208. $url = dirname($url);
  27209. }
  27210. if (is_dir($url)) {
  27211. return;
  27212. }
  27213. }
  27214. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  27215. }
  27216. foreach ($urlMatches as $url) {
  27217. $path = realpath($url) . DIRECTORY_SEPARATOR;
  27218. $composerFilePath = $path.'composer.json';
  27219. if (!file_exists($composerFilePath)) {
  27220. continue;
  27221. }
  27222. $json = file_get_contents($composerFilePath);
  27223. $package = JsonFile::parseJson($json, $composerFilePath);
  27224. $package['dist'] = array(
  27225. 'type' => 'path',
  27226. 'url' => $url,
  27227. 'reference' => sha1($json . serialize($this->options)),
  27228. );
  27229. $package['transport-options'] = array_intersect_key($this->options, array('symlink' => true, 'relative' => true));
  27230. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  27231. $package['version'] = $this->options['versions'][$package['name']];
  27232. }
  27233. if (!isset($package['version']) && ($rootVersion = Platform::getEnv('COMPOSER_ROOT_VERSION'))) {
  27234. if (
  27235. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  27236. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  27237. && $ref1 === $ref2
  27238. ) {
  27239. $package['version'] = $rootVersion;
  27240. }
  27241. }
  27242. $output = '';
  27243. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  27244. $package['dist']['reference'] = trim($output);
  27245. }
  27246. $needsAlias = false;
  27247. if (!isset($package['version'])) {
  27248. $versionData = $this->versionGuesser->guessVersion($package, $path);
  27249. if (is_array($versionData) && $versionData['pretty_version']) {
  27250. if (!empty($versionData['feature_pretty_version'])) {
  27251. $package['version'] = $versionData['feature_pretty_version'];
  27252. $this->addPackage($this->loader->load($package));
  27253. }
  27254. $package['version'] = $versionData['pretty_version'];
  27255. } else {
  27256. $package['version'] = 'dev-main';
  27257. $needsAlias = true;
  27258. }
  27259. }
  27260. $package = $this->loader->load($package);
  27261. if ($needsAlias && $package instanceof CompletePackage) {
  27262. $package = new CompleteAliasPackage($package, 'dev-master', 'dev-master');
  27263. }
  27264. $this->addPackage($package);
  27265. }
  27266. }
  27267. private function getUrlMatches()
  27268. {
  27269. $flags = GLOB_MARK | GLOB_ONLYDIR;
  27270. if (defined('GLOB_BRACE')) {
  27271. $flags |= GLOB_BRACE;
  27272. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  27273. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  27274. }
  27275. return array_map(function ($val) {
  27276. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  27277. }, glob($this->url, $flags));
  27278. }
  27279. }
  27280. <?php
  27281. namespace Composer\Repository;
  27282. class PearRepository extends ArrayRepository
  27283. {
  27284. public function __construct()
  27285. {
  27286. throw new \InvalidArgumentException('The PEAR repository has been removed from Composer 2.x');
  27287. }
  27288. }
  27289. <?php
  27290. namespace Composer\Repository;
  27291. use Composer\Composer;
  27292. use Composer\Package\CompletePackage;
  27293. use Composer\Package\CompletePackageInterface;
  27294. use Composer\Package\Link;
  27295. use Composer\Package\PackageInterface;
  27296. use Composer\Package\Version\VersionParser;
  27297. use Composer\Pcre\Preg;
  27298. use Composer\Platform\HhvmDetector;
  27299. use Composer\Platform\Runtime;
  27300. use Composer\Platform\Version;
  27301. use Composer\Plugin\PluginInterface;
  27302. use Composer\Semver\Constraint\Constraint;
  27303. use Composer\Util\Silencer;
  27304. use Composer\XdebugHandler\XdebugHandler;
  27305. class PlatformRepository extends ArrayRepository
  27306. {
  27307. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer(?:-(?:plugin|runtime)-api)?)$}iD';
  27308. private static $lastSeenPlatformPhp = null;
  27309. private $versionParser;
  27310. private $overrides = array();
  27311. private $disabledPackages = array();
  27312. private $runtime;
  27313. private $hhvmDetector;
  27314. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  27315. {
  27316. $this->runtime = $runtime ?: new Runtime();
  27317. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  27318. foreach ($overrides as $name => $version) {
  27319. if (!is_string($version) && false !== $version) {
  27320. throw new \UnexpectedValueException('config.platform.'.$name.' should be a string or false, but got '.gettype($version).' '.var_export($version, true));
  27321. }
  27322. if ($name === 'php' && $version === false) {
  27323. throw new \UnexpectedValueException('config.platform.'.$name.' cannot be set to false as you cannot disable php entirely.');
  27324. }
  27325. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  27326. }
  27327. parent::__construct($packages);
  27328. }
  27329. public function getRepoName()
  27330. {
  27331. return 'platform repo';
  27332. }
  27333. public function isPlatformPackageDisabled($name)
  27334. {
  27335. return isset($this->disabledPackages[$name]);
  27336. }
  27337. public function getDisabledPackages()
  27338. {
  27339. return $this->disabledPackages;
  27340. }
  27341. protected function initialize()
  27342. {
  27343. parent::initialize();
  27344. $this->versionParser = new VersionParser();
  27345. foreach ($this->overrides as $override) {
  27346. if (!self::isPlatformPackage($override['name'])) {
  27347. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  27348. }
  27349. if ($override['version'] !== false) {
  27350. $this->addOverriddenPackage($override);
  27351. }
  27352. }
  27353. $prettyVersion = Composer::getVersion();
  27354. $version = $this->versionParser->normalize($prettyVersion);
  27355. $composer = new CompletePackage('composer', $version, $prettyVersion);
  27356. $composer->setDescription('Composer package');
  27357. $this->addPackage($composer);
  27358. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  27359. $version = $this->versionParser->normalize($prettyVersion);
  27360. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  27361. $composerPluginApi->setDescription('The Composer Plugin API');
  27362. $this->addPackage($composerPluginApi);
  27363. $prettyVersion = Composer::RUNTIME_API_VERSION;
  27364. $version = $this->versionParser->normalize($prettyVersion);
  27365. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  27366. $composerRuntimeApi->setDescription('The Composer Runtime API');
  27367. $this->addPackage($composerRuntimeApi);
  27368. try {
  27369. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  27370. $version = $this->versionParser->normalize($prettyVersion);
  27371. } catch (\UnexpectedValueException $e) {
  27372. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  27373. $version = $this->versionParser->normalize($prettyVersion);
  27374. }
  27375. $php = new CompletePackage('php', $version, $prettyVersion);
  27376. $php->setDescription('The PHP interpreter');
  27377. $this->addPackage($php);
  27378. if ($this->runtime->getConstant('PHP_DEBUG')) {
  27379. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  27380. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  27381. $this->addPackage($phpdebug);
  27382. }
  27383. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  27384. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  27385. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  27386. $this->addPackage($phpzts);
  27387. }
  27388. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  27389. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  27390. $php64->setDescription('The PHP interpreter, 64bit');
  27391. $this->addPackage($php64);
  27392. }
  27393. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  27394. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  27395. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  27396. $this->addPackage($phpIpv6);
  27397. }
  27398. $loadedExtensions = $this->runtime->getExtensions();
  27399. foreach ($loadedExtensions as $name) {
  27400. if (in_array($name, array('standard', 'Core'))) {
  27401. continue;
  27402. }
  27403. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  27404. }
  27405. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  27406. $this->addExtension('xdebug', $prettyVersion);
  27407. }
  27408. foreach ($loadedExtensions as $name) {
  27409. switch ($name) {
  27410. case 'amqp':
  27411. $info = $this->runtime->getExtensionInfo($name);
  27412. if (Preg::isMatch('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  27413. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  27414. }
  27415. if (Preg::isMatch('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  27416. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  27417. }
  27418. break;
  27419. case 'bz2':
  27420. $info = $this->runtime->getExtensionInfo($name);
  27421. if (Preg::isMatch('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  27422. $this->addLibrary($name, $matches['version']);
  27423. }
  27424. break;
  27425. case 'curl':
  27426. $curlVersion = $this->runtime->invoke('curl_version');
  27427. $this->addLibrary($name, $curlVersion['version']);
  27428. $info = $this->runtime->getExtensionInfo($name);
  27429. if (Preg::isMatch('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  27430. $library = strtolower($sslMatches['library']);
  27431. if ($library === 'openssl') {
  27432. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  27433. $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl') : array());
  27434. } else {
  27435. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  27436. }
  27437. }
  27438. if (Preg::isMatch('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  27439. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  27440. }
  27441. if (Preg::isMatch('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  27442. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  27443. }
  27444. break;
  27445. case 'date':
  27446. $info = $this->runtime->getExtensionInfo($name);
  27447. if (Preg::isMatch('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  27448. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  27449. }
  27450. if (Preg::isMatch('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  27451. $external = $zoneinfoSourceMatches['source'] === 'external';
  27452. if (Preg::isMatch('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  27453. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  27454. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  27455. } else {
  27456. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  27457. }
  27458. }
  27459. }
  27460. break;
  27461. case 'fileinfo':
  27462. $info = $this->runtime->getExtensionInfo($name);
  27463. if (Preg::isMatch('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  27464. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  27465. }
  27466. break;
  27467. case 'gd':
  27468. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  27469. $info = $this->runtime->getExtensionInfo($name);
  27470. if (Preg::isMatch('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  27471. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  27472. }
  27473. if (Preg::isMatch('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  27474. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  27475. }
  27476. if (Preg::isMatch('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  27477. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  27478. }
  27479. if (Preg::isMatch('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  27480. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId($libxpmMatches['versionId']), 'libxpm version for gd');
  27481. }
  27482. break;
  27483. case 'gmp':
  27484. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  27485. break;
  27486. case 'iconv':
  27487. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  27488. break;
  27489. case 'intl':
  27490. $info = $this->runtime->getExtensionInfo($name);
  27491. $description = 'The ICU unicode and globalization support library';
  27492. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  27493. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  27494. } elseif (Preg::isMatch('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  27495. $this->addLibrary('icu', $matches['version'], $description);
  27496. }
  27497. if (Preg::isMatch('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches)) {
  27498. $this->addLibrary('icu-zoneinfo', Version::parseZoneinfoVersion($zoneinfoMatches['version']), 'zoneinfo ("Olson") database for icu');
  27499. }
  27500. if ($this->runtime->hasClass('ResourceBundle')) {
  27501. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  27502. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  27503. }
  27504. if ($this->runtime->hasClass('IntlChar')) {
  27505. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  27506. }
  27507. break;
  27508. case 'imagick':
  27509. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  27510. Preg::match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  27511. $version = $matches['version'];
  27512. if (isset($matches['patch'])) {
  27513. $version .= '.'.$matches['patch'];
  27514. }
  27515. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  27516. break;
  27517. case 'ldap':
  27518. $info = $this->runtime->getExtensionInfo($name);
  27519. if (Preg::isMatch('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && Preg::isMatch('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  27520. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId($matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  27521. }
  27522. break;
  27523. case 'libxml':
  27524. $libxmlProvides = array_map(function ($extension) {
  27525. return $extension . '-libxml';
  27526. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  27527. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  27528. break;
  27529. case 'mbstring':
  27530. $info = $this->runtime->getExtensionInfo($name);
  27531. if (Preg::isMatch('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  27532. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  27533. }
  27534. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  27535. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  27536. } elseif (Preg::isMatch('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  27537. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  27538. }
  27539. break;
  27540. case 'memcached':
  27541. $info = $this->runtime->getExtensionInfo($name);
  27542. if (Preg::isMatch('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  27543. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  27544. }
  27545. break;
  27546. case 'openssl':
  27547. if (Preg::isMatch('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  27548. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  27549. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  27550. }
  27551. break;
  27552. case 'pcre':
  27553. $this->addLibrary($name, Preg::replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  27554. $info = $this->runtime->getExtensionInfo($name);
  27555. if (Preg::isMatch('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  27556. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  27557. }
  27558. break;
  27559. case 'mysqlnd':
  27560. case 'pdo_mysql':
  27561. $info = $this->runtime->getExtensionInfo($name);
  27562. if (Preg::isMatch('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  27563. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  27564. }
  27565. break;
  27566. case 'mongodb':
  27567. $info = $this->runtime->getExtensionInfo($name);
  27568. if (Preg::isMatch('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  27569. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  27570. }
  27571. if (Preg::isMatch('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  27572. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  27573. }
  27574. break;
  27575. case 'pgsql':
  27576. case 'pdo_pgsql':
  27577. $info = $this->runtime->getExtensionInfo($name);
  27578. if (Preg::isMatch('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  27579. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  27580. }
  27581. break;
  27582. case 'libsodium':
  27583. case 'sodium':
  27584. if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) {
  27585. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  27586. }
  27587. break;
  27588. case 'sqlite3':
  27589. case 'pdo_sqlite':
  27590. $info = $this->runtime->getExtensionInfo($name);
  27591. if (Preg::isMatch('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  27592. $this->addLibrary($name.'-sqlite', $matches['version']);
  27593. }
  27594. break;
  27595. case 'ssh2':
  27596. $info = $this->runtime->getExtensionInfo($name);
  27597. if (Preg::isMatch('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  27598. $this->addLibrary($name.'-libssh2', $matches['version']);
  27599. }
  27600. break;
  27601. case 'xsl':
  27602. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  27603. $info = $this->runtime->getExtensionInfo('xsl');
  27604. if (Preg::isMatch('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  27605. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  27606. }
  27607. break;
  27608. case 'yaml':
  27609. $info = $this->runtime->getExtensionInfo('yaml');
  27610. if (Preg::isMatch('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  27611. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  27612. }
  27613. break;
  27614. case 'zip':
  27615. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  27616. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, array('zip'));
  27617. }
  27618. break;
  27619. case 'zlib':
  27620. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  27621. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  27622. } elseif (Preg::isMatch('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  27623. $this->addLibrary($name, $matches['version']);
  27624. }
  27625. break;
  27626. default:
  27627. break;
  27628. }
  27629. }
  27630. $hhvmVersion = $this->hhvmDetector->getVersion();
  27631. if ($hhvmVersion) {
  27632. try {
  27633. $prettyVersion = $hhvmVersion;
  27634. $version = $this->versionParser->normalize($prettyVersion);
  27635. } catch (\UnexpectedValueException $e) {
  27636. $prettyVersion = Preg::replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  27637. $version = $this->versionParser->normalize($prettyVersion);
  27638. }
  27639. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  27640. $hhvm->setDescription('The HHVM Runtime (64bit)');
  27641. $this->addPackage($hhvm);
  27642. }
  27643. }
  27644. public function addPackage(PackageInterface $package)
  27645. {
  27646. if (!$package instanceof CompletePackage) {
  27647. throw new \UnexpectedValueException('Expected CompletePackage but got '.get_class($package));
  27648. }
  27649. if (isset($this->overrides[$package->getName()])) {
  27650. if ($this->overrides[$package->getName()]['version'] === false) {
  27651. $this->addDisabledPackage($package);
  27652. return;
  27653. }
  27654. $overrider = $this->findPackage($package->getName(), '*');
  27655. if ($package->getVersion() === $overrider->getVersion()) {
  27656. $actualText = 'same as actual';
  27657. } else {
  27658. $actualText = 'actual: '.$package->getPrettyVersion();
  27659. }
  27660. if ($overrider instanceof CompletePackageInterface) {
  27661. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  27662. }
  27663. return;
  27664. }
  27665. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  27666. if (isset($this->overrides[$package->getName()]) && $this->overrides[$package->getName()]['version'] === false) {
  27667. $this->addDisabledPackage($package);
  27668. return;
  27669. }
  27670. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  27671. if ($package->getVersion() === $overrider->getVersion()) {
  27672. $actualText = 'same as actual';
  27673. } else {
  27674. $actualText = 'actual: '.$package->getPrettyVersion();
  27675. }
  27676. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  27677. return;
  27678. }
  27679. parent::addPackage($package);
  27680. }
  27681. private function addOverriddenPackage(array $override, $name = null)
  27682. {
  27683. $version = $this->versionParser->normalize($override['version']);
  27684. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  27685. $package->setDescription('Package overridden via config.platform');
  27686. $package->setExtra(array('config.platform' => true));
  27687. parent::addPackage($package);
  27688. if ($package->getName() === 'php') {
  27689. self::$lastSeenPlatformPhp = implode('.', array_slice(explode('.', $package->getVersion()), 0, 3));
  27690. }
  27691. return $package;
  27692. }
  27693. private function addDisabledPackage(CompletePackage $package)
  27694. {
  27695. $package->setDescription($package->getDescription().'. <warning>Package disabled via config.platform</warning>');
  27696. $package->setExtra(array('config.platform' => true));
  27697. $this->disabledPackages[$package->getName()] = $package;
  27698. }
  27699. private function addExtension($name, $prettyVersion)
  27700. {
  27701. $extraDescription = null;
  27702. try {
  27703. $version = $this->versionParser->normalize($prettyVersion);
  27704. } catch (\UnexpectedValueException $e) {
  27705. $extraDescription = ' (actual version: '.$prettyVersion.')';
  27706. if (Preg::isMatch('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  27707. $prettyVersion = $match[1];
  27708. } else {
  27709. $prettyVersion = '0';
  27710. }
  27711. $version = $this->versionParser->normalize($prettyVersion);
  27712. }
  27713. $packageName = $this->buildPackageName($name);
  27714. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  27715. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  27716. if ($name === 'uuid') {
  27717. $ext->setReplaces(array(
  27718. 'lib-uuid' => new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  27719. ));
  27720. }
  27721. $this->addPackage($ext);
  27722. }
  27723. private function buildPackageName($name)
  27724. {
  27725. return 'ext-' . str_replace(' ', '-', strtolower($name));
  27726. }
  27727. private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
  27728. {
  27729. try {
  27730. $version = $this->versionParser->normalize($prettyVersion);
  27731. } catch (\UnexpectedValueException $e) {
  27732. return;
  27733. }
  27734. if ($description === null) {
  27735. $description = 'The '.$name.' library';
  27736. }
  27737. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  27738. $lib->setDescription($description);
  27739. $replaceLinks = array();
  27740. foreach ($replaces as $replace) {
  27741. $replace = strtolower($replace);
  27742. $replaceLinks[$replace] = new Link('lib-'.$name, 'lib-'.$replace, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  27743. }
  27744. $provideLinks = array();
  27745. foreach ($provides as $provide) {
  27746. $provide = strtolower($provide);
  27747. $provideLinks[$provide] = new Link('lib-'.$name, 'lib-'.$provide, new Constraint('=', $version), Link::TYPE_PROVIDE, $lib->getPrettyVersion());
  27748. }
  27749. $lib->setReplaces($replaceLinks);
  27750. $lib->setProvides($provideLinks);
  27751. $this->addPackage($lib);
  27752. }
  27753. public static function isPlatformPackage($name)
  27754. {
  27755. static $cache = array();
  27756. if (isset($cache[$name])) {
  27757. return $cache[$name];
  27758. }
  27759. return $cache[$name] = Preg::isMatch(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  27760. }
  27761. public static function getPlatformPhpVersion()
  27762. {
  27763. return self::$lastSeenPlatformPhp;
  27764. }
  27765. public function search($query, $mode = 0, $type = null)
  27766. {
  27767. if ($mode === self::SEARCH_VENDOR) {
  27768. return array();
  27769. }
  27770. return parent::search($query, $mode, $type);
  27771. }
  27772. }
  27773. <?php
  27774. namespace Composer\Repository;
  27775. use Composer\Factory;
  27776. use Composer\IO\IOInterface;
  27777. use Composer\Config;
  27778. use Composer\EventDispatcher\EventDispatcher;
  27779. use Composer\Pcre\Preg;
  27780. use Composer\Util\HttpDownloader;
  27781. use Composer\Util\ProcessExecutor;
  27782. use Composer\Json\JsonFile;
  27783. class RepositoryFactory
  27784. {
  27785. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  27786. {
  27787. if (0 === strpos($repository, 'http')) {
  27788. $repoConfig = array('type' => 'composer', 'url' => $repository);
  27789. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  27790. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  27791. $data = $json->read();
  27792. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  27793. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  27794. } elseif ($allowFilesystem) {
  27795. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  27796. } else {
  27797. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  27798. }
  27799. } elseif (strpos($repository, '{') === 0) {
  27800. $repoConfig = JsonFile::parseJson($repository);
  27801. } else {
  27802. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  27803. }
  27804. return $repoConfig;
  27805. }
  27806. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
  27807. {
  27808. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  27809. return static::createRepo($io, $config, $repoConfig, $rm);
  27810. }
  27811. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
  27812. {
  27813. if (!$rm) {
  27814. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  27815. }
  27816. $repos = self::createRepos($rm, array($repoConfig));
  27817. return reset($repos);
  27818. }
  27819. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  27820. {
  27821. if (!$config) {
  27822. $config = Factory::createConfig($io);
  27823. }
  27824. if ($io) {
  27825. $io->loadConfiguration($config);
  27826. }
  27827. if (!$rm) {
  27828. if (!$io) {
  27829. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  27830. }
  27831. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  27832. }
  27833. return self::createRepos($rm, $config->getRepositories());
  27834. }
  27835. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  27836. {
  27837. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  27838. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  27839. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  27840. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  27841. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  27842. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  27843. $rm->setRepositoryClass('bitbucket', 'Composer\Repository\VcsRepository');
  27844. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  27845. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  27846. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  27847. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  27848. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  27849. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  27850. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  27851. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  27852. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  27853. return $rm;
  27854. }
  27855. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  27856. {
  27857. $repos = array();
  27858. foreach ($repoConfigs as $index => $repo) {
  27859. if (is_string($repo)) {
  27860. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  27861. }
  27862. if (!is_array($repo)) {
  27863. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  27864. }
  27865. if (!isset($repo['type'])) {
  27866. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  27867. }
  27868. $name = self::generateRepositoryName($index, $repo, $repos);
  27869. if ($repo['type'] === 'filesystem') {
  27870. $repos[$name] = new FilesystemRepository($repo['json']);
  27871. } else {
  27872. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  27873. }
  27874. }
  27875. return $repos;
  27876. }
  27877. public static function generateRepositoryName($index, array $repo, array $existingRepos)
  27878. {
  27879. $name = is_int($index) && isset($repo['url']) ? Preg::replace('{^https?://}i', '', $repo['url']) : $index;
  27880. while (isset($existingRepos[$name])) {
  27881. $name .= '2';
  27882. }
  27883. return $name;
  27884. }
  27885. }
  27886. <?php
  27887. namespace Composer\Repository;
  27888. use Composer\Package\PackageInterface;
  27889. use Composer\Package\BasePackage;
  27890. use Composer\Semver\Constraint\ConstraintInterface;
  27891. interface RepositoryInterface extends \Countable
  27892. {
  27893. const SEARCH_FULLTEXT = 0;
  27894. const SEARCH_NAME = 1;
  27895. const SEARCH_VENDOR = 2;
  27896. public function hasPackage(PackageInterface $package);
  27897. public function findPackage($name, $constraint);
  27898. public function findPackages($name, $constraint = null);
  27899. public function getPackages();
  27900. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  27901. public function search($query, $mode = 0, $type = null);
  27902. public function getProviders($packageName);
  27903. public function getRepoName();
  27904. }
  27905. <?php
  27906. namespace Composer\Repository;
  27907. use Composer\IO\IOInterface;
  27908. use Composer\Config;
  27909. use Composer\EventDispatcher\EventDispatcher;
  27910. use Composer\Package\PackageInterface;
  27911. use Composer\Util\HttpDownloader;
  27912. use Composer\Util\ProcessExecutor;
  27913. class RepositoryManager
  27914. {
  27915. private $localRepository;
  27916. private $repositories = array();
  27917. private $repositoryClasses = array();
  27918. private $io;
  27919. private $config;
  27920. private $httpDownloader;
  27921. private $eventDispatcher;
  27922. private $process;
  27923. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  27924. {
  27925. $this->io = $io;
  27926. $this->config = $config;
  27927. $this->httpDownloader = $httpDownloader;
  27928. $this->eventDispatcher = $eventDispatcher;
  27929. $this->process = $process ?: new ProcessExecutor($io);
  27930. }
  27931. public function findPackage($name, $constraint)
  27932. {
  27933. foreach ($this->repositories as $repository) {
  27934. if ($package = $repository->findPackage($name, $constraint)) {
  27935. return $package;
  27936. }
  27937. }
  27938. return null;
  27939. }
  27940. public function findPackages($name, $constraint)
  27941. {
  27942. $packages = array();
  27943. foreach ($this->getRepositories() as $repository) {
  27944. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  27945. }
  27946. return $packages;
  27947. }
  27948. public function addRepository(RepositoryInterface $repository)
  27949. {
  27950. $this->repositories[] = $repository;
  27951. }
  27952. public function prependRepository(RepositoryInterface $repository)
  27953. {
  27954. array_unshift($this->repositories, $repository);
  27955. }
  27956. public function createRepository($type, $config, $name = null)
  27957. {
  27958. if (!isset($this->repositoryClasses[$type])) {
  27959. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  27960. }
  27961. if (isset($config['packagist']) && false === $config['packagist']) {
  27962. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  27963. }
  27964. $class = $this->repositoryClasses[$type];
  27965. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  27966. $filterConfig = $config;
  27967. unset($config['only'], $config['exclude'], $config['canonical']);
  27968. }
  27969. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  27970. if (isset($filterConfig)) {
  27971. $repository = new FilterRepository($repository, $filterConfig);
  27972. }
  27973. return $repository;
  27974. }
  27975. public function setRepositoryClass($type, $class)
  27976. {
  27977. $this->repositoryClasses[$type] = $class;
  27978. }
  27979. public function getRepositories()
  27980. {
  27981. return $this->repositories;
  27982. }
  27983. public function setLocalRepository(InstalledRepositoryInterface $repository)
  27984. {
  27985. $this->localRepository = $repository;
  27986. }
  27987. public function getLocalRepository()
  27988. {
  27989. return $this->localRepository;
  27990. }
  27991. }
  27992. <?php
  27993. namespace Composer\Repository;
  27994. class RepositorySecurityException extends \Exception
  27995. {
  27996. }
  27997. <?php
  27998. namespace Composer\Repository;
  27999. use Composer\DependencyResolver\PoolOptimizer;
  28000. use Composer\DependencyResolver\PolicyInterface;
  28001. use Composer\DependencyResolver\Pool;
  28002. use Composer\DependencyResolver\PoolBuilder;
  28003. use Composer\DependencyResolver\Request;
  28004. use Composer\EventDispatcher\EventDispatcher;
  28005. use Composer\IO\IOInterface;
  28006. use Composer\IO\NullIO;
  28007. use Composer\Package\BasePackage;
  28008. use Composer\Package\AliasPackage;
  28009. use Composer\Package\CompleteAliasPackage;
  28010. use Composer\Package\CompletePackage;
  28011. use Composer\Semver\Constraint\ConstraintInterface;
  28012. use Composer\Package\Version\StabilityFilter;
  28013. class RepositorySet
  28014. {
  28015. const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  28016. const ALLOW_SHADOWED_REPOSITORIES = 2;
  28017. private $rootAliases;
  28018. private $rootReferences;
  28019. private $repositories = array();
  28020. private $acceptableStabilities;
  28021. private $stabilityFlags;
  28022. private $rootRequires;
  28023. private $locked = false;
  28024. private $allowInstalledRepositories = false;
  28025. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  28026. {
  28027. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  28028. $this->rootReferences = $rootReferences;
  28029. $this->acceptableStabilities = array();
  28030. foreach (BasePackage::$stabilities as $stability => $value) {
  28031. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  28032. $this->acceptableStabilities[$stability] = $value;
  28033. }
  28034. }
  28035. $this->stabilityFlags = $stabilityFlags;
  28036. $this->rootRequires = $rootRequires;
  28037. foreach ($rootRequires as $name => $constraint) {
  28038. if (PlatformRepository::isPlatformPackage($name)) {
  28039. unset($this->rootRequires[$name]);
  28040. }
  28041. }
  28042. }
  28043. public function allowInstalledRepositories($allow = true)
  28044. {
  28045. $this->allowInstalledRepositories = $allow;
  28046. }
  28047. public function getRootRequires()
  28048. {
  28049. return $this->rootRequires;
  28050. }
  28051. public function addRepository(RepositoryInterface $repo)
  28052. {
  28053. if ($this->locked) {
  28054. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  28055. }
  28056. if ($repo instanceof CompositeRepository) {
  28057. $repos = $repo->getRepositories();
  28058. } else {
  28059. $repos = array($repo);
  28060. }
  28061. foreach ($repos as $repo) {
  28062. $this->repositories[] = $repo;
  28063. }
  28064. }
  28065. public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
  28066. {
  28067. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  28068. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  28069. $packages = array();
  28070. if ($loadFromAllRepos) {
  28071. foreach ($this->repositories as $repository) {
  28072. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  28073. }
  28074. } else {
  28075. foreach ($this->repositories as $repository) {
  28076. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  28077. $packages[] = $result['packages'];
  28078. foreach ($result['namesFound'] as $nameFound) {
  28079. if ($name === $nameFound) {
  28080. break 2;
  28081. }
  28082. }
  28083. }
  28084. }
  28085. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  28086. if ($ignoreStability || !$loadFromAllRepos) {
  28087. return $candidates;
  28088. }
  28089. $result = array();
  28090. foreach ($candidates as $candidate) {
  28091. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  28092. $result[] = $candidate;
  28093. }
  28094. }
  28095. return $result;
  28096. }
  28097. public function getProviders($packageName)
  28098. {
  28099. $providers = array();
  28100. foreach ($this->repositories as $repository) {
  28101. if ($repoProviders = $repository->getProviders($packageName)) {
  28102. $providers = array_merge($providers, $repoProviders);
  28103. }
  28104. }
  28105. return $providers;
  28106. }
  28107. public function isPackageAcceptable($names, $stability)
  28108. {
  28109. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  28110. }
  28111. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null, PoolOptimizer $poolOptimizer = null)
  28112. {
  28113. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher, $poolOptimizer);
  28114. foreach ($this->repositories as $repo) {
  28115. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  28116. throw new \LogicException('The pool can not accept packages from an installed repository');
  28117. }
  28118. }
  28119. $this->locked = true;
  28120. return $poolBuilder->buildPool($this->repositories, $request);
  28121. }
  28122. public function createPoolWithAllPackages()
  28123. {
  28124. foreach ($this->repositories as $repo) {
  28125. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  28126. throw new \LogicException('The pool can not accept packages from an installed repository');
  28127. }
  28128. }
  28129. $this->locked = true;
  28130. $packages = array();
  28131. foreach ($this->repositories as $repository) {
  28132. foreach ($repository->getPackages() as $package) {
  28133. $packages[] = $package;
  28134. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  28135. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  28136. while ($package instanceof AliasPackage) {
  28137. $package = $package->getAliasOf();
  28138. }
  28139. if ($package instanceof CompletePackage) {
  28140. $aliasPackage = new CompleteAliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  28141. } else {
  28142. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  28143. }
  28144. $aliasPackage->setRootPackageAlias(true);
  28145. $packages[] = $aliasPackage;
  28146. }
  28147. }
  28148. }
  28149. return new Pool($packages);
  28150. }
  28151. public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
  28152. {
  28153. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  28154. }
  28155. public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
  28156. {
  28157. $request = new Request($lockedRepo);
  28158. foreach ($packageNames as $packageName) {
  28159. if (PlatformRepository::isPlatformPackage($packageName)) {
  28160. 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.');
  28161. }
  28162. $request->requireName($packageName);
  28163. }
  28164. return $this->createPool($request, new NullIO());
  28165. }
  28166. private static function getRootAliasesPerPackage(array $aliases)
  28167. {
  28168. $normalizedAliases = array();
  28169. foreach ($aliases as $alias) {
  28170. $normalizedAliases[$alias['package']][$alias['version']] = array(
  28171. 'alias' => $alias['alias'],
  28172. 'alias_normalized' => $alias['alias_normalized'],
  28173. );
  28174. }
  28175. return $normalizedAliases;
  28176. }
  28177. }
  28178. <?php
  28179. namespace Composer\Repository;
  28180. use Composer\Package\RootPackageInterface;
  28181. class RootPackageRepository extends ArrayRepository
  28182. {
  28183. public function __construct(RootPackageInterface $package)
  28184. {
  28185. parent::__construct(array($package));
  28186. }
  28187. public function getRepoName()
  28188. {
  28189. return 'root package repo';
  28190. }
  28191. }
  28192. <?php
  28193. namespace Composer\Repository\Vcs;
  28194. use Composer\Cache;
  28195. use Composer\Config;
  28196. use Composer\Pcre\Preg;
  28197. use Composer\Util\ProcessExecutor;
  28198. use Composer\Util\Filesystem;
  28199. use Composer\IO\IOInterface;
  28200. class FossilDriver extends VcsDriver
  28201. {
  28202. protected $tags;
  28203. protected $branches;
  28204. protected $rootIdentifier = null;
  28205. protected $repoFile = null;
  28206. protected $checkoutDir;
  28207. public function initialize()
  28208. {
  28209. $this->checkFossil();
  28210. $this->config->prohibitUrlByConfig($this->url, $this->io);
  28211. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  28212. $this->checkoutDir = $this->url;
  28213. } else {
  28214. if (!Cache::isUsable((string) $this->config->get('cache-repo-dir')) || !Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  28215. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  28216. }
  28217. $localName = Preg::replace('{[^a-z0-9]}i', '-', $this->url);
  28218. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  28219. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  28220. $this->updateLocalRepo();
  28221. }
  28222. $this->getTags();
  28223. $this->getBranches();
  28224. }
  28225. protected function checkFossil()
  28226. {
  28227. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  28228. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  28229. }
  28230. }
  28231. protected function updateLocalRepo()
  28232. {
  28233. $fs = new Filesystem();
  28234. $fs->ensureDirectoryExists($this->checkoutDir);
  28235. if (!is_writable(dirname($this->checkoutDir))) {
  28236. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  28237. }
  28238. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  28239. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  28240. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  28241. }
  28242. } else {
  28243. $fs->removeDirectory($this->checkoutDir);
  28244. $fs->remove($this->repoFile);
  28245. $fs->ensureDirectoryExists($this->checkoutDir);
  28246. if (0 !== $this->process->execute(sprintf('fossil clone -- %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  28247. $output = $this->process->getErrorOutput();
  28248. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  28249. }
  28250. if (0 !== $this->process->execute(sprintf('fossil open --nested -- %s', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  28251. $output = $this->process->getErrorOutput();
  28252. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  28253. }
  28254. }
  28255. }
  28256. public function getRootIdentifier()
  28257. {
  28258. if (null === $this->rootIdentifier) {
  28259. $this->rootIdentifier = 'trunk';
  28260. }
  28261. return $this->rootIdentifier;
  28262. }
  28263. public function getUrl()
  28264. {
  28265. return $this->url;
  28266. }
  28267. public function getSource($identifier)
  28268. {
  28269. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  28270. }
  28271. public function getDist($identifier)
  28272. {
  28273. return null;
  28274. }
  28275. public function getFileContent($file, $identifier)
  28276. {
  28277. $command = sprintf('fossil cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  28278. $this->process->execute($command, $content, $this->checkoutDir);
  28279. if (!trim($content)) {
  28280. return null;
  28281. }
  28282. return $content;
  28283. }
  28284. public function getChangeDate($identifier)
  28285. {
  28286. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  28287. list(, $date) = explode(' ', trim($output), 3);
  28288. return new \DateTime($date, new \DateTimeZone('UTC'));
  28289. }
  28290. public function getTags()
  28291. {
  28292. if (null === $this->tags) {
  28293. $tags = array();
  28294. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  28295. foreach ($this->process->splitLines($output) as $tag) {
  28296. $tags[$tag] = $tag;
  28297. }
  28298. $this->tags = $tags;
  28299. }
  28300. return $this->tags;
  28301. }
  28302. public function getBranches()
  28303. {
  28304. if (null === $this->branches) {
  28305. $branches = array();
  28306. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  28307. foreach ($this->process->splitLines($output) as $branch) {
  28308. $branch = trim(Preg::replace('/^\*/', '', trim($branch)));
  28309. $branches[$branch] = $branch;
  28310. }
  28311. $this->branches = $branches;
  28312. }
  28313. return $this->branches;
  28314. }
  28315. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28316. {
  28317. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  28318. return true;
  28319. }
  28320. if (Preg::isMatch('!/fossil/|\.fossil!', $url)) {
  28321. return true;
  28322. }
  28323. if (Filesystem::isLocalPath($url)) {
  28324. $url = Filesystem::getPlatformPath($url);
  28325. if (!is_dir($url)) {
  28326. return false;
  28327. }
  28328. $process = new ProcessExecutor($io);
  28329. if ($process->execute('fossil info', $output, $url) === 0) {
  28330. return true;
  28331. }
  28332. }
  28333. return false;
  28334. }
  28335. }
  28336. <?php
  28337. namespace Composer\Repository\Vcs;
  28338. use Composer\Config;
  28339. use Composer\IO\IOInterface;
  28340. use Composer\Cache;
  28341. use Composer\Downloader\TransportException;
  28342. use Composer\Json\JsonFile;
  28343. use Composer\Pcre\Preg;
  28344. use Composer\Util\Bitbucket;
  28345. use Composer\Util\Http\Response;
  28346. class GitBitbucketDriver extends VcsDriver
  28347. {
  28348. protected $owner;
  28349. protected $repository;
  28350. private $hasIssues = false;
  28351. private $rootIdentifier;
  28352. private $tags;
  28353. private $branches;
  28354. private $branchesUrl = '';
  28355. private $tagsUrl = '';
  28356. private $homeUrl = '';
  28357. private $website = '';
  28358. private $cloneHttpsUrl = '';
  28359. protected $fallbackDriver = null;
  28360. private $vcsType;
  28361. public function initialize()
  28362. {
  28363. Preg::match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $this->url, $match);
  28364. $this->owner = $match[1];
  28365. $this->repository = $match[2];
  28366. $this->originUrl = 'bitbucket.org';
  28367. $this->cache = new Cache(
  28368. $this->io,
  28369. implode('/', array(
  28370. $this->config->get('cache-repo-dir'),
  28371. $this->originUrl,
  28372. $this->owner,
  28373. $this->repository,
  28374. ))
  28375. );
  28376. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  28377. }
  28378. public function getUrl()
  28379. {
  28380. if ($this->fallbackDriver) {
  28381. return $this->fallbackDriver->getUrl();
  28382. }
  28383. return $this->cloneHttpsUrl;
  28384. }
  28385. protected function getRepoData()
  28386. {
  28387. $resource = sprintf(
  28388. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  28389. $this->owner,
  28390. $this->repository,
  28391. http_build_query(
  28392. array('fields' => '-project,-owner'),
  28393. '',
  28394. '&'
  28395. )
  28396. );
  28397. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  28398. if ($this->fallbackDriver) {
  28399. return false;
  28400. }
  28401. $this->parseCloneUrls($repoData['links']['clone']);
  28402. $this->hasIssues = !empty($repoData['has_issues']);
  28403. $this->branchesUrl = $repoData['links']['branches']['href'];
  28404. $this->tagsUrl = $repoData['links']['tags']['href'];
  28405. $this->homeUrl = $repoData['links']['html']['href'];
  28406. $this->website = $repoData['website'];
  28407. $this->vcsType = $repoData['scm'];
  28408. return true;
  28409. }
  28410. public function getComposerInformation($identifier)
  28411. {
  28412. if ($this->fallbackDriver) {
  28413. return $this->fallbackDriver->getComposerInformation($identifier);
  28414. }
  28415. if (!isset($this->infoCache[$identifier])) {
  28416. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  28417. $composer = JsonFile::parseJson($res);
  28418. } else {
  28419. $composer = $this->getBaseComposerInformation($identifier);
  28420. if ($this->shouldCache($identifier)) {
  28421. $this->cache->write($identifier, json_encode($composer));
  28422. }
  28423. }
  28424. if ($composer) {
  28425. if (!isset($composer['support']['source'])) {
  28426. $label = array_search(
  28427. $identifier,
  28428. $this->getTags()
  28429. ) ?: array_search(
  28430. $identifier,
  28431. $this->getBranches()
  28432. ) ?: $identifier;
  28433. if (array_key_exists($label, $tags = $this->getTags())) {
  28434. $hash = $tags[$label];
  28435. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  28436. $hash = $branches[$label];
  28437. }
  28438. if (!isset($hash)) {
  28439. $composer['support']['source'] = sprintf(
  28440. 'https://%s/%s/%s/src',
  28441. $this->originUrl,
  28442. $this->owner,
  28443. $this->repository
  28444. );
  28445. } else {
  28446. $composer['support']['source'] = sprintf(
  28447. 'https://%s/%s/%s/src/%s/?at=%s',
  28448. $this->originUrl,
  28449. $this->owner,
  28450. $this->repository,
  28451. $hash,
  28452. $label
  28453. );
  28454. }
  28455. }
  28456. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  28457. $composer['support']['issues'] = sprintf(
  28458. 'https://%s/%s/%s/issues',
  28459. $this->originUrl,
  28460. $this->owner,
  28461. $this->repository
  28462. );
  28463. }
  28464. if (!isset($composer['homepage'])) {
  28465. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  28466. }
  28467. }
  28468. $this->infoCache[$identifier] = $composer;
  28469. }
  28470. return $this->infoCache[$identifier];
  28471. }
  28472. public function getFileContent($file, $identifier)
  28473. {
  28474. if ($this->fallbackDriver) {
  28475. return $this->fallbackDriver->getFileContent($file, $identifier);
  28476. }
  28477. if (strpos($identifier, '/') !== false) {
  28478. $branches = $this->getBranches();
  28479. if (isset($branches[$identifier])) {
  28480. $identifier = $branches[$identifier];
  28481. }
  28482. }
  28483. $resource = sprintf(
  28484. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  28485. $this->owner,
  28486. $this->repository,
  28487. $identifier,
  28488. $file
  28489. );
  28490. return $this->fetchWithOAuthCredentials($resource)->getBody();
  28491. }
  28492. public function getChangeDate($identifier)
  28493. {
  28494. if ($this->fallbackDriver) {
  28495. return $this->fallbackDriver->getChangeDate($identifier);
  28496. }
  28497. if (strpos($identifier, '/') !== false) {
  28498. $branches = $this->getBranches();
  28499. if (isset($branches[$identifier])) {
  28500. $identifier = $branches[$identifier];
  28501. }
  28502. }
  28503. $resource = sprintf(
  28504. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  28505. $this->owner,
  28506. $this->repository,
  28507. $identifier
  28508. );
  28509. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  28510. return new \DateTime($commit['date']);
  28511. }
  28512. public function getSource($identifier)
  28513. {
  28514. if ($this->fallbackDriver) {
  28515. return $this->fallbackDriver->getSource($identifier);
  28516. }
  28517. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  28518. }
  28519. public function getDist($identifier)
  28520. {
  28521. if ($this->fallbackDriver) {
  28522. return $this->fallbackDriver->getDist($identifier);
  28523. }
  28524. $url = sprintf(
  28525. 'https://bitbucket.org/%s/%s/get/%s.zip',
  28526. $this->owner,
  28527. $this->repository,
  28528. $identifier
  28529. );
  28530. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  28531. }
  28532. public function getTags()
  28533. {
  28534. if ($this->fallbackDriver) {
  28535. return $this->fallbackDriver->getTags();
  28536. }
  28537. if (null === $this->tags) {
  28538. $tags = array();
  28539. $resource = sprintf(
  28540. '%s?%s',
  28541. $this->tagsUrl,
  28542. http_build_query(
  28543. array(
  28544. 'pagelen' => 100,
  28545. 'fields' => 'values.name,values.target.hash,next',
  28546. 'sort' => '-target.date',
  28547. ),
  28548. '',
  28549. '&'
  28550. )
  28551. );
  28552. $hasNext = true;
  28553. while ($hasNext) {
  28554. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  28555. foreach ($tagsData['values'] as $data) {
  28556. $tags[$data['name']] = $data['target']['hash'];
  28557. }
  28558. if (empty($tagsData['next'])) {
  28559. $hasNext = false;
  28560. } else {
  28561. $resource = $tagsData['next'];
  28562. }
  28563. }
  28564. $this->tags = $tags;
  28565. }
  28566. return $this->tags;
  28567. }
  28568. public function getBranches()
  28569. {
  28570. if ($this->fallbackDriver) {
  28571. return $this->fallbackDriver->getBranches();
  28572. }
  28573. if (null === $this->branches) {
  28574. $branches = array();
  28575. $resource = sprintf(
  28576. '%s?%s',
  28577. $this->branchesUrl,
  28578. http_build_query(
  28579. array(
  28580. 'pagelen' => 100,
  28581. 'fields' => 'values.name,values.target.hash,values.heads,next',
  28582. 'sort' => '-target.date',
  28583. ),
  28584. '',
  28585. '&'
  28586. )
  28587. );
  28588. $hasNext = true;
  28589. while ($hasNext) {
  28590. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  28591. foreach ($branchData['values'] as $data) {
  28592. $branches[$data['name']] = $data['target']['hash'];
  28593. }
  28594. if (empty($branchData['next'])) {
  28595. $hasNext = false;
  28596. } else {
  28597. $resource = $branchData['next'];
  28598. }
  28599. }
  28600. $this->branches = $branches;
  28601. }
  28602. return $this->branches;
  28603. }
  28604. protected function fetchWithOAuthCredentials($url, $fetchingRepoData = false)
  28605. {
  28606. try {
  28607. return parent::getContents($url);
  28608. } catch (TransportException $e) {
  28609. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  28610. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  28611. if (!$this->io->hasAuthentication($this->originUrl)
  28612. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  28613. ) {
  28614. return parent::getContents($url);
  28615. }
  28616. if (!$this->io->isInteractive() && $fetchingRepoData) {
  28617. $this->attemptCloneFallback();
  28618. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  28619. }
  28620. }
  28621. throw $e;
  28622. }
  28623. }
  28624. protected function generateSshUrl()
  28625. {
  28626. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  28627. }
  28628. protected function attemptCloneFallback()
  28629. {
  28630. try {
  28631. $this->setupFallbackDriver($this->generateSshUrl());
  28632. return true;
  28633. } catch (\RuntimeException $e) {
  28634. $this->fallbackDriver = null;
  28635. $this->io->writeError(
  28636. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  28637. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  28638. );
  28639. throw $e;
  28640. }
  28641. }
  28642. protected function setupFallbackDriver($url)
  28643. {
  28644. $this->fallbackDriver = new GitDriver(
  28645. array('url' => $url),
  28646. $this->io,
  28647. $this->config,
  28648. $this->httpDownloader,
  28649. $this->process
  28650. );
  28651. $this->fallbackDriver->initialize();
  28652. }
  28653. protected function parseCloneUrls(array $cloneLinks)
  28654. {
  28655. foreach ($cloneLinks as $cloneLink) {
  28656. if ($cloneLink['name'] === 'https') {
  28657. $this->cloneHttpsUrl = Preg::replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  28658. }
  28659. }
  28660. }
  28661. protected function getMainBranchData()
  28662. {
  28663. $resource = sprintf(
  28664. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  28665. $this->owner,
  28666. $this->repository
  28667. );
  28668. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  28669. if (isset($data['mainbranch'])) {
  28670. return $data['mainbranch'];
  28671. }
  28672. return null;
  28673. }
  28674. public function getRootIdentifier()
  28675. {
  28676. if ($this->fallbackDriver) {
  28677. return $this->fallbackDriver->getRootIdentifier();
  28678. }
  28679. if (null === $this->rootIdentifier) {
  28680. if (!$this->getRepoData()) {
  28681. if (!$this->fallbackDriver) {
  28682. throw new \LogicException('A fallback driver should be setup if getRepoData returns false');
  28683. }
  28684. return $this->fallbackDriver->getRootIdentifier();
  28685. }
  28686. if ($this->vcsType !== 'git') {
  28687. throw new \RuntimeException(
  28688. $this->url.' does not appear to be a git repository, use '.
  28689. $this->cloneHttpsUrl.' but remember that Bitbucket no longer supports the mercurial repositories. '.
  28690. 'https://bitbucket.org/blog/sunsetting-mercurial-support-in-bitbucket'
  28691. );
  28692. }
  28693. $mainBranchData = $this->getMainBranchData();
  28694. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  28695. }
  28696. return $this->rootIdentifier;
  28697. }
  28698. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28699. {
  28700. if (!Preg::isMatch('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)?$#i', $url)) {
  28701. return false;
  28702. }
  28703. if (!extension_loaded('openssl')) {
  28704. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  28705. return false;
  28706. }
  28707. return true;
  28708. }
  28709. }
  28710. <?php
  28711. namespace Composer\Repository\Vcs;
  28712. use Composer\Pcre\Preg;
  28713. use Composer\Util\ProcessExecutor;
  28714. use Composer\Util\Filesystem;
  28715. use Composer\Util\Url;
  28716. use Composer\Util\Git as GitUtil;
  28717. use Composer\IO\IOInterface;
  28718. use Composer\Cache;
  28719. use Composer\Config;
  28720. class GitDriver extends VcsDriver
  28721. {
  28722. protected $tags;
  28723. protected $branches;
  28724. protected $rootIdentifier;
  28725. protected $repoDir;
  28726. public function initialize()
  28727. {
  28728. if (Filesystem::isLocalPath($this->url)) {
  28729. $this->url = Preg::replace('{[\\/]\.git/?$}', '', $this->url);
  28730. if (!is_dir($this->url)) {
  28731. throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist');
  28732. }
  28733. $this->repoDir = $this->url;
  28734. $cacheUrl = realpath($this->url);
  28735. } else {
  28736. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  28737. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  28738. }
  28739. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . Preg::replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  28740. GitUtil::cleanEnv();
  28741. $fs = new Filesystem();
  28742. $fs->ensureDirectoryExists(dirname($this->repoDir));
  28743. if (!is_writable(dirname($this->repoDir))) {
  28744. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  28745. }
  28746. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  28747. 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.');
  28748. }
  28749. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  28750. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  28751. if (!is_dir($this->repoDir)) {
  28752. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  28753. }
  28754. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  28755. }
  28756. $cacheUrl = $this->url;
  28757. }
  28758. $this->getTags();
  28759. $this->getBranches();
  28760. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  28761. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  28762. }
  28763. public function getRootIdentifier()
  28764. {
  28765. if (null === $this->rootIdentifier) {
  28766. $this->rootIdentifier = 'master';
  28767. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  28768. $branches = $this->process->splitLines($output);
  28769. if (!in_array('* master', $branches)) {
  28770. foreach ($branches as $branch) {
  28771. if ($branch && Preg::isMatch('{^\* +(\S+)}', $branch, $match)) {
  28772. $this->rootIdentifier = $match[1];
  28773. break;
  28774. }
  28775. }
  28776. }
  28777. }
  28778. return $this->rootIdentifier;
  28779. }
  28780. public function getUrl()
  28781. {
  28782. return $this->url;
  28783. }
  28784. public function getSource($identifier)
  28785. {
  28786. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  28787. }
  28788. public function getDist($identifier)
  28789. {
  28790. return null;
  28791. }
  28792. public function getFileContent($file, $identifier)
  28793. {
  28794. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  28795. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  28796. if (!trim($content)) {
  28797. return null;
  28798. }
  28799. return $content;
  28800. }
  28801. public function getChangeDate($identifier)
  28802. {
  28803. $this->process->execute(sprintf(
  28804. 'git -c log.showSignature=false log -1 --format=%%at %s',
  28805. ProcessExecutor::escape($identifier)
  28806. ), $output, $this->repoDir);
  28807. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  28808. }
  28809. public function getTags()
  28810. {
  28811. if (null === $this->tags) {
  28812. $this->tags = array();
  28813. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  28814. foreach ($output = $this->process->splitLines($output) as $tag) {
  28815. if ($tag && Preg::isMatch('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  28816. $this->tags[$match[2]] = (string) $match[1];
  28817. }
  28818. }
  28819. }
  28820. return $this->tags;
  28821. }
  28822. public function getBranches()
  28823. {
  28824. if (null === $this->branches) {
  28825. $branches = array();
  28826. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  28827. foreach ($this->process->splitLines($output) as $branch) {
  28828. if ($branch && !Preg::isMatch('{^ *[^/]+/HEAD }', $branch)) {
  28829. if (Preg::isMatch('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  28830. $branches[$match[1]] = $match[2];
  28831. }
  28832. }
  28833. }
  28834. $this->branches = $branches;
  28835. }
  28836. return $this->branches;
  28837. }
  28838. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  28839. {
  28840. if (Preg::isMatch('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  28841. return true;
  28842. }
  28843. if (Filesystem::isLocalPath($url)) {
  28844. $url = Filesystem::getPlatformPath($url);
  28845. if (!is_dir($url)) {
  28846. return false;
  28847. }
  28848. $process = new ProcessExecutor($io);
  28849. if ($process->execute('git tag', $output, $url) === 0) {
  28850. return true;
  28851. }
  28852. }
  28853. if (!$deep) {
  28854. return false;
  28855. }
  28856. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  28857. GitUtil::cleanEnv();
  28858. try {
  28859. $gitUtil->runCommand(function ($url) {
  28860. return 'git ls-remote --heads -- ' . ProcessExecutor::escape($url);
  28861. }, $url, sys_get_temp_dir());
  28862. } catch (\RuntimeException $e) {
  28863. return false;
  28864. }
  28865. return true;
  28866. }
  28867. }
  28868. <?php
  28869. namespace Composer\Repository\Vcs;
  28870. use Composer\Config;
  28871. use Composer\Downloader\TransportException;
  28872. use Composer\Json\JsonFile;
  28873. use Composer\Cache;
  28874. use Composer\IO\IOInterface;
  28875. use Composer\Pcre\Preg;
  28876. use Composer\Util\GitHub;
  28877. use Composer\Util\Http\Response;
  28878. class GitHubDriver extends VcsDriver
  28879. {
  28880. protected $owner;
  28881. protected $repository;
  28882. protected $tags;
  28883. protected $branches;
  28884. protected $rootIdentifier;
  28885. protected $repoData;
  28886. protected $hasIssues = false;
  28887. protected $isPrivate = false;
  28888. private $isArchived = false;
  28889. private $fundingInfo;
  28890. protected $gitDriver = null;
  28891. public function initialize()
  28892. {
  28893. Preg::match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  28894. $this->owner = $match[3];
  28895. $this->repository = $match[4];
  28896. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  28897. if ($this->originUrl === 'www.github.com') {
  28898. $this->originUrl = 'github.com';
  28899. }
  28900. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  28901. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  28902. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  28903. $this->setupGitDriver($this->url);
  28904. return;
  28905. }
  28906. $this->fetchRootIdentifier();
  28907. }
  28908. public function getRepositoryUrl()
  28909. {
  28910. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  28911. }
  28912. public function getRootIdentifier()
  28913. {
  28914. if ($this->gitDriver) {
  28915. return $this->gitDriver->getRootIdentifier();
  28916. }
  28917. return $this->rootIdentifier;
  28918. }
  28919. public function getUrl()
  28920. {
  28921. if ($this->gitDriver) {
  28922. return $this->gitDriver->getUrl();
  28923. }
  28924. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  28925. }
  28926. protected function getApiUrl()
  28927. {
  28928. if ('github.com' === $this->originUrl) {
  28929. $apiUrl = 'api.github.com';
  28930. } else {
  28931. $apiUrl = $this->originUrl . '/api/v3';
  28932. }
  28933. return 'https://' . $apiUrl;
  28934. }
  28935. public function getSource($identifier)
  28936. {
  28937. if ($this->gitDriver) {
  28938. return $this->gitDriver->getSource($identifier);
  28939. }
  28940. if ($this->isPrivate) {
  28941. $url = $this->generateSshUrl();
  28942. } else {
  28943. $url = $this->getUrl();
  28944. }
  28945. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  28946. }
  28947. public function getDist($identifier)
  28948. {
  28949. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  28950. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  28951. }
  28952. public function getComposerInformation($identifier)
  28953. {
  28954. if ($this->gitDriver) {
  28955. return $this->gitDriver->getComposerInformation($identifier);
  28956. }
  28957. if (!isset($this->infoCache[$identifier])) {
  28958. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  28959. $composer = JsonFile::parseJson($res);
  28960. } else {
  28961. $composer = $this->getBaseComposerInformation($identifier);
  28962. if ($this->shouldCache($identifier)) {
  28963. $this->cache->write($identifier, json_encode($composer));
  28964. }
  28965. }
  28966. if ($composer) {
  28967. if (!isset($composer['support']['source'])) {
  28968. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  28969. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  28970. }
  28971. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  28972. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  28973. }
  28974. if (!isset($composer['abandoned']) && $this->isArchived) {
  28975. $composer['abandoned'] = true;
  28976. }
  28977. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  28978. $composer['funding'] = $funding;
  28979. }
  28980. }
  28981. $this->infoCache[$identifier] = $composer;
  28982. }
  28983. return $this->infoCache[$identifier];
  28984. }
  28985. private function getFundingInfo()
  28986. {
  28987. if (null !== $this->fundingInfo) {
  28988. return $this->fundingInfo;
  28989. }
  28990. if ($this->originUrl !== 'github.com') {
  28991. return $this->fundingInfo = false;
  28992. }
  28993. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  28994. try {
  28995. $response = $this->httpDownloader->get($file, array(
  28996. 'retry-auth-failure' => false,
  28997. ))->decodeJson();
  28998. } catch (TransportException $e) {
  28999. continue;
  29000. }
  29001. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  29002. continue;
  29003. }
  29004. break;
  29005. }
  29006. if (empty($funding)) {
  29007. return $this->fundingInfo = false;
  29008. }
  29009. $result = array();
  29010. $key = null;
  29011. foreach (Preg::split('{\r?\n}', $funding) as $line) {
  29012. $line = trim($line);
  29013. if (Preg::isMatch('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  29014. if (Preg::isMatch('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  29015. foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  29016. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  29017. }
  29018. } elseif (Preg::isMatch('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  29019. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  29020. }
  29021. $key = null;
  29022. } elseif (Preg::isMatch('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  29023. $key = $match[1];
  29024. } elseif ($key && Preg::isMatch('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  29025. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  29026. }
  29027. }
  29028. foreach ($result as $key => $item) {
  29029. switch ($item['type']) {
  29030. case 'tidelift':
  29031. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  29032. break;
  29033. case 'github':
  29034. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  29035. break;
  29036. case 'patreon':
  29037. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  29038. break;
  29039. case 'otechie':
  29040. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  29041. break;
  29042. case 'open_collective':
  29043. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  29044. break;
  29045. case 'liberapay':
  29046. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  29047. break;
  29048. case 'ko_fi':
  29049. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  29050. break;
  29051. case 'issuehunt':
  29052. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  29053. break;
  29054. case 'community_bridge':
  29055. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  29056. break;
  29057. }
  29058. }
  29059. return $this->fundingInfo = $result;
  29060. }
  29061. public function getFileContent($file, $identifier)
  29062. {
  29063. if ($this->gitDriver) {
  29064. return $this->gitDriver->getFileContent($file, $identifier);
  29065. }
  29066. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  29067. $resource = $this->getContents($resource)->decodeJson();
  29068. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  29069. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  29070. }
  29071. return $content;
  29072. }
  29073. public function getChangeDate($identifier)
  29074. {
  29075. if ($this->gitDriver) {
  29076. return $this->gitDriver->getChangeDate($identifier);
  29077. }
  29078. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  29079. $commit = $this->getContents($resource)->decodeJson();
  29080. return new \DateTime($commit['commit']['committer']['date']);
  29081. }
  29082. public function getTags()
  29083. {
  29084. if ($this->gitDriver) {
  29085. return $this->gitDriver->getTags();
  29086. }
  29087. if (null === $this->tags) {
  29088. $tags = array();
  29089. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  29090. do {
  29091. $response = $this->getContents($resource);
  29092. $tagsData = $response->decodeJson();
  29093. foreach ($tagsData as $tag) {
  29094. $tags[$tag['name']] = $tag['commit']['sha'];
  29095. }
  29096. $resource = $this->getNextPage($response);
  29097. } while ($resource);
  29098. $this->tags = $tags;
  29099. }
  29100. return $this->tags;
  29101. }
  29102. public function getBranches()
  29103. {
  29104. if ($this->gitDriver) {
  29105. return $this->gitDriver->getBranches();
  29106. }
  29107. if (null === $this->branches) {
  29108. $branches = array();
  29109. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  29110. do {
  29111. $response = $this->getContents($resource);
  29112. $branchData = $response->decodeJson();
  29113. foreach ($branchData as $branch) {
  29114. $name = substr($branch['ref'], 11);
  29115. if ($name !== 'gh-pages') {
  29116. $branches[$name] = $branch['object']['sha'];
  29117. }
  29118. }
  29119. $resource = $this->getNextPage($response);
  29120. } while ($resource);
  29121. $this->branches = $branches;
  29122. }
  29123. return $this->branches;
  29124. }
  29125. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  29126. {
  29127. if (!Preg::isMatch('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  29128. return false;
  29129. }
  29130. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  29131. if (!in_array(strtolower(Preg::replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  29132. return false;
  29133. }
  29134. if (!extension_loaded('openssl')) {
  29135. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  29136. return false;
  29137. }
  29138. return true;
  29139. }
  29140. public function getRepoData()
  29141. {
  29142. $this->fetchRootIdentifier();
  29143. return $this->repoData;
  29144. }
  29145. protected function generateSshUrl()
  29146. {
  29147. if (false !== strpos($this->originUrl, ':')) {
  29148. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  29149. }
  29150. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  29151. }
  29152. protected function getContents($url, $fetchingRepoData = false)
  29153. {
  29154. try {
  29155. return parent::getContents($url);
  29156. } catch (TransportException $e) {
  29157. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  29158. switch ($e->getCode()) {
  29159. case 401:
  29160. case 404:
  29161. if (!$fetchingRepoData) {
  29162. throw $e;
  29163. }
  29164. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  29165. return parent::getContents($url);
  29166. }
  29167. if (!$this->io->isInteractive()) {
  29168. $this->attemptCloneFallback();
  29169. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29170. }
  29171. $scopesIssued = array();
  29172. $scopesNeeded = array();
  29173. if ($headers = $e->getHeaders()) {
  29174. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  29175. $scopesIssued = explode(' ', $scopes);
  29176. }
  29177. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  29178. $scopesNeeded = explode(' ', $scopes);
  29179. }
  29180. }
  29181. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  29182. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  29183. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  29184. }
  29185. return parent::getContents($url);
  29186. case 403:
  29187. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  29188. return parent::getContents($url);
  29189. }
  29190. if (!$this->io->isInteractive() && $fetchingRepoData) {
  29191. $this->attemptCloneFallback();
  29192. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29193. }
  29194. $rateLimited = $gitHubUtil->isRateLimited((array) $e->getHeaders());
  29195. if (!$this->io->hasAuthentication($this->originUrl)) {
  29196. if (!$this->io->isInteractive()) {
  29197. $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>');
  29198. throw $e;
  29199. }
  29200. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  29201. return parent::getContents($url);
  29202. }
  29203. if ($rateLimited) {
  29204. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  29205. $this->io->writeError(sprintf(
  29206. '<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>',
  29207. $rateLimit['limit'],
  29208. $rateLimit['reset']
  29209. ));
  29210. }
  29211. throw $e;
  29212. default:
  29213. throw $e;
  29214. }
  29215. }
  29216. }
  29217. protected function fetchRootIdentifier()
  29218. {
  29219. if ($this->repoData) {
  29220. return;
  29221. }
  29222. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  29223. try {
  29224. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  29225. } catch (TransportException $e) {
  29226. if ($e->getCode() === 499) {
  29227. $this->attemptCloneFallback();
  29228. } else {
  29229. throw $e;
  29230. }
  29231. }
  29232. if (null === $this->repoData && null !== $this->gitDriver) {
  29233. return;
  29234. }
  29235. $this->owner = $this->repoData['owner']['login'];
  29236. $this->repository = $this->repoData['name'];
  29237. $this->isPrivate = !empty($this->repoData['private']);
  29238. if (isset($this->repoData['default_branch'])) {
  29239. $this->rootIdentifier = $this->repoData['default_branch'];
  29240. } elseif (isset($this->repoData['master_branch'])) {
  29241. $this->rootIdentifier = $this->repoData['master_branch'];
  29242. } else {
  29243. $this->rootIdentifier = 'master';
  29244. }
  29245. $this->hasIssues = !empty($this->repoData['has_issues']);
  29246. $this->isArchived = !empty($this->repoData['archived']);
  29247. }
  29248. protected function attemptCloneFallback()
  29249. {
  29250. $this->isPrivate = true;
  29251. try {
  29252. $this->setupGitDriver($this->generateSshUrl());
  29253. return true;
  29254. } catch (\RuntimeException $e) {
  29255. $this->gitDriver = null;
  29256. $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>');
  29257. throw $e;
  29258. }
  29259. }
  29260. protected function setupGitDriver($url)
  29261. {
  29262. $this->gitDriver = new GitDriver(
  29263. array('url' => $url),
  29264. $this->io,
  29265. $this->config,
  29266. $this->httpDownloader,
  29267. $this->process
  29268. );
  29269. $this->gitDriver->initialize();
  29270. }
  29271. protected function getNextPage(Response $response)
  29272. {
  29273. $header = $response->getHeader('link');
  29274. if (!$header) {
  29275. return null;
  29276. }
  29277. $links = explode(',', $header);
  29278. foreach ($links as $link) {
  29279. if (Preg::isMatch('{<(.+?)>; *rel="next"}', $link, $match)) {
  29280. return $match[1];
  29281. }
  29282. }
  29283. return null;
  29284. }
  29285. }
  29286. <?php
  29287. namespace Composer\Repository\Vcs;
  29288. use Composer\Config;
  29289. use Composer\Cache;
  29290. use Composer\IO\IOInterface;
  29291. use Composer\Json\JsonFile;
  29292. use Composer\Downloader\TransportException;
  29293. use Composer\Pcre\Preg;
  29294. use Composer\Util\HttpDownloader;
  29295. use Composer\Util\GitLab;
  29296. use Composer\Util\Http\Response;
  29297. class GitLabDriver extends VcsDriver
  29298. {
  29299. private $scheme;
  29300. private $namespace;
  29301. private $repository;
  29302. private $project;
  29303. private $commits = array();
  29304. private $tags;
  29305. private $branches;
  29306. protected $gitDriver = null;
  29307. protected $protocol;
  29308. private $isPrivate = true;
  29309. private $hasNonstandardOrigin = false;
  29310. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  29311. public function initialize()
  29312. {
  29313. if (!Preg::isMatch(self::URL_REGEX, $this->url, $match)) {
  29314. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  29315. }
  29316. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  29317. $configuredDomains = $this->config->get('gitlab-domains');
  29318. $urlParts = explode('/', $match['parts']);
  29319. $this->scheme = !empty($match['scheme'])
  29320. ? $match['scheme']
  29321. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  29322. ;
  29323. $this->originUrl = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  29324. if ($protocol = $this->config->get('gitlab-protocol')) {
  29325. if (!in_array($protocol, array('git', 'http', 'https'))) {
  29326. throw new \RuntimeException('gitlab-protocol must be one of git, http.');
  29327. }
  29328. $this->protocol = $protocol === 'git' ? 'ssh' : 'http';
  29329. }
  29330. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  29331. $this->hasNonstandardOrigin = true;
  29332. }
  29333. $this->namespace = implode('/', $urlParts);
  29334. $this->repository = Preg::replace('#(\.git)$#', '', $match['repo']);
  29335. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  29336. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  29337. $this->fetchProject();
  29338. }
  29339. public function setHttpDownloader(HttpDownloader $httpDownloader)
  29340. {
  29341. $this->httpDownloader = $httpDownloader;
  29342. }
  29343. public function getComposerInformation($identifier)
  29344. {
  29345. if ($this->gitDriver) {
  29346. return $this->gitDriver->getComposerInformation($identifier);
  29347. }
  29348. if (!isset($this->infoCache[$identifier])) {
  29349. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  29350. $composer = JsonFile::parseJson($res);
  29351. } else {
  29352. $composer = $this->getBaseComposerInformation($identifier);
  29353. if ($this->shouldCache($identifier)) {
  29354. $this->cache->write($identifier, json_encode($composer));
  29355. }
  29356. }
  29357. if ($composer) {
  29358. if (!isset($composer['support']['source']) && isset($this->project['web_url'])) {
  29359. $label = array_search($identifier, $this->getTags(), true) ?: array_search($identifier, $this->getBranches(), true) ?: $identifier;
  29360. $composer['support']['source'] = sprintf('%s/-/tree/%s', $this->project['web_url'], $label);
  29361. }
  29362. if (!isset($composer['support']['issues']) && !empty($this->project['issues_enabled']) && isset($this->project['web_url'])) {
  29363. $composer['support']['issues'] = sprintf('%s/-/issues', $this->project['web_url']);
  29364. }
  29365. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  29366. $composer['abandoned'] = true;
  29367. }
  29368. }
  29369. $this->infoCache[$identifier] = $composer;
  29370. }
  29371. return $this->infoCache[$identifier];
  29372. }
  29373. public function getFileContent($file, $identifier)
  29374. {
  29375. if ($this->gitDriver) {
  29376. return $this->gitDriver->getFileContent($file, $identifier);
  29377. }
  29378. if (!Preg::isMatch('{[a-f0-9]{40}}i', $identifier)) {
  29379. $branches = $this->getBranches();
  29380. if (isset($branches[$identifier])) {
  29381. $identifier = $branches[$identifier];
  29382. }
  29383. }
  29384. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  29385. try {
  29386. $content = $this->getContents($resource)->getBody();
  29387. } catch (TransportException $e) {
  29388. if ($e->getCode() !== 404) {
  29389. throw $e;
  29390. }
  29391. return null;
  29392. }
  29393. return $content;
  29394. }
  29395. public function getChangeDate($identifier)
  29396. {
  29397. if ($this->gitDriver) {
  29398. return $this->gitDriver->getChangeDate($identifier);
  29399. }
  29400. if (isset($this->commits[$identifier])) {
  29401. return new \DateTime($this->commits[$identifier]['committed_date']);
  29402. }
  29403. return new \DateTime();
  29404. }
  29405. public function getRepositoryUrl()
  29406. {
  29407. if ($this->protocol) {
  29408. return $this->project["{$this->protocol}_url_to_repo"];
  29409. }
  29410. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  29411. }
  29412. public function getUrl()
  29413. {
  29414. if ($this->gitDriver) {
  29415. return $this->gitDriver->getUrl();
  29416. }
  29417. return $this->project['web_url'];
  29418. }
  29419. public function getDist($identifier)
  29420. {
  29421. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  29422. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  29423. }
  29424. public function getSource($identifier)
  29425. {
  29426. if ($this->gitDriver) {
  29427. return $this->gitDriver->getSource($identifier);
  29428. }
  29429. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  29430. }
  29431. public function getRootIdentifier()
  29432. {
  29433. if ($this->gitDriver) {
  29434. return $this->gitDriver->getRootIdentifier();
  29435. }
  29436. return $this->project['default_branch'];
  29437. }
  29438. public function getBranches()
  29439. {
  29440. if ($this->gitDriver) {
  29441. return $this->gitDriver->getBranches();
  29442. }
  29443. if (!$this->branches) {
  29444. $this->branches = $this->getReferences('branches');
  29445. }
  29446. return $this->branches;
  29447. }
  29448. public function getTags()
  29449. {
  29450. if ($this->gitDriver) {
  29451. return $this->gitDriver->getTags();
  29452. }
  29453. if (!$this->tags) {
  29454. $this->tags = $this->getReferences('tags');
  29455. }
  29456. return $this->tags;
  29457. }
  29458. public function getApiUrl()
  29459. {
  29460. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  29461. }
  29462. private function urlEncodeAll($string)
  29463. {
  29464. $encoded = '';
  29465. for ($i = 0; isset($string[$i]); $i++) {
  29466. $character = $string[$i];
  29467. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  29468. $character = '%' . sprintf('%02X', ord($character));
  29469. }
  29470. $encoded .= $character;
  29471. }
  29472. return $encoded;
  29473. }
  29474. protected function getReferences($type)
  29475. {
  29476. $perPage = 100;
  29477. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  29478. $references = array();
  29479. do {
  29480. $response = $this->getContents($resource);
  29481. $data = $response->decodeJson();
  29482. foreach ($data as $datum) {
  29483. $references[$datum['name']] = $datum['commit']['id'];
  29484. $this->commits[$datum['commit']['id']] = $datum['commit'];
  29485. }
  29486. if (count($data) >= $perPage) {
  29487. $resource = $this->getNextPage($response);
  29488. } else {
  29489. $resource = false;
  29490. }
  29491. } while ($resource);
  29492. return $references;
  29493. }
  29494. protected function fetchProject()
  29495. {
  29496. $resource = $this->getApiUrl();
  29497. $this->project = $this->getContents($resource, true)->decodeJson();
  29498. if (isset($this->project['visibility'])) {
  29499. $this->isPrivate = $this->project['visibility'] !== 'public';
  29500. } else {
  29501. $this->isPrivate = false;
  29502. }
  29503. }
  29504. protected function attemptCloneFallback()
  29505. {
  29506. if ($this->isPrivate === false) {
  29507. $url = $this->generatePublicUrl();
  29508. } else {
  29509. $url = $this->generateSshUrl();
  29510. }
  29511. try {
  29512. $this->setupGitDriver($url);
  29513. return true;
  29514. } catch (\RuntimeException $e) {
  29515. $this->gitDriver = null;
  29516. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  29517. throw $e;
  29518. }
  29519. }
  29520. protected function generateSshUrl()
  29521. {
  29522. if ($this->hasNonstandardOrigin) {
  29523. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  29524. }
  29525. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  29526. }
  29527. protected function generatePublicUrl()
  29528. {
  29529. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  29530. }
  29531. protected function setupGitDriver($url)
  29532. {
  29533. $this->gitDriver = new GitDriver(
  29534. array('url' => $url),
  29535. $this->io,
  29536. $this->config,
  29537. $this->httpDownloader,
  29538. $this->process
  29539. );
  29540. $this->gitDriver->initialize();
  29541. }
  29542. protected function getContents($url, $fetchingRepoData = false)
  29543. {
  29544. try {
  29545. $response = parent::getContents($url);
  29546. if ($fetchingRepoData) {
  29547. $json = $response->decodeJson();
  29548. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  29549. $this->isPrivate = $json['visibility'] !== 'public';
  29550. $moreThanGuestAccess = false;
  29551. foreach ($json['permissions'] as $permission) {
  29552. if ($permission && $permission['access_level'] > 10) {
  29553. $moreThanGuestAccess = true;
  29554. }
  29555. }
  29556. if (!$moreThanGuestAccess) {
  29557. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  29558. $this->attemptCloneFallback();
  29559. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29560. }
  29561. }
  29562. if (!isset($json['default_branch'])) {
  29563. if (isset($json['repository_access_level']) && $json['repository_access_level'] === 'disabled') {
  29564. throw new TransportException('The GitLab repository is disabled in the project', 400);
  29565. }
  29566. if (!empty($json['id'])) {
  29567. $this->isPrivate = false;
  29568. }
  29569. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  29570. }
  29571. }
  29572. return $response;
  29573. } catch (TransportException $e) {
  29574. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  29575. switch ($e->getCode()) {
  29576. case 401:
  29577. case 404:
  29578. if (!$fetchingRepoData) {
  29579. throw $e;
  29580. }
  29581. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  29582. return parent::getContents($url);
  29583. }
  29584. if (!$this->io->isInteractive()) {
  29585. $this->attemptCloneFallback();
  29586. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29587. }
  29588. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  29589. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  29590. return parent::getContents($url);
  29591. case 403:
  29592. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  29593. return parent::getContents($url);
  29594. }
  29595. if (!$this->io->isInteractive() && $fetchingRepoData) {
  29596. $this->attemptCloneFallback();
  29597. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  29598. }
  29599. throw $e;
  29600. default:
  29601. throw $e;
  29602. }
  29603. }
  29604. }
  29605. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  29606. {
  29607. if (!Preg::isMatch(self::URL_REGEX, $url, $match)) {
  29608. return false;
  29609. }
  29610. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  29611. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  29612. $urlParts = explode('/', $match['parts']);
  29613. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  29614. return false;
  29615. }
  29616. if ('https' === $scheme && !extension_loaded('openssl')) {
  29617. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  29618. return false;
  29619. }
  29620. return true;
  29621. }
  29622. protected function getNextPage(Response $response)
  29623. {
  29624. $header = $response->getHeader('link');
  29625. $links = explode(',', $header);
  29626. foreach ($links as $link) {
  29627. if (Preg::isMatch('{<(.+?)>; *rel="next"}', $link, $match)) {
  29628. return $match[1];
  29629. }
  29630. }
  29631. return null;
  29632. }
  29633. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
  29634. {
  29635. $guessedDomain = strtolower($guessedDomain);
  29636. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  29637. if ($portNumber) {
  29638. return $guessedDomain.':'.$portNumber;
  29639. }
  29640. return $guessedDomain;
  29641. }
  29642. if ($portNumber) {
  29643. $guessedDomain .= ':'.$portNumber;
  29644. }
  29645. while (null !== ($part = array_shift($urlParts))) {
  29646. $guessedDomain .= '/' . $part;
  29647. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array(Preg::replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  29648. return $guessedDomain;
  29649. }
  29650. }
  29651. return false;
  29652. }
  29653. }
  29654. <?php
  29655. namespace Composer\Repository\Vcs;
  29656. use Composer\Config;
  29657. use Composer\Cache;
  29658. use Composer\Pcre\Preg;
  29659. use Composer\Util\Hg as HgUtils;
  29660. use Composer\Util\ProcessExecutor;
  29661. use Composer\Util\Filesystem;
  29662. use Composer\IO\IOInterface;
  29663. class HgDriver extends VcsDriver
  29664. {
  29665. protected $tags;
  29666. protected $branches;
  29667. protected $rootIdentifier;
  29668. protected $repoDir;
  29669. public function initialize()
  29670. {
  29671. if (Filesystem::isLocalPath($this->url)) {
  29672. $this->repoDir = $this->url;
  29673. } else {
  29674. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  29675. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  29676. }
  29677. $cacheDir = $this->config->get('cache-vcs-dir');
  29678. $this->repoDir = $cacheDir . '/' . Preg::replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  29679. $fs = new Filesystem();
  29680. $fs->ensureDirectoryExists($cacheDir);
  29681. if (!is_writable(dirname($this->repoDir))) {
  29682. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  29683. }
  29684. $this->config->prohibitUrlByConfig($this->url, $this->io);
  29685. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  29686. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  29687. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  29688. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  29689. }
  29690. } else {
  29691. $fs->removeDirectory($this->repoDir);
  29692. $repoDir = $this->repoDir;
  29693. $command = function ($url) use ($repoDir) {
  29694. return sprintf('hg clone --noupdate -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  29695. };
  29696. $hgUtils->runCommand($command, $this->url, null);
  29697. }
  29698. }
  29699. $this->getTags();
  29700. $this->getBranches();
  29701. }
  29702. public function getRootIdentifier()
  29703. {
  29704. if (null === $this->rootIdentifier) {
  29705. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  29706. $output = $this->process->splitLines($output);
  29707. $this->rootIdentifier = $output[0];
  29708. }
  29709. return $this->rootIdentifier;
  29710. }
  29711. public function getUrl()
  29712. {
  29713. return $this->url;
  29714. }
  29715. public function getSource($identifier)
  29716. {
  29717. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  29718. }
  29719. public function getDist($identifier)
  29720. {
  29721. return null;
  29722. }
  29723. public function getFileContent($file, $identifier)
  29724. {
  29725. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  29726. $this->process->execute($resource, $content, $this->repoDir);
  29727. if (!trim($content)) {
  29728. return null;
  29729. }
  29730. return $content;
  29731. }
  29732. public function getChangeDate($identifier)
  29733. {
  29734. $this->process->execute(
  29735. sprintf(
  29736. 'hg log --template "{date|rfc3339date}" -r %s',
  29737. ProcessExecutor::escape($identifier)
  29738. ),
  29739. $output,
  29740. $this->repoDir
  29741. );
  29742. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  29743. }
  29744. public function getTags()
  29745. {
  29746. if (null === $this->tags) {
  29747. $tags = array();
  29748. $this->process->execute('hg tags', $output, $this->repoDir);
  29749. foreach ($this->process->splitLines($output) as $tag) {
  29750. if ($tag && Preg::isMatch('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  29751. $tags[$match[1]] = $match[2];
  29752. }
  29753. }
  29754. unset($tags['tip']);
  29755. $this->tags = $tags;
  29756. }
  29757. return $this->tags;
  29758. }
  29759. public function getBranches()
  29760. {
  29761. if (null === $this->branches) {
  29762. $branches = array();
  29763. $bookmarks = array();
  29764. $this->process->execute('hg branches', $output, $this->repoDir);
  29765. foreach ($this->process->splitLines($output) as $branch) {
  29766. if ($branch && Preg::isMatch('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  29767. $branches[$match[1]] = $match[2];
  29768. }
  29769. }
  29770. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  29771. foreach ($this->process->splitLines($output) as $branch) {
  29772. if ($branch && Preg::isMatch('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  29773. $bookmarks[$match[1]] = $match[2];
  29774. }
  29775. }
  29776. $this->branches = array_merge($bookmarks, $branches);
  29777. }
  29778. return $this->branches;
  29779. }
  29780. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  29781. {
  29782. if (Preg::isMatch('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  29783. return true;
  29784. }
  29785. if (Filesystem::isLocalPath($url)) {
  29786. $url = Filesystem::getPlatformPath($url);
  29787. if (!is_dir($url)) {
  29788. return false;
  29789. }
  29790. $process = new ProcessExecutor($io);
  29791. if ($process->execute('hg summary', $output, $url) === 0) {
  29792. return true;
  29793. }
  29794. }
  29795. if (!$deep) {
  29796. return false;
  29797. }
  29798. $process = new ProcessExecutor($io);
  29799. $exit = $process->execute(sprintf('hg identify -- %s', ProcessExecutor::escape($url)), $ignored);
  29800. return $exit === 0;
  29801. }
  29802. }
  29803. <?php
  29804. namespace Composer\Repository\Vcs;
  29805. use Composer\Config;
  29806. use Composer\Cache;
  29807. use Composer\IO\IOInterface;
  29808. use Composer\Pcre\Preg;
  29809. use Composer\Util\ProcessExecutor;
  29810. use Composer\Util\Perforce;
  29811. class PerforceDriver extends VcsDriver
  29812. {
  29813. protected $depot;
  29814. protected $branch;
  29815. protected $perforce = null;
  29816. public function initialize()
  29817. {
  29818. $this->depot = $this->repoConfig['depot'];
  29819. $this->branch = '';
  29820. if (!empty($this->repoConfig['branch'])) {
  29821. $this->branch = $this->repoConfig['branch'];
  29822. }
  29823. $this->initPerforce($this->repoConfig);
  29824. $this->perforce->p4Login();
  29825. $this->perforce->checkStream();
  29826. $this->perforce->writeP4ClientSpec();
  29827. $this->perforce->connectClient();
  29828. }
  29829. private function initPerforce($repoConfig)
  29830. {
  29831. if (!empty($this->perforce)) {
  29832. return;
  29833. }
  29834. if (!Cache::isUsable((string) $this->config->get('cache-vcs-dir'))) {
  29835. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  29836. }
  29837. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  29838. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  29839. }
  29840. public function getFileContent($file, $identifier)
  29841. {
  29842. return $this->perforce->getFileContent($file, $identifier);
  29843. }
  29844. public function getChangeDate($identifier)
  29845. {
  29846. return null;
  29847. }
  29848. public function getRootIdentifier()
  29849. {
  29850. return $this->branch;
  29851. }
  29852. public function getBranches()
  29853. {
  29854. return $this->perforce->getBranches();
  29855. }
  29856. public function getTags()
  29857. {
  29858. return $this->perforce->getTags();
  29859. }
  29860. public function getDist($identifier)
  29861. {
  29862. return null;
  29863. }
  29864. public function getSource($identifier)
  29865. {
  29866. return array(
  29867. 'type' => 'perforce',
  29868. 'url' => $this->repoConfig['url'],
  29869. 'reference' => $identifier,
  29870. 'p4user' => $this->perforce->getUser(),
  29871. );
  29872. }
  29873. public function getUrl()
  29874. {
  29875. return $this->url;
  29876. }
  29877. public function hasComposerFile($identifier)
  29878. {
  29879. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  29880. return !empty($composerInfo);
  29881. }
  29882. public function getContents($url)
  29883. {
  29884. throw new \BadMethodCallException('Not implemented/used in PerforceDriver');
  29885. }
  29886. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  29887. {
  29888. if ($deep || Preg::isMatch('#\b(perforce|p4)\b#i', $url)) {
  29889. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  29890. }
  29891. return false;
  29892. }
  29893. public function cleanup()
  29894. {
  29895. $this->perforce->cleanupClientSpec();
  29896. $this->perforce = null;
  29897. }
  29898. public function getDepot()
  29899. {
  29900. return $this->depot;
  29901. }
  29902. public function getBranch()
  29903. {
  29904. return $this->branch;
  29905. }
  29906. }
  29907. <?php
  29908. namespace Composer\Repository\Vcs;
  29909. use Composer\Cache;
  29910. use Composer\Config;
  29911. use Composer\Json\JsonFile;
  29912. use Composer\Pcre\Preg;
  29913. use Composer\Util\ProcessExecutor;
  29914. use Composer\Util\Filesystem;
  29915. use Composer\Util\Url;
  29916. use Composer\Util\Svn as SvnUtil;
  29917. use Composer\IO\IOInterface;
  29918. use Composer\Downloader\TransportException;
  29919. class SvnDriver extends VcsDriver
  29920. {
  29921. protected $baseUrl;
  29922. protected $tags;
  29923. protected $branches;
  29924. protected $rootIdentifier;
  29925. protected $trunkPath = 'trunk';
  29926. protected $branchesPath = 'branches';
  29927. protected $tagsPath = 'tags';
  29928. protected $packagePath = '';
  29929. protected $cacheCredentials = true;
  29930. private $util;
  29931. public function initialize()
  29932. {
  29933. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  29934. SvnUtil::cleanEnv();
  29935. if (isset($this->repoConfig['trunk-path'])) {
  29936. $this->trunkPath = $this->repoConfig['trunk-path'];
  29937. }
  29938. if (isset($this->repoConfig['branches-path'])) {
  29939. $this->branchesPath = $this->repoConfig['branches-path'];
  29940. }
  29941. if (isset($this->repoConfig['tags-path'])) {
  29942. $this->tagsPath = $this->repoConfig['tags-path'];
  29943. }
  29944. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  29945. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  29946. }
  29947. if (isset($this->repoConfig['package-path'])) {
  29948. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  29949. }
  29950. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  29951. $this->baseUrl = substr($this->url, 0, $pos);
  29952. }
  29953. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.Preg::replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  29954. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  29955. $this->getBranches();
  29956. $this->getTags();
  29957. }
  29958. public function getRootIdentifier()
  29959. {
  29960. return $this->rootIdentifier ?: $this->trunkPath;
  29961. }
  29962. public function getUrl()
  29963. {
  29964. return $this->url;
  29965. }
  29966. public function getSource($identifier)
  29967. {
  29968. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  29969. }
  29970. public function getDist($identifier)
  29971. {
  29972. return null;
  29973. }
  29974. protected function shouldCache($identifier)
  29975. {
  29976. return $this->cache && Preg::isMatch('{@\d+$}', $identifier);
  29977. }
  29978. public function getComposerInformation($identifier)
  29979. {
  29980. if (!isset($this->infoCache[$identifier])) {
  29981. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  29982. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  29983. }
  29984. try {
  29985. $composer = $this->getBaseComposerInformation($identifier);
  29986. } catch (TransportException $e) {
  29987. $message = $e->getMessage();
  29988. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  29989. throw $e;
  29990. }
  29991. $composer = '';
  29992. }
  29993. if ($this->shouldCache($identifier)) {
  29994. $this->cache->write($identifier.'.json', json_encode($composer));
  29995. }
  29996. $this->infoCache[$identifier] = $composer;
  29997. }
  29998. return $this->infoCache[$identifier];
  29999. }
  30000. public function getFileContent($file, $identifier)
  30001. {
  30002. $identifier = '/' . trim($identifier, '/') . '/';
  30003. Preg::match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  30004. if (!empty($match[2])) {
  30005. $path = $match[1];
  30006. $rev = $match[2];
  30007. } else {
  30008. $path = $identifier;
  30009. $rev = '';
  30010. }
  30011. try {
  30012. $resource = $path.$file;
  30013. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  30014. if (!trim($output)) {
  30015. return null;
  30016. }
  30017. } catch (\RuntimeException $e) {
  30018. throw new TransportException($e->getMessage());
  30019. }
  30020. return $output;
  30021. }
  30022. public function getChangeDate($identifier)
  30023. {
  30024. $identifier = '/' . trim($identifier, '/') . '/';
  30025. Preg::match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  30026. if (!empty($match[2])) {
  30027. $path = $match[1];
  30028. $rev = $match[2];
  30029. } else {
  30030. $path = $identifier;
  30031. $rev = '';
  30032. }
  30033. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  30034. foreach ($this->process->splitLines($output) as $line) {
  30035. if ($line && Preg::isMatch('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  30036. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  30037. }
  30038. }
  30039. return null;
  30040. }
  30041. public function getTags()
  30042. {
  30043. if (null === $this->tags) {
  30044. $tags = array();
  30045. if ($this->tagsPath !== false) {
  30046. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  30047. if ($output) {
  30048. foreach ($this->process->splitLines($output) as $line) {
  30049. $line = trim($line);
  30050. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  30051. if (isset($match[1], $match[2]) && $match[2] !== './') {
  30052. $tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  30053. '/' . $this->tagsPath . '/' . $match[2],
  30054. $match[1]
  30055. );
  30056. }
  30057. }
  30058. }
  30059. }
  30060. }
  30061. $this->tags = $tags;
  30062. }
  30063. return $this->tags;
  30064. }
  30065. public function getBranches()
  30066. {
  30067. if (null === $this->branches) {
  30068. $branches = array();
  30069. if (false === $this->trunkPath) {
  30070. $trunkParent = $this->baseUrl . '/';
  30071. } else {
  30072. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  30073. }
  30074. $output = $this->execute('svn ls --verbose', $trunkParent);
  30075. if ($output) {
  30076. foreach ($this->process->splitLines($output) as $line) {
  30077. $line = trim($line);
  30078. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  30079. if (isset($match[1], $match[2]) && $match[2] === './') {
  30080. $branches['trunk'] = $this->buildIdentifier(
  30081. '/' . $this->trunkPath,
  30082. $match[1]
  30083. );
  30084. $this->rootIdentifier = $branches['trunk'];
  30085. break;
  30086. }
  30087. }
  30088. }
  30089. }
  30090. unset($output);
  30091. if ($this->branchesPath !== false) {
  30092. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  30093. if ($output) {
  30094. foreach ($this->process->splitLines(trim($output)) as $line) {
  30095. $line = trim($line);
  30096. if ($line && Preg::isMatch('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  30097. if (isset($match[1], $match[2]) && $match[2] !== './') {
  30098. $branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  30099. '/' . $this->branchesPath . '/' . $match[2],
  30100. $match[1]
  30101. );
  30102. }
  30103. }
  30104. }
  30105. }
  30106. }
  30107. $this->branches = $branches;
  30108. }
  30109. return $this->branches;
  30110. }
  30111. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  30112. {
  30113. $url = self::normalizeUrl($url);
  30114. if (Preg::isMatch('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  30115. return true;
  30116. }
  30117. if (!$deep && !Filesystem::isLocalPath($url)) {
  30118. return false;
  30119. }
  30120. $process = new ProcessExecutor($io);
  30121. $exit = $process->execute(
  30122. "svn info --non-interactive -- ".ProcessExecutor::escape($url),
  30123. $ignoredOutput
  30124. );
  30125. if ($exit === 0) {
  30126. return true;
  30127. }
  30128. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  30129. return true;
  30130. }
  30131. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  30132. return true;
  30133. }
  30134. return false;
  30135. }
  30136. protected static function normalizeUrl($url)
  30137. {
  30138. $fs = new Filesystem();
  30139. if ($fs->isAbsolutePath($url)) {
  30140. return 'file://' . strtr($url, '\\', '/');
  30141. }
  30142. return $url;
  30143. }
  30144. protected function execute($command, $url)
  30145. {
  30146. if (null === $this->util) {
  30147. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  30148. $this->util->setCacheCredentials($this->cacheCredentials);
  30149. }
  30150. try {
  30151. return $this->util->execute($command, $url);
  30152. } catch (\RuntimeException $e) {
  30153. if (null === $this->util->binaryVersion()) {
  30154. 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());
  30155. }
  30156. throw new \RuntimeException(
  30157. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  30158. );
  30159. }
  30160. }
  30161. protected function buildIdentifier($baseDir, $revision)
  30162. {
  30163. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  30164. }
  30165. }
  30166. <?php
  30167. namespace Composer\Repository\Vcs;
  30168. use Composer\Cache;
  30169. use Composer\Downloader\TransportException;
  30170. use Composer\Config;
  30171. use Composer\IO\IOInterface;
  30172. use Composer\Json\JsonFile;
  30173. use Composer\Pcre\Preg;
  30174. use Composer\Util\ProcessExecutor;
  30175. use Composer\Util\HttpDownloader;
  30176. use Composer\Util\Filesystem;
  30177. use Composer\Util\Http\Response;
  30178. abstract class VcsDriver implements VcsDriverInterface
  30179. {
  30180. protected $url;
  30181. protected $originUrl;
  30182. protected $repoConfig;
  30183. protected $io;
  30184. protected $config;
  30185. protected $process;
  30186. protected $httpDownloader;
  30187. protected $infoCache = array();
  30188. protected $cache;
  30189. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  30190. {
  30191. if (Filesystem::isLocalPath($repoConfig['url'])) {
  30192. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  30193. }
  30194. $this->url = $repoConfig['url'];
  30195. $this->originUrl = $repoConfig['url'];
  30196. $this->repoConfig = $repoConfig;
  30197. $this->io = $io;
  30198. $this->config = $config;
  30199. $this->httpDownloader = $httpDownloader;
  30200. $this->process = $process;
  30201. }
  30202. protected function shouldCache($identifier)
  30203. {
  30204. return $this->cache && Preg::isMatch('{^[a-f0-9]{40}$}iD', $identifier);
  30205. }
  30206. public function getComposerInformation($identifier)
  30207. {
  30208. if (!isset($this->infoCache[$identifier])) {
  30209. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  30210. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  30211. }
  30212. $composer = $this->getBaseComposerInformation($identifier);
  30213. if ($this->shouldCache($identifier)) {
  30214. $this->cache->write($identifier, JsonFile::encode($composer, 0));
  30215. }
  30216. $this->infoCache[$identifier] = $composer;
  30217. }
  30218. return $this->infoCache[$identifier];
  30219. }
  30220. protected function getBaseComposerInformation($identifier)
  30221. {
  30222. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  30223. if (!$composerFileContent) {
  30224. return null;
  30225. }
  30226. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  30227. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  30228. $composer['time'] = $changeDate->format(DATE_RFC3339);
  30229. }
  30230. return $composer;
  30231. }
  30232. public function hasComposerFile($identifier)
  30233. {
  30234. try {
  30235. return (bool) $this->getComposerInformation($identifier);
  30236. } catch (TransportException $e) {
  30237. }
  30238. return false;
  30239. }
  30240. protected function getScheme()
  30241. {
  30242. if (extension_loaded('openssl')) {
  30243. return 'https';
  30244. }
  30245. return 'http';
  30246. }
  30247. protected function getContents($url)
  30248. {
  30249. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  30250. return $this->httpDownloader->get($url, $options);
  30251. }
  30252. public function cleanup()
  30253. {
  30254. return;
  30255. }
  30256. }
  30257. <?php
  30258. namespace Composer\Repository\Vcs;
  30259. use Composer\Config;
  30260. use Composer\IO\IOInterface;
  30261. interface VcsDriverInterface
  30262. {
  30263. public function initialize();
  30264. public function getComposerInformation($identifier);
  30265. public function getFileContent($file, $identifier);
  30266. public function getChangeDate($identifier);
  30267. public function getRootIdentifier();
  30268. public function getBranches();
  30269. public function getTags();
  30270. public function getDist($identifier);
  30271. public function getSource($identifier);
  30272. public function getUrl();
  30273. public function hasComposerFile($identifier);
  30274. public function cleanup();
  30275. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  30276. }
  30277. <?php
  30278. namespace Composer\Repository;
  30279. use Composer\Downloader\TransportException;
  30280. use Composer\Pcre\Preg;
  30281. use Composer\Repository\Vcs\VcsDriverInterface;
  30282. use Composer\Package\Version\VersionParser;
  30283. use Composer\Package\Loader\ArrayLoader;
  30284. use Composer\Package\Loader\ValidatingArrayLoader;
  30285. use Composer\Package\Loader\InvalidPackageException;
  30286. use Composer\Package\Loader\LoaderInterface;
  30287. use Composer\EventDispatcher\EventDispatcher;
  30288. use Composer\Util\ProcessExecutor;
  30289. use Composer\Util\HttpDownloader;
  30290. use Composer\Util\Url;
  30291. use Composer\Semver\Constraint\Constraint;
  30292. use Composer\IO\IOInterface;
  30293. use Composer\Config;
  30294. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  30295. {
  30296. protected $url;
  30297. protected $packageName;
  30298. protected $isVerbose;
  30299. protected $isVeryVerbose;
  30300. protected $io;
  30301. protected $config;
  30302. protected $versionParser;
  30303. protected $type;
  30304. protected $loader;
  30305. protected $repoConfig;
  30306. protected $httpDownloader;
  30307. protected $processExecutor;
  30308. protected $branchErrorOccurred = false;
  30309. private $drivers;
  30310. private $driver;
  30311. private $versionCache;
  30312. private $emptyReferences = array();
  30313. private $versionTransportExceptions = array();
  30314. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  30315. {
  30316. parent::__construct();
  30317. $this->drivers = $drivers ?: array(
  30318. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  30319. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  30320. 'bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  30321. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  30322. 'git' => 'Composer\Repository\Vcs\GitDriver',
  30323. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  30324. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  30325. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  30326. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  30327. );
  30328. $this->url = $repoConfig['url'];
  30329. $this->io = $io;
  30330. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  30331. $this->isVerbose = $io->isVerbose();
  30332. $this->isVeryVerbose = $io->isVeryVerbose();
  30333. $this->config = $config;
  30334. $this->repoConfig = $repoConfig;
  30335. $this->versionCache = $versionCache;
  30336. $this->httpDownloader = $httpDownloader;
  30337. $this->processExecutor = $process ?: new ProcessExecutor($io);
  30338. }
  30339. public function getRepoName()
  30340. {
  30341. $driverClass = get_class($this->getDriver());
  30342. $driverType = array_search($driverClass, $this->drivers);
  30343. if (!$driverType) {
  30344. $driverType = $driverClass;
  30345. }
  30346. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  30347. }
  30348. public function getRepoConfig()
  30349. {
  30350. return $this->repoConfig;
  30351. }
  30352. public function setLoader(LoaderInterface $loader)
  30353. {
  30354. $this->loader = $loader;
  30355. }
  30356. public function getDriver()
  30357. {
  30358. if ($this->driver) {
  30359. return $this->driver;
  30360. }
  30361. if (isset($this->drivers[$this->type])) {
  30362. $class = $this->drivers[$this->type];
  30363. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  30364. $this->driver->initialize();
  30365. return $this->driver;
  30366. }
  30367. foreach ($this->drivers as $driver) {
  30368. if ($driver::supports($this->io, $this->config, $this->url)) {
  30369. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  30370. $this->driver->initialize();
  30371. return $this->driver;
  30372. }
  30373. }
  30374. foreach ($this->drivers as $driver) {
  30375. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  30376. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  30377. $this->driver->initialize();
  30378. return $this->driver;
  30379. }
  30380. }
  30381. return null;
  30382. }
  30383. public function hadInvalidBranches()
  30384. {
  30385. return $this->branchErrorOccurred;
  30386. }
  30387. public function getEmptyReferences()
  30388. {
  30389. return $this->emptyReferences;
  30390. }
  30391. public function getVersionTransportExceptions()
  30392. {
  30393. return $this->versionTransportExceptions;
  30394. }
  30395. protected function initialize()
  30396. {
  30397. parent::initialize();
  30398. $isVerbose = $this->isVerbose;
  30399. $isVeryVerbose = $this->isVeryVerbose;
  30400. $driver = $this->getDriver();
  30401. if (!$driver) {
  30402. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  30403. }
  30404. $this->versionParser = new VersionParser;
  30405. if (!$this->loader) {
  30406. $this->loader = new ArrayLoader($this->versionParser);
  30407. }
  30408. $hasRootIdentifierComposerJson = false;
  30409. try {
  30410. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  30411. if ($hasRootIdentifierComposerJson) {
  30412. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  30413. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  30414. }
  30415. } catch (\Exception $e) {
  30416. if ($e instanceof TransportException && $this->shouldRethrowTransportException($e)) {
  30417. throw $e;
  30418. }
  30419. if ($isVeryVerbose) {
  30420. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  30421. }
  30422. }
  30423. foreach ($driver->getTags() as $tag => $identifier) {
  30424. $tag = (string) $tag;
  30425. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  30426. if ($isVeryVerbose) {
  30427. $this->io->writeError($msg);
  30428. } elseif ($isVerbose) {
  30429. $this->io->overwriteError($msg, false);
  30430. }
  30431. $tag = str_replace('release-', '', $tag);
  30432. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  30433. if ($cachedPackage) {
  30434. $this->addPackage($cachedPackage);
  30435. continue;
  30436. }
  30437. if ($cachedPackage === false) {
  30438. $this->emptyReferences[] = $identifier;
  30439. continue;
  30440. }
  30441. if (!$parsedTag = $this->validateTag($tag)) {
  30442. if ($isVeryVerbose) {
  30443. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  30444. }
  30445. continue;
  30446. }
  30447. try {
  30448. if (!$data = $driver->getComposerInformation($identifier)) {
  30449. if ($isVeryVerbose) {
  30450. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  30451. }
  30452. $this->emptyReferences[] = $identifier;
  30453. continue;
  30454. }
  30455. if (isset($data['version'])) {
  30456. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  30457. } else {
  30458. $data['version'] = $tag;
  30459. $data['version_normalized'] = $parsedTag;
  30460. }
  30461. $data['version'] = Preg::replace('{[.-]?dev$}i', '', $data['version']);
  30462. $data['version_normalized'] = Preg::replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  30463. unset($data['default-branch']);
  30464. if ($data['version_normalized'] !== $parsedTag) {
  30465. if ($isVeryVerbose) {
  30466. if (Preg::isMatch('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  30467. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  30468. } else {
  30469. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  30470. }
  30471. }
  30472. continue;
  30473. }
  30474. $tagPackageName = $this->packageName ?: (isset($data['name']) ? $data['name'] : '');
  30475. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  30476. if ($isVeryVerbose) {
  30477. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  30478. }
  30479. continue;
  30480. }
  30481. if ($isVeryVerbose) {
  30482. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  30483. }
  30484. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  30485. } catch (\Exception $e) {
  30486. if ($e instanceof TransportException) {
  30487. $this->versionTransportExceptions['tags'][$tag] = $e;
  30488. if ($e->getCode() === 404) {
  30489. $this->emptyReferences[] = $identifier;
  30490. }
  30491. if ($this->shouldRethrowTransportException($e)) {
  30492. throw $e;
  30493. }
  30494. }
  30495. if ($isVeryVerbose) {
  30496. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  30497. }
  30498. continue;
  30499. }
  30500. }
  30501. if (!$isVeryVerbose) {
  30502. $this->io->overwriteError('', false);
  30503. }
  30504. $branches = $driver->getBranches();
  30505. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  30506. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  30507. }
  30508. foreach ($branches as $branch => $identifier) {
  30509. $branch = (string) $branch;
  30510. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  30511. if ($isVeryVerbose) {
  30512. $this->io->writeError($msg);
  30513. } elseif ($isVerbose) {
  30514. $this->io->overwriteError($msg, false);
  30515. }
  30516. if (!$parsedBranch = $this->validateBranch($branch)) {
  30517. if ($isVeryVerbose) {
  30518. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  30519. }
  30520. continue;
  30521. }
  30522. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  30523. $version = 'dev-' . $branch;
  30524. } else {
  30525. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  30526. $version = $prefix . Preg::replace('{(\.9{7})+}', '.x', $parsedBranch);
  30527. }
  30528. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  30529. if ($cachedPackage) {
  30530. $this->addPackage($cachedPackage);
  30531. continue;
  30532. }
  30533. if ($cachedPackage === false) {
  30534. $this->emptyReferences[] = $identifier;
  30535. continue;
  30536. }
  30537. try {
  30538. if (!$data = $driver->getComposerInformation($identifier)) {
  30539. if ($isVeryVerbose) {
  30540. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  30541. }
  30542. $this->emptyReferences[] = $identifier;
  30543. continue;
  30544. }
  30545. $data['version'] = $version;
  30546. $data['version_normalized'] = $parsedBranch;
  30547. unset($data['default-branch']);
  30548. if ($driver->getRootIdentifier() === $branch) {
  30549. $data['default-branch'] = true;
  30550. }
  30551. if ($isVeryVerbose) {
  30552. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  30553. }
  30554. $packageData = $this->preProcess($driver, $data, $identifier);
  30555. $package = $this->loader->load($packageData);
  30556. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  30557. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  30558. }
  30559. $this->addPackage($package);
  30560. } catch (TransportException $e) {
  30561. $this->versionTransportExceptions['branches'][$branch] = $e;
  30562. if ($e->getCode() === 404) {
  30563. $this->emptyReferences[] = $identifier;
  30564. }
  30565. if ($this->shouldRethrowTransportException($e)) {
  30566. throw $e;
  30567. }
  30568. if ($isVeryVerbose) {
  30569. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  30570. }
  30571. continue;
  30572. } catch (\Exception $e) {
  30573. if (!$isVeryVerbose) {
  30574. $this->io->writeError('');
  30575. }
  30576. $this->branchErrorOccurred = true;
  30577. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  30578. $this->io->writeError('');
  30579. continue;
  30580. }
  30581. }
  30582. $driver->cleanup();
  30583. if (!$isVeryVerbose) {
  30584. $this->io->overwriteError('', false);
  30585. }
  30586. if (!$this->getPackages()) {
  30587. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  30588. }
  30589. }
  30590. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  30591. {
  30592. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  30593. $data['name'] = $this->packageName ?: $dataPackageName;
  30594. if (!isset($data['dist'])) {
  30595. $data['dist'] = $driver->getDist($identifier);
  30596. }
  30597. if (!isset($data['source'])) {
  30598. $data['source'] = $driver->getSource($identifier);
  30599. }
  30600. return $data;
  30601. }
  30602. private function validateBranch($branch)
  30603. {
  30604. try {
  30605. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  30606. $this->versionParser->parseConstraints($normalizedBranch);
  30607. return $normalizedBranch;
  30608. } catch (\Exception $e) {
  30609. }
  30610. return false;
  30611. }
  30612. private function validateTag($version)
  30613. {
  30614. try {
  30615. return $this->versionParser->normalize($version);
  30616. } catch (\Exception $e) {
  30617. }
  30618. return false;
  30619. }
  30620. private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
  30621. {
  30622. if (!$this->versionCache) {
  30623. return null;
  30624. }
  30625. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  30626. if ($cachedPackage === false) {
  30627. if ($isVeryVerbose) {
  30628. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  30629. }
  30630. return false;
  30631. }
  30632. if ($cachedPackage) {
  30633. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  30634. if ($isVeryVerbose) {
  30635. $this->io->writeError($msg);
  30636. } elseif ($isVerbose) {
  30637. $this->io->overwriteError($msg, false);
  30638. }
  30639. unset($cachedPackage['default-branch']);
  30640. if ($isDefaultBranch) {
  30641. $cachedPackage['default-branch'] = true;
  30642. }
  30643. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  30644. if ($isVeryVerbose) {
  30645. $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>');
  30646. }
  30647. $cachedPackage = null;
  30648. }
  30649. }
  30650. if ($cachedPackage) {
  30651. return $this->loader->load($cachedPackage);
  30652. }
  30653. return null;
  30654. }
  30655. private function shouldRethrowTransportException(TransportException $e)
  30656. {
  30657. return in_array($e->getCode(), array(401, 403, 429), true) || $e->getCode() >= 500;
  30658. }
  30659. }
  30660. <?php
  30661. namespace Composer\Repository;
  30662. interface VersionCacheInterface
  30663. {
  30664. public function getVersionPackage($version, $identifier);
  30665. }
  30666. <?php
  30667. namespace Composer\Repository;
  30668. use Composer\Package\AliasPackage;
  30669. use Composer\Installer\InstallationManager;
  30670. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  30671. {
  30672. protected $devPackageNames = array();
  30673. private $devMode = null;
  30674. public function getDevMode()
  30675. {
  30676. return $this->devMode;
  30677. }
  30678. public function setDevPackageNames(array $devPackageNames)
  30679. {
  30680. $this->devPackageNames = $devPackageNames;
  30681. }
  30682. public function getDevPackageNames()
  30683. {
  30684. return $this->devPackageNames;
  30685. }
  30686. public function write($devMode, InstallationManager $installationManager)
  30687. {
  30688. $this->devMode = $devMode;
  30689. }
  30690. public function reload()
  30691. {
  30692. $this->devMode = null;
  30693. }
  30694. public function getCanonicalPackages()
  30695. {
  30696. $packages = $this->getPackages();
  30697. $packagesByName = array();
  30698. foreach ($packages as $package) {
  30699. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  30700. $packagesByName[$package->getName()] = $package;
  30701. }
  30702. }
  30703. $canonicalPackages = array();
  30704. foreach ($packagesByName as $package) {
  30705. while ($package instanceof AliasPackage) {
  30706. $package = $package->getAliasOf();
  30707. }
  30708. $canonicalPackages[] = $package;
  30709. }
  30710. return $canonicalPackages;
  30711. }
  30712. }
  30713. <?php
  30714. namespace Composer\Repository;
  30715. use Composer\Package\PackageInterface;
  30716. use Composer\Installer\InstallationManager;
  30717. interface WritableRepositoryInterface extends RepositoryInterface
  30718. {
  30719. public function write($devMode, InstallationManager $installationManager);
  30720. public function addPackage(PackageInterface $package);
  30721. public function removePackage(PackageInterface $package);
  30722. public function getCanonicalPackages();
  30723. public function reload();
  30724. public function setDevPackageNames(array $devPackageNames);
  30725. public function getDevPackageNames();
  30726. }
  30727. <?php
  30728. namespace Composer\Script;
  30729. use Composer\Composer;
  30730. use Composer\IO\IOInterface;
  30731. use Composer\EventDispatcher\Event as BaseEvent;
  30732. class Event extends BaseEvent
  30733. {
  30734. private $composer;
  30735. private $io;
  30736. private $devMode;
  30737. private $originatingEvent;
  30738. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  30739. {
  30740. parent::__construct($name, $args, $flags);
  30741. $this->composer = $composer;
  30742. $this->io = $io;
  30743. $this->devMode = $devMode;
  30744. }
  30745. public function getComposer()
  30746. {
  30747. return $this->composer;
  30748. }
  30749. public function getIO()
  30750. {
  30751. return $this->io;
  30752. }
  30753. public function isDevMode()
  30754. {
  30755. return $this->devMode;
  30756. }
  30757. public function getOriginatingEvent()
  30758. {
  30759. return $this->originatingEvent;
  30760. }
  30761. public function setOriginatingEvent(BaseEvent $event)
  30762. {
  30763. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  30764. return $this;
  30765. }
  30766. private function calculateOriginatingEvent(BaseEvent $event)
  30767. {
  30768. if ($event instanceof Event && $event->getOriginatingEvent()) {
  30769. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  30770. }
  30771. return $event;
  30772. }
  30773. }
  30774. <?php
  30775. namespace Composer\Script;
  30776. class ScriptEvents
  30777. {
  30778. const PRE_INSTALL_CMD = 'pre-install-cmd';
  30779. const POST_INSTALL_CMD = 'post-install-cmd';
  30780. const PRE_UPDATE_CMD = 'pre-update-cmd';
  30781. const POST_UPDATE_CMD = 'post-update-cmd';
  30782. const PRE_STATUS_CMD = 'pre-status-cmd';
  30783. const POST_STATUS_CMD = 'post-status-cmd';
  30784. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  30785. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  30786. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  30787. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  30788. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  30789. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  30790. }
  30791. <?php
  30792. namespace Composer\SelfUpdate;
  30793. use Composer\Pcre\Preg;
  30794. class Keys
  30795. {
  30796. public static function fingerprint($path)
  30797. {
  30798. $hash = strtoupper(hash('sha256', Preg::replace('{\s}', '', file_get_contents($path))));
  30799. return implode(' ', array(
  30800. substr($hash, 0, 8),
  30801. substr($hash, 8, 8),
  30802. substr($hash, 16, 8),
  30803. substr($hash, 24, 8),
  30804. '',
  30805. substr($hash, 32, 8),
  30806. substr($hash, 40, 8),
  30807. substr($hash, 48, 8),
  30808. substr($hash, 56, 8),
  30809. ));
  30810. }
  30811. }
  30812. <?php
  30813. namespace Composer\SelfUpdate;
  30814. use Composer\Util\HttpDownloader;
  30815. use Composer\Config;
  30816. class Versions
  30817. {
  30818. public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
  30819. private $httpDownloader;
  30820. private $config;
  30821. private $channel;
  30822. private $versionsData;
  30823. public function __construct(Config $config, HttpDownloader $httpDownloader)
  30824. {
  30825. $this->httpDownloader = $httpDownloader;
  30826. $this->config = $config;
  30827. }
  30828. public function getChannel()
  30829. {
  30830. if ($this->channel) {
  30831. return $this->channel;
  30832. }
  30833. $channelFile = $this->config->get('home').'/update-channel';
  30834. if (file_exists($channelFile)) {
  30835. $channel = trim(file_get_contents($channelFile));
  30836. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  30837. return $this->channel = $channel;
  30838. }
  30839. }
  30840. return $this->channel = 'stable';
  30841. }
  30842. public function setChannel($channel)
  30843. {
  30844. if (!in_array($channel, self::$channels, true)) {
  30845. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  30846. }
  30847. $channelFile = $this->config->get('home').'/update-channel';
  30848. $this->channel = $channel;
  30849. file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
  30850. }
  30851. public function getLatest($channel = null)
  30852. {
  30853. $versions = $this->getVersionsData();
  30854. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  30855. if ($version['min-php'] <= PHP_VERSION_ID) {
  30856. return $version;
  30857. }
  30858. }
  30859. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  30860. }
  30861. private function getVersionsData()
  30862. {
  30863. if (!$this->versionsData) {
  30864. if ($this->config->get('disable-tls') === true) {
  30865. $protocol = 'http';
  30866. } else {
  30867. $protocol = 'https';
  30868. }
  30869. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  30870. }
  30871. return $this->versionsData;
  30872. }
  30873. }
  30874. <?php
  30875. namespace Composer\Util;
  30876. use Composer\Config;
  30877. use Composer\IO\IOInterface;
  30878. use Composer\Downloader\TransportException;
  30879. use Composer\Pcre\Preg;
  30880. class AuthHelper
  30881. {
  30882. protected $io;
  30883. protected $config;
  30884. private $displayedOriginAuthentications = array();
  30885. public function __construct(IOInterface $io, Config $config)
  30886. {
  30887. $this->io = $io;
  30888. $this->config = $config;
  30889. }
  30890. public function storeAuth($origin, $storeAuth)
  30891. {
  30892. $store = false;
  30893. $configSource = $this->config->getAuthConfigSource();
  30894. if ($storeAuth === true) {
  30895. $store = $configSource;
  30896. } elseif ($storeAuth === 'prompt') {
  30897. $answer = $this->io->askAndValidate(
  30898. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  30899. function ($value) {
  30900. $input = strtolower(substr(trim($value), 0, 1));
  30901. if (in_array($input, array('y','n'))) {
  30902. return $input;
  30903. }
  30904. throw new \RuntimeException('Please answer (y)es or (n)o');
  30905. },
  30906. null,
  30907. 'y'
  30908. );
  30909. if ($answer === 'y') {
  30910. $store = $configSource;
  30911. }
  30912. }
  30913. if ($store) {
  30914. $store->addConfigSetting(
  30915. 'http-basic.'.$origin,
  30916. $this->io->getAuthentication($origin)
  30917. );
  30918. }
  30919. }
  30920. public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
  30921. {
  30922. $storeAuth = false;
  30923. if (in_array($origin, $this->config->get('github-domains'), true)) {
  30924. $gitHubUtil = new GitHub($this->io, $this->config, null);
  30925. $message = "\n";
  30926. $rateLimited = $gitHubUtil->isRateLimited($headers);
  30927. $requiresSso = $gitHubUtil->requiresSso($headers);
  30928. if ($requiresSso) {
  30929. $ssoUrl = $gitHubUtil->getSsoUrl($headers);
  30930. $message = 'GitHub API token requires SSO authorization. Authorize this token at ' . $ssoUrl . "\n";
  30931. $this->io->writeError($message);
  30932. if (!$this->io->isInteractive()) {
  30933. throw new TransportException('Could not authenticate against ' . $origin, 403);
  30934. }
  30935. $this->io->ask('After authorizing your token, confirm that you would like to retry the request');
  30936. return array('retry' => true, 'storeAuth' => $storeAuth);
  30937. }
  30938. if ($rateLimited) {
  30939. $rateLimit = $gitHubUtil->getRateLimit($headers);
  30940. if ($this->io->hasAuthentication($origin)) {
  30941. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  30942. } else {
  30943. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  30944. }
  30945. $message = sprintf(
  30946. '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.',
  30947. $rateLimit['limit'],
  30948. $rateLimit['reset']
  30949. )."\n";
  30950. } else {
  30951. $message .= 'Could not fetch '.$url.', please ';
  30952. if ($this->io->hasAuthentication($origin)) {
  30953. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  30954. } else {
  30955. $message .= 'create a GitHub OAuth token to access private repos';
  30956. }
  30957. }
  30958. if (!$gitHubUtil->authorizeOAuth($origin)
  30959. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  30960. ) {
  30961. throw new TransportException('Could not authenticate against '.$origin, 401);
  30962. }
  30963. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  30964. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  30965. $gitLabUtil = new GitLab($this->io, $this->config, null);
  30966. if ($this->io->hasAuthentication($origin)) {
  30967. $auth = $this->io->getAuthentication($origin);
  30968. if (in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  30969. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  30970. }
  30971. }
  30972. if (!$gitLabUtil->authorizeOAuth($origin)
  30973. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  30974. ) {
  30975. throw new TransportException('Could not authenticate against '.$origin, 401);
  30976. }
  30977. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  30978. $askForOAuthToken = true;
  30979. $origin = 'bitbucket.org';
  30980. if ($this->io->hasAuthentication($origin)) {
  30981. $auth = $this->io->getAuthentication($origin);
  30982. if ($auth['username'] !== 'x-token-auth') {
  30983. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  30984. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  30985. if (!empty($accessToken)) {
  30986. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  30987. $askForOAuthToken = false;
  30988. }
  30989. } else {
  30990. throw new TransportException('Could not authenticate against ' . $origin, 401);
  30991. }
  30992. }
  30993. if ($askForOAuthToken) {
  30994. $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');
  30995. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  30996. if (!$bitBucketUtil->authorizeOAuth($origin)
  30997. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  30998. ) {
  30999. throw new TransportException('Could not authenticate against ' . $origin, 401);
  31000. }
  31001. }
  31002. } else {
  31003. if ($statusCode === 404) {
  31004. return null;
  31005. }
  31006. if (!$this->io->isInteractive()) {
  31007. if ($statusCode === 401) {
  31008. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  31009. } elseif ($statusCode === 403) {
  31010. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  31011. } else {
  31012. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  31013. }
  31014. throw new TransportException($message, $statusCode);
  31015. }
  31016. if ($this->io->hasAuthentication($origin)) {
  31017. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  31018. }
  31019. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  31020. $username = $this->io->ask(' Username: ');
  31021. $password = $this->io->askAndHideAnswer(' Password: ');
  31022. $this->io->setAuthentication($origin, $username, $password);
  31023. $storeAuth = $this->config->get('store-auths');
  31024. }
  31025. return array('retry' => true, 'storeAuth' => $storeAuth);
  31026. }
  31027. public function addAuthenticationHeader(array $headers, $origin, $url)
  31028. {
  31029. if ($this->io->hasAuthentication($origin)) {
  31030. $authenticationDisplayMessage = null;
  31031. $auth = $this->io->getAuthentication($origin);
  31032. if ($auth['password'] === 'bearer') {
  31033. $headers[] = 'Authorization: Bearer '.$auth['username'];
  31034. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  31035. if (Preg::isMatch('{^https?://api\.github\.com/}', $url)) {
  31036. $headers[] = 'Authorization: token '.$auth['username'];
  31037. $authenticationDisplayMessage = 'Using GitHub token authentication';
  31038. }
  31039. } elseif (
  31040. in_array($origin, $this->config->get('gitlab-domains'), true)
  31041. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  31042. ) {
  31043. if ($auth['password'] === 'oauth2') {
  31044. $headers[] = 'Authorization: Bearer '.$auth['username'];
  31045. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  31046. } else {
  31047. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  31048. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  31049. }
  31050. } elseif (
  31051. 'bitbucket.org' === $origin
  31052. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  31053. && 'x-token-auth' === $auth['username']
  31054. ) {
  31055. if (!$this->isPublicBitBucketDownload($url)) {
  31056. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  31057. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  31058. }
  31059. } else {
  31060. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  31061. $headers[] = 'Authorization: Basic '.$authStr;
  31062. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  31063. }
  31064. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  31065. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  31066. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  31067. }
  31068. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  31069. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  31070. }
  31071. return $headers;
  31072. }
  31073. public function isPublicBitBucketDownload($urlToBitBucketFile)
  31074. {
  31075. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  31076. if (strpos($domain, 'bitbucket.org') === false) {
  31077. return true;
  31078. }
  31079. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  31080. $pathParts = explode('/', $path);
  31081. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  31082. }
  31083. }
  31084. <?php
  31085. namespace Composer\Util;
  31086. use Composer\Factory;
  31087. use Composer\IO\IOInterface;
  31088. use Composer\Config;
  31089. use Composer\Downloader\TransportException;
  31090. class Bitbucket
  31091. {
  31092. private $io;
  31093. private $config;
  31094. private $process;
  31095. private $httpDownloader;
  31096. private $token = null;
  31097. private $time;
  31098. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  31099. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null)
  31100. {
  31101. $this->io = $io;
  31102. $this->config = $config;
  31103. $this->process = $process ?: new ProcessExecutor($io);
  31104. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  31105. $this->time = $time;
  31106. }
  31107. public function getToken()
  31108. {
  31109. if (!isset($this->token['access_token'])) {
  31110. return '';
  31111. }
  31112. return $this->token['access_token'];
  31113. }
  31114. public function authorizeOAuth($originUrl)
  31115. {
  31116. if ($originUrl !== 'bitbucket.org') {
  31117. return false;
  31118. }
  31119. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  31120. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  31121. return true;
  31122. }
  31123. return false;
  31124. }
  31125. private function requestAccessToken()
  31126. {
  31127. try {
  31128. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  31129. 'retry-auth-failure' => false,
  31130. 'http' => array(
  31131. 'method' => 'POST',
  31132. 'content' => 'grant_type=client_credentials',
  31133. ),
  31134. ));
  31135. $token = $response->decodeJson();
  31136. if (!isset($token['expires_in']) || !isset($token['access_token'])) {
  31137. throw new \LogicException('Expected a token configured with expires_in and access_token present, got '.json_encode($token));
  31138. }
  31139. $this->token = $token;
  31140. } catch (TransportException $e) {
  31141. if ($e->getCode() === 400) {
  31142. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  31143. $this->io->writeError('This can have two reasons:');
  31144. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  31145. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  31146. return false;
  31147. }
  31148. if (in_array($e->getCode(), array(403, 401))) {
  31149. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  31150. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  31151. return false;
  31152. }
  31153. throw $e;
  31154. }
  31155. return true;
  31156. }
  31157. public function authorizeOAuthInteractively($originUrl, $message = null)
  31158. {
  31159. if ($message) {
  31160. $this->io->writeError($message);
  31161. }
  31162. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  31163. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  31164. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  31165. $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)');
  31166. $consumerKey = trim((string) $this->io->askAndHideAnswer('Consumer Key (hidden): '));
  31167. if (!$consumerKey) {
  31168. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  31169. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  31170. return false;
  31171. }
  31172. $consumerSecret = trim((string) $this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  31173. if (!$consumerSecret) {
  31174. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  31175. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  31176. return false;
  31177. }
  31178. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  31179. if (!$this->requestAccessToken()) {
  31180. return false;
  31181. }
  31182. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  31183. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  31184. $this->io->writeError('<info>Consumer stored successfully.</info>');
  31185. return true;
  31186. }
  31187. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  31188. {
  31189. if ($this->token !== null || $this->getTokenFromConfig($originUrl)) {
  31190. return $this->token['access_token'];
  31191. }
  31192. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  31193. if (!$this->requestAccessToken()) {
  31194. return '';
  31195. }
  31196. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  31197. if (!isset($this->token['access_token'])) {
  31198. throw new \LogicException('Failed to initialize token above');
  31199. }
  31200. return $this->token['access_token'];
  31201. }
  31202. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  31203. {
  31204. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  31205. if (null === $this->token || !isset($this->token['expires_in'])) {
  31206. throw new \LogicException('Expected a token configured with expires_in present, got '.json_encode($this->token));
  31207. }
  31208. $time = null === $this->time ? time() : $this->time;
  31209. $consumer = array(
  31210. "consumer-key" => $consumerKey,
  31211. "consumer-secret" => $consumerSecret,
  31212. "access-token" => $this->token['access_token'],
  31213. "access-token-expiration" => $time + $this->token['expires_in'],
  31214. );
  31215. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  31216. }
  31217. private function getTokenFromConfig($originUrl)
  31218. {
  31219. $authConfig = $this->config->get('bitbucket-oauth');
  31220. if (
  31221. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  31222. || time() > $authConfig[$originUrl]['access-token-expiration']
  31223. ) {
  31224. return false;
  31225. }
  31226. $this->token = array(
  31227. 'access_token' => $authConfig[$originUrl]['access-token'],
  31228. );
  31229. return true;
  31230. }
  31231. }
  31232. <?php
  31233. namespace Composer\Util;
  31234. use Composer\Pcre\Preg;
  31235. class ComposerMirror
  31236. {
  31237. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type, $prettyVersion = null)
  31238. {
  31239. if ($reference) {
  31240. $reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  31241. }
  31242. $version = strpos($version, '/') === false ? $version : md5($version);
  31243. $from = array('%package%', '%version%', '%reference%', '%type%');
  31244. $to = array($packageName, $version, $reference, $type);
  31245. if (null !== $prettyVersion) {
  31246. $from[] = '%prettyVersion%';
  31247. $to[] = $prettyVersion;
  31248. }
  31249. return str_replace($from, $to, $mirrorUrl);
  31250. }
  31251. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  31252. {
  31253. if (Preg::isMatch('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  31254. $url = 'gh-'.$match[1].'/'.$match[2];
  31255. } elseif (Preg::isMatch('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  31256. $url = 'bb-'.$match[1].'/'.$match[2];
  31257. } else {
  31258. $url = Preg::replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  31259. }
  31260. return str_replace(
  31261. array('%package%', '%normalizedUrl%', '%type%'),
  31262. array($packageName, $url, $type),
  31263. $mirrorUrl
  31264. );
  31265. }
  31266. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  31267. {
  31268. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  31269. }
  31270. }
  31271. <?php
  31272. namespace Composer\Util;
  31273. use Composer\Package\Loader\ArrayLoader;
  31274. use Composer\Package\Loader\ValidatingArrayLoader;
  31275. use Composer\Package\Loader\InvalidPackageException;
  31276. use Composer\Json\JsonValidationException;
  31277. use Composer\IO\IOInterface;
  31278. use Composer\Json\JsonFile;
  31279. use Composer\Pcre\Preg;
  31280. use Composer\Spdx\SpdxLicenses;
  31281. class ConfigValidator
  31282. {
  31283. const CHECK_VERSION = 1;
  31284. private $io;
  31285. public function __construct(IOInterface $io)
  31286. {
  31287. $this->io = $io;
  31288. }
  31289. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
  31290. {
  31291. $errors = array();
  31292. $publishErrors = array();
  31293. $warnings = array();
  31294. $laxValid = false;
  31295. try {
  31296. $json = new JsonFile($file, null, $this->io);
  31297. $manifest = $json->read();
  31298. $json->validateSchema(JsonFile::LAX_SCHEMA);
  31299. $laxValid = true;
  31300. $json->validateSchema();
  31301. } catch (JsonValidationException $e) {
  31302. foreach ($e->getErrors() as $message) {
  31303. if ($laxValid) {
  31304. $publishErrors[] = $message;
  31305. } else {
  31306. $errors[] = $message;
  31307. }
  31308. }
  31309. } catch (\Exception $e) {
  31310. $errors[] = $e->getMessage();
  31311. return array($errors, $publishErrors, $warnings);
  31312. }
  31313. if (empty($manifest['license'])) {
  31314. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  31315. } else {
  31316. $licenses = (array) $manifest['license'];
  31317. foreach ($licenses as $key => $license) {
  31318. if ('proprietary' === $license) {
  31319. unset($licenses[$key]);
  31320. }
  31321. }
  31322. $licenseValidator = new SpdxLicenses();
  31323. foreach ($licenses as $license) {
  31324. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  31325. if ($spdxLicense && $spdxLicense[3]) {
  31326. if (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  31327. $warnings[] = sprintf(
  31328. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  31329. $license
  31330. );
  31331. } elseif (Preg::isMatch('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  31332. $warnings[] = sprintf(
  31333. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  31334. $license
  31335. );
  31336. } else {
  31337. $warnings[] = sprintf(
  31338. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  31339. $license
  31340. );
  31341. }
  31342. }
  31343. }
  31344. }
  31345. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  31346. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  31347. }
  31348. if (!empty($manifest['name']) && Preg::isMatch('{[A-Z]}', $manifest['name'])) {
  31349. $suggestName = Preg::replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  31350. $suggestName = strtolower($suggestName);
  31351. $publishErrors[] = sprintf(
  31352. '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.',
  31353. $manifest['name'],
  31354. $suggestName
  31355. );
  31356. }
  31357. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  31358. $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.";
  31359. }
  31360. if (isset($manifest['require'], $manifest['require-dev'])) {
  31361. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  31362. if (!empty($requireOverrides)) {
  31363. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  31364. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  31365. }
  31366. }
  31367. foreach (array('provide', 'replace') as $linkType) {
  31368. if (isset($manifest[$linkType])) {
  31369. foreach (array('require', 'require-dev') as $requireType) {
  31370. if (isset($manifest[$requireType])) {
  31371. foreach ($manifest[$linkType] as $provide => $constraint) {
  31372. if (isset($manifest[$requireType][$provide])) {
  31373. $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.';
  31374. }
  31375. }
  31376. }
  31377. }
  31378. }
  31379. }
  31380. $require = isset($manifest['require']) ? $manifest['require'] : array();
  31381. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  31382. $packages = array_merge($require, $requireDev);
  31383. foreach ($packages as $package => $version) {
  31384. if (Preg::isMatch('/#/', $version)) {
  31385. $warnings[] = sprintf(
  31386. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  31387. $package
  31388. );
  31389. }
  31390. }
  31391. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  31392. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  31393. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  31394. if (!array_key_exists($scriptName, $scripts)) {
  31395. $warnings[] = sprintf(
  31396. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  31397. $scriptName
  31398. );
  31399. }
  31400. }
  31401. if (isset($manifest['autoload']['psr-0'][''])) {
  31402. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  31403. }
  31404. if (isset($manifest['autoload']['psr-4'][''])) {
  31405. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  31406. }
  31407. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  31408. try {
  31409. if (!isset($manifest['version'])) {
  31410. $manifest['version'] = '1.0.0';
  31411. }
  31412. if (!isset($manifest['name'])) {
  31413. $manifest['name'] = 'dummy/dummy';
  31414. }
  31415. $loader->load($manifest);
  31416. } catch (InvalidPackageException $e) {
  31417. $errors = array_merge($errors, $e->getErrors());
  31418. }
  31419. $warnings = array_merge($warnings, $loader->getWarnings());
  31420. return array($errors, $publishErrors, $warnings);
  31421. }
  31422. }
  31423. <?php
  31424. namespace Composer\Util;
  31425. use Composer\IO\IOInterface;
  31426. use Composer\Pcre\Preg;
  31427. class ErrorHandler
  31428. {
  31429. private static $io;
  31430. public static function handle($level, $message, $file, $line)
  31431. {
  31432. if (!(error_reporting() & $level)) {
  31433. return true;
  31434. }
  31435. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  31436. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  31437. "\na legitimately suppressed error that you were not supposed to see.";
  31438. }
  31439. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  31440. throw new \ErrorException($message, 0, $level, $file, $line);
  31441. }
  31442. if (self::$io) {
  31443. if (Preg::isMatch('{^Return type of Symfony\\\\.*ReturnTypeWillChange}is', $message)) {
  31444. return true;
  31445. }
  31446. if (strpos(strtr($file, '\\', '/'), 'vendor/symfony/') !== false) {
  31447. return true;
  31448. }
  31449. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  31450. if (self::$io->isVerbose()) {
  31451. self::$io->writeError('<warning>Stack trace:</warning>');
  31452. self::$io->writeError(array_filter(array_map(function ($a) {
  31453. if (isset($a['line'], $a['file'])) {
  31454. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  31455. }
  31456. return null;
  31457. }, array_slice(debug_backtrace(), 2))));
  31458. }
  31459. }
  31460. return true;
  31461. }
  31462. public static function register(IOInterface $io = null)
  31463. {
  31464. set_error_handler(array(__CLASS__, 'handle'));
  31465. error_reporting(E_ALL | E_STRICT);
  31466. self::$io = $io;
  31467. }
  31468. }
  31469. <?php
  31470. namespace Composer\Util;
  31471. use Composer\Pcre\Preg;
  31472. use React\Promise\PromiseInterface;
  31473. use RecursiveDirectoryIterator;
  31474. use RecursiveIteratorIterator;
  31475. use Symfony\Component\Filesystem\Exception\IOException;
  31476. use Symfony\Component\Finder\Finder;
  31477. class Filesystem
  31478. {
  31479. private $processExecutor;
  31480. public function __construct(ProcessExecutor $executor = null)
  31481. {
  31482. $this->processExecutor = $executor;
  31483. }
  31484. public function remove($file)
  31485. {
  31486. if (is_dir($file)) {
  31487. return $this->removeDirectory($file);
  31488. }
  31489. if (file_exists($file)) {
  31490. return $this->unlink($file);
  31491. }
  31492. return false;
  31493. }
  31494. public function isDirEmpty($dir)
  31495. {
  31496. $finder = Finder::create()
  31497. ->ignoreVCS(false)
  31498. ->ignoreDotFiles(false)
  31499. ->depth(0)
  31500. ->in($dir);
  31501. return \count($finder) === 0;
  31502. }
  31503. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  31504. {
  31505. if (is_link($dir) && file_exists($dir)) {
  31506. $this->unlink($dir);
  31507. }
  31508. if ($ensureDirectoryExists) {
  31509. $this->ensureDirectoryExists($dir);
  31510. }
  31511. if (is_dir($dir)) {
  31512. $finder = Finder::create()
  31513. ->ignoreVCS(false)
  31514. ->ignoreDotFiles(false)
  31515. ->depth(0)
  31516. ->in($dir);
  31517. foreach ($finder as $path) {
  31518. $this->remove((string) $path);
  31519. }
  31520. }
  31521. }
  31522. public function removeDirectory($directory)
  31523. {
  31524. $edgeCaseResult = $this->removeEdgeCases($directory);
  31525. if ($edgeCaseResult !== null) {
  31526. return $edgeCaseResult;
  31527. }
  31528. if (Platform::isWindows()) {
  31529. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  31530. } else {
  31531. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  31532. }
  31533. $result = $this->getProcess()->execute($cmd, $output) === 0;
  31534. clearstatcache();
  31535. if ($result && !is_dir($directory)) {
  31536. return true;
  31537. }
  31538. return $this->removeDirectoryPhp($directory);
  31539. }
  31540. public function removeDirectoryAsync($directory)
  31541. {
  31542. $edgeCaseResult = $this->removeEdgeCases($directory);
  31543. if ($edgeCaseResult !== null) {
  31544. return \React\Promise\resolve($edgeCaseResult);
  31545. }
  31546. if (Platform::isWindows()) {
  31547. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  31548. } else {
  31549. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  31550. }
  31551. $promise = $this->getProcess()->executeAsync($cmd);
  31552. $self = $this;
  31553. return $promise->then(function ($process) use ($directory, $self) {
  31554. clearstatcache();
  31555. if ($process->isSuccessful()) {
  31556. if (!is_dir($directory)) {
  31557. return \React\Promise\resolve(true);
  31558. }
  31559. }
  31560. return \React\Promise\resolve($self->removeDirectoryPhp($directory));
  31561. });
  31562. }
  31563. private function removeEdgeCases($directory, $fallbackToPhp = true)
  31564. {
  31565. if ($this->isSymlinkedDirectory($directory)) {
  31566. return $this->unlinkSymlinkedDirectory($directory);
  31567. }
  31568. if ($this->isJunction($directory)) {
  31569. return $this->removeJunction($directory);
  31570. }
  31571. if (is_link($directory)) {
  31572. return unlink($directory);
  31573. }
  31574. if (!is_dir($directory) || !file_exists($directory)) {
  31575. return true;
  31576. }
  31577. if (Preg::isMatch('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  31578. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  31579. }
  31580. if (!\function_exists('proc_open') && $fallbackToPhp) {
  31581. return $this->removeDirectoryPhp($directory);
  31582. }
  31583. return null;
  31584. }
  31585. public function removeDirectoryPhp($directory)
  31586. {
  31587. $edgeCaseResult = $this->removeEdgeCases($directory, false);
  31588. if ($edgeCaseResult !== null) {
  31589. return $edgeCaseResult;
  31590. }
  31591. try {
  31592. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  31593. } catch (\UnexpectedValueException $e) {
  31594. clearstatcache();
  31595. usleep(100000);
  31596. if (!is_dir($directory)) {
  31597. return true;
  31598. }
  31599. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  31600. }
  31601. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  31602. foreach ($ri as $file) {
  31603. if ($file->isDir()) {
  31604. $this->rmdir($file->getPathname());
  31605. } else {
  31606. $this->unlink($file->getPathname());
  31607. }
  31608. }
  31609. unset($ri, $it, $file);
  31610. return $this->rmdir($directory);
  31611. }
  31612. public function ensureDirectoryExists($directory)
  31613. {
  31614. if (!is_dir($directory)) {
  31615. if (file_exists($directory)) {
  31616. throw new \RuntimeException(
  31617. $directory.' exists and is not a directory.'
  31618. );
  31619. }
  31620. if (!@mkdir($directory, 0777, true)) {
  31621. throw new \RuntimeException(
  31622. $directory.' does not exist and could not be created.'
  31623. );
  31624. }
  31625. }
  31626. }
  31627. public function unlink($path)
  31628. {
  31629. $unlinked = @$this->unlinkImplementation($path);
  31630. if (!$unlinked) {
  31631. if (Platform::isWindows()) {
  31632. usleep(350000);
  31633. $unlinked = @$this->unlinkImplementation($path);
  31634. }
  31635. if (!$unlinked) {
  31636. $error = error_get_last();
  31637. $message = 'Could not delete '.$path.': ' . @$error['message'];
  31638. if (Platform::isWindows()) {
  31639. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  31640. }
  31641. throw new \RuntimeException($message);
  31642. }
  31643. }
  31644. return true;
  31645. }
  31646. public function rmdir($path)
  31647. {
  31648. $deleted = @rmdir($path);
  31649. if (!$deleted) {
  31650. if (Platform::isWindows()) {
  31651. usleep(350000);
  31652. $deleted = @rmdir($path);
  31653. }
  31654. if (!$deleted) {
  31655. $error = error_get_last();
  31656. $message = 'Could not delete '.$path.': ' . @$error['message'];
  31657. if (Platform::isWindows()) {
  31658. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  31659. }
  31660. throw new \RuntimeException($message);
  31661. }
  31662. }
  31663. return true;
  31664. }
  31665. public function copyThenRemove($source, $target)
  31666. {
  31667. $this->copy($source, $target);
  31668. if (!is_dir($source)) {
  31669. $this->unlink($source);
  31670. return;
  31671. }
  31672. $this->removeDirectoryPhp($source);
  31673. }
  31674. public function copy($source, $target)
  31675. {
  31676. if (!is_dir($source)) {
  31677. return copy($source, $target);
  31678. }
  31679. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  31680. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  31681. $this->ensureDirectoryExists($target);
  31682. $result = true;
  31683. foreach ($ri as $file) {
  31684. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  31685. if ($file->isDir()) {
  31686. $this->ensureDirectoryExists($targetPath);
  31687. } else {
  31688. $result = $result && copy($file->getPathname(), $targetPath);
  31689. }
  31690. }
  31691. return $result;
  31692. }
  31693. public function rename($source, $target)
  31694. {
  31695. if (true === @rename($source, $target)) {
  31696. return;
  31697. }
  31698. if (!\function_exists('proc_open')) {
  31699. $this->copyThenRemove($source, $target);
  31700. return;
  31701. }
  31702. if (Platform::isWindows()) {
  31703. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  31704. $result = $this->getProcess()->execute($command, $output);
  31705. clearstatcache();
  31706. if (0 === $result) {
  31707. $this->remove($source);
  31708. return;
  31709. }
  31710. } else {
  31711. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  31712. $result = $this->getProcess()->execute($command, $output);
  31713. clearstatcache();
  31714. if (0 === $result) {
  31715. return;
  31716. }
  31717. }
  31718. $this->copyThenRemove($source, $target);
  31719. }
  31720. public function findShortestPath($from, $to, $directories = false)
  31721. {
  31722. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  31723. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  31724. }
  31725. $from = lcfirst($this->normalizePath($from));
  31726. $to = lcfirst($this->normalizePath($to));
  31727. if ($directories) {
  31728. $from = rtrim($from, '/') . '/dummy_file';
  31729. }
  31730. if (\dirname($from) === \dirname($to)) {
  31731. return './'.basename($to);
  31732. }
  31733. $commonPath = $to;
  31734. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[a-z]:/?$}i', $commonPath)) {
  31735. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  31736. }
  31737. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  31738. return $to;
  31739. }
  31740. $commonPath = rtrim($commonPath, '/') . '/';
  31741. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
  31742. $commonPathCode = str_repeat('../', $sourcePathDepth);
  31743. return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
  31744. }
  31745. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  31746. {
  31747. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  31748. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  31749. }
  31750. $from = lcfirst($this->normalizePath($from));
  31751. $to = lcfirst($this->normalizePath($to));
  31752. if ($from === $to) {
  31753. return $directories ? '__DIR__' : '__FILE__';
  31754. }
  31755. $commonPath = $to;
  31756. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !Preg::isMatch('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  31757. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  31758. }
  31759. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  31760. return var_export($to, true);
  31761. }
  31762. $commonPath = rtrim($commonPath, '/') . '/';
  31763. if (strpos($to, $from.'/') === 0) {
  31764. return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
  31765. }
  31766. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
  31767. if ($staticCode) {
  31768. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  31769. } else {
  31770. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  31771. }
  31772. $relTarget = substr($to, \strlen($commonPath));
  31773. return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  31774. }
  31775. public function isAbsolutePath($path)
  31776. {
  31777. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  31778. }
  31779. public function size($path)
  31780. {
  31781. if (!file_exists($path)) {
  31782. throw new \RuntimeException("$path does not exist.");
  31783. }
  31784. if (is_dir($path)) {
  31785. return $this->directorySize($path);
  31786. }
  31787. return filesize($path);
  31788. }
  31789. public function normalizePath($path)
  31790. {
  31791. $parts = array();
  31792. $path = strtr($path, '\\', '/');
  31793. $prefix = '';
  31794. $absolute = '';
  31795. if (strpos($path, '//') === 0 && \strlen($path) > 2) {
  31796. $absolute = '//';
  31797. $path = substr($path, 2);
  31798. }
  31799. if (Preg::isMatch('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  31800. $prefix = $match[1];
  31801. $path = substr($path, \strlen($prefix));
  31802. }
  31803. if (strpos($path, '/') === 0) {
  31804. $absolute = '/';
  31805. $path = substr($path, 1);
  31806. }
  31807. $up = false;
  31808. foreach (explode('/', $path) as $chunk) {
  31809. if ('..' === $chunk && ($absolute !== '' || $up)) {
  31810. array_pop($parts);
  31811. $up = !(empty($parts) || '..' === end($parts));
  31812. } elseif ('.' !== $chunk && '' !== $chunk) {
  31813. $parts[] = $chunk;
  31814. $up = '..' !== $chunk;
  31815. }
  31816. }
  31817. return $prefix.((string) $absolute).implode('/', $parts);
  31818. }
  31819. public static function trimTrailingSlash($path)
  31820. {
  31821. if (!Preg::isMatch('{^[/\\\\]+$}', $path)) {
  31822. $path = rtrim($path, '/\\');
  31823. }
  31824. return $path;
  31825. }
  31826. public static function isLocalPath($path)
  31827. {
  31828. return Preg::isMatch('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  31829. }
  31830. public static function getPlatformPath($path)
  31831. {
  31832. if (Platform::isWindows()) {
  31833. $path = Preg::replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  31834. }
  31835. return (string) Preg::replace('{^file://}i', '', $path);
  31836. }
  31837. public static function isReadable($path)
  31838. {
  31839. if (is_readable($path)) {
  31840. return true;
  31841. }
  31842. if (is_file($path)) {
  31843. return false !== Silencer::call('file_get_contents', $path, false, null, 0, 1);
  31844. }
  31845. if (is_dir($path)) {
  31846. return false !== Silencer::call('opendir', $path);
  31847. }
  31848. return false;
  31849. }
  31850. protected function directorySize($directory)
  31851. {
  31852. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  31853. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  31854. $size = 0;
  31855. foreach ($ri as $file) {
  31856. if ($file->isFile()) {
  31857. $size += $file->getSize();
  31858. }
  31859. }
  31860. return $size;
  31861. }
  31862. protected function getProcess()
  31863. {
  31864. if (!$this->processExecutor) {
  31865. $this->processExecutor = new ProcessExecutor();
  31866. }
  31867. return $this->processExecutor;
  31868. }
  31869. private function unlinkImplementation($path)
  31870. {
  31871. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  31872. return rmdir($path);
  31873. }
  31874. return unlink($path);
  31875. }
  31876. public function relativeSymlink($target, $link)
  31877. {
  31878. if (!function_exists('symlink')) {
  31879. return false;
  31880. }
  31881. $cwd = getcwd();
  31882. $relativePath = $this->findShortestPath($link, $target);
  31883. chdir(\dirname($link));
  31884. $result = @symlink($relativePath, $link);
  31885. chdir($cwd);
  31886. return $result;
  31887. }
  31888. public function isSymlinkedDirectory($directory)
  31889. {
  31890. if (!is_dir($directory)) {
  31891. return false;
  31892. }
  31893. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  31894. return is_link($resolved);
  31895. }
  31896. private function unlinkSymlinkedDirectory($directory)
  31897. {
  31898. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  31899. return $this->unlink($resolved);
  31900. }
  31901. private function resolveSymlinkedDirectorySymlink($pathname)
  31902. {
  31903. if (!is_dir($pathname)) {
  31904. return $pathname;
  31905. }
  31906. $resolved = rtrim($pathname, '/');
  31907. if (!\strlen($resolved)) {
  31908. return $pathname;
  31909. }
  31910. return $resolved;
  31911. }
  31912. public function junction($target, $junction)
  31913. {
  31914. if (!Platform::isWindows()) {
  31915. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  31916. }
  31917. if (!is_dir($target)) {
  31918. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  31919. }
  31920. $cmd = sprintf(
  31921. 'mklink /J %s %s',
  31922. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  31923. ProcessExecutor::escape(realpath($target))
  31924. );
  31925. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  31926. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  31927. }
  31928. clearstatcache(true, $junction);
  31929. }
  31930. public function isJunction($junction)
  31931. {
  31932. if (!Platform::isWindows()) {
  31933. return false;
  31934. }
  31935. clearstatcache(true, $junction);
  31936. if (!is_dir($junction) || is_link($junction)) {
  31937. return false;
  31938. }
  31939. $stat = lstat($junction);
  31940. return $stat ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  31941. }
  31942. public function removeJunction($junction)
  31943. {
  31944. if (!Platform::isWindows()) {
  31945. return false;
  31946. }
  31947. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  31948. if (!$this->isJunction($junction)) {
  31949. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  31950. }
  31951. return $this->rmdir($junction);
  31952. }
  31953. public function filePutContentsIfModified($path, $content)
  31954. {
  31955. $currentContent = @file_get_contents($path);
  31956. if (!$currentContent || ($currentContent != $content)) {
  31957. return file_put_contents($path, $content);
  31958. }
  31959. return 0;
  31960. }
  31961. public function safeCopy($source, $target)
  31962. {
  31963. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  31964. $source = fopen($source, 'r');
  31965. $target = fopen($target, 'w+');
  31966. stream_copy_to_stream($source, $target);
  31967. fclose($source);
  31968. fclose($target);
  31969. }
  31970. }
  31971. private function filesAreEqual($a, $b)
  31972. {
  31973. if (filesize($a) !== filesize($b)) {
  31974. return false;
  31975. }
  31976. $ah = fopen($a, 'rb');
  31977. $bh = fopen($b, 'rb');
  31978. $result = true;
  31979. while (!feof($ah)) {
  31980. if (fread($ah, 8192) != fread($bh, 8192)) {
  31981. $result = false;
  31982. break;
  31983. }
  31984. }
  31985. fclose($ah);
  31986. fclose($bh);
  31987. return $result;
  31988. }
  31989. }
  31990. <?php
  31991. namespace Composer\Util;
  31992. use Composer\Config;
  31993. use Composer\IO\IOInterface;
  31994. use Composer\Pcre\Preg;
  31995. class Git
  31996. {
  31997. private static $version = false;
  31998. protected $io;
  31999. protected $config;
  32000. protected $process;
  32001. protected $filesystem;
  32002. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  32003. {
  32004. $this->io = $io;
  32005. $this->config = $config;
  32006. $this->process = $process;
  32007. $this->filesystem = $fs;
  32008. }
  32009. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  32010. {
  32011. $this->config->prohibitUrlByConfig($url, $this->io);
  32012. if ($initialClone) {
  32013. $origCwd = $cwd;
  32014. $cwd = null;
  32015. }
  32016. if (Preg::isMatch('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  32017. 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.');
  32018. }
  32019. if (!$initialClone) {
  32020. $this->process->execute('git remote -v', $output, $cwd);
  32021. if (Preg::isMatch('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  32022. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  32023. }
  32024. }
  32025. $protocols = $this->config->get('github-protocols');
  32026. if (!is_array($protocols)) {
  32027. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  32028. }
  32029. if (Preg::isMatch('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  32030. $messages = array();
  32031. foreach ($protocols as $protocol) {
  32032. if ('ssh' === $protocol) {
  32033. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  32034. } else {
  32035. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  32036. }
  32037. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  32038. return;
  32039. }
  32040. $messages[] = '- ' . $protoUrl . "\n" . Preg::replace('#^#m', ' ', $this->process->getErrorOutput());
  32041. if ($initialClone && isset($origCwd)) {
  32042. $this->filesystem->removeDirectory($origCwd);
  32043. }
  32044. }
  32045. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  32046. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  32047. }
  32048. }
  32049. $bypassSshForGitHub = Preg::isMatch('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  32050. $command = call_user_func($commandCallable, $url);
  32051. $auth = null;
  32052. $credentials = array();
  32053. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  32054. $errorMsg = $this->process->getErrorOutput();
  32055. if (Preg::isMatch('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  32056. || Preg::isMatch('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}i', $url, $match)
  32057. ) {
  32058. if (!$this->io->hasAuthentication($match[1])) {
  32059. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  32060. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  32061. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  32062. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  32063. }
  32064. }
  32065. if ($this->io->hasAuthentication($match[1])) {
  32066. $auth = $this->io->getAuthentication($match[1]);
  32067. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  32068. $command = call_user_func($commandCallable, $authUrl);
  32069. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32070. return;
  32071. }
  32072. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32073. $errorMsg = $this->process->getErrorOutput();
  32074. }
  32075. } elseif (Preg::isMatch('{^https://(bitbucket\.org)/(.*?)(?:\.git)?$}i', $url, $match)) {
  32076. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  32077. if (!$this->io->hasAuthentication($match[1])) {
  32078. $message = 'Enter your Bitbucket credentials to access private repos';
  32079. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  32080. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  32081. $accessToken = $bitbucketUtil->getToken();
  32082. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  32083. }
  32084. } else {
  32085. $auth = $this->io->getAuthentication($match[1]);
  32086. if ($auth['username'] !== 'x-token-auth') {
  32087. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  32088. if (!empty($accessToken)) {
  32089. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  32090. }
  32091. }
  32092. }
  32093. if ($this->io->hasAuthentication($match[1])) {
  32094. $auth = $this->io->getAuthentication($match[1]);
  32095. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  32096. $command = call_user_func($commandCallable, $authUrl);
  32097. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32098. return;
  32099. }
  32100. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32101. $errorMsg = $this->process->getErrorOutput();
  32102. } else {
  32103. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  32104. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  32105. $command = call_user_func($commandCallable, $sshUrl);
  32106. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32107. return;
  32108. }
  32109. $errorMsg = $this->process->getErrorOutput();
  32110. }
  32111. } elseif (
  32112. Preg::isMatch('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  32113. || Preg::isMatch('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}i', $url, $match)
  32114. ) {
  32115. if ($match[1] === 'git') {
  32116. $match[1] = 'https';
  32117. }
  32118. if (!$this->io->hasAuthentication($match[2])) {
  32119. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  32120. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  32121. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  32122. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  32123. }
  32124. }
  32125. if ($this->io->hasAuthentication($match[2])) {
  32126. $auth = $this->io->getAuthentication($match[2]);
  32127. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  32128. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  32129. } else {
  32130. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  32131. }
  32132. $command = call_user_func($commandCallable, $authUrl);
  32133. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32134. return;
  32135. }
  32136. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32137. $errorMsg = $this->process->getErrorOutput();
  32138. }
  32139. } elseif ($this->isAuthenticationFailure($url, $match)) {
  32140. if (strpos($match[2], '@')) {
  32141. list($authParts, $match[2]) = explode('@', $match[2], 2);
  32142. }
  32143. $storeAuth = false;
  32144. if ($this->io->hasAuthentication($match[2])) {
  32145. $auth = $this->io->getAuthentication($match[2]);
  32146. } elseif ($this->io->isInteractive()) {
  32147. $defaultUsername = null;
  32148. if (isset($authParts) && $authParts) {
  32149. if (false !== strpos($authParts, ':')) {
  32150. list($defaultUsername, ) = explode(':', $authParts, 2);
  32151. } else {
  32152. $defaultUsername = $authParts;
  32153. }
  32154. }
  32155. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  32156. $auth = array(
  32157. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  32158. 'password' => $this->io->askAndHideAnswer(' Password: '),
  32159. );
  32160. $storeAuth = $this->config->get('store-auths');
  32161. }
  32162. if ($auth) {
  32163. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  32164. $command = call_user_func($commandCallable, $authUrl);
  32165. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32166. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  32167. $authHelper = new AuthHelper($this->io, $this->config);
  32168. $authHelper->storeAuth($match[2], $storeAuth);
  32169. return;
  32170. }
  32171. $credentials = array(rawurlencode($auth['username']), rawurlencode($auth['password']));
  32172. $errorMsg = $this->process->getErrorOutput();
  32173. }
  32174. }
  32175. if ($initialClone && isset($origCwd)) {
  32176. $this->filesystem->removeDirectory($origCwd);
  32177. }
  32178. if (count($credentials) > 0) {
  32179. $command = $this->maskCredentials($command, $credentials);
  32180. $errorMsg = $this->maskCredentials($errorMsg, $credentials);
  32181. }
  32182. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  32183. }
  32184. }
  32185. public function syncMirror($url, $dir)
  32186. {
  32187. if (Platform::getEnv('COMPOSER_DISABLE_NETWORK') && Platform::getEnv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  32188. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  32189. return false;
  32190. }
  32191. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  32192. try {
  32193. $commandCallable = function ($url) {
  32194. $sanitizedUrl = Preg::replace('{://([^@]+?):(.+?)@}', '://', $url);
  32195. 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));
  32196. };
  32197. $this->runCommand($commandCallable, $url, $dir);
  32198. } catch (\Exception $e) {
  32199. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  32200. return false;
  32201. }
  32202. return true;
  32203. }
  32204. $this->filesystem->removeDirectory($dir);
  32205. $commandCallable = function ($url) use ($dir) {
  32206. return sprintf('git clone --mirror -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  32207. };
  32208. $this->runCommand($commandCallable, $url, $dir, true);
  32209. return true;
  32210. }
  32211. public function fetchRefOrSyncMirror($url, $dir, $ref)
  32212. {
  32213. if ($this->checkRefIsInMirror($dir, $ref)) {
  32214. return true;
  32215. }
  32216. if ($this->syncMirror($url, $dir)) {
  32217. return $this->checkRefIsInMirror($dir, $ref);
  32218. }
  32219. return false;
  32220. }
  32221. public static function getNoShowSignatureFlag(ProcessExecutor $process)
  32222. {
  32223. $gitVersion = self::getVersion($process);
  32224. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  32225. return ' --no-show-signature';
  32226. }
  32227. return '';
  32228. }
  32229. private function checkRefIsInMirror($dir, $ref)
  32230. {
  32231. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  32232. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  32233. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  32234. if ($exitCode === 0) {
  32235. return true;
  32236. }
  32237. }
  32238. return false;
  32239. }
  32240. private function isAuthenticationFailure($url, &$match)
  32241. {
  32242. if (!Preg::isMatch('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  32243. return false;
  32244. }
  32245. $authFailures = array(
  32246. 'fatal: Authentication failed',
  32247. 'remote error: Invalid username or password.',
  32248. 'error: 401 Unauthorized',
  32249. 'fatal: unable to access',
  32250. 'fatal: could not read Username',
  32251. );
  32252. $errorOutput = $this->process->getErrorOutput();
  32253. foreach ($authFailures as $authFailure) {
  32254. if (strpos($errorOutput, $authFailure) !== false) {
  32255. return true;
  32256. }
  32257. }
  32258. return false;
  32259. }
  32260. public static function cleanEnv()
  32261. {
  32262. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  32263. 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');
  32264. }
  32265. if (Platform::getEnv('GIT_ASKPASS') !== 'echo') {
  32266. Platform::putEnv('GIT_ASKPASS', 'echo');
  32267. }
  32268. if (Platform::getEnv('GIT_DIR')) {
  32269. Platform::clearEnv('GIT_DIR');
  32270. }
  32271. if (Platform::getEnv('GIT_WORK_TREE')) {
  32272. Platform::clearEnv('GIT_WORK_TREE');
  32273. }
  32274. if (Platform::getEnv('LANGUAGE') !== 'C') {
  32275. Platform::putEnv('LANGUAGE', 'C');
  32276. }
  32277. Platform::clearEnv('DYLD_LIBRARY_PATH');
  32278. }
  32279. public static function getGitHubDomainsRegex(Config $config)
  32280. {
  32281. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  32282. }
  32283. public static function getGitLabDomainsRegex(Config $config)
  32284. {
  32285. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  32286. }
  32287. private function throwException($message, $url)
  32288. {
  32289. clearstatcache();
  32290. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  32291. 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()));
  32292. }
  32293. throw new \RuntimeException(Url::sanitize($message));
  32294. }
  32295. public static function getVersion(ProcessExecutor $process)
  32296. {
  32297. if (false === self::$version) {
  32298. self::$version = null;
  32299. if (0 === $process->execute('git --version', $output) && Preg::isMatch('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  32300. self::$version = $matches[1];
  32301. }
  32302. }
  32303. return self::$version;
  32304. }
  32305. private function maskCredentials($error, array $credentials)
  32306. {
  32307. $maskedCredentials = array();
  32308. foreach ($credentials as $credential) {
  32309. if (in_array($credential, array('private-token', 'x-token-auth', 'oauth2', 'gitlab-ci-token', 'x-oauth-basic'))) {
  32310. $maskedCredentials[] = $credential;
  32311. } elseif (strlen($credential) > 6) {
  32312. $maskedCredentials[] = substr($credential, 0, 3) . '...' . substr($credential, -3);
  32313. } elseif (strlen($credential) > 3) {
  32314. $maskedCredentials[] = substr($credential, 0, 3) . '...';
  32315. } else {
  32316. $maskedCredentials[] = 'XXX';
  32317. }
  32318. }
  32319. return str_replace($credentials, $maskedCredentials, $error);
  32320. }
  32321. }
  32322. <?php
  32323. namespace Composer\Util;
  32324. use Composer\Factory;
  32325. use Composer\IO\IOInterface;
  32326. use Composer\Config;
  32327. use Composer\Downloader\TransportException;
  32328. use Composer\Pcre\Preg;
  32329. class GitHub
  32330. {
  32331. protected $io;
  32332. protected $config;
  32333. protected $process;
  32334. protected $httpDownloader;
  32335. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  32336. {
  32337. $this->io = $io;
  32338. $this->config = $config;
  32339. $this->process = $process ?: new ProcessExecutor($io);
  32340. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  32341. }
  32342. public function authorizeOAuth($originUrl)
  32343. {
  32344. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  32345. return false;
  32346. }
  32347. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  32348. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  32349. return true;
  32350. }
  32351. return false;
  32352. }
  32353. public function authorizeOAuthInteractively($originUrl, $message = null)
  32354. {
  32355. if ($message) {
  32356. $this->io->writeError($message);
  32357. }
  32358. $note = 'Composer';
  32359. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  32360. $note .= ' on ' . trim($output);
  32361. }
  32362. $note .= ' ' . date('Y-m-d Hi');
  32363. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=&description=' . str_replace('%20', '+', rawurlencode($note));
  32364. $this->io->writeError(sprintf('When working with _public_ GitHub repositories only, head to %s to retrieve a token.', $url));
  32365. $this->io->writeError('This token will have read-only permission for public information only.');
  32366. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  32367. $this->io->writeError(sprintf('When you need to access _private_ GitHub repositories as well, go to %s', $url));
  32368. $this->io->writeError('Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.');
  32369. $this->io->writeError(sprintf('Tokens will be stored in plain text in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  32370. $this->io->writeError('For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth');
  32371. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  32372. if (!$token) {
  32373. $this->io->writeError('<warning>No token given, aborting.</warning>');
  32374. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  32375. return false;
  32376. }
  32377. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  32378. try {
  32379. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  32380. $this->httpDownloader->get('https://'. $apiUrl, array(
  32381. 'retry-auth-failure' => false,
  32382. ));
  32383. } catch (TransportException $e) {
  32384. if (in_array($e->getCode(), array(403, 401))) {
  32385. $this->io->writeError('<error>Invalid token provided.</error>');
  32386. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  32387. return false;
  32388. }
  32389. throw $e;
  32390. }
  32391. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  32392. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  32393. $this->io->writeError('<info>Token stored successfully.</info>');
  32394. return true;
  32395. }
  32396. public function getRateLimit(array $headers)
  32397. {
  32398. $rateLimit = array(
  32399. 'limit' => '?',
  32400. 'reset' => '?',
  32401. );
  32402. foreach ($headers as $header) {
  32403. $header = trim($header);
  32404. if (false === strpos($header, 'X-RateLimit-')) {
  32405. continue;
  32406. }
  32407. list($type, $value) = explode(':', $header, 2);
  32408. switch ($type) {
  32409. case 'X-RateLimit-Limit':
  32410. $rateLimit['limit'] = (int) trim($value);
  32411. break;
  32412. case 'X-RateLimit-Reset':
  32413. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  32414. break;
  32415. }
  32416. }
  32417. return $rateLimit;
  32418. }
  32419. public function getSsoUrl(array $headers)
  32420. {
  32421. foreach ($headers as $header) {
  32422. $header = trim($header);
  32423. if (false === stripos($header, 'x-github-sso: required')) {
  32424. continue;
  32425. }
  32426. if (Preg::isMatch('{\burl=(?P<url>[^\s;]+)}', $header, $match)) {
  32427. return $match['url'];
  32428. }
  32429. }
  32430. return null;
  32431. }
  32432. public function isRateLimited(array $headers)
  32433. {
  32434. foreach ($headers as $header) {
  32435. if (Preg::isMatch('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  32436. return true;
  32437. }
  32438. }
  32439. return false;
  32440. }
  32441. public function requiresSso(array $headers)
  32442. {
  32443. foreach ($headers as $header) {
  32444. if (Preg::isMatch('{^X-GitHub-SSO: required}i', trim($header))) {
  32445. return true;
  32446. }
  32447. }
  32448. return false;
  32449. }
  32450. }
  32451. <?php
  32452. namespace Composer\Util;
  32453. use Composer\IO\IOInterface;
  32454. use Composer\Config;
  32455. use Composer\Factory;
  32456. use Composer\Downloader\TransportException;
  32457. use Composer\Pcre\Preg;
  32458. class GitLab
  32459. {
  32460. protected $io;
  32461. protected $config;
  32462. protected $process;
  32463. protected $httpDownloader;
  32464. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  32465. {
  32466. $this->io = $io;
  32467. $this->config = $config;
  32468. $this->process = $process ?: new ProcessExecutor($io);
  32469. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  32470. }
  32471. public function authorizeOAuth($originUrl)
  32472. {
  32473. $bcOriginUrl = Preg::replace('{:\d+}', '', $originUrl);
  32474. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  32475. return false;
  32476. }
  32477. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  32478. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  32479. return true;
  32480. }
  32481. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  32482. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  32483. return true;
  32484. }
  32485. $authTokens = $this->config->get('gitlab-token');
  32486. if (isset($authTokens[$originUrl])) {
  32487. $token = $authTokens[$originUrl];
  32488. }
  32489. if (isset($authTokens[$bcOriginUrl])) {
  32490. $token = $authTokens[$bcOriginUrl];
  32491. }
  32492. if (isset($token)) {
  32493. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  32494. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  32495. $this->io->setAuthentication($originUrl, $username, $password);
  32496. return true;
  32497. }
  32498. return false;
  32499. }
  32500. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  32501. {
  32502. if ($message) {
  32503. $this->io->writeError($message);
  32504. }
  32505. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  32506. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/-/profile/personal_access_tokens');
  32507. $attemptCounter = 0;
  32508. while ($attemptCounter++ < 5) {
  32509. try {
  32510. $response = $this->createToken($scheme, $originUrl);
  32511. } catch (TransportException $e) {
  32512. if (in_array($e->getCode(), array(403, 401))) {
  32513. if (401 === $e->getCode()) {
  32514. $response = json_decode($e->getResponse(), true);
  32515. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  32516. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  32517. } else {
  32518. $this->io->writeError('Bad credentials.');
  32519. }
  32520. } else {
  32521. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  32522. }
  32523. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  32524. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  32525. continue;
  32526. }
  32527. throw $e;
  32528. }
  32529. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  32530. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  32531. return true;
  32532. }
  32533. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  32534. }
  32535. private function createToken($scheme, $originUrl)
  32536. {
  32537. $username = $this->io->ask('Username: ');
  32538. $password = $this->io->askAndHideAnswer('Password: ');
  32539. $headers = array('Content-Type: application/x-www-form-urlencoded');
  32540. $apiUrl = $originUrl;
  32541. $data = http_build_query(array(
  32542. 'username' => $username,
  32543. 'password' => $password,
  32544. 'grant_type' => 'password',
  32545. ), '', '&');
  32546. $options = array(
  32547. 'retry-auth-failure' => false,
  32548. 'http' => array(
  32549. 'method' => 'POST',
  32550. 'header' => $headers,
  32551. 'content' => $data,
  32552. ),
  32553. );
  32554. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  32555. $this->io->writeError('Token successfully created');
  32556. return $token;
  32557. }
  32558. }
  32559. <?php
  32560. namespace Composer\Util;
  32561. use Composer\Config;
  32562. use Composer\IO\IOInterface;
  32563. use Composer\Pcre\Preg;
  32564. class Hg
  32565. {
  32566. private static $version = false;
  32567. private $io;
  32568. private $config;
  32569. private $process;
  32570. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  32571. {
  32572. $this->io = $io;
  32573. $this->config = $config;
  32574. $this->process = $process;
  32575. }
  32576. public function runCommand($commandCallable, $url, $cwd)
  32577. {
  32578. $this->config->prohibitUrlByConfig($url, $this->io);
  32579. $command = call_user_func($commandCallable, $url);
  32580. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32581. return;
  32582. }
  32583. if (Preg::isMatch('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  32584. $auth = $this->io->getAuthentication($match[5]);
  32585. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  32586. $command = call_user_func($commandCallable, $authenticatedUrl);
  32587. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  32588. return;
  32589. }
  32590. $error = $this->process->getErrorOutput();
  32591. } else {
  32592. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  32593. }
  32594. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  32595. }
  32596. private function throwException($message, $url)
  32597. {
  32598. if (null === self::getVersion($this->process)) {
  32599. 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()));
  32600. }
  32601. throw new \RuntimeException(Url::sanitize($message));
  32602. }
  32603. public static function getVersion(ProcessExecutor $process)
  32604. {
  32605. if (false === self::$version) {
  32606. self::$version = null;
  32607. if (0 === $process->execute('hg --version', $output) && Preg::isMatch('/^.+? (\d+(?:\.\d+)+)\)?\r?\n/', $output, $matches)) {
  32608. self::$version = $matches[1];
  32609. }
  32610. }
  32611. return self::$version;
  32612. }
  32613. }
  32614. <?php
  32615. namespace Composer\Util\Http;
  32616. use Composer\Config;
  32617. use Composer\Downloader\MaxFileSizeExceededException;
  32618. use Composer\IO\IOInterface;
  32619. use Composer\Downloader\TransportException;
  32620. use Composer\Pcre\Preg;
  32621. use Composer\Util\StreamContextFactory;
  32622. use Composer\Util\AuthHelper;
  32623. use Composer\Util\Url;
  32624. use Composer\Util\HttpDownloader;
  32625. use React\Promise\Promise;
  32626. class CurlDownloader
  32627. {
  32628. private $multiHandle;
  32629. private $shareHandle;
  32630. private $jobs = array();
  32631. private $io;
  32632. private $config;
  32633. private $authHelper;
  32634. private $selectTimeout = 5.0;
  32635. private $maxRedirects = 20;
  32636. private $maxRetries = 3;
  32637. private $proxyManager;
  32638. private $supportsSecureProxy;
  32639. protected $multiErrors = array(
  32640. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  32641. 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."),
  32642. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  32643. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'),
  32644. );
  32645. private static $options = array(
  32646. 'http' => array(
  32647. 'method' => CURLOPT_CUSTOMREQUEST,
  32648. 'content' => CURLOPT_POSTFIELDS,
  32649. 'header' => CURLOPT_HTTPHEADER,
  32650. 'timeout' => CURLOPT_TIMEOUT,
  32651. ),
  32652. 'ssl' => array(
  32653. 'cafile' => CURLOPT_CAINFO,
  32654. 'capath' => CURLOPT_CAPATH,
  32655. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  32656. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  32657. 'local_cert' => CURLOPT_SSLCERT,
  32658. 'local_pk' => CURLOPT_SSLKEY,
  32659. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  32660. ),
  32661. );
  32662. private static $timeInfo = array(
  32663. 'total_time' => true,
  32664. 'namelookup_time' => true,
  32665. 'connect_time' => true,
  32666. 'pretransfer_time' => true,
  32667. 'starttransfer_time' => true,
  32668. 'redirect_time' => true,
  32669. );
  32670. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  32671. {
  32672. $this->io = $io;
  32673. $this->config = $config;
  32674. $this->multiHandle = $mh = curl_multi_init();
  32675. if (function_exists('curl_multi_setopt')) {
  32676. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  32677. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  32678. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  32679. }
  32680. }
  32681. if (function_exists('curl_share_init')) {
  32682. $this->shareHandle = $sh = curl_share_init();
  32683. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  32684. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  32685. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  32686. }
  32687. $this->authHelper = new AuthHelper($io, $config);
  32688. $this->proxyManager = ProxyManager::getInstance();
  32689. $version = curl_version();
  32690. $features = $version['features'];
  32691. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  32692. }
  32693. public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
  32694. {
  32695. $attributes = array();
  32696. if (isset($options['retry-auth-failure'])) {
  32697. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  32698. unset($options['retry-auth-failure']);
  32699. }
  32700. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  32701. }
  32702. private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
  32703. {
  32704. $attributes = array_merge(array(
  32705. 'retryAuthFailure' => true,
  32706. 'redirects' => 0,
  32707. 'retries' => 0,
  32708. 'storeAuth' => false,
  32709. ), $attributes);
  32710. $originalOptions = $options;
  32711. if (!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  32712. $this->config->prohibitUrlByConfig($url, $this->io);
  32713. }
  32714. $curlHandle = curl_init();
  32715. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  32716. if (false === $headerHandle) {
  32717. throw new \RuntimeException('Failed to open a temp stream to store curl headers');
  32718. }
  32719. if ($copyTo) {
  32720. $errorMessage = '';
  32721. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32722. if ($errorMessage) {
  32723. $errorMessage .= "\n";
  32724. }
  32725. $errorMessage .= Preg::replace('{^fopen\(.*?\): }', '', $msg);
  32726. });
  32727. $bodyHandle = fopen($copyTo.'~', 'w+b');
  32728. restore_error_handler();
  32729. if (!$bodyHandle) {
  32730. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  32731. }
  32732. } else {
  32733. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  32734. }
  32735. curl_setopt($curlHandle, CURLOPT_URL, $url);
  32736. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  32737. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  32738. curl_setopt($curlHandle, CURLOPT_TIMEOUT, max((int) ini_get("default_socket_timeout"), 300));
  32739. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  32740. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  32741. curl_setopt($curlHandle, CURLOPT_ENCODING, "");
  32742. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  32743. if (function_exists('curl_share_init')) {
  32744. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  32745. }
  32746. if (!isset($options['http']['header'])) {
  32747. $options['http']['header'] = array();
  32748. }
  32749. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  32750. $options['http']['header'][] = 'Connection: keep-alive';
  32751. $version = curl_version();
  32752. $features = $version['features'];
  32753. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  32754. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  32755. }
  32756. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  32757. $options = StreamContextFactory::initOptions($url, $options, true);
  32758. foreach (self::$options as $type => $curlOptions) {
  32759. foreach ($curlOptions as $name => $curlOption) {
  32760. if (isset($options[$type][$name])) {
  32761. if ($type === 'ssl' && $name === 'verify_peer_name') {
  32762. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  32763. } else {
  32764. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  32765. }
  32766. }
  32767. }
  32768. }
  32769. $proxy = $this->proxyManager->getProxyForRequest($url);
  32770. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  32771. if ($proxy->isSecure()) {
  32772. if (!$this->supportsSecureProxy) {
  32773. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  32774. }
  32775. if (!empty($options['ssl']['cafile'])) {
  32776. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  32777. }
  32778. if (!empty($options['ssl']['capath'])) {
  32779. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  32780. }
  32781. }
  32782. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  32783. $this->jobs[(int) $curlHandle] = array(
  32784. 'url' => $url,
  32785. 'origin' => $origin,
  32786. 'attributes' => $attributes,
  32787. 'options' => $originalOptions,
  32788. 'progress' => $progress,
  32789. 'curlHandle' => $curlHandle,
  32790. 'filename' => $copyTo,
  32791. 'headerHandle' => $headerHandle,
  32792. 'bodyHandle' => $bodyHandle,
  32793. 'resolve' => $resolve,
  32794. 'reject' => $reject,
  32795. );
  32796. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  32797. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  32798. if ($attributes['redirects'] === 0 && $attributes['retries'] === 0) {
  32799. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  32800. }
  32801. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  32802. return (int) $curlHandle;
  32803. }
  32804. public function abortRequest($id)
  32805. {
  32806. if (isset($this->jobs[$id], $this->jobs[$id]['curlHandle'])) {
  32807. $job = $this->jobs[$id];
  32808. curl_multi_remove_handle($this->multiHandle, $job['curlHandle']);
  32809. curl_close($job['curlHandle']);
  32810. if (is_resource($job['headerHandle'])) {
  32811. fclose($job['headerHandle']);
  32812. }
  32813. if (is_resource($job['bodyHandle'])) {
  32814. fclose($job['bodyHandle']);
  32815. }
  32816. if ($job['filename']) {
  32817. @unlink($job['filename'].'~');
  32818. }
  32819. unset($this->jobs[$id]);
  32820. }
  32821. }
  32822. public function tick()
  32823. {
  32824. static $timeoutWarning = false;
  32825. if (!$this->jobs) {
  32826. return;
  32827. }
  32828. $active = true;
  32829. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  32830. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  32831. usleep(150);
  32832. }
  32833. while ($progress = curl_multi_info_read($this->multiHandle)) {
  32834. $curlHandle = $progress['handle'];
  32835. $result = $progress['result'];
  32836. $i = (int) $curlHandle;
  32837. if (!isset($this->jobs[$i])) {
  32838. continue;
  32839. }
  32840. $progress = curl_getinfo($curlHandle);
  32841. $job = $this->jobs[$i];
  32842. unset($this->jobs[$i]);
  32843. $error = curl_error($curlHandle);
  32844. $errno = curl_errno($curlHandle);
  32845. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  32846. curl_close($curlHandle);
  32847. $headers = null;
  32848. $statusCode = null;
  32849. $response = null;
  32850. try {
  32851. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  32852. $errno = $errno ?: $result;
  32853. if (!$error && function_exists('curl_strerror')) {
  32854. $error = curl_strerror($errno);
  32855. }
  32856. $progress['error_code'] = $errno;
  32857. if (
  32858. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  32859. && (
  32860. in_array($errno, array(7 , 16 , 92 ), true)
  32861. || ($errno === 35 && false !== strpos($error, 'Connection reset by peer'))
  32862. ) && $job['attributes']['retries'] < $this->maxRetries
  32863. ) {
  32864. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to curl error '. $errno, true, IOInterface::DEBUG);
  32865. $this->restartJob($job, $job['url'], array('retries' => $job['attributes']['retries'] + 1));
  32866. continue;
  32867. }
  32868. if ($errno === 28 && isset($progress['namelookup_time']) && $progress['namelookup_time'] == 0 && !$timeoutWarning) {
  32869. $timeoutWarning = true;
  32870. $this->io->writeError('<warning>A connection timeout was encountered. If you intend to run Composer without connecting to the internet, run the command again prefixed with COMPOSER_DISABLE_NETWORK=1 to make Composer run in offline mode.</warning>');
  32871. }
  32872. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  32873. }
  32874. $statusCode = $progress['http_code'];
  32875. rewind($job['headerHandle']);
  32876. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  32877. fclose($job['headerHandle']);
  32878. if ($statusCode === 0) {
  32879. 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));
  32880. }
  32881. if ($job['filename']) {
  32882. $contents = $job['filename'].'~';
  32883. if ($statusCode >= 300) {
  32884. rewind($job['bodyHandle']);
  32885. $contents = stream_get_contents($job['bodyHandle']);
  32886. }
  32887. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  32888. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  32889. } else {
  32890. rewind($job['bodyHandle']);
  32891. $contents = stream_get_contents($job['bodyHandle']);
  32892. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  32893. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  32894. }
  32895. fclose($job['bodyHandle']);
  32896. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  32897. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  32898. }
  32899. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  32900. if ($result['retry']) {
  32901. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  32902. continue;
  32903. }
  32904. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  32905. $location = $this->handleRedirect($job, $response);
  32906. if ($location) {
  32907. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  32908. continue;
  32909. }
  32910. }
  32911. if ($statusCode >= 400 && $statusCode <= 599) {
  32912. if (
  32913. (!isset($job['options']['http']['method']) || $job['options']['http']['method'] === 'GET')
  32914. && in_array($statusCode, array(423, 425, 500, 502, 503, 504, 507, 510), true)
  32915. && $job['attributes']['retries'] < $this->maxRetries
  32916. ) {
  32917. $this->io->writeError('Retrying ('.($job['attributes']['retries'] + 1).') ' . Url::sanitize($job['url']) . ' due to status code '. $statusCode, true, IOInterface::DEBUG);
  32918. $this->restartJob($job, $job['url'], array('retries' => $job['attributes']['retries'] + 1));
  32919. continue;
  32920. }
  32921. throw $this->failResponse($job, $response, $response->getStatusMessage());
  32922. }
  32923. if ($job['attributes']['storeAuth']) {
  32924. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  32925. }
  32926. if ($job['filename']) {
  32927. rename($job['filename'].'~', $job['filename']);
  32928. call_user_func($job['resolve'], $response);
  32929. } else {
  32930. call_user_func($job['resolve'], $response);
  32931. }
  32932. } catch (\Exception $e) {
  32933. if ($e instanceof TransportException && $headers) {
  32934. $e->setHeaders($headers);
  32935. $e->setStatusCode($statusCode);
  32936. }
  32937. if ($e instanceof TransportException && $response) {
  32938. $e->setResponse($response->getBody());
  32939. }
  32940. if ($e instanceof TransportException && $progress) {
  32941. $e->setResponseInfo($progress);
  32942. }
  32943. $this->rejectJob($job, $e);
  32944. }
  32945. }
  32946. foreach ($this->jobs as $i => $curlHandle) {
  32947. if (!isset($this->jobs[$i])) {
  32948. continue;
  32949. }
  32950. $curlHandle = $this->jobs[$i]['curlHandle'];
  32951. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  32952. if ($this->jobs[$i]['progress'] !== $progress) {
  32953. $this->jobs[$i]['progress'] = $progress;
  32954. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  32955. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  32956. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Content-length header indicates ' . $progress['download_content_length'] . ' bytes. Allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  32957. }
  32958. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  32959. $this->rejectJob($this->jobs[$i], new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes'));
  32960. }
  32961. }
  32962. }
  32963. }
  32964. }
  32965. private function handleRedirect(array $job, Response $response)
  32966. {
  32967. if ($locationHeader = $response->getHeader('location')) {
  32968. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  32969. $targetUrl = $locationHeader;
  32970. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  32971. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  32972. } elseif ('/' === $locationHeader[0]) {
  32973. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  32974. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  32975. } else {
  32976. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  32977. }
  32978. }
  32979. if (!empty($targetUrl)) {
  32980. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  32981. return $targetUrl;
  32982. }
  32983. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  32984. }
  32985. private function isAuthenticatedRetryNeeded(array $job, Response $response)
  32986. {
  32987. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  32988. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  32989. if ($result['retry']) {
  32990. return $result;
  32991. }
  32992. }
  32993. $locationHeader = $response->getHeader('location');
  32994. $needsAuthRetry = false;
  32995. if (
  32996. $job['origin'] === 'bitbucket.org'
  32997. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  32998. && substr($job['url'], -4) === '.zip'
  32999. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  33000. && Preg::isMatch('{^text/html\b}i', $response->getHeader('content-type'))
  33001. ) {
  33002. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  33003. }
  33004. if (
  33005. $response->getStatusCode() === 404
  33006. && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  33007. && false !== strpos($job['url'], 'archive.zip')
  33008. ) {
  33009. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  33010. }
  33011. if ($needsAuthRetry) {
  33012. if ($job['attributes']['retryAuthFailure']) {
  33013. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  33014. if ($result['retry']) {
  33015. return $result;
  33016. }
  33017. }
  33018. throw $this->failResponse($job, $response, $needsAuthRetry);
  33019. }
  33020. return array('retry' => false, 'storeAuth' => false);
  33021. }
  33022. private function restartJob(array $job, $url, array $attributes = array())
  33023. {
  33024. if ($job['filename']) {
  33025. @unlink($job['filename'].'~');
  33026. }
  33027. $attributes = array_merge($job['attributes'], $attributes);
  33028. $origin = Url::getOrigin($this->config, $url);
  33029. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  33030. }
  33031. private function failResponse(array $job, Response $response, $errorMessage)
  33032. {
  33033. if ($job['filename']) {
  33034. @unlink($job['filename'].'~');
  33035. }
  33036. $details = '';
  33037. if (in_array(strtolower($response->getHeader('content-type')), array('application/json', 'application/json; charset=utf-8'), true)) {
  33038. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  33039. }
  33040. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  33041. }
  33042. private function rejectJob(array $job, \Exception $e)
  33043. {
  33044. if (is_resource($job['headerHandle'])) {
  33045. fclose($job['headerHandle']);
  33046. }
  33047. if (is_resource($job['bodyHandle'])) {
  33048. fclose($job['bodyHandle']);
  33049. }
  33050. if ($job['filename']) {
  33051. @unlink($job['filename'].'~');
  33052. }
  33053. call_user_func($job['reject'], $e);
  33054. }
  33055. private function checkCurlResult($code)
  33056. {
  33057. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  33058. throw new \RuntimeException(
  33059. isset($this->multiErrors[$code])
  33060. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  33061. : 'Unexpected cURL error: ' . $code
  33062. );
  33063. }
  33064. }
  33065. }
  33066. <?php
  33067. namespace Composer\Util\Http;
  33068. class CurlResponse extends Response
  33069. {
  33070. private $curlInfo;
  33071. public function __construct(array $request, $code, array $headers, $body, array $curlInfo)
  33072. {
  33073. parent::__construct($request, $code, $headers, $body);
  33074. $this->curlInfo = $curlInfo;
  33075. }
  33076. public function getCurlInfo()
  33077. {
  33078. return $this->curlInfo;
  33079. }
  33080. }
  33081. <?php
  33082. namespace Composer\Util\Http;
  33083. class ProxyHelper
  33084. {
  33085. public static function getProxyData()
  33086. {
  33087. $httpProxy = null;
  33088. $httpsProxy = null;
  33089. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  33090. if ($env = self::getProxyEnv(array('http_proxy', 'HTTP_PROXY'), $name)) {
  33091. $httpProxy = self::checkProxy($env, $name);
  33092. }
  33093. }
  33094. if ($env = self::getProxyEnv(array('CGI_HTTP_PROXY'), $name)) {
  33095. $httpProxy = self::checkProxy($env, $name);
  33096. }
  33097. if ($env = self::getProxyEnv(array('https_proxy', 'HTTPS_PROXY'), $name)) {
  33098. $httpsProxy = self::checkProxy($env, $name);
  33099. } else {
  33100. $httpsProxy = $httpProxy;
  33101. }
  33102. $noProxy = self::getProxyEnv(array('no_proxy', 'NO_PROXY'), $name);
  33103. return array($httpProxy, $httpsProxy, $noProxy);
  33104. }
  33105. public static function getContextOptions($proxyUrl)
  33106. {
  33107. $proxy = parse_url($proxyUrl);
  33108. $proxyUrl = self::formatParsedUrl($proxy, false);
  33109. $proxyUrl = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyUrl);
  33110. $options['http']['proxy'] = $proxyUrl;
  33111. if (isset($proxy['user'])) {
  33112. $auth = rawurldecode($proxy['user']);
  33113. if (isset($proxy['pass'])) {
  33114. $auth .= ':' . rawurldecode($proxy['pass']);
  33115. }
  33116. $auth = base64_encode($auth);
  33117. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  33118. }
  33119. return $options;
  33120. }
  33121. public static function setRequestFullUri($requestUrl, array &$options)
  33122. {
  33123. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  33124. $options['http']['request_fulluri'] = true;
  33125. } else {
  33126. unset($options['http']['request_fulluri']);
  33127. }
  33128. }
  33129. private static function getProxyEnv(array $names, &$name)
  33130. {
  33131. foreach ($names as $name) {
  33132. if (!empty($_SERVER[$name])) {
  33133. return $_SERVER[$name];
  33134. }
  33135. }
  33136. return null;
  33137. }
  33138. private static function checkProxy($proxyUrl, $envName)
  33139. {
  33140. $error = sprintf('malformed %s url', $envName);
  33141. $proxy = parse_url($proxyUrl);
  33142. if (!isset($proxy['host'])) {
  33143. throw new \RuntimeException($error);
  33144. }
  33145. $proxyUrl = self::formatParsedUrl($proxy, true);
  33146. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  33147. throw new \RuntimeException($error);
  33148. }
  33149. return $proxyUrl;
  33150. }
  33151. private static function formatParsedUrl(array $proxy, $includeAuth)
  33152. {
  33153. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  33154. if ($includeAuth && isset($proxy['user'])) {
  33155. $proxyUrl .= $proxy['user'];
  33156. if (isset($proxy['pass'])) {
  33157. $proxyUrl .= ':' . $proxy['pass'];
  33158. }
  33159. $proxyUrl .= '@';
  33160. }
  33161. $proxyUrl .= $proxy['host'];
  33162. if (isset($proxy['port'])) {
  33163. $proxyUrl .= ':' . $proxy['port'];
  33164. } elseif (strpos($proxyUrl, 'http://') === 0) {
  33165. $proxyUrl .= ':80';
  33166. } elseif (strpos($proxyUrl, 'https://') === 0) {
  33167. $proxyUrl .= ':443';
  33168. }
  33169. return $proxyUrl;
  33170. }
  33171. }
  33172. <?php
  33173. namespace Composer\Util\Http;
  33174. use Composer\Downloader\TransportException;
  33175. use Composer\Util\NoProxyPattern;
  33176. use Composer\Util\Url;
  33177. class ProxyManager
  33178. {
  33179. private $error = null;
  33180. private $fullProxy;
  33181. private $safeProxy;
  33182. private $streams;
  33183. private $hasProxy;
  33184. private $info = null;
  33185. private $noProxyHandler = null;
  33186. private static $instance = null;
  33187. private function __construct()
  33188. {
  33189. $this->fullProxy = $this->safeProxy = array(
  33190. 'http' => null,
  33191. 'https' => null,
  33192. );
  33193. $this->streams['http'] = $this->streams['https'] = array(
  33194. 'options' => null,
  33195. );
  33196. $this->hasProxy = false;
  33197. $this->initProxyData();
  33198. }
  33199. public static function getInstance()
  33200. {
  33201. if (!self::$instance) {
  33202. self::$instance = new self();
  33203. }
  33204. return self::$instance;
  33205. }
  33206. public static function reset()
  33207. {
  33208. self::$instance = null;
  33209. }
  33210. public function getProxyForRequest($requestUrl)
  33211. {
  33212. if ($this->error) {
  33213. throw new TransportException('Unable to use a proxy: '.$this->error);
  33214. }
  33215. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  33216. $proxyUrl = '';
  33217. $options = array();
  33218. $formattedProxyUrl = '';
  33219. if ($this->hasProxy && in_array($scheme, array('http', 'https'), true) && $this->fullProxy[$scheme]) {
  33220. if ($this->noProxy($requestUrl)) {
  33221. $formattedProxyUrl = 'excluded by no_proxy';
  33222. } else {
  33223. $proxyUrl = $this->fullProxy[$scheme];
  33224. $options = $this->streams[$scheme]['options'];
  33225. ProxyHelper::setRequestFullUri($requestUrl, $options);
  33226. $formattedProxyUrl = $this->safeProxy[$scheme];
  33227. }
  33228. }
  33229. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  33230. }
  33231. public function isProxying()
  33232. {
  33233. return $this->hasProxy;
  33234. }
  33235. public function getFormattedProxy()
  33236. {
  33237. return $this->hasProxy ? $this->info : $this->error;
  33238. }
  33239. private function initProxyData()
  33240. {
  33241. try {
  33242. list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
  33243. } catch (\RuntimeException $e) {
  33244. $this->error = $e->getMessage();
  33245. return;
  33246. }
  33247. $info = array();
  33248. if ($httpProxy) {
  33249. $info[] = $this->setData($httpProxy, 'http');
  33250. }
  33251. if ($httpsProxy) {
  33252. $info[] = $this->setData($httpsProxy, 'https');
  33253. }
  33254. if ($this->hasProxy) {
  33255. $this->info = implode(', ', $info);
  33256. if ($noProxy) {
  33257. $this->noProxyHandler = new NoProxyPattern($noProxy);
  33258. }
  33259. }
  33260. }
  33261. private function setData($url, $scheme)
  33262. {
  33263. $safeProxy = Url::sanitize($url);
  33264. $this->fullProxy[$scheme] = $url;
  33265. $this->safeProxy[$scheme] = $safeProxy;
  33266. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  33267. $this->hasProxy = true;
  33268. return sprintf('%s=%s', $scheme, $safeProxy);
  33269. }
  33270. private function noProxy($requestUrl)
  33271. {
  33272. return $this->noProxyHandler && $this->noProxyHandler->test($requestUrl);
  33273. }
  33274. }
  33275. <?php
  33276. namespace Composer\Util\Http;
  33277. use Composer\Util\Url;
  33278. class RequestProxy
  33279. {
  33280. private $contextOptions;
  33281. private $isSecure;
  33282. private $formattedUrl;
  33283. private $url;
  33284. public function __construct($url, array $contextOptions, $formattedUrl)
  33285. {
  33286. $this->url = $url;
  33287. $this->contextOptions = $contextOptions;
  33288. $this->formattedUrl = $formattedUrl;
  33289. $this->isSecure = 0 === strpos($url, 'https://');
  33290. }
  33291. public function getContextOptions()
  33292. {
  33293. return $this->contextOptions;
  33294. }
  33295. public function getFormattedUrl($format = '')
  33296. {
  33297. $result = '';
  33298. if ($this->formattedUrl) {
  33299. $format = $format ?: '%s';
  33300. $result = sprintf($format, $this->formattedUrl);
  33301. }
  33302. return $result;
  33303. }
  33304. public function getUrl()
  33305. {
  33306. return $this->url;
  33307. }
  33308. public function isSecure()
  33309. {
  33310. return $this->isSecure;
  33311. }
  33312. }
  33313. <?php
  33314. namespace Composer\Util\Http;
  33315. use Composer\Json\JsonFile;
  33316. use Composer\Pcre\Preg;
  33317. use Composer\Util\HttpDownloader;
  33318. class Response
  33319. {
  33320. private $request;
  33321. private $code;
  33322. private $headers;
  33323. private $body;
  33324. public function __construct(array $request, $code, array $headers, $body)
  33325. {
  33326. if (!isset($request['url'])) {
  33327. throw new \LogicException('url key missing from request array');
  33328. }
  33329. $this->request = $request;
  33330. $this->code = (int) $code;
  33331. $this->headers = $headers;
  33332. $this->body = $body;
  33333. }
  33334. public function getStatusCode()
  33335. {
  33336. return $this->code;
  33337. }
  33338. public function getStatusMessage()
  33339. {
  33340. $value = null;
  33341. foreach ($this->headers as $header) {
  33342. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  33343. $value = $header;
  33344. }
  33345. }
  33346. return $value;
  33347. }
  33348. public function getHeaders()
  33349. {
  33350. return $this->headers;
  33351. }
  33352. public function getHeader($name)
  33353. {
  33354. return self::findHeaderValue($this->headers, $name);
  33355. }
  33356. public function getBody()
  33357. {
  33358. return $this->body;
  33359. }
  33360. public function decodeJson()
  33361. {
  33362. return JsonFile::parseJson($this->body, $this->request['url']);
  33363. }
  33364. public function collect()
  33365. {
  33366. $this->request = $this->code = $this->headers = $this->body = null;
  33367. }
  33368. public static function findHeaderValue(array $headers, $name)
  33369. {
  33370. $value = null;
  33371. foreach ($headers as $header) {
  33372. if (Preg::isMatch('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  33373. $value = $match[1];
  33374. }
  33375. }
  33376. return $value;
  33377. }
  33378. }
  33379. <?php
  33380. namespace Composer\Util;
  33381. use Composer\Config;
  33382. use Composer\IO\IOInterface;
  33383. use Composer\Downloader\TransportException;
  33384. use Composer\Pcre\Preg;
  33385. use Composer\Util\Http\Response;
  33386. use Composer\Util\Http\CurlDownloader;
  33387. use Composer\Composer;
  33388. use Composer\Package\Version\VersionParser;
  33389. use Composer\Semver\Constraint\Constraint;
  33390. use Composer\Exception\IrrecoverableDownloadException;
  33391. use React\Promise\Promise;
  33392. use React\Promise\PromiseInterface;
  33393. class HttpDownloader
  33394. {
  33395. const STATUS_QUEUED = 1;
  33396. const STATUS_STARTED = 2;
  33397. const STATUS_COMPLETED = 3;
  33398. const STATUS_FAILED = 4;
  33399. const STATUS_ABORTED = 5;
  33400. private $io;
  33401. private $config;
  33402. private $jobs = array();
  33403. private $options = array();
  33404. private $runningJobs = 0;
  33405. private $maxJobs = 12;
  33406. private $curl;
  33407. private $rfs;
  33408. private $idGen = 0;
  33409. private $disabled;
  33410. private $allowAsync = false;
  33411. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  33412. {
  33413. $this->io = $io;
  33414. $this->disabled = (bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK');
  33415. if ($disableTls === false) {
  33416. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  33417. }
  33418. $this->options = array_replace_recursive($this->options, $options);
  33419. $this->config = $config;
  33420. if (self::isCurlEnabled()) {
  33421. $this->curl = new CurlDownloader($io, $config, $options, $disableTls);
  33422. }
  33423. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  33424. if (is_numeric($maxJobs = Platform::getEnv('COMPOSER_MAX_PARALLEL_HTTP'))) {
  33425. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  33426. }
  33427. }
  33428. public function get($url, $options = array())
  33429. {
  33430. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null), true);
  33431. $this->wait($job['id']);
  33432. $response = $this->getResponse($job['id']);
  33433. if (
  33434. $this->curl
  33435. && PHP_VERSION_ID < 70000
  33436. && $response->getBody() === null
  33437. && $response->getStatusCode() === 200
  33438. && $response->getHeader('content-length') !== '0'
  33439. ) {
  33440. $this->io->writeError('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
  33441. $this->curl = null;
  33442. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null), true);
  33443. $this->wait($job['id']);
  33444. $response = $this->getResponse($job['id']);
  33445. }
  33446. return $response;
  33447. }
  33448. public function add($url, $options = array())
  33449. {
  33450. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => null));
  33451. return $promise;
  33452. }
  33453. public function copy($url, $to, $options = array())
  33454. {
  33455. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  33456. $this->wait($job['id']);
  33457. return $this->getResponse($job['id']);
  33458. }
  33459. public function addCopy($url, $to, $options = array())
  33460. {
  33461. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  33462. return $promise;
  33463. }
  33464. public function getOptions()
  33465. {
  33466. return $this->options;
  33467. }
  33468. public function setOptions(array $options)
  33469. {
  33470. $this->options = array_replace_recursive($this->options, $options);
  33471. }
  33472. private function addJob($request, $sync = false)
  33473. {
  33474. $request['options'] = array_replace_recursive($this->options, $request['options']);
  33475. $job = array(
  33476. 'id' => $this->idGen++,
  33477. 'status' => self::STATUS_QUEUED,
  33478. 'request' => $request,
  33479. 'sync' => $sync,
  33480. 'origin' => Url::getOrigin($this->config, $request['url']),
  33481. );
  33482. if (!$sync && !$this->allowAsync) {
  33483. 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');
  33484. }
  33485. if (Preg::isMatch('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  33486. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  33487. }
  33488. $rfs = $this->rfs;
  33489. if ($this->canUseCurl($job)) {
  33490. $resolver = function ($resolve, $reject) use (&$job) {
  33491. $job['status'] = HttpDownloader::STATUS_QUEUED;
  33492. $job['resolve'] = $resolve;
  33493. $job['reject'] = $reject;
  33494. };
  33495. } else {
  33496. $resolver = function ($resolve, $reject) use (&$job, $rfs) {
  33497. $url = $job['request']['url'];
  33498. $options = $job['request']['options'];
  33499. $job['status'] = HttpDownloader::STATUS_STARTED;
  33500. if ($job['request']['copyTo']) {
  33501. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  33502. $headers = $rfs->getLastHeaders();
  33503. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  33504. $resolve($response);
  33505. } else {
  33506. $body = $rfs->getContents($job['origin'], $url, false , $options);
  33507. $headers = $rfs->getLastHeaders();
  33508. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  33509. $resolve($response);
  33510. }
  33511. };
  33512. }
  33513. $downloader = $this;
  33514. $curl = $this->curl;
  33515. $canceler = function () use (&$job, $curl) {
  33516. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  33517. $job['status'] = HttpDownloader::STATUS_ABORTED;
  33518. }
  33519. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  33520. return;
  33521. }
  33522. $job['status'] = HttpDownloader::STATUS_ABORTED;
  33523. if (isset($job['curl_id'])) {
  33524. $curl->abortRequest($job['curl_id']);
  33525. }
  33526. throw new IrrecoverableDownloadException('Download of ' . Url::sanitize($job['request']['url']) . ' canceled');
  33527. };
  33528. $promise = new Promise($resolver, $canceler);
  33529. $promise = $promise->then(function ($response) use (&$job, $downloader) {
  33530. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  33531. $job['response'] = $response;
  33532. $downloader->markJobDone();
  33533. return $response;
  33534. }, function ($e) use (&$job, $downloader) {
  33535. $job['status'] = HttpDownloader::STATUS_FAILED;
  33536. $job['exception'] = $e;
  33537. $downloader->markJobDone();
  33538. throw $e;
  33539. });
  33540. $this->jobs[$job['id']] = &$job;
  33541. if ($this->runningJobs < $this->maxJobs) {
  33542. $this->startJob($job['id']);
  33543. }
  33544. return array($job, $promise);
  33545. }
  33546. private function startJob($id)
  33547. {
  33548. $job = &$this->jobs[$id];
  33549. if ($job['status'] !== self::STATUS_QUEUED) {
  33550. return;
  33551. }
  33552. $job['status'] = self::STATUS_STARTED;
  33553. $this->runningJobs++;
  33554. $resolve = $job['resolve'];
  33555. $reject = $job['reject'];
  33556. $url = $job['request']['url'];
  33557. $options = $job['request']['options'];
  33558. $origin = $job['origin'];
  33559. if ($this->disabled) {
  33560. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  33561. $resolve(new Response(array('url' => $url), 304, array(), ''));
  33562. } else {
  33563. $e = new TransportException('Network disabled, request canceled: '.Url::sanitize($url), 499);
  33564. $e->setStatusCode(499);
  33565. $reject($e);
  33566. }
  33567. return;
  33568. }
  33569. try {
  33570. if ($job['request']['copyTo']) {
  33571. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  33572. } else {
  33573. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  33574. }
  33575. } catch (\Exception $exception) {
  33576. $reject($exception);
  33577. }
  33578. }
  33579. public function markJobDone()
  33580. {
  33581. $this->runningJobs--;
  33582. }
  33583. public function wait($index = null)
  33584. {
  33585. do {
  33586. $jobCount = $this->countActiveJobs($index);
  33587. } while ($jobCount);
  33588. }
  33589. public function enableAsync()
  33590. {
  33591. $this->allowAsync = true;
  33592. }
  33593. public function countActiveJobs($index = null)
  33594. {
  33595. if ($this->runningJobs < $this->maxJobs) {
  33596. foreach ($this->jobs as $job) {
  33597. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  33598. $this->startJob($job['id']);
  33599. }
  33600. }
  33601. }
  33602. if ($this->curl) {
  33603. $this->curl->tick();
  33604. }
  33605. if (null !== $index) {
  33606. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  33607. }
  33608. $active = 0;
  33609. foreach ($this->jobs as $job) {
  33610. if ($job['status'] < self::STATUS_COMPLETED) {
  33611. $active++;
  33612. } elseif (!$job['sync']) {
  33613. unset($this->jobs[$job['id']]);
  33614. }
  33615. }
  33616. return $active;
  33617. }
  33618. private function getResponse($index)
  33619. {
  33620. if (!isset($this->jobs[$index])) {
  33621. throw new \LogicException('Invalid request id');
  33622. }
  33623. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  33624. throw $this->jobs[$index]['exception'];
  33625. }
  33626. if (!isset($this->jobs[$index]['response'])) {
  33627. throw new \LogicException('Response not available yet, call wait() first');
  33628. }
  33629. $resp = $this->jobs[$index]['response'];
  33630. unset($this->jobs[$index]);
  33631. return $resp;
  33632. }
  33633. public static function outputWarnings(IOInterface $io, $url, $data)
  33634. {
  33635. foreach (array('warning', 'info') as $type) {
  33636. if (empty($data[$type])) {
  33637. continue;
  33638. }
  33639. if (!empty($data[$type . '-versions'])) {
  33640. $versionParser = new VersionParser();
  33641. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  33642. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  33643. if (!$constraint->matches($composer)) {
  33644. continue;
  33645. }
  33646. }
  33647. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$data[$type].'</'.$type.'>');
  33648. }
  33649. foreach (array('warnings', 'infos') as $key) {
  33650. if (empty($data[$key])) {
  33651. continue;
  33652. }
  33653. $versionParser = new VersionParser();
  33654. foreach ($data[$key] as $spec) {
  33655. $type = substr($key, 0, -1);
  33656. $constraint = $versionParser->parseConstraints($spec['versions']);
  33657. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  33658. if (!$constraint->matches($composer)) {
  33659. continue;
  33660. }
  33661. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$spec['message'].'</'.$type.'>');
  33662. }
  33663. }
  33664. }
  33665. public static function getExceptionHints(\Exception $e)
  33666. {
  33667. if (!$e instanceof TransportException) {
  33668. return null;
  33669. }
  33670. if (
  33671. false !== strpos($e->getMessage(), 'Resolving timed out')
  33672. || false !== strpos($e->getMessage(), 'Could not resolve host')
  33673. ) {
  33674. Silencer::suppress();
  33675. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
  33676. 'ssl' => array('verify_peer' => false),
  33677. 'http' => array('follow_location' => false, 'ignore_errors' => true),
  33678. )));
  33679. Silencer::restore();
  33680. if (false !== $testConnectivity) {
  33681. return array(
  33682. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  33683. );
  33684. }
  33685. return array(
  33686. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  33687. );
  33688. }
  33689. return null;
  33690. }
  33691. private function canUseCurl(array $job)
  33692. {
  33693. if (!$this->curl) {
  33694. return false;
  33695. }
  33696. if (!Preg::isMatch('{^https?://}i', $job['request']['url'])) {
  33697. return false;
  33698. }
  33699. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  33700. return false;
  33701. }
  33702. return true;
  33703. }
  33704. public static function isCurlEnabled()
  33705. {
  33706. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  33707. }
  33708. }
  33709. <?php
  33710. namespace Composer\Util;
  33711. use Composer\XdebugHandler\XdebugHandler;
  33712. class IniHelper
  33713. {
  33714. public static function getAll()
  33715. {
  33716. return XdebugHandler::getAllIniFiles();
  33717. }
  33718. public static function getMessage()
  33719. {
  33720. $paths = self::getAll();
  33721. if (empty($paths[0])) {
  33722. array_shift($paths);
  33723. }
  33724. $ini = array_shift($paths);
  33725. if (empty($ini)) {
  33726. return 'A php.ini file does not exist. You will have to create one.';
  33727. }
  33728. if (!empty($paths)) {
  33729. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  33730. }
  33731. return 'The php.ini used by your command-line PHP is: '.$ini;
  33732. }
  33733. }
  33734. <?php
  33735. namespace Composer\Util;
  33736. use React\Promise\CancellablePromiseInterface;
  33737. use Symfony\Component\Console\Helper\ProgressBar;
  33738. use React\Promise\PromiseInterface;
  33739. class Loop
  33740. {
  33741. private $httpDownloader;
  33742. private $processExecutor;
  33743. private $currentPromises = array();
  33744. private $waitIndex = 0;
  33745. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  33746. {
  33747. $this->httpDownloader = $httpDownloader;
  33748. $this->httpDownloader->enableAsync();
  33749. $this->processExecutor = $processExecutor;
  33750. if ($this->processExecutor) {
  33751. $this->processExecutor->enableAsync();
  33752. }
  33753. }
  33754. public function getHttpDownloader()
  33755. {
  33756. return $this->httpDownloader;
  33757. }
  33758. public function getProcessExecutor()
  33759. {
  33760. return $this->processExecutor;
  33761. }
  33762. public function wait(array $promises, ProgressBar $progress = null)
  33763. {
  33764. $uncaught = null;
  33765. \React\Promise\all($promises)->then(
  33766. function () {
  33767. },
  33768. function ($e) use (&$uncaught) {
  33769. $uncaught = $e;
  33770. }
  33771. );
  33772. $waitIndex = $this->waitIndex++;
  33773. $this->currentPromises[$waitIndex] = $promises;
  33774. if ($progress) {
  33775. $totalJobs = 0;
  33776. $totalJobs += $this->httpDownloader->countActiveJobs();
  33777. if ($this->processExecutor) {
  33778. $totalJobs += $this->processExecutor->countActiveJobs();
  33779. }
  33780. $progress->start($totalJobs);
  33781. }
  33782. $lastUpdate = 0;
  33783. while (true) {
  33784. $activeJobs = 0;
  33785. $activeJobs += $this->httpDownloader->countActiveJobs();
  33786. if ($this->processExecutor) {
  33787. $activeJobs += $this->processExecutor->countActiveJobs();
  33788. }
  33789. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  33790. $lastUpdate = microtime(true);
  33791. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  33792. }
  33793. if (!$activeJobs) {
  33794. break;
  33795. }
  33796. }
  33797. if ($progress) {
  33798. $progress->finish();
  33799. }
  33800. unset($this->currentPromises[$waitIndex]);
  33801. if ($uncaught) {
  33802. throw $uncaught;
  33803. }
  33804. }
  33805. public function abortJobs()
  33806. {
  33807. foreach ($this->currentPromises as $promiseGroup) {
  33808. foreach ($promiseGroup as $promise) {
  33809. if ($promise instanceof CancellablePromiseInterface) {
  33810. $promise->cancel();
  33811. }
  33812. }
  33813. }
  33814. }
  33815. }
  33816. <?php
  33817. namespace Composer\Util;
  33818. @trigger_error('Composer\Util\MetadataMinifier is deprecated, use Composer\MetadataMinifier\MetadataMinifier from composer/metadata-minifier instead.', E_USER_DEPRECATED);
  33819. class MetadataMinifier extends \Composer\MetadataMinifier\MetadataMinifier
  33820. {
  33821. }
  33822. <?php
  33823. namespace Composer\Util;
  33824. use Composer\Pcre\Preg;
  33825. use stdClass;
  33826. class NoProxyPattern
  33827. {
  33828. protected $hostNames = array();
  33829. protected $rules = array();
  33830. protected $noproxy;
  33831. public function __construct($pattern)
  33832. {
  33833. $this->hostNames = Preg::split('{[\s,]+}', $pattern, -1, PREG_SPLIT_NO_EMPTY);
  33834. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  33835. }
  33836. public function test($url)
  33837. {
  33838. if ($this->noproxy) {
  33839. return true;
  33840. }
  33841. if (!$urlData = $this->getUrlData($url)) {
  33842. return false;
  33843. }
  33844. foreach ($this->hostNames as $index => $hostName) {
  33845. if ($this->match($index, $hostName, $urlData)) {
  33846. return true;
  33847. }
  33848. }
  33849. return false;
  33850. }
  33851. protected function getUrlData($url)
  33852. {
  33853. if (!$host = parse_url($url, PHP_URL_HOST)) {
  33854. return false;
  33855. }
  33856. $port = parse_url($url, PHP_URL_PORT);
  33857. if (empty($port)) {
  33858. switch (parse_url($url, PHP_URL_SCHEME)) {
  33859. case 'http':
  33860. $port = 80;
  33861. break;
  33862. case 'https':
  33863. $port = 443;
  33864. break;
  33865. }
  33866. }
  33867. $hostName = $host . ($port ? ':' . $port : '');
  33868. list($host, $port, $err) = $this->splitHostPort($hostName);
  33869. if ($err || !$this->ipCheckData($host, $ipdata)) {
  33870. return false;
  33871. }
  33872. return $this->makeData($host, $port, $ipdata);
  33873. }
  33874. protected function match($index, $hostName, $url)
  33875. {
  33876. if (!$rule = $this->getRule($index, $hostName)) {
  33877. return false;
  33878. }
  33879. if ($rule->ipdata) {
  33880. if (!$url->ipdata) {
  33881. return false;
  33882. }
  33883. if ($rule->ipdata->netmask) {
  33884. return $this->matchRange($rule->ipdata, $url->ipdata);
  33885. }
  33886. $match = $rule->ipdata->ip === $url->ipdata->ip;
  33887. } else {
  33888. $haystack = substr($url->name, -strlen($rule->name));
  33889. $match = stripos($haystack, $rule->name) === 0;
  33890. }
  33891. if ($match && $rule->port) {
  33892. $match = $rule->port === $url->port;
  33893. }
  33894. return $match;
  33895. }
  33896. protected function matchRange(stdClass $network, stdClass $target)
  33897. {
  33898. $net = unpack('C*', $network->ip);
  33899. $mask = unpack('C*', $network->netmask);
  33900. $ip = unpack('C*', $target->ip);
  33901. if (false === $net) {
  33902. throw new \RuntimeException('Could not parse network IP '.$network->ip);
  33903. }
  33904. if (false === $mask) {
  33905. throw new \RuntimeException('Could not parse netmask '.$network->netmask);
  33906. }
  33907. if (false === $ip) {
  33908. throw new \RuntimeException('Could not parse target IP '.$target->ip);
  33909. }
  33910. for ($i = 1; $i < 17; ++$i) {
  33911. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  33912. return false;
  33913. }
  33914. }
  33915. return true;
  33916. }
  33917. private function getRule($index, $hostName)
  33918. {
  33919. if (array_key_exists($index, $this->rules)) {
  33920. return $this->rules[$index];
  33921. }
  33922. $this->rules[$index] = null;
  33923. list($host, $port, $err) = $this->splitHostPort($hostName);
  33924. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  33925. return null;
  33926. }
  33927. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  33928. return $this->rules[$index];
  33929. }
  33930. private function ipCheckData($host, &$ipdata, $allowPrefix = false)
  33931. {
  33932. $ipdata = null;
  33933. $netmask = null;
  33934. $prefix = null;
  33935. $modified = false;
  33936. if (strpos($host, '/') !== false) {
  33937. list($host, $prefix) = explode('/', $host);
  33938. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  33939. return false;
  33940. }
  33941. $prefix = (int) $prefix;
  33942. $modified = true;
  33943. }
  33944. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  33945. return !$modified;
  33946. }
  33947. list($ip, $size) = $this->ipGetAddr($host);
  33948. if ($prefix !== null) {
  33949. if ($prefix > $size * 8) {
  33950. return false;
  33951. }
  33952. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  33953. }
  33954. $ipdata = $this->makeIpData($ip, $size, $netmask);
  33955. return true;
  33956. }
  33957. private function ipGetAddr($host)
  33958. {
  33959. $ip = inet_pton($host);
  33960. $size = strlen($ip);
  33961. $mapped = $this->ipMapTo6($ip, $size);
  33962. return array($mapped, $size);
  33963. }
  33964. private function ipGetMask($prefix, $size)
  33965. {
  33966. $mask = '';
  33967. if ($ones = floor($prefix / 8)) {
  33968. $mask = str_repeat(chr(255), (int) $ones);
  33969. }
  33970. if ($remainder = $prefix % 8) {
  33971. $mask .= chr(0xff ^ (0xff >> $remainder));
  33972. }
  33973. $mask = str_pad($mask, $size, chr(0));
  33974. return $this->ipMapTo6($mask, $size);
  33975. }
  33976. private function ipGetNetwork($rangeIp, $size, $prefix)
  33977. {
  33978. $netmask = $this->ipGetMask($prefix, $size);
  33979. $mask = unpack('C*', $netmask);
  33980. $ip = unpack('C*', $rangeIp);
  33981. $net = '';
  33982. if (false === $mask) {
  33983. throw new \RuntimeException('Could not parse netmask '.$netmask);
  33984. }
  33985. if (false === $ip) {
  33986. throw new \RuntimeException('Could not parse range IP '.$rangeIp);
  33987. }
  33988. for ($i = 1; $i < 17; ++$i) {
  33989. $net .= chr($ip[$i] & $mask[$i]);
  33990. }
  33991. return array($net, $netmask);
  33992. }
  33993. private function ipMapTo6($binary, $size)
  33994. {
  33995. if ($size === 4) {
  33996. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  33997. $binary = $prefix . $binary;
  33998. }
  33999. return $binary;
  34000. }
  34001. private function makeData($host, $port, $ipdata)
  34002. {
  34003. return (object) array(
  34004. 'host' => $host,
  34005. 'name' => '.' . ltrim($host, '.'),
  34006. 'port' => $port,
  34007. 'ipdata' => $ipdata,
  34008. );
  34009. }
  34010. private function makeIpData($ip, $size, $netmask)
  34011. {
  34012. return (object) array(
  34013. 'ip' => $ip,
  34014. 'size' => $size,
  34015. 'netmask' => $netmask,
  34016. );
  34017. }
  34018. private function splitHostPort($hostName)
  34019. {
  34020. $error = array('', '', true);
  34021. $port = 0;
  34022. $ip6 = '';
  34023. if ($hostName[0] === '[') {
  34024. $index = strpos($hostName, ']');
  34025. if (false === $index || $index < 3) {
  34026. return $error;
  34027. }
  34028. $ip6 = substr($hostName, 1, $index - 1);
  34029. $hostName = substr($hostName, $index + 1);
  34030. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  34031. return $error;
  34032. }
  34033. }
  34034. if (substr_count($hostName, ':') === 1) {
  34035. $index = strpos($hostName, ':');
  34036. $port = substr($hostName, $index + 1);
  34037. $hostName = substr($hostName, 0, $index);
  34038. if (!$this->validateInt($port, 1, 65535)) {
  34039. return $error;
  34040. }
  34041. $port = (int) $port;
  34042. }
  34043. $host = $ip6 . $hostName;
  34044. return array($host, $port, false);
  34045. }
  34046. private function validateInt($int, $min, $max)
  34047. {
  34048. $options = array(
  34049. 'options' => array(
  34050. 'min_range' => $min,
  34051. 'max_range' => $max,
  34052. ),
  34053. );
  34054. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  34055. }
  34056. }
  34057. <?php
  34058. namespace Composer\Util;
  34059. use Composer\Package\PackageInterface;
  34060. class PackageSorter
  34061. {
  34062. public static function sortPackages(array $packages)
  34063. {
  34064. $usageList = array();
  34065. foreach ($packages as $package) {
  34066. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  34067. $target = $link->getTarget();
  34068. $usageList[$target][] = $package->getName();
  34069. }
  34070. }
  34071. $computing = array();
  34072. $computed = array();
  34073. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  34074. if (isset($computed[$name])) {
  34075. return $computed[$name];
  34076. }
  34077. if (isset($computing[$name])) {
  34078. return 0;
  34079. }
  34080. $computing[$name] = true;
  34081. $weight = 0;
  34082. if (isset($usageList[$name])) {
  34083. foreach ($usageList[$name] as $user) {
  34084. $weight -= 1 - $computeImportance($user);
  34085. }
  34086. }
  34087. unset($computing[$name]);
  34088. $computed[$name] = $weight;
  34089. return $weight;
  34090. };
  34091. $weightList = array();
  34092. foreach ($packages as $index => $package) {
  34093. $weight = $computeImportance($package->getName());
  34094. $weightList[$index] = $weight;
  34095. }
  34096. $stable_sort = function (&$array) {
  34097. static $transform, $restore;
  34098. $i = 0;
  34099. if (!$transform) {
  34100. $transform = function (&$v, $k) use (&$i) {
  34101. $v = array($v, ++$i, $k, $v);
  34102. };
  34103. $restore = function (&$v) {
  34104. $v = $v[3];
  34105. };
  34106. }
  34107. array_walk($array, $transform);
  34108. asort($array);
  34109. array_walk($array, $restore);
  34110. };
  34111. $stable_sort($weightList);
  34112. $sortedPackages = array();
  34113. foreach (array_keys($weightList) as $index) {
  34114. $sortedPackages[] = $packages[$index];
  34115. }
  34116. return $sortedPackages;
  34117. }
  34118. }
  34119. <?php
  34120. namespace Composer\Util;
  34121. use Composer\IO\IOInterface;
  34122. use Composer\Pcre\Preg;
  34123. use Symfony\Component\Process\Process;
  34124. class Perforce
  34125. {
  34126. protected $path;
  34127. protected $p4Depot;
  34128. protected $p4Client;
  34129. protected $p4User;
  34130. protected $p4Password;
  34131. protected $p4Port;
  34132. protected $p4Stream;
  34133. protected $p4ClientSpec;
  34134. protected $p4DepotType;
  34135. protected $p4Branch;
  34136. protected $process;
  34137. protected $uniquePerforceClientName;
  34138. protected $windowsFlag;
  34139. protected $commandResult;
  34140. protected $io;
  34141. protected $filesystem;
  34142. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  34143. {
  34144. $this->windowsFlag = $isWindows;
  34145. $this->p4Port = $port;
  34146. $this->initializePath($path);
  34147. $this->process = $process;
  34148. $this->initialize($repoConfig);
  34149. $this->io = $io;
  34150. }
  34151. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  34152. {
  34153. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  34154. }
  34155. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  34156. {
  34157. $output = null;
  34158. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  34159. }
  34160. public function initialize($repoConfig)
  34161. {
  34162. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  34163. if (!$repoConfig) {
  34164. return;
  34165. }
  34166. if (isset($repoConfig['unique_perforce_client_name'])) {
  34167. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  34168. }
  34169. if (isset($repoConfig['depot'])) {
  34170. $this->p4Depot = $repoConfig['depot'];
  34171. }
  34172. if (isset($repoConfig['branch'])) {
  34173. $this->p4Branch = $repoConfig['branch'];
  34174. }
  34175. if (isset($repoConfig['p4user'])) {
  34176. $this->p4User = $repoConfig['p4user'];
  34177. } else {
  34178. $this->p4User = $this->getP4variable('P4USER');
  34179. }
  34180. if (isset($repoConfig['p4password'])) {
  34181. $this->p4Password = $repoConfig['p4password'];
  34182. }
  34183. }
  34184. public function initializeDepotAndBranch($depot, $branch)
  34185. {
  34186. if (isset($depot)) {
  34187. $this->p4Depot = $depot;
  34188. }
  34189. if (isset($branch)) {
  34190. $this->p4Branch = $branch;
  34191. }
  34192. }
  34193. public function generateUniquePerforceClientName()
  34194. {
  34195. return gethostname() . "_" . time();
  34196. }
  34197. public function cleanupClientSpec()
  34198. {
  34199. $client = $this->getClient();
  34200. $task = 'client -d ' . ProcessExecutor::escape($client);
  34201. $useP4Client = false;
  34202. $command = $this->generateP4Command($task, $useP4Client);
  34203. $this->executeCommand($command);
  34204. $clientSpec = $this->getP4ClientSpec();
  34205. $fileSystem = $this->getFilesystem();
  34206. $fileSystem->remove($clientSpec);
  34207. }
  34208. protected function executeCommand($command)
  34209. {
  34210. $this->commandResult = '';
  34211. return $this->process->execute($command, $this->commandResult);
  34212. }
  34213. public function getClient()
  34214. {
  34215. if (!isset($this->p4Client)) {
  34216. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  34217. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  34218. }
  34219. return $this->p4Client;
  34220. }
  34221. protected function getPath()
  34222. {
  34223. return $this->path;
  34224. }
  34225. public function initializePath($path)
  34226. {
  34227. $this->path = $path;
  34228. $fs = $this->getFilesystem();
  34229. $fs->ensureDirectoryExists($path);
  34230. }
  34231. protected function getPort()
  34232. {
  34233. return $this->p4Port;
  34234. }
  34235. public function setStream($stream)
  34236. {
  34237. $this->p4Stream = $stream;
  34238. $index = strrpos($stream, '/');
  34239. if ($index > 2) {
  34240. $this->p4DepotType = 'stream';
  34241. }
  34242. }
  34243. public function isStream()
  34244. {
  34245. return is_string($this->p4DepotType) && (strcmp($this->p4DepotType, 'stream') === 0);
  34246. }
  34247. public function getStream()
  34248. {
  34249. if (!isset($this->p4Stream)) {
  34250. if ($this->isStream()) {
  34251. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  34252. } else {
  34253. $this->p4Stream = '//' . $this->p4Depot;
  34254. }
  34255. }
  34256. return $this->p4Stream;
  34257. }
  34258. public function getStreamWithoutLabel($stream)
  34259. {
  34260. $index = strpos($stream, '@');
  34261. if ($index === false) {
  34262. return $stream;
  34263. }
  34264. return substr($stream, 0, $index);
  34265. }
  34266. public function getP4ClientSpec()
  34267. {
  34268. return $this->path . '/' . $this->getClient() . '.p4.spec';
  34269. }
  34270. public function getUser()
  34271. {
  34272. return $this->p4User;
  34273. }
  34274. public function setUser($user)
  34275. {
  34276. $this->p4User = $user;
  34277. }
  34278. public function queryP4User()
  34279. {
  34280. $this->getUser();
  34281. if (strlen((string) $this->p4User) > 0) {
  34282. return;
  34283. }
  34284. $this->p4User = $this->getP4variable('P4USER');
  34285. if (strlen((string) $this->p4User) > 0) {
  34286. return;
  34287. }
  34288. $this->p4User = $this->io->ask('Enter P4 User:');
  34289. if ($this->windowsFlag) {
  34290. $command = 'p4 set P4USER=' . $this->p4User;
  34291. } else {
  34292. $command = 'export P4USER=' . $this->p4User;
  34293. }
  34294. $this->executeCommand($command);
  34295. }
  34296. protected function getP4variable($name)
  34297. {
  34298. if ($this->windowsFlag) {
  34299. $command = 'p4 set';
  34300. $this->executeCommand($command);
  34301. $result = trim($this->commandResult);
  34302. $resArray = explode(PHP_EOL, $result);
  34303. foreach ($resArray as $line) {
  34304. $fields = explode('=', $line);
  34305. if (strcmp($name, $fields[0]) == 0) {
  34306. $index = strpos($fields[1], ' ');
  34307. if ($index === false) {
  34308. $value = $fields[1];
  34309. } else {
  34310. $value = substr($fields[1], 0, $index);
  34311. }
  34312. $value = trim($value);
  34313. return $value;
  34314. }
  34315. }
  34316. return null;
  34317. }
  34318. $command = 'echo $' . $name;
  34319. $this->executeCommand($command);
  34320. $result = trim($this->commandResult);
  34321. return $result;
  34322. }
  34323. public function queryP4Password()
  34324. {
  34325. if (isset($this->p4Password)) {
  34326. return $this->p4Password;
  34327. }
  34328. $password = $this->getP4variable('P4PASSWD');
  34329. if (strlen((string) $password) <= 0) {
  34330. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  34331. }
  34332. $this->p4Password = $password;
  34333. return $password;
  34334. }
  34335. public function generateP4Command($command, $useClient = true)
  34336. {
  34337. $p4Command = 'p4 ';
  34338. $p4Command .= '-u ' . $this->getUser() . ' ';
  34339. if ($useClient) {
  34340. $p4Command .= '-c ' . $this->getClient() . ' ';
  34341. }
  34342. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  34343. return $p4Command;
  34344. }
  34345. public function isLoggedIn()
  34346. {
  34347. $command = $this->generateP4Command('login -s', false);
  34348. $exitCode = $this->executeCommand($command);
  34349. if ($exitCode) {
  34350. $errorOutput = $this->process->getErrorOutput();
  34351. $index = strpos($errorOutput, $this->getUser());
  34352. if ($index === false) {
  34353. $index = strpos($errorOutput, 'p4');
  34354. if ($index === false) {
  34355. return false;
  34356. }
  34357. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  34358. }
  34359. throw new \Exception('Invalid user name: ' . $this->getUser());
  34360. }
  34361. return true;
  34362. }
  34363. public function connectClient()
  34364. {
  34365. $p4CreateClientCommand = $this->generateP4Command(
  34366. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  34367. );
  34368. $this->executeCommand($p4CreateClientCommand);
  34369. }
  34370. public function syncCodeBase($sourceReference)
  34371. {
  34372. $prevDir = getcwd();
  34373. chdir($this->path);
  34374. $p4SyncCommand = $this->generateP4Command('sync -f ');
  34375. if (null !== $sourceReference) {
  34376. $p4SyncCommand .= '@' . $sourceReference;
  34377. }
  34378. $this->executeCommand($p4SyncCommand);
  34379. chdir($prevDir);
  34380. }
  34381. public function writeClientSpecToFile($spec)
  34382. {
  34383. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  34384. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  34385. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  34386. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  34387. fwrite($spec, 'Description:' . PHP_EOL);
  34388. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  34389. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  34390. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  34391. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  34392. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  34393. if ($this->isStream()) {
  34394. fwrite($spec, 'Stream:' . PHP_EOL);
  34395. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  34396. } else {
  34397. fwrite(
  34398. $spec,
  34399. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  34400. );
  34401. }
  34402. }
  34403. public function writeP4ClientSpec()
  34404. {
  34405. $clientSpec = $this->getP4ClientSpec();
  34406. $spec = fopen($clientSpec, 'w');
  34407. try {
  34408. $this->writeClientSpecToFile($spec);
  34409. } catch (\Exception $e) {
  34410. fclose($spec);
  34411. throw $e;
  34412. }
  34413. fclose($spec);
  34414. }
  34415. protected function read($pipe, $name)
  34416. {
  34417. if (feof($pipe)) {
  34418. return;
  34419. }
  34420. $line = fgets($pipe);
  34421. while ($line !== false) {
  34422. $line = fgets($pipe);
  34423. }
  34424. }
  34425. public function windowsLogin($password)
  34426. {
  34427. $command = $this->generateP4Command(' login -a');
  34428. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  34429. $process = Process::fromShellCommandline($command, null, null, $password);
  34430. } else {
  34431. $process = new Process($command, null, null, $password);
  34432. }
  34433. return $process->run();
  34434. }
  34435. public function p4Login()
  34436. {
  34437. $this->queryP4User();
  34438. if (!$this->isLoggedIn()) {
  34439. $password = $this->queryP4Password();
  34440. if ($this->windowsFlag) {
  34441. $this->windowsLogin($password);
  34442. } else {
  34443. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  34444. $exitCode = $this->executeCommand($command);
  34445. if ($exitCode) {
  34446. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  34447. }
  34448. }
  34449. }
  34450. }
  34451. public function getComposerInformation($identifier)
  34452. {
  34453. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  34454. if (!$composerFileContent) {
  34455. return;
  34456. }
  34457. return json_decode($composerFileContent, true);
  34458. }
  34459. public function getFileContent($file, $identifier)
  34460. {
  34461. $path = $this->getFilePath($file, $identifier);
  34462. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  34463. $this->executeCommand($command);
  34464. $result = $this->commandResult;
  34465. if (!trim($result)) {
  34466. return null;
  34467. }
  34468. return $result;
  34469. }
  34470. public function getFilePath($file, $identifier)
  34471. {
  34472. $index = strpos($identifier, '@');
  34473. if ($index === false) {
  34474. return $identifier. '/' . $file;
  34475. }
  34476. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  34477. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  34478. $this->executeCommand($command);
  34479. $result = $this->commandResult;
  34480. $index2 = strpos($result, 'no such file(s).');
  34481. if ($index2 === false) {
  34482. $index3 = strpos($result, 'change');
  34483. if ($index3 !== false) {
  34484. $phrase = trim(substr($result, $index3));
  34485. $fields = explode(' ', $phrase);
  34486. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  34487. }
  34488. }
  34489. return null;
  34490. }
  34491. public function getBranches()
  34492. {
  34493. $possibleBranches = array();
  34494. if (!$this->isStream()) {
  34495. $possibleBranches[$this->p4Branch] = $this->getStream();
  34496. } else {
  34497. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  34498. $this->executeCommand($command);
  34499. $result = $this->commandResult;
  34500. $resArray = explode(PHP_EOL, $result);
  34501. foreach ($resArray as $line) {
  34502. $resBits = explode(' ', $line);
  34503. if (count($resBits) > 4) {
  34504. $branch = Preg::replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  34505. $possibleBranches[$branch] = $resBits[1];
  34506. }
  34507. }
  34508. }
  34509. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  34510. $this->executeCommand($command);
  34511. $result = $this->commandResult;
  34512. $resArray = explode(PHP_EOL, $result);
  34513. $lastCommit = $resArray[0];
  34514. $lastCommitArr = explode(' ', $lastCommit);
  34515. $lastCommitNum = $lastCommitArr[1];
  34516. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  34517. }
  34518. public function getTags()
  34519. {
  34520. $command = $this->generateP4Command('labels');
  34521. $this->executeCommand($command);
  34522. $result = $this->commandResult;
  34523. $resArray = explode(PHP_EOL, $result);
  34524. $tags = array();
  34525. foreach ($resArray as $line) {
  34526. if (strpos($line, 'Label') !== false) {
  34527. $fields = explode(' ', $line);
  34528. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  34529. }
  34530. }
  34531. return $tags;
  34532. }
  34533. public function checkStream()
  34534. {
  34535. $command = $this->generateP4Command('depots', false);
  34536. $this->executeCommand($command);
  34537. $result = $this->commandResult;
  34538. $resArray = explode(PHP_EOL, $result);
  34539. foreach ($resArray as $line) {
  34540. if (strpos($line, 'Depot') !== false) {
  34541. $fields = explode(' ', $line);
  34542. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  34543. $this->p4DepotType = $fields[3];
  34544. return $this->isStream();
  34545. }
  34546. }
  34547. }
  34548. return false;
  34549. }
  34550. protected function getChangeList($reference)
  34551. {
  34552. $index = strpos($reference, '@');
  34553. if ($index === false) {
  34554. return null;
  34555. }
  34556. $label = substr($reference, $index);
  34557. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  34558. $this->executeCommand($command);
  34559. $changes = $this->commandResult;
  34560. if (strpos($changes, 'Change') !== 0) {
  34561. return null;
  34562. }
  34563. $fields = explode(' ', $changes);
  34564. return $fields[1];
  34565. }
  34566. public function getCommitLogs($fromReference, $toReference)
  34567. {
  34568. $fromChangeList = $this->getChangeList($fromReference);
  34569. if ($fromChangeList === null) {
  34570. return null;
  34571. }
  34572. $toChangeList = $this->getChangeList($toReference);
  34573. if ($toChangeList === null) {
  34574. return null;
  34575. }
  34576. $index = strpos($fromReference, '@');
  34577. $main = substr($fromReference, 0, $index) . '/...';
  34578. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  34579. $this->executeCommand($command);
  34580. return $this->commandResult;
  34581. }
  34582. public function getFilesystem()
  34583. {
  34584. if (null === $this->filesystem) {
  34585. $this->filesystem = new Filesystem($this->process);
  34586. }
  34587. return $this->filesystem;
  34588. }
  34589. public function setFilesystem(Filesystem $fs)
  34590. {
  34591. $this->filesystem = $fs;
  34592. }
  34593. }
  34594. <?php
  34595. namespace Composer\Util;
  34596. use Composer\Pcre\Preg;
  34597. class Platform
  34598. {
  34599. private static $isVirtualBoxGuest = null;
  34600. private static $isWindowsSubsystemForLinux = null;
  34601. public static function getEnv($name)
  34602. {
  34603. if (array_key_exists($name, $_SERVER)) {
  34604. return (string) $_SERVER[$name];
  34605. }
  34606. if (array_key_exists($name, $_ENV)) {
  34607. return (string) $_ENV[$name];
  34608. }
  34609. return getenv($name);
  34610. }
  34611. public static function putEnv($name, $value)
  34612. {
  34613. $value = (string) $value;
  34614. putenv($name . '=' . $value);
  34615. $_SERVER[$name] = $_ENV[$name] = $value;
  34616. }
  34617. public static function clearEnv($name)
  34618. {
  34619. putenv($name);
  34620. unset($_SERVER[$name], $_ENV[$name]);
  34621. }
  34622. public static function expandPath($path)
  34623. {
  34624. if (Preg::isMatch('#^~[\\/]#', $path)) {
  34625. return self::getUserDirectory() . substr($path, 1);
  34626. }
  34627. return Preg::replaceCallback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  34628. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  34629. return (Platform::getEnv('HOME') ?: Platform::getEnv('USERPROFILE')) . $matches['path'];
  34630. }
  34631. return Platform::getEnv($matches['var']) . $matches['path'];
  34632. }, $path);
  34633. }
  34634. public static function getUserDirectory()
  34635. {
  34636. if (false !== ($home = self::getEnv('HOME'))) {
  34637. return $home;
  34638. }
  34639. if (self::isWindows() && false !== ($home = self::getEnv('USERPROFILE'))) {
  34640. return $home;
  34641. }
  34642. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  34643. $info = posix_getpwuid(posix_getuid());
  34644. return $info['dir'];
  34645. }
  34646. throw new \RuntimeException('Could not determine user directory');
  34647. }
  34648. public static function isWindowsSubsystemForLinux()
  34649. {
  34650. if (null === self::$isWindowsSubsystemForLinux) {
  34651. self::$isWindowsSubsystemForLinux = false;
  34652. if (self::isWindows()) {
  34653. return self::$isWindowsSubsystemForLinux = false;
  34654. }
  34655. if (
  34656. !ini_get('open_basedir')
  34657. && is_readable('/proc/version')
  34658. && false !== stripos(Silencer::call('file_get_contents', '/proc/version'), 'microsoft')
  34659. && !file_exists('/.dockerenv')
  34660. ) {
  34661. return self::$isWindowsSubsystemForLinux = true;
  34662. }
  34663. }
  34664. return self::$isWindowsSubsystemForLinux;
  34665. }
  34666. public static function isWindows()
  34667. {
  34668. return \defined('PHP_WINDOWS_VERSION_BUILD');
  34669. }
  34670. public static function strlen($str)
  34671. {
  34672. static $useMbString = null;
  34673. if (null === $useMbString) {
  34674. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  34675. }
  34676. if ($useMbString) {
  34677. return mb_strlen($str, '8bit');
  34678. }
  34679. return \strlen($str);
  34680. }
  34681. public static function isTty($fd = null)
  34682. {
  34683. if ($fd === null) {
  34684. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  34685. }
  34686. if (in_array(strtoupper(self::getEnv('MSYSTEM') ?: ''), array('MINGW32', 'MINGW64'), true)) {
  34687. return true;
  34688. }
  34689. if (function_exists('stream_isatty')) {
  34690. return stream_isatty($fd);
  34691. }
  34692. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  34693. return true;
  34694. }
  34695. $stat = @fstat($fd);
  34696. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  34697. }
  34698. public static function workaroundFilesystemIssues()
  34699. {
  34700. if (self::isVirtualBoxGuest()) {
  34701. usleep(200000);
  34702. }
  34703. }
  34704. private static function isVirtualBoxGuest()
  34705. {
  34706. if (null === self::$isVirtualBoxGuest) {
  34707. self::$isVirtualBoxGuest = false;
  34708. if (self::isWindows()) {
  34709. return self::$isVirtualBoxGuest;
  34710. }
  34711. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  34712. $processUser = posix_getpwuid(posix_geteuid());
  34713. if ($processUser && $processUser['name'] === 'vagrant') {
  34714. return self::$isVirtualBoxGuest = true;
  34715. }
  34716. }
  34717. if (self::getEnv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
  34718. return self::$isVirtualBoxGuest = true;
  34719. }
  34720. if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
  34721. $process = new ProcessExecutor();
  34722. try {
  34723. if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) {
  34724. return self::$isVirtualBoxGuest = true;
  34725. }
  34726. } catch (\Exception $e) {
  34727. }
  34728. }
  34729. }
  34730. return self::$isVirtualBoxGuest;
  34731. }
  34732. }
  34733. <?php
  34734. namespace Composer\Util;
  34735. use Composer\IO\IOInterface;
  34736. use Composer\Pcre\Preg;
  34737. use Symfony\Component\Process\Process;
  34738. use Symfony\Component\Process\Exception\RuntimeException;
  34739. use React\Promise\Promise;
  34740. use React\Promise\PromiseInterface;
  34741. class ProcessExecutor
  34742. {
  34743. const STATUS_QUEUED = 1;
  34744. const STATUS_STARTED = 2;
  34745. const STATUS_COMPLETED = 3;
  34746. const STATUS_FAILED = 4;
  34747. const STATUS_ABORTED = 5;
  34748. protected static $timeout = 300;
  34749. protected $captureOutput = false;
  34750. protected $errorOutput = '';
  34751. protected $io;
  34752. private $jobs = array();
  34753. private $runningJobs = 0;
  34754. private $maxJobs = 10;
  34755. private $idGen = 0;
  34756. private $allowAsync = false;
  34757. public function __construct(IOInterface $io = null)
  34758. {
  34759. $this->io = $io;
  34760. }
  34761. public function execute($command, &$output = null, $cwd = null)
  34762. {
  34763. if (func_num_args() > 1) {
  34764. return $this->doExecute($command, $cwd, false, $output);
  34765. }
  34766. return $this->doExecute($command, $cwd, false);
  34767. }
  34768. public function executeTty($command, $cwd = null)
  34769. {
  34770. if (Platform::isTty()) {
  34771. return $this->doExecute($command, $cwd, true);
  34772. }
  34773. return $this->doExecute($command, $cwd, false);
  34774. }
  34775. private function doExecute($command, $cwd, $tty, &$output = null)
  34776. {
  34777. $this->outputCommandRun($command, $cwd, false);
  34778. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  34779. $cwd = realpath(getcwd());
  34780. }
  34781. if (null !== $cwd && !is_dir($cwd)) {
  34782. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  34783. }
  34784. $this->captureOutput = func_num_args() > 3;
  34785. $this->errorOutput = '';
  34786. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  34787. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  34788. } else {
  34789. $process = new Process($command, $cwd, null, null, static::getTimeout());
  34790. }
  34791. if (!Platform::isWindows() && $tty) {
  34792. try {
  34793. $process->setTty(true);
  34794. } catch (RuntimeException $e) {
  34795. }
  34796. }
  34797. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  34798. $process->run($callback);
  34799. if ($this->captureOutput && !is_callable($output)) {
  34800. $output = $process->getOutput();
  34801. }
  34802. $this->errorOutput = $process->getErrorOutput();
  34803. return $process->getExitCode();
  34804. }
  34805. public function executeAsync($command, $cwd = null)
  34806. {
  34807. if (!$this->allowAsync) {
  34808. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  34809. }
  34810. $job = array(
  34811. 'id' => $this->idGen++,
  34812. 'status' => self::STATUS_QUEUED,
  34813. 'command' => $command,
  34814. 'cwd' => $cwd,
  34815. );
  34816. $resolver = function ($resolve, $reject) use (&$job) {
  34817. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  34818. $job['resolve'] = $resolve;
  34819. $job['reject'] = $reject;
  34820. };
  34821. $self = $this;
  34822. $canceler = function () use (&$job) {
  34823. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  34824. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  34825. }
  34826. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  34827. return;
  34828. }
  34829. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  34830. try {
  34831. if (defined('SIGINT')) {
  34832. $job['process']->signal(SIGINT);
  34833. }
  34834. } catch (\Exception $e) {
  34835. }
  34836. $job['process']->stop(1);
  34837. throw new \RuntimeException('Aborted process');
  34838. };
  34839. $promise = new Promise($resolver, $canceler);
  34840. $promise = $promise->then(function () use (&$job, $self) {
  34841. if ($job['process']->isSuccessful()) {
  34842. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  34843. } else {
  34844. $job['status'] = ProcessExecutor::STATUS_FAILED;
  34845. }
  34846. $self->markJobDone();
  34847. return $job['process'];
  34848. }, function ($e) use (&$job, $self) {
  34849. $job['status'] = ProcessExecutor::STATUS_FAILED;
  34850. $self->markJobDone();
  34851. throw $e;
  34852. });
  34853. $this->jobs[$job['id']] = &$job;
  34854. if ($this->runningJobs < $this->maxJobs) {
  34855. $this->startJob($job['id']);
  34856. }
  34857. return $promise;
  34858. }
  34859. private function startJob($id)
  34860. {
  34861. $job = &$this->jobs[$id];
  34862. if ($job['status'] !== self::STATUS_QUEUED) {
  34863. return;
  34864. }
  34865. $job['status'] = self::STATUS_STARTED;
  34866. $this->runningJobs++;
  34867. $command = $job['command'];
  34868. $cwd = $job['cwd'];
  34869. $this->outputCommandRun($command, $cwd, true);
  34870. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  34871. $cwd = realpath(getcwd());
  34872. }
  34873. if (null !== $cwd && !is_dir($cwd)) {
  34874. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  34875. }
  34876. try {
  34877. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  34878. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  34879. } else {
  34880. $process = new Process($command, $cwd, null, null, static::getTimeout());
  34881. }
  34882. } catch (\Exception $e) {
  34883. call_user_func($job['reject'], $e);
  34884. return;
  34885. } catch (\Throwable $e) {
  34886. call_user_func($job['reject'], $e);
  34887. return;
  34888. }
  34889. $job['process'] = $process;
  34890. try {
  34891. $process->start();
  34892. } catch (\Exception $e) {
  34893. call_user_func($job['reject'], $e);
  34894. return;
  34895. } catch (\Throwable $e) {
  34896. call_user_func($job['reject'], $e);
  34897. return;
  34898. }
  34899. }
  34900. public function wait($index = null)
  34901. {
  34902. while (true) {
  34903. if (!$this->countActiveJobs($index)) {
  34904. return;
  34905. }
  34906. usleep(1000);
  34907. }
  34908. }
  34909. public function enableAsync()
  34910. {
  34911. $this->allowAsync = true;
  34912. }
  34913. public function countActiveJobs($index = null)
  34914. {
  34915. foreach ($this->jobs as $job) {
  34916. if ($job['status'] === self::STATUS_STARTED) {
  34917. if (!$job['process']->isRunning()) {
  34918. call_user_func($job['resolve'], $job['process']);
  34919. }
  34920. $job['process']->checkTimeout();
  34921. }
  34922. if ($this->runningJobs < $this->maxJobs) {
  34923. if ($job['status'] === self::STATUS_QUEUED) {
  34924. $this->startJob($job['id']);
  34925. }
  34926. }
  34927. }
  34928. if (null !== $index) {
  34929. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  34930. }
  34931. $active = 0;
  34932. foreach ($this->jobs as $job) {
  34933. if ($job['status'] < self::STATUS_COMPLETED) {
  34934. $active++;
  34935. } else {
  34936. unset($this->jobs[$job['id']]);
  34937. }
  34938. }
  34939. return $active;
  34940. }
  34941. public function markJobDone()
  34942. {
  34943. $this->runningJobs--;
  34944. }
  34945. public function splitLines($output)
  34946. {
  34947. $output = trim((string) $output);
  34948. return $output === '' ? array() : Preg::split('{\r?\n}', $output);
  34949. }
  34950. public function getErrorOutput()
  34951. {
  34952. return $this->errorOutput;
  34953. }
  34954. public function outputHandler($type, $buffer)
  34955. {
  34956. if ($this->captureOutput) {
  34957. return;
  34958. }
  34959. if (null === $this->io) {
  34960. echo $buffer;
  34961. return;
  34962. }
  34963. if (Process::ERR === $type) {
  34964. $this->io->writeErrorRaw($buffer, false);
  34965. } else {
  34966. $this->io->writeRaw($buffer, false);
  34967. }
  34968. }
  34969. public static function getTimeout()
  34970. {
  34971. return static::$timeout;
  34972. }
  34973. public static function setTimeout($timeout)
  34974. {
  34975. static::$timeout = $timeout;
  34976. }
  34977. public static function escape($argument)
  34978. {
  34979. return self::escapeArgument($argument);
  34980. }
  34981. private function outputCommandRun($command, $cwd, $async)
  34982. {
  34983. if (null === $this->io || !$this->io->isDebug()) {
  34984. return;
  34985. }
  34986. $safeCommand = Preg::replaceCallback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  34987. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  34988. return '://***:***@';
  34989. }
  34990. if (Preg::isMatch('{^[a-f0-9]{12,}$}', $m['user'])) {
  34991. return '://***:***@';
  34992. }
  34993. return '://'.$m['user'].':***@';
  34994. }, $command);
  34995. $safeCommand = Preg::replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  34996. $this->io->writeError('Executing'.($async ? ' async' : '').' command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  34997. }
  34998. private static function escapeArgument($argument)
  34999. {
  35000. if ('' === ($argument = (string) $argument)) {
  35001. return escapeshellarg($argument);
  35002. }
  35003. if (!Platform::isWindows()) {
  35004. return "'".str_replace("'", "'\\''", $argument)."'";
  35005. }
  35006. $argument = strtr($argument, "\n", ' ');
  35007. $quote = strpbrk($argument, " \t") !== false;
  35008. $argument = Preg::replace('/(\\\\*)"/', '$1$1\\"', $argument, -1, $dquotes);
  35009. $meta = $dquotes || Preg::isMatch('/%[^%]+%|![^!]+!/', $argument);
  35010. if (!$meta && !$quote) {
  35011. $quote = strpbrk($argument, '^&|<>()') !== false;
  35012. }
  35013. if ($quote) {
  35014. $argument = '"'.Preg::replace('/(\\\\*)$/', '$1$1', $argument).'"';
  35015. }
  35016. if ($meta) {
  35017. $argument = Preg::replace('/(["^&|<>()%])/', '^$1', $argument);
  35018. $argument = Preg::replace('/(!)/', '^^$1', $argument);
  35019. }
  35020. return $argument;
  35021. }
  35022. }
  35023. <?php
  35024. namespace Composer\Util;
  35025. use Composer\Config;
  35026. use Composer\Downloader\MaxFileSizeExceededException;
  35027. use Composer\IO\IOInterface;
  35028. use Composer\Downloader\TransportException;
  35029. use Composer\CaBundle\CaBundle;
  35030. use Composer\Pcre\Preg;
  35031. use Composer\Util\Http\Response;
  35032. use Composer\Util\Http\ProxyManager;
  35033. class RemoteFilesystem
  35034. {
  35035. private $io;
  35036. private $config;
  35037. private $scheme;
  35038. private $bytesMax;
  35039. private $originUrl;
  35040. private $fileUrl;
  35041. private $fileName;
  35042. private $retry = false;
  35043. private $progress;
  35044. private $lastProgress;
  35045. private $options = array();
  35046. private $peerCertificateMap = array();
  35047. private $disableTls = false;
  35048. private $lastHeaders;
  35049. private $storeAuth = false;
  35050. private $authHelper;
  35051. private $degradedMode = false;
  35052. private $redirects;
  35053. private $maxRedirects = 20;
  35054. private $proxyManager;
  35055. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false, AuthHelper $authHelper = null)
  35056. {
  35057. $this->io = $io;
  35058. if ($disableTls === false) {
  35059. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  35060. } else {
  35061. $this->disableTls = true;
  35062. }
  35063. $this->options = array_replace_recursive($this->options, $options);
  35064. $this->config = $config;
  35065. $this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
  35066. $this->proxyManager = ProxyManager::getInstance();
  35067. }
  35068. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  35069. {
  35070. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  35071. }
  35072. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  35073. {
  35074. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  35075. }
  35076. public function getOptions()
  35077. {
  35078. return $this->options;
  35079. }
  35080. public function setOptions(array $options)
  35081. {
  35082. $this->options = array_replace_recursive($this->options, $options);
  35083. }
  35084. public function isTlsDisabled()
  35085. {
  35086. return $this->disableTls === true;
  35087. }
  35088. public function getLastHeaders()
  35089. {
  35090. return $this->lastHeaders;
  35091. }
  35092. public static function findStatusCode(array $headers)
  35093. {
  35094. $value = null;
  35095. foreach ($headers as $header) {
  35096. if (Preg::isMatch('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  35097. $value = (int) $match[1];
  35098. }
  35099. }
  35100. return $value;
  35101. }
  35102. public function findStatusMessage(array $headers)
  35103. {
  35104. $value = null;
  35105. foreach ($headers as $header) {
  35106. if (Preg::isMatch('{^HTTP/\S+ \d+}i', $header)) {
  35107. $value = $header;
  35108. }
  35109. }
  35110. return $value;
  35111. }
  35112. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  35113. {
  35114. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  35115. $this->bytesMax = 0;
  35116. $this->originUrl = $originUrl;
  35117. $this->fileUrl = $fileUrl;
  35118. $this->fileName = $fileName;
  35119. $this->progress = $progress;
  35120. $this->lastProgress = null;
  35121. $retryAuthFailure = true;
  35122. $this->lastHeaders = array();
  35123. $this->redirects = 1;
  35124. $tempAdditionalOptions = $additionalOptions;
  35125. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  35126. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  35127. unset($tempAdditionalOptions['retry-auth-failure']);
  35128. }
  35129. $isRedirect = false;
  35130. if (isset($tempAdditionalOptions['redirects'])) {
  35131. $this->redirects = $tempAdditionalOptions['redirects'];
  35132. $isRedirect = true;
  35133. unset($tempAdditionalOptions['redirects']);
  35134. }
  35135. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  35136. unset($tempAdditionalOptions);
  35137. $origFileUrl = $fileUrl;
  35138. if (isset($options['gitlab-token'])) {
  35139. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  35140. unset($options['gitlab-token']);
  35141. }
  35142. if (isset($options['http'])) {
  35143. $options['http']['ignore_errors'] = true;
  35144. }
  35145. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  35146. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  35147. $degradedPackagist = true;
  35148. }
  35149. $maxFileSize = null;
  35150. if (isset($options['max_file_size'])) {
  35151. $maxFileSize = $options['max_file_size'];
  35152. unset($options['max_file_size']);
  35153. }
  35154. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  35155. $proxy = $this->proxyManager->getProxyForRequest($fileUrl);
  35156. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  35157. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  35158. unset($origFileUrl, $proxy, $usingProxy);
  35159. if ((!Preg::isMatch('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist)) {
  35160. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  35161. }
  35162. if ($this->progress && !$isRedirect) {
  35163. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  35164. }
  35165. $errorMessage = '';
  35166. $errorCode = 0;
  35167. $result = false;
  35168. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  35169. if ($errorMessage) {
  35170. $errorMessage .= "\n";
  35171. }
  35172. $errorMessage .= Preg::replace('{^file_get_contents\(.*?\): }', '', $msg);
  35173. return true;
  35174. });
  35175. $http_response_header = array();
  35176. try {
  35177. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  35178. if (!empty($http_response_header[0])) {
  35179. $statusCode = self::findStatusCode($http_response_header);
  35180. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  35181. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  35182. }
  35183. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  35184. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  35185. }
  35186. }
  35187. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  35188. if ($contentLength && Platform::strlen($result) < $contentLength) {
  35189. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  35190. $e->setHeaders($http_response_header);
  35191. $e->setStatusCode(self::findStatusCode($http_response_header));
  35192. try {
  35193. $e->setResponse($this->decodeResult($result, $http_response_header));
  35194. } catch (\Exception $discarded) {
  35195. $e->setResponse($this->normalizeResult($result));
  35196. }
  35197. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  35198. throw $e;
  35199. }
  35200. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  35201. $params = stream_context_get_params($ctx);
  35202. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  35203. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  35204. if ($expectedPeerFingerprint !== $peerFingerprint) {
  35205. throw new TransportException('Peer fingerprint did not match');
  35206. }
  35207. }
  35208. } catch (\Exception $e) {
  35209. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  35210. $e->setHeaders($http_response_header);
  35211. $e->setStatusCode(self::findStatusCode($http_response_header));
  35212. }
  35213. if ($e instanceof TransportException && $result !== false) {
  35214. $e->setResponse($this->decodeResult($result, $http_response_header));
  35215. }
  35216. $result = false;
  35217. }
  35218. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  35219. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  35220. }
  35221. restore_error_handler();
  35222. if (isset($e) && !$this->retry) {
  35223. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  35224. $this->degradedMode = true;
  35225. $this->io->writeError('');
  35226. $this->io->writeError(array(
  35227. '<error>'.$e->getMessage().'</error>',
  35228. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  35229. ));
  35230. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35231. }
  35232. throw $e;
  35233. }
  35234. $statusCode = null;
  35235. $contentType = null;
  35236. $locationHeader = null;
  35237. if (!empty($http_response_header[0])) {
  35238. $statusCode = self::findStatusCode($http_response_header);
  35239. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  35240. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  35241. }
  35242. if ($originUrl === 'bitbucket.org'
  35243. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  35244. && substr($fileUrl, -4) === '.zip'
  35245. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  35246. && $contentType && Preg::isMatch('{^text/html\b}i', $contentType)
  35247. ) {
  35248. $result = false;
  35249. if ($retryAuthFailure) {
  35250. $this->promptAuthAndRetry(401);
  35251. }
  35252. }
  35253. if ($statusCode === 404
  35254. && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  35255. && false !== strpos($fileUrl, 'archive.zip')
  35256. ) {
  35257. $result = false;
  35258. if ($retryAuthFailure) {
  35259. $this->promptAuthAndRetry(401);
  35260. }
  35261. }
  35262. $hasFollowedRedirect = false;
  35263. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  35264. $hasFollowedRedirect = true;
  35265. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  35266. }
  35267. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  35268. if (!$this->retry) {
  35269. if ($this->progress && !$isRedirect) {
  35270. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  35271. }
  35272. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  35273. $e->setHeaders($http_response_header);
  35274. $e->setResponse($this->decodeResult($result, $http_response_header));
  35275. $e->setStatusCode($statusCode);
  35276. throw $e;
  35277. }
  35278. $result = false;
  35279. }
  35280. if ($this->progress && !$this->retry && !$isRedirect) {
  35281. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  35282. }
  35283. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  35284. try {
  35285. $result = $this->decodeResult($result, $http_response_header);
  35286. } catch (\Exception $e) {
  35287. if ($this->degradedMode) {
  35288. throw $e;
  35289. }
  35290. $this->degradedMode = true;
  35291. $this->io->writeError(array(
  35292. '',
  35293. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  35294. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  35295. ));
  35296. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35297. }
  35298. }
  35299. if (false !== $result && null !== $fileName && !$isRedirect) {
  35300. if ('' === $result) {
  35301. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  35302. }
  35303. $errorMessage = '';
  35304. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  35305. if ($errorMessage) {
  35306. $errorMessage .= "\n";
  35307. }
  35308. $errorMessage .= Preg::replace('{^file_put_contents\(.*?\): }', '', $msg);
  35309. return true;
  35310. });
  35311. $result = (bool) file_put_contents($fileName, $result);
  35312. restore_error_handler();
  35313. if (false === $result) {
  35314. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  35315. }
  35316. }
  35317. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  35318. if (CaBundle::isOpensslParseSafe()) {
  35319. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  35320. if ($certDetails) {
  35321. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  35322. $this->retry = true;
  35323. }
  35324. } else {
  35325. $this->io->writeError('');
  35326. $this->io->writeError(sprintf(
  35327. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  35328. PHP_VERSION
  35329. ));
  35330. }
  35331. }
  35332. if ($this->retry) {
  35333. $this->retry = false;
  35334. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35335. if ($this->storeAuth) {
  35336. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  35337. $this->storeAuth = false;
  35338. }
  35339. return $result;
  35340. }
  35341. if (false === $result) {
  35342. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  35343. if (!empty($http_response_header[0])) {
  35344. $e->setHeaders($http_response_header);
  35345. }
  35346. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  35347. $this->degradedMode = true;
  35348. $this->io->writeError('');
  35349. $this->io->writeError(array(
  35350. '<error>'.$e->getMessage().'</error>',
  35351. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  35352. ));
  35353. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  35354. }
  35355. throw $e;
  35356. }
  35357. if (!empty($http_response_header[0])) {
  35358. $this->lastHeaders = $http_response_header;
  35359. }
  35360. return $result;
  35361. }
  35362. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null, $maxFileSize = null)
  35363. {
  35364. $result = false;
  35365. try {
  35366. $e = null;
  35367. if ($maxFileSize !== null) {
  35368. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  35369. } else {
  35370. $result = file_get_contents($fileUrl, false, $context);
  35371. }
  35372. } catch (\Exception $e) {
  35373. } catch (\Throwable $e) {
  35374. }
  35375. if ($maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  35376. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  35377. }
  35378. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  35379. if (null !== $e) {
  35380. throw $e;
  35381. }
  35382. return $result;
  35383. }
  35384. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  35385. {
  35386. switch ($notificationCode) {
  35387. case STREAM_NOTIFY_FAILURE:
  35388. if (400 === $messageCode) {
  35389. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  35390. }
  35391. break;
  35392. case STREAM_NOTIFY_FILE_SIZE_IS:
  35393. $this->bytesMax = $bytesMax;
  35394. break;
  35395. case STREAM_NOTIFY_PROGRESS:
  35396. if ($this->bytesMax > 0 && $this->progress) {
  35397. $progression = min(100, (int) round($bytesTransferred / $this->bytesMax * 100));
  35398. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  35399. $this->lastProgress = $progression;
  35400. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  35401. }
  35402. }
  35403. break;
  35404. default:
  35405. break;
  35406. }
  35407. }
  35408. protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
  35409. {
  35410. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  35411. $this->storeAuth = $result['storeAuth'];
  35412. $this->retry = $result['retry'];
  35413. if ($this->retry) {
  35414. throw new TransportException('RETRY');
  35415. }
  35416. }
  35417. protected function getOptionsForUrl($originUrl, $additionalOptions)
  35418. {
  35419. $tlsOptions = array();
  35420. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  35421. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  35422. if (PHP_VERSION_ID < 50304) {
  35423. if ($host === 'github.com' || $host === 'api.github.com') {
  35424. $host = '*.github.com';
  35425. }
  35426. }
  35427. $tlsOptions['ssl']['CN_match'] = $host;
  35428. $tlsOptions['ssl']['SNI_server_name'] = $host;
  35429. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  35430. if (isset($this->peerCertificateMap[$urlAuthority])) {
  35431. $certMap = $this->peerCertificateMap[$urlAuthority];
  35432. $this->io->writeError('', true, IOInterface::DEBUG);
  35433. $this->io->writeError(sprintf(
  35434. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  35435. $certMap['cn'],
  35436. $urlAuthority
  35437. ), true, IOInterface::DEBUG);
  35438. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  35439. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  35440. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  35441. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  35442. }
  35443. }
  35444. $headers = array();
  35445. if (extension_loaded('zlib')) {
  35446. $headers[] = 'Accept-Encoding: gzip';
  35447. }
  35448. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  35449. if (!$this->degradedMode) {
  35450. $options['http']['protocol_version'] = 1.1;
  35451. $headers[] = 'Connection: close';
  35452. }
  35453. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  35454. $options['http']['follow_location'] = 0;
  35455. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  35456. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  35457. }
  35458. foreach ($headers as $header) {
  35459. $options['http']['header'][] = $header;
  35460. }
  35461. return $options;
  35462. }
  35463. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  35464. {
  35465. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  35466. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  35467. $targetUrl = $locationHeader;
  35468. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  35469. $targetUrl = $this->scheme.':'.$locationHeader;
  35470. } elseif ('/' === $locationHeader[0]) {
  35471. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  35472. $targetUrl = Preg::replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  35473. } else {
  35474. $targetUrl = Preg::replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  35475. }
  35476. }
  35477. if (!empty($targetUrl)) {
  35478. $this->redirects++;
  35479. $this->io->writeError('', true, IOInterface::DEBUG);
  35480. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  35481. $additionalOptions['redirects'] = $this->redirects;
  35482. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  35483. }
  35484. if (!$this->retry) {
  35485. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  35486. $e->setHeaders($http_response_header);
  35487. $e->setResponse($this->decodeResult($result, $http_response_header));
  35488. throw $e;
  35489. }
  35490. return false;
  35491. }
  35492. private function getCertificateCnAndFp($url, $options)
  35493. {
  35494. if (PHP_VERSION_ID >= 50600) {
  35495. throw new \BadMethodCallException(sprintf(
  35496. '%s must not be used on PHP >= 5.6',
  35497. __METHOD__
  35498. ));
  35499. }
  35500. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  35501. 'ssl' => array(
  35502. 'capture_peer_cert' => true,
  35503. 'verify_peer' => false,
  35504. ), ),
  35505. ));
  35506. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  35507. return null;
  35508. }
  35509. fclose($handle);
  35510. $handle = null;
  35511. $params = stream_context_get_params($context);
  35512. if (!empty($params['options']['ssl']['peer_certificate'])) {
  35513. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  35514. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  35515. return array(
  35516. 'cn' => $commonName,
  35517. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  35518. );
  35519. }
  35520. }
  35521. return null;
  35522. }
  35523. private function getUrlAuthority($url)
  35524. {
  35525. $defaultPorts = array(
  35526. 'ftp' => 21,
  35527. 'http' => 80,
  35528. 'https' => 443,
  35529. 'ssh2.sftp' => 22,
  35530. 'ssh2.scp' => 22,
  35531. );
  35532. $scheme = parse_url($url, PHP_URL_SCHEME);
  35533. if (!isset($defaultPorts[$scheme])) {
  35534. throw new \InvalidArgumentException(sprintf(
  35535. 'Could not get default port for unknown scheme: %s',
  35536. $scheme
  35537. ));
  35538. }
  35539. $defaultPort = $defaultPorts[$scheme];
  35540. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  35541. return parse_url($url, PHP_URL_HOST).':'.$port;
  35542. }
  35543. private function decodeResult($result, $http_response_header)
  35544. {
  35545. if ($result && extension_loaded('zlib')) {
  35546. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  35547. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  35548. if ($decode) {
  35549. if (PHP_VERSION_ID >= 50400) {
  35550. $result = zlib_decode($result);
  35551. } else {
  35552. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  35553. }
  35554. if ($result === false) {
  35555. throw new TransportException('Failed to decode zlib stream');
  35556. }
  35557. }
  35558. }
  35559. return $this->normalizeResult($result);
  35560. }
  35561. private function normalizeResult($result)
  35562. {
  35563. if ($result === false) {
  35564. return null;
  35565. }
  35566. return $result;
  35567. }
  35568. }
  35569. <?php
  35570. namespace Composer\Util;
  35571. class Silencer
  35572. {
  35573. private static $stack = array();
  35574. public static function suppress($mask = null)
  35575. {
  35576. if (!isset($mask)) {
  35577. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  35578. }
  35579. $old = error_reporting();
  35580. self::$stack[] = $old;
  35581. error_reporting($old & ~$mask);
  35582. return $old;
  35583. }
  35584. public static function restore()
  35585. {
  35586. if (!empty(self::$stack)) {
  35587. error_reporting(array_pop(self::$stack));
  35588. }
  35589. }
  35590. public static function call($callable )
  35591. {
  35592. try {
  35593. self::suppress();
  35594. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  35595. self::restore();
  35596. return $result;
  35597. } catch (\Exception $e) {
  35598. self::restore();
  35599. throw $e;
  35600. }
  35601. }
  35602. }
  35603. <?php
  35604. namespace Composer\Util;
  35605. use Composer\Composer;
  35606. use Composer\CaBundle\CaBundle;
  35607. use Composer\Downloader\TransportException;
  35608. use Composer\Repository\PlatformRepository;
  35609. use Composer\Util\Http\ProxyManager;
  35610. use Psr\Log\LoggerInterface;
  35611. final class StreamContextFactory
  35612. {
  35613. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  35614. {
  35615. $options = array('http' => array(
  35616. 'follow_location' => 1,
  35617. 'max_redirects' => 20,
  35618. ));
  35619. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  35620. unset($defaultOptions['http']['header']);
  35621. $options = array_replace_recursive($options, $defaultOptions);
  35622. if (isset($options['http']['header'])) {
  35623. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  35624. }
  35625. return stream_context_create($options, $defaultParams);
  35626. }
  35627. public static function initOptions($url, array $options, $forCurl = false)
  35628. {
  35629. if (!isset($options['http']['header'])) {
  35630. $options['http']['header'] = array();
  35631. }
  35632. if (is_string($options['http']['header'])) {
  35633. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  35634. }
  35635. if (!$forCurl) {
  35636. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  35637. if ($proxyOptions = $proxy->getContextOptions()) {
  35638. $isHttpsRequest = 0 === strpos($url, 'https://');
  35639. if ($proxy->isSecure()) {
  35640. if (!extension_loaded('openssl')) {
  35641. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  35642. }
  35643. if ($isHttpsRequest) {
  35644. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  35645. }
  35646. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  35647. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  35648. }
  35649. if (isset($proxyOptions['http']['header'])) {
  35650. $options['http']['header'][] = $proxyOptions['http']['header'];
  35651. unset($proxyOptions['http']['header']);
  35652. }
  35653. $options = array_replace_recursive($options, $proxyOptions);
  35654. }
  35655. }
  35656. if (defined('HHVM_VERSION')) {
  35657. $phpVersion = 'HHVM ' . HHVM_VERSION;
  35658. } else {
  35659. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  35660. }
  35661. if ($forCurl) {
  35662. $curl = curl_version();
  35663. $httpVersion = 'cURL '.$curl['version'];
  35664. } else {
  35665. $httpVersion = 'streams';
  35666. }
  35667. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  35668. $platformPhpVersion = PlatformRepository::getPlatformPhpVersion();
  35669. $options['http']['header'][] = sprintf(
  35670. 'User-Agent: Composer/%s (%s; %s; %s; %s%s%s)',
  35671. Composer::getVersion(),
  35672. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  35673. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  35674. $phpVersion,
  35675. $httpVersion,
  35676. $platformPhpVersion ? '; Platform-PHP '.$platformPhpVersion : '',
  35677. Platform::getEnv('CI') ? '; CI' : ''
  35678. );
  35679. }
  35680. return $options;
  35681. }
  35682. public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
  35683. {
  35684. $ciphers = implode(':', array(
  35685. 'ECDHE-RSA-AES128-GCM-SHA256',
  35686. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  35687. 'ECDHE-RSA-AES256-GCM-SHA384',
  35688. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  35689. 'DHE-RSA-AES128-GCM-SHA256',
  35690. 'DHE-DSS-AES128-GCM-SHA256',
  35691. 'kEDH+AESGCM',
  35692. 'ECDHE-RSA-AES128-SHA256',
  35693. 'ECDHE-ECDSA-AES128-SHA256',
  35694. 'ECDHE-RSA-AES128-SHA',
  35695. 'ECDHE-ECDSA-AES128-SHA',
  35696. 'ECDHE-RSA-AES256-SHA384',
  35697. 'ECDHE-ECDSA-AES256-SHA384',
  35698. 'ECDHE-RSA-AES256-SHA',
  35699. 'ECDHE-ECDSA-AES256-SHA',
  35700. 'DHE-RSA-AES128-SHA256',
  35701. 'DHE-RSA-AES128-SHA',
  35702. 'DHE-DSS-AES128-SHA256',
  35703. 'DHE-RSA-AES256-SHA256',
  35704. 'DHE-DSS-AES256-SHA',
  35705. 'DHE-RSA-AES256-SHA',
  35706. 'AES128-GCM-SHA256',
  35707. 'AES256-GCM-SHA384',
  35708. 'AES128-SHA256',
  35709. 'AES256-SHA256',
  35710. 'AES128-SHA',
  35711. 'AES256-SHA',
  35712. 'AES',
  35713. 'CAMELLIA',
  35714. 'DES-CBC3-SHA',
  35715. '!aNULL',
  35716. '!eNULL',
  35717. '!EXPORT',
  35718. '!DES',
  35719. '!RC4',
  35720. '!MD5',
  35721. '!PSK',
  35722. '!aECDH',
  35723. '!EDH-DSS-DES-CBC3-SHA',
  35724. '!EDH-RSA-DES-CBC3-SHA',
  35725. '!KRB5-DES-CBC3-SHA',
  35726. ));
  35727. $defaults = array(
  35728. 'ssl' => array(
  35729. 'ciphers' => $ciphers,
  35730. 'verify_peer' => true,
  35731. 'verify_depth' => 7,
  35732. 'SNI_enabled' => true,
  35733. 'capture_peer_cert' => true,
  35734. ),
  35735. );
  35736. if (isset($options['ssl'])) {
  35737. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  35738. }
  35739. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  35740. $result = CaBundle::getSystemCaRootBundlePath($logger);
  35741. if (is_dir($result)) {
  35742. $defaults['ssl']['capath'] = $result;
  35743. } else {
  35744. $defaults['ssl']['cafile'] = $result;
  35745. }
  35746. }
  35747. if (isset($defaults['ssl']['cafile']) && (!Filesystem::isReadable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  35748. throw new TransportException('The configured cafile was not valid or could not be read.');
  35749. }
  35750. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !Filesystem::isReadable($defaults['ssl']['capath']))) {
  35751. throw new TransportException('The configured capath was not valid or could not be read.');
  35752. }
  35753. if (PHP_VERSION_ID >= 50413) {
  35754. $defaults['ssl']['disable_compression'] = true;
  35755. }
  35756. return $defaults;
  35757. }
  35758. private static function fixHttpHeaderField($header)
  35759. {
  35760. if (!is_array($header)) {
  35761. $header = explode("\r\n", $header);
  35762. }
  35763. uasort($header, function ($el) {
  35764. return stripos($el, 'content-type') === 0 ? 1 : -1;
  35765. });
  35766. return $header;
  35767. }
  35768. }
  35769. <?php
  35770. namespace Composer\Util;
  35771. use Composer\Config;
  35772. use Composer\IO\IOInterface;
  35773. use Composer\Pcre\Preg;
  35774. class Svn
  35775. {
  35776. const MAX_QTY_AUTH_TRIES = 5;
  35777. protected $credentials;
  35778. protected $hasAuth;
  35779. protected $io;
  35780. protected $url;
  35781. protected $cacheCredentials = true;
  35782. protected $process;
  35783. protected $qtyAuthTries = 0;
  35784. protected $config;
  35785. private static $version;
  35786. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  35787. {
  35788. $this->url = $url;
  35789. $this->io = $io;
  35790. $this->config = $config;
  35791. $this->process = $process ?: new ProcessExecutor($io);
  35792. }
  35793. public static function cleanEnv()
  35794. {
  35795. Platform::clearEnv('DYLD_LIBRARY_PATH');
  35796. }
  35797. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  35798. {
  35799. $this->config->prohibitUrlByConfig($url, $this->io);
  35800. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  35801. }
  35802. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  35803. {
  35804. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  35805. }
  35806. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  35807. {
  35808. $command = $this->getCommand($svnCommand, $url, $path);
  35809. $output = null;
  35810. $io = $this->io;
  35811. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  35812. if ($type !== 'out') {
  35813. return null;
  35814. }
  35815. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  35816. return null;
  35817. }
  35818. $output .= $buffer;
  35819. if ($verbose) {
  35820. $io->writeError($buffer, false);
  35821. }
  35822. };
  35823. $status = $this->process->execute($command, $handler, $cwd);
  35824. if (0 === $status) {
  35825. return $output;
  35826. }
  35827. $errorOutput = $this->process->getErrorOutput();
  35828. $fullOutput = implode("\n", array($output, $errorOutput));
  35829. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  35830. && false === stripos($fullOutput, 'authorization failed')
  35831. && false === stripos($fullOutput, 'svn: E170001:')
  35832. && false === stripos($fullOutput, 'svn: E215004:')) {
  35833. throw new \RuntimeException($fullOutput);
  35834. }
  35835. if (!$this->hasAuth()) {
  35836. $this->doAuthDance();
  35837. }
  35838. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  35839. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  35840. }
  35841. throw new \RuntimeException(
  35842. 'wrong credentials provided ('.$fullOutput.')'
  35843. );
  35844. }
  35845. public function setCacheCredentials($cacheCredentials)
  35846. {
  35847. $this->cacheCredentials = $cacheCredentials;
  35848. }
  35849. protected function doAuthDance()
  35850. {
  35851. if (!$this->io->isInteractive()) {
  35852. throw new \RuntimeException(
  35853. 'can not ask for authentication in non interactive mode'
  35854. );
  35855. }
  35856. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  35857. $this->hasAuth = true;
  35858. $this->credentials = array(
  35859. 'username' => (string) $this->io->ask("Username: ", ''),
  35860. 'password' => (string) $this->io->askAndHideAnswer("Password: "),
  35861. );
  35862. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  35863. return $this;
  35864. }
  35865. protected function getCommand($cmd, $url, $path = null)
  35866. {
  35867. $cmd = sprintf(
  35868. '%s %s%s -- %s',
  35869. $cmd,
  35870. '--non-interactive ',
  35871. $this->getCredentialString(),
  35872. ProcessExecutor::escape($url)
  35873. );
  35874. if ($path) {
  35875. $cmd .= ' ' . ProcessExecutor::escape($path);
  35876. }
  35877. return $cmd;
  35878. }
  35879. protected function getCredentialString()
  35880. {
  35881. if (!$this->hasAuth()) {
  35882. return '';
  35883. }
  35884. return sprintf(
  35885. ' %s--username %s --password %s ',
  35886. $this->getAuthCache(),
  35887. ProcessExecutor::escape($this->getUsername()),
  35888. ProcessExecutor::escape($this->getPassword())
  35889. );
  35890. }
  35891. protected function getPassword()
  35892. {
  35893. if ($this->credentials === null) {
  35894. throw new \LogicException("No svn auth detected.");
  35895. }
  35896. return $this->credentials['password'];
  35897. }
  35898. protected function getUsername()
  35899. {
  35900. if ($this->credentials === null) {
  35901. throw new \LogicException("No svn auth detected.");
  35902. }
  35903. return $this->credentials['username'];
  35904. }
  35905. protected function hasAuth()
  35906. {
  35907. if (null !== $this->hasAuth) {
  35908. return $this->hasAuth;
  35909. }
  35910. if (false === $this->createAuthFromConfig()) {
  35911. $this->createAuthFromUrl();
  35912. }
  35913. return (bool) $this->hasAuth;
  35914. }
  35915. protected function getAuthCache()
  35916. {
  35917. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  35918. }
  35919. private function createAuthFromConfig()
  35920. {
  35921. if (!$this->config->has('http-basic')) {
  35922. return $this->hasAuth = false;
  35923. }
  35924. $authConfig = $this->config->get('http-basic');
  35925. $host = parse_url($this->url, PHP_URL_HOST);
  35926. if (isset($authConfig[$host])) {
  35927. $this->credentials = array(
  35928. 'username' => $authConfig[$host]['username'],
  35929. 'password' => $authConfig[$host]['password'],
  35930. );
  35931. return $this->hasAuth = true;
  35932. }
  35933. return $this->hasAuth = false;
  35934. }
  35935. private function createAuthFromUrl()
  35936. {
  35937. $uri = parse_url($this->url);
  35938. if (empty($uri['user'])) {
  35939. return $this->hasAuth = false;
  35940. }
  35941. $this->credentials = array(
  35942. 'username' => $uri['user'],
  35943. 'password' => !empty($uri['pass']) ? $uri['pass'] : '',
  35944. );
  35945. return $this->hasAuth = true;
  35946. }
  35947. public function binaryVersion()
  35948. {
  35949. if (!self::$version) {
  35950. if (0 === $this->process->execute('svn --version', $output)) {
  35951. if (Preg::isMatch('{(\d+(?:\.\d+)+)}', $output, $match)) {
  35952. self::$version = $match[1];
  35953. }
  35954. }
  35955. }
  35956. return self::$version;
  35957. }
  35958. }
  35959. <?php
  35960. namespace Composer\Util;
  35961. use Composer\Downloader\DownloaderInterface;
  35962. use Composer\Package\PackageInterface;
  35963. use React\Promise\PromiseInterface;
  35964. class SyncHelper
  35965. {
  35966. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, $path, PackageInterface $package, PackageInterface $prevPackage = null)
  35967. {
  35968. $type = $prevPackage ? 'update' : 'install';
  35969. try {
  35970. self::await($loop, $downloader->download($package, $path, $prevPackage));
  35971. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  35972. if ($type === 'update') {
  35973. self::await($loop, $downloader->update($package, $prevPackage, $path));
  35974. } else {
  35975. self::await($loop, $downloader->install($package, $path));
  35976. }
  35977. } catch (\Exception $e) {
  35978. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  35979. throw $e;
  35980. }
  35981. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  35982. }
  35983. public static function await(Loop $loop, PromiseInterface $promise = null)
  35984. {
  35985. if ($promise) {
  35986. $loop->wait(array($promise));
  35987. }
  35988. }
  35989. }
  35990. <?php
  35991. namespace Composer\Util;
  35992. class Tar
  35993. {
  35994. public static function getComposerJson($pathToArchive)
  35995. {
  35996. $phar = new \PharData($pathToArchive);
  35997. if (!$phar->valid()) {
  35998. return null;
  35999. }
  36000. return self::extractComposerJsonFromFolder($phar);
  36001. }
  36002. private static function extractComposerJsonFromFolder(\PharData $phar)
  36003. {
  36004. if (isset($phar['composer.json'])) {
  36005. return $phar['composer.json']->getContent();
  36006. }
  36007. $topLevelPaths = array();
  36008. foreach ($phar as $folderFile) {
  36009. $name = $folderFile->getBasename();
  36010. if ($folderFile->isDir()) {
  36011. $topLevelPaths[$name] = true;
  36012. if (\count($topLevelPaths) > 1) {
  36013. 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)));
  36014. }
  36015. }
  36016. }
  36017. $composerJsonPath = key($topLevelPaths).'/composer.json';
  36018. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  36019. return $phar[$composerJsonPath]->getContent();
  36020. }
  36021. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  36022. }
  36023. }
  36024. <?php
  36025. namespace Composer\Util;
  36026. use Composer\CaBundle\CaBundle;
  36027. use Composer\Pcre\Preg;
  36028. final class TlsHelper
  36029. {
  36030. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  36031. {
  36032. $names = self::getCertificateNames($certificate);
  36033. if (empty($names)) {
  36034. return false;
  36035. }
  36036. $combinedNames = array_merge($names['san'], array($names['cn']));
  36037. $hostname = strtolower($hostname);
  36038. foreach ($combinedNames as $certName) {
  36039. $matcher = self::certNameMatcher($certName);
  36040. if ($matcher && $matcher($hostname)) {
  36041. $cn = $names['cn'];
  36042. return true;
  36043. }
  36044. }
  36045. return false;
  36046. }
  36047. public static function getCertificateNames($certificate)
  36048. {
  36049. if (is_array($certificate)) {
  36050. $info = $certificate;
  36051. } elseif (CaBundle::isOpensslParseSafe()) {
  36052. $info = openssl_x509_parse($certificate, false);
  36053. }
  36054. if (!isset($info['subject']['commonName'])) {
  36055. return null;
  36056. }
  36057. $commonName = strtolower($info['subject']['commonName']);
  36058. $subjectAltNames = array();
  36059. if (isset($info['extensions']['subjectAltName'])) {
  36060. $subjectAltNames = Preg::split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  36061. $subjectAltNames = array_filter(array_map(function ($name) {
  36062. if (0 === strpos($name, 'DNS:')) {
  36063. return strtolower(ltrim(substr($name, 4)));
  36064. }
  36065. return null;
  36066. }, $subjectAltNames));
  36067. $subjectAltNames = array_values($subjectAltNames);
  36068. }
  36069. return array(
  36070. 'cn' => $commonName,
  36071. 'san' => $subjectAltNames,
  36072. );
  36073. }
  36074. public static function getCertificateFingerprint($certificate)
  36075. {
  36076. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  36077. $pubkeypem = $pubkeydetails['key'];
  36078. $start = '-----BEGIN PUBLIC KEY-----';
  36079. $end = '-----END PUBLIC KEY-----';
  36080. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  36081. $der = base64_decode($pemtrim);
  36082. return sha1($der);
  36083. }
  36084. public static function isOpensslParseSafe()
  36085. {
  36086. return CaBundle::isOpensslParseSafe();
  36087. }
  36088. private static function certNameMatcher($certName)
  36089. {
  36090. $wildcards = substr_count($certName, '*');
  36091. if (0 === $wildcards) {
  36092. return function ($hostname) use ($certName) {
  36093. return $hostname === $certName;
  36094. };
  36095. }
  36096. if (1 === $wildcards) {
  36097. $components = explode('.', $certName);
  36098. if (3 > count($components)) {
  36099. return null;
  36100. }
  36101. $firstComponent = $components[0];
  36102. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  36103. return null;
  36104. }
  36105. $wildcardRegex = preg_quote($certName);
  36106. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  36107. $wildcardRegex = "{^{$wildcardRegex}$}";
  36108. return function ($hostname) use ($wildcardRegex) {
  36109. return Preg::isMatch($wildcardRegex, $hostname);
  36110. };
  36111. }
  36112. return null;
  36113. }
  36114. }
  36115. <?php
  36116. namespace Composer\Util;
  36117. use Composer\Config;
  36118. use Composer\Pcre\Preg;
  36119. class Url
  36120. {
  36121. public static function updateDistReference(Config $config, $url, $ref)
  36122. {
  36123. $host = parse_url($url, PHP_URL_HOST);
  36124. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  36125. if (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  36126. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  36127. } elseif (Preg::isMatch('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  36128. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  36129. } elseif (Preg::isMatch('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  36130. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  36131. }
  36132. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  36133. if (Preg::isMatch('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  36134. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  36135. }
  36136. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  36137. if (Preg::isMatch('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  36138. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  36139. }
  36140. } elseif (in_array($host, $config->get('github-domains'), true)) {
  36141. $url = Preg::replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  36142. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  36143. $url = Preg::replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  36144. }
  36145. return $url;
  36146. }
  36147. public static function getOrigin(Config $config, $url)
  36148. {
  36149. if (0 === strpos($url, 'file://')) {
  36150. return $url;
  36151. }
  36152. $origin = (string) parse_url($url, PHP_URL_HOST);
  36153. if ($port = parse_url($url, PHP_URL_PORT)) {
  36154. $origin .= ':'.$port;
  36155. }
  36156. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  36157. return 'github.com';
  36158. }
  36159. if ($origin === 'repo.packagist.org') {
  36160. return 'packagist.org';
  36161. }
  36162. if ($origin === '') {
  36163. $origin = $url;
  36164. }
  36165. if (
  36166. is_array($config->get('gitlab-domains'))
  36167. && false === strpos($origin, '/')
  36168. && !in_array($origin, $config->get('gitlab-domains'))
  36169. ) {
  36170. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  36171. if (0 === strpos($gitlabDomain, $origin)) {
  36172. return $gitlabDomain;
  36173. }
  36174. }
  36175. }
  36176. return $origin;
  36177. }
  36178. public static function sanitize($url)
  36179. {
  36180. $url = Preg::replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  36181. $url = Preg::replaceCallback('{^(?P<prefix>[a-z0-9]+://)?(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  36182. if (Preg::isMatch('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  36183. return $m['prefix'].'***:***@';
  36184. }
  36185. return $m['prefix'].$m['user'].':***@';
  36186. }, $url);
  36187. return $url;
  36188. }
  36189. }
  36190. <?php
  36191. namespace Composer\Util;
  36192. class Zip
  36193. {
  36194. public static function getComposerJson($pathToZip)
  36195. {
  36196. if (!extension_loaded('zip')) {
  36197. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  36198. }
  36199. $zip = new \ZipArchive();
  36200. if ($zip->open($pathToZip) !== true) {
  36201. return null;
  36202. }
  36203. if (0 == $zip->numFiles) {
  36204. $zip->close();
  36205. return null;
  36206. }
  36207. $foundFileIndex = self::locateFile($zip, 'composer.json');
  36208. $content = null;
  36209. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  36210. $stream = $zip->getStream($configurationFileName);
  36211. if (false !== $stream) {
  36212. $content = stream_get_contents($stream);
  36213. }
  36214. $zip->close();
  36215. return $content;
  36216. }
  36217. private static function locateFile(\ZipArchive $zip, $filename)
  36218. {
  36219. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  36220. return $index;
  36221. }
  36222. $topLevelPaths = array();
  36223. for ($i = 0; $i < $zip->numFiles; $i++) {
  36224. $name = $zip->getNameIndex($i);
  36225. $dirname = dirname($name);
  36226. if (strpos($name, '__MACOSX') !== false) {
  36227. continue;
  36228. }
  36229. if ($dirname === '.') {
  36230. $topLevelPaths[$name] = true;
  36231. if (\count($topLevelPaths) > 1) {
  36232. 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)));
  36233. }
  36234. continue;
  36235. }
  36236. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  36237. $topLevelPaths[$dirname.'/'] = true;
  36238. if (\count($topLevelPaths) > 1) {
  36239. 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)));
  36240. }
  36241. }
  36242. }
  36243. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  36244. return $index;
  36245. }
  36246. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  36247. }
  36248. }
  36249. <?php
  36250. function includeIfExists($file)
  36251. {
  36252. return file_exists($file) ? include $file : null;
  36253. }
  36254. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  36255. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  36256. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  36257. exit(1);
  36258. }
  36259. return $loader;
  36260. <?php
  36261. /*
  36262. * This file is part of Composer.
  36263. *
  36264. * (c) Nils Adermann <naderman@naderman.de>
  36265. * Jordi Boggiano <j.boggiano@seld.be>
  36266. *
  36267. * For the full copyright and license information, please view the LICENSE
  36268. * file that was distributed with this source code.
  36269. */
  36270. namespace Composer\Autoload;
  36271. /**
  36272. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  36273. *
  36274. * $loader = new \Composer\Autoload\ClassLoader();
  36275. *
  36276. * // register classes with namespaces
  36277. * $loader->add('Symfony\Component', __DIR__.'/component');
  36278. * $loader->add('Symfony', __DIR__.'/framework');
  36279. *
  36280. * // activate the autoloader
  36281. * $loader->register();
  36282. *
  36283. * // to enable searching the include path (eg. for PEAR packages)
  36284. * $loader->setUseIncludePath(true);
  36285. *
  36286. * In this example, if you try to use a class in the Symfony\Component
  36287. * namespace or one of its children (Symfony\Component\Console for instance),
  36288. * the autoloader will first look for the class under the component/
  36289. * directory, and it will then fallback to the framework/ directory if not
  36290. * found before giving up.
  36291. *
  36292. * This class is loosely based on the Symfony UniversalClassLoader.
  36293. *
  36294. * @author Fabien Potencier <fabien@symfony.com>
  36295. * @author Jordi Boggiano <j.boggiano@seld.be>
  36296. * @see https://www.php-fig.org/psr/psr-0/
  36297. * @see https://www.php-fig.org/psr/psr-4/
  36298. */
  36299. class ClassLoader
  36300. {
  36301. /** @var ?string */
  36302. private $vendorDir;
  36303. // PSR-4
  36304. /**
  36305. * @var array[]
  36306. * @psalm-var array<string, array<string, int>>
  36307. */
  36308. private $prefixLengthsPsr4 = array();
  36309. /**
  36310. * @var array[]
  36311. * @psalm-var array<string, array<int, string>>
  36312. */
  36313. private $prefixDirsPsr4 = array();
  36314. /**
  36315. * @var array[]
  36316. * @psalm-var array<string, string>
  36317. */
  36318. private $fallbackDirsPsr4 = array();
  36319. // PSR-0
  36320. /**
  36321. * @var array[]
  36322. * @psalm-var array<string, array<string, string[]>>
  36323. */
  36324. private $prefixesPsr0 = array();
  36325. /**
  36326. * @var array[]
  36327. * @psalm-var array<string, string>
  36328. */
  36329. private $fallbackDirsPsr0 = array();
  36330. /** @var bool */
  36331. private $useIncludePath = false;
  36332. /**
  36333. * @var string[]
  36334. * @psalm-var array<string, string>
  36335. */
  36336. private $classMap = array();
  36337. /** @var bool */
  36338. private $classMapAuthoritative = false;
  36339. /**
  36340. * @var bool[]
  36341. * @psalm-var array<string, bool>
  36342. */
  36343. private $missingClasses = array();
  36344. /** @var ?string */
  36345. private $apcuPrefix;
  36346. /**
  36347. * @var self[]
  36348. */
  36349. private static $registeredLoaders = array();
  36350. /**
  36351. * @param ?string $vendorDir
  36352. */
  36353. public function __construct($vendorDir = null)
  36354. {
  36355. $this->vendorDir = $vendorDir;
  36356. }
  36357. /**
  36358. * @return string[]
  36359. */
  36360. public function getPrefixes()
  36361. {
  36362. if (!empty($this->prefixesPsr0)) {
  36363. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  36364. }
  36365. return array();
  36366. }
  36367. /**
  36368. * @return array[]
  36369. * @psalm-return array<string, array<int, string>>
  36370. */
  36371. public function getPrefixesPsr4()
  36372. {
  36373. return $this->prefixDirsPsr4;
  36374. }
  36375. /**
  36376. * @return array[]
  36377. * @psalm-return array<string, string>
  36378. */
  36379. public function getFallbackDirs()
  36380. {
  36381. return $this->fallbackDirsPsr0;
  36382. }
  36383. /**
  36384. * @return array[]
  36385. * @psalm-return array<string, string>
  36386. */
  36387. public function getFallbackDirsPsr4()
  36388. {
  36389. return $this->fallbackDirsPsr4;
  36390. }
  36391. /**
  36392. * @return string[] Array of classname => path
  36393. * @psalm-return array<string, string>
  36394. */
  36395. public function getClassMap()
  36396. {
  36397. return $this->classMap;
  36398. }
  36399. /**
  36400. * @param string[] $classMap Class to filename map
  36401. * @psalm-param array<string, string> $classMap
  36402. *
  36403. * @return void
  36404. */
  36405. public function addClassMap(array $classMap)
  36406. {
  36407. if ($this->classMap) {
  36408. $this->classMap = array_merge($this->classMap, $classMap);
  36409. } else {
  36410. $this->classMap = $classMap;
  36411. }
  36412. }
  36413. /**
  36414. * Registers a set of PSR-0 directories for a given prefix, either
  36415. * appending or prepending to the ones previously set for this prefix.
  36416. *
  36417. * @param string $prefix The prefix
  36418. * @param string[]|string $paths The PSR-0 root directories
  36419. * @param bool $prepend Whether to prepend the directories
  36420. *
  36421. * @return void
  36422. */
  36423. public function add($prefix, $paths, $prepend = false)
  36424. {
  36425. if (!$prefix) {
  36426. if ($prepend) {
  36427. $this->fallbackDirsPsr0 = array_merge(
  36428. (array) $paths,
  36429. $this->fallbackDirsPsr0
  36430. );
  36431. } else {
  36432. $this->fallbackDirsPsr0 = array_merge(
  36433. $this->fallbackDirsPsr0,
  36434. (array) $paths
  36435. );
  36436. }
  36437. return;
  36438. }
  36439. $first = $prefix[0];
  36440. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  36441. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  36442. return;
  36443. }
  36444. if ($prepend) {
  36445. $this->prefixesPsr0[$first][$prefix] = array_merge(
  36446. (array) $paths,
  36447. $this->prefixesPsr0[$first][$prefix]
  36448. );
  36449. } else {
  36450. $this->prefixesPsr0[$first][$prefix] = array_merge(
  36451. $this->prefixesPsr0[$first][$prefix],
  36452. (array) $paths
  36453. );
  36454. }
  36455. }
  36456. /**
  36457. * Registers a set of PSR-4 directories for a given namespace, either
  36458. * appending or prepending to the ones previously set for this namespace.
  36459. *
  36460. * @param string $prefix The prefix/namespace, with trailing '\\'
  36461. * @param string[]|string $paths The PSR-4 base directories
  36462. * @param bool $prepend Whether to prepend the directories
  36463. *
  36464. * @throws \InvalidArgumentException
  36465. *
  36466. * @return void
  36467. */
  36468. public function addPsr4($prefix, $paths, $prepend = false)
  36469. {
  36470. if (!$prefix) {
  36471. // Register directories for the root namespace.
  36472. if ($prepend) {
  36473. $this->fallbackDirsPsr4 = array_merge(
  36474. (array) $paths,
  36475. $this->fallbackDirsPsr4
  36476. );
  36477. } else {
  36478. $this->fallbackDirsPsr4 = array_merge(
  36479. $this->fallbackDirsPsr4,
  36480. (array) $paths
  36481. );
  36482. }
  36483. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  36484. // Register directories for a new namespace.
  36485. $length = strlen($prefix);
  36486. if ('\\' !== $prefix[$length - 1]) {
  36487. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  36488. }
  36489. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  36490. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  36491. } elseif ($prepend) {
  36492. // Prepend directories for an already registered namespace.
  36493. $this->prefixDirsPsr4[$prefix] = array_merge(
  36494. (array) $paths,
  36495. $this->prefixDirsPsr4[$prefix]
  36496. );
  36497. } else {
  36498. // Append directories for an already registered namespace.
  36499. $this->prefixDirsPsr4[$prefix] = array_merge(
  36500. $this->prefixDirsPsr4[$prefix],
  36501. (array) $paths
  36502. );
  36503. }
  36504. }
  36505. /**
  36506. * Registers a set of PSR-0 directories for a given prefix,
  36507. * replacing any others previously set for this prefix.
  36508. *
  36509. * @param string $prefix The prefix
  36510. * @param string[]|string $paths The PSR-0 base directories
  36511. *
  36512. * @return void
  36513. */
  36514. public function set($prefix, $paths)
  36515. {
  36516. if (!$prefix) {
  36517. $this->fallbackDirsPsr0 = (array) $paths;
  36518. } else {
  36519. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  36520. }
  36521. }
  36522. /**
  36523. * Registers a set of PSR-4 directories for a given namespace,
  36524. * replacing any others previously set for this namespace.
  36525. *
  36526. * @param string $prefix The prefix/namespace, with trailing '\\'
  36527. * @param string[]|string $paths The PSR-4 base directories
  36528. *
  36529. * @throws \InvalidArgumentException
  36530. *
  36531. * @return void
  36532. */
  36533. public function setPsr4($prefix, $paths)
  36534. {
  36535. if (!$prefix) {
  36536. $this->fallbackDirsPsr4 = (array) $paths;
  36537. } else {
  36538. $length = strlen($prefix);
  36539. if ('\\' !== $prefix[$length - 1]) {
  36540. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  36541. }
  36542. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  36543. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  36544. }
  36545. }
  36546. /**
  36547. * Turns on searching the include path for class files.
  36548. *
  36549. * @param bool $useIncludePath
  36550. *
  36551. * @return void
  36552. */
  36553. public function setUseIncludePath($useIncludePath)
  36554. {
  36555. $this->useIncludePath = $useIncludePath;
  36556. }
  36557. /**
  36558. * Can be used to check if the autoloader uses the include path to check
  36559. * for classes.
  36560. *
  36561. * @return bool
  36562. */
  36563. public function getUseIncludePath()
  36564. {
  36565. return $this->useIncludePath;
  36566. }
  36567. /**
  36568. * Turns off searching the prefix and fallback directories for classes
  36569. * that have not been registered with the class map.
  36570. *
  36571. * @param bool $classMapAuthoritative
  36572. *
  36573. * @return void
  36574. */
  36575. public function setClassMapAuthoritative($classMapAuthoritative)
  36576. {
  36577. $this->classMapAuthoritative = $classMapAuthoritative;
  36578. }
  36579. /**
  36580. * Should class lookup fail if not found in the current class map?
  36581. *
  36582. * @return bool
  36583. */
  36584. public function isClassMapAuthoritative()
  36585. {
  36586. return $this->classMapAuthoritative;
  36587. }
  36588. /**
  36589. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  36590. *
  36591. * @param string|null $apcuPrefix
  36592. *
  36593. * @return void
  36594. */
  36595. public function setApcuPrefix($apcuPrefix)
  36596. {
  36597. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  36598. }
  36599. /**
  36600. * The APCu prefix in use, or null if APCu caching is not enabled.
  36601. *
  36602. * @return string|null
  36603. */
  36604. public function getApcuPrefix()
  36605. {
  36606. return $this->apcuPrefix;
  36607. }
  36608. /**
  36609. * Registers this instance as an autoloader.
  36610. *
  36611. * @param bool $prepend Whether to prepend the autoloader or not
  36612. *
  36613. * @return void
  36614. */
  36615. public function register($prepend = false)
  36616. {
  36617. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  36618. if (null === $this->vendorDir) {
  36619. return;
  36620. }
  36621. if ($prepend) {
  36622. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  36623. } else {
  36624. unset(self::$registeredLoaders[$this->vendorDir]);
  36625. self::$registeredLoaders[$this->vendorDir] = $this;
  36626. }
  36627. }
  36628. /**
  36629. * Unregisters this instance as an autoloader.
  36630. *
  36631. * @return void
  36632. */
  36633. public function unregister()
  36634. {
  36635. spl_autoload_unregister(array($this, 'loadClass'));
  36636. if (null !== $this->vendorDir) {
  36637. unset(self::$registeredLoaders[$this->vendorDir]);
  36638. }
  36639. }
  36640. /**
  36641. * Loads the given class or interface.
  36642. *
  36643. * @param string $class The name of the class
  36644. * @return true|null True if loaded, null otherwise
  36645. */
  36646. public function loadClass($class)
  36647. {
  36648. if ($file = $this->findFile($class)) {
  36649. includeFile($file);
  36650. return true;
  36651. }
  36652. return null;
  36653. }
  36654. /**
  36655. * Finds the path to the file where the class is defined.
  36656. *
  36657. * @param string $class The name of the class
  36658. *
  36659. * @return string|false The path if found, false otherwise
  36660. */
  36661. public function findFile($class)
  36662. {
  36663. // class map lookup
  36664. if (isset($this->classMap[$class])) {
  36665. return $this->classMap[$class];
  36666. }
  36667. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  36668. return false;
  36669. }
  36670. if (null !== $this->apcuPrefix) {
  36671. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  36672. if ($hit) {
  36673. return $file;
  36674. }
  36675. }
  36676. $file = $this->findFileWithExtension($class, '.php');
  36677. // Search for Hack files if we are running on HHVM
  36678. if (false === $file && defined('HHVM_VERSION')) {
  36679. $file = $this->findFileWithExtension($class, '.hh');
  36680. }
  36681. if (null !== $this->apcuPrefix) {
  36682. apcu_add($this->apcuPrefix.$class, $file);
  36683. }
  36684. if (false === $file) {
  36685. // Remember that this class does not exist.
  36686. $this->missingClasses[$class] = true;
  36687. }
  36688. return $file;
  36689. }
  36690. /**
  36691. * Returns the currently registered loaders indexed by their corresponding vendor directories.
  36692. *
  36693. * @return self[]
  36694. */
  36695. public static function getRegisteredLoaders()
  36696. {
  36697. return self::$registeredLoaders;
  36698. }
  36699. /**
  36700. * @param string $class
  36701. * @param string $ext
  36702. * @return string|false
  36703. */
  36704. private function findFileWithExtension($class, $ext)
  36705. {
  36706. // PSR-4 lookup
  36707. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  36708. $first = $class[0];
  36709. if (isset($this->prefixLengthsPsr4[$first])) {
  36710. $subPath = $class;
  36711. while (false !== $lastPos = strrpos($subPath, '\\')) {
  36712. $subPath = substr($subPath, 0, $lastPos);
  36713. $search = $subPath . '\\';
  36714. if (isset($this->prefixDirsPsr4[$search])) {
  36715. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  36716. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  36717. if (file_exists($file = $dir . $pathEnd)) {
  36718. return $file;
  36719. }
  36720. }
  36721. }
  36722. }
  36723. }
  36724. // PSR-4 fallback dirs
  36725. foreach ($this->fallbackDirsPsr4 as $dir) {
  36726. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  36727. return $file;
  36728. }
  36729. }
  36730. // PSR-0 lookup
  36731. if (false !== $pos = strrpos($class, '\\')) {
  36732. // namespaced class name
  36733. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  36734. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  36735. } else {
  36736. // PEAR-like class name
  36737. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  36738. }
  36739. if (isset($this->prefixesPsr0[$first])) {
  36740. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  36741. if (0 === strpos($class, $prefix)) {
  36742. foreach ($dirs as $dir) {
  36743. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  36744. return $file;
  36745. }
  36746. }
  36747. }
  36748. }
  36749. }
  36750. // PSR-0 fallback dirs
  36751. foreach ($this->fallbackDirsPsr0 as $dir) {
  36752. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  36753. return $file;
  36754. }
  36755. }
  36756. // PSR-0 include paths.
  36757. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  36758. return $file;
  36759. }
  36760. return false;
  36761. }
  36762. }
  36763. /**
  36764. * Scope isolated include.
  36765. *
  36766. * Prevents access to $this/self from included files.
  36767. *
  36768. * @param string $file
  36769. * @return void
  36770. * @private
  36771. */
  36772. function includeFile($file)
  36773. {
  36774. include $file;
  36775. }
  36776. <?php
  36777. /*
  36778. * This file is part of Composer.
  36779. *
  36780. * (c) Nils Adermann <naderman@naderman.de>
  36781. * Jordi Boggiano <j.boggiano@seld.be>
  36782. *
  36783. * For the full copyright and license information, please view the LICENSE
  36784. * file that was distributed with this source code.
  36785. */
  36786. namespace Composer;
  36787. use Composer\Autoload\ClassLoader;
  36788. use Composer\Semver\VersionParser;
  36789. /**
  36790. * This class is copied in every Composer installed project and available to all
  36791. *
  36792. * See also https://getcomposer.org/doc/07-runtime.md#installed-versions
  36793. *
  36794. * To require its presence, you can require `composer-runtime-api ^2.0`
  36795. */
  36796. class InstalledVersions
  36797. {
  36798. /**
  36799. * @var mixed[]|null
  36800. * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
  36801. */
  36802. private static $installed;
  36803. /**
  36804. * @var bool|null
  36805. */
  36806. private static $canGetVendors;
  36807. /**
  36808. * @var array[]
  36809. * @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  36810. */
  36811. private static $installedByVendor = array();
  36812. /**
  36813. * Returns a list of all package names which are present, either by being installed, replaced or provided
  36814. *
  36815. * @return string[]
  36816. * @psalm-return list<string>
  36817. */
  36818. public static function getInstalledPackages()
  36819. {
  36820. $packages = array();
  36821. foreach (self::getInstalled() as $installed) {
  36822. $packages[] = array_keys($installed['versions']);
  36823. }
  36824. if (1 === \count($packages)) {
  36825. return $packages[0];
  36826. }
  36827. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  36828. }
  36829. /**
  36830. * Returns a list of all package names with a specific type e.g. 'library'
  36831. *
  36832. * @param string $type
  36833. * @return string[]
  36834. * @psalm-return list<string>
  36835. */
  36836. public static function getInstalledPackagesByType($type)
  36837. {
  36838. $packagesByType = array();
  36839. foreach (self::getInstalled() as $installed) {
  36840. foreach ($installed['versions'] as $name => $package) {
  36841. if (isset($package['type']) && $package['type'] === $type) {
  36842. $packagesByType[] = $name;
  36843. }
  36844. }
  36845. }
  36846. return $packagesByType;
  36847. }
  36848. /**
  36849. * Checks whether the given package is installed
  36850. *
  36851. * This also returns true if the package name is provided or replaced by another package
  36852. *
  36853. * @param string $packageName
  36854. * @param bool $includeDevRequirements
  36855. * @return bool
  36856. */
  36857. public static function isInstalled($packageName, $includeDevRequirements = true)
  36858. {
  36859. foreach (self::getInstalled() as $installed) {
  36860. if (isset($installed['versions'][$packageName])) {
  36861. return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
  36862. }
  36863. }
  36864. return false;
  36865. }
  36866. /**
  36867. * Checks whether the given package satisfies a version constraint
  36868. *
  36869. * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
  36870. *
  36871. * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
  36872. *
  36873. * @param VersionParser $parser Install composer/semver to have access to this class and functionality
  36874. * @param string $packageName
  36875. * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
  36876. * @return bool
  36877. */
  36878. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  36879. {
  36880. $constraint = $parser->parseConstraints($constraint);
  36881. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  36882. return $provided->matches($constraint);
  36883. }
  36884. /**
  36885. * Returns a version constraint representing all the range(s) which are installed for a given package
  36886. *
  36887. * It is easier to use this via isInstalled() with the $constraint argument if you need to check
  36888. * whether a given version of a package is installed, and not just whether it exists
  36889. *
  36890. * @param string $packageName
  36891. * @return string Version constraint usable with composer/semver
  36892. */
  36893. public static function getVersionRanges($packageName)
  36894. {
  36895. foreach (self::getInstalled() as $installed) {
  36896. if (!isset($installed['versions'][$packageName])) {
  36897. continue;
  36898. }
  36899. $ranges = array();
  36900. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  36901. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  36902. }
  36903. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  36904. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  36905. }
  36906. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  36907. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  36908. }
  36909. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  36910. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  36911. }
  36912. return implode(' || ', $ranges);
  36913. }
  36914. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  36915. }
  36916. /**
  36917. * @param string $packageName
  36918. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
  36919. */
  36920. public static function getVersion($packageName)
  36921. {
  36922. foreach (self::getInstalled() as $installed) {
  36923. if (!isset($installed['versions'][$packageName])) {
  36924. continue;
  36925. }
  36926. if (!isset($installed['versions'][$packageName]['version'])) {
  36927. return null;
  36928. }
  36929. return $installed['versions'][$packageName]['version'];
  36930. }
  36931. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  36932. }
  36933. /**
  36934. * @param string $packageName
  36935. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
  36936. */
  36937. public static function getPrettyVersion($packageName)
  36938. {
  36939. foreach (self::getInstalled() as $installed) {
  36940. if (!isset($installed['versions'][$packageName])) {
  36941. continue;
  36942. }
  36943. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  36944. return null;
  36945. }
  36946. return $installed['versions'][$packageName]['pretty_version'];
  36947. }
  36948. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  36949. }
  36950. /**
  36951. * @param string $packageName
  36952. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
  36953. */
  36954. public static function getReference($packageName)
  36955. {
  36956. foreach (self::getInstalled() as $installed) {
  36957. if (!isset($installed['versions'][$packageName])) {
  36958. continue;
  36959. }
  36960. if (!isset($installed['versions'][$packageName]['reference'])) {
  36961. return null;
  36962. }
  36963. return $installed['versions'][$packageName]['reference'];
  36964. }
  36965. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  36966. }
  36967. /**
  36968. * @param string $packageName
  36969. * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
  36970. */
  36971. public static function getInstallPath($packageName)
  36972. {
  36973. foreach (self::getInstalled() as $installed) {
  36974. if (!isset($installed['versions'][$packageName])) {
  36975. continue;
  36976. }
  36977. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  36978. }
  36979. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  36980. }
  36981. /**
  36982. * @return array
  36983. * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
  36984. */
  36985. public static function getRootPackage()
  36986. {
  36987. $installed = self::getInstalled();
  36988. return $installed[0]['root'];
  36989. }
  36990. /**
  36991. * Returns the raw installed.php data for custom implementations
  36992. *
  36993. * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
  36994. * @return array[]
  36995. * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
  36996. */
  36997. public static function getRawData()
  36998. {
  36999. @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
  37000. if (null === self::$installed) {
  37001. // only require the installed.php file if this file is loaded from its dumped location,
  37002. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  37003. if (substr(__DIR__, -8, 1) !== 'C') {
  37004. self::$installed = include __DIR__ . '/installed.php';
  37005. } else {
  37006. self::$installed = array();
  37007. }
  37008. }
  37009. return self::$installed;
  37010. }
  37011. /**
  37012. * Returns the raw data of all installed.php which are currently loaded for custom implementations
  37013. *
  37014. * @return array[]
  37015. * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  37016. */
  37017. public static function getAllRawData()
  37018. {
  37019. return self::getInstalled();
  37020. }
  37021. /**
  37022. * Lets you reload the static array from another file
  37023. *
  37024. * This is only useful for complex integrations in which a project needs to use
  37025. * this class but then also needs to execute another project's autoloader in process,
  37026. * and wants to ensure both projects have access to their version of installed.php.
  37027. *
  37028. * A typical case would be PHPUnit, where it would need to make sure it reads all
  37029. * the data it needs from this class, then call reload() with
  37030. * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
  37031. * the project in which it runs can then also use this class safely, without
  37032. * interference between PHPUnit's dependencies and the project's dependencies.
  37033. *
  37034. * @param array[] $data A vendor/composer/installed.php data set
  37035. * @return void
  37036. *
  37037. * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
  37038. */
  37039. public static function reload($data)
  37040. {
  37041. self::$installed = $data;
  37042. self::$installedByVendor = array();
  37043. }
  37044. /**
  37045. * @return array[]
  37046. * @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
  37047. */
  37048. private static function getInstalled()
  37049. {
  37050. if (null === self::$canGetVendors) {
  37051. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  37052. }
  37053. $installed = array();
  37054. if (self::$canGetVendors) {
  37055. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  37056. if (isset(self::$installedByVendor[$vendorDir])) {
  37057. $installed[] = self::$installedByVendor[$vendorDir];
  37058. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  37059. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  37060. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  37061. self::$installed = $installed[count($installed) - 1];
  37062. }
  37063. }
  37064. }
  37065. }
  37066. if (null === self::$installed) {
  37067. // only require the installed.php file if this file is loaded from its dumped location,
  37068. // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
  37069. if (substr(__DIR__, -8, 1) !== 'C') {
  37070. self::$installed = require __DIR__ . '/installed.php';
  37071. } else {
  37072. self::$installed = array();
  37073. }
  37074. }
  37075. $installed[] = self::$installed;
  37076. return $installed;
  37077. }
  37078. }
  37079. {
  37080. "$schema": "https://json-schema.org/draft-04/schema#",
  37081. "description": "A representation of packages metadata.",
  37082. "type": "object",
  37083. "oneOf": [
  37084. { "required": [ "packages" ] },
  37085. { "required": [ "providers" ] },
  37086. { "required": [ "provider-includes", "providers-url" ] }
  37087. ],
  37088. "properties": {
  37089. "packages": {
  37090. "type": ["object", "array"],
  37091. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  37092. "additionalProperties": { "$ref": "#/definitions/versions" }
  37093. },
  37094. "providers-url": {
  37095. "type": "string",
  37096. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  37097. },
  37098. "provider-includes": {
  37099. "type": "object",
  37100. "description": "A hashmap of provider listings.",
  37101. "additionalProperties": { "$ref": "#/definitions/provider" }
  37102. },
  37103. "providers": {
  37104. "type": "object",
  37105. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  37106. "additionalProperties": { "$ref": "#/definitions/provider" }
  37107. },
  37108. "notify-batch": {
  37109. "type": "string",
  37110. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  37111. },
  37112. "search": {
  37113. "type": "string",
  37114. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  37115. },
  37116. "warning": {
  37117. "type": "string",
  37118. "description": "A message that will be output by Composer as a warning when this source is consulted."
  37119. }
  37120. },
  37121. "definitions": {
  37122. "versions": {
  37123. "type": "object",
  37124. "description": "A hashmap of versions and their metadata.",
  37125. "additionalProperties": { "$ref": "#/definitions/version" }
  37126. },
  37127. "version": {
  37128. "type": "object",
  37129. "oneOf": [
  37130. { "$ref": "#/definitions/package" },
  37131. { "$ref": "#/definitions/metapackage" }
  37132. ]
  37133. },
  37134. "package-base": {
  37135. "properties": {
  37136. "name": { "type": "string" },
  37137. "type": { "type": "string" },
  37138. "version": { "type": "string" },
  37139. "version_normalized": {
  37140. "type": "string",
  37141. "description": "Normalized version, optional but can save computational time on client side."
  37142. },
  37143. "autoload": { "type": "object" },
  37144. "require": { "type": "object" },
  37145. "replace": { "type": "object" },
  37146. "conflict": { "type": "object" },
  37147. "provide": { "type": "object" },
  37148. "time": { "type": "string" }
  37149. },
  37150. "additionalProperties": true
  37151. },
  37152. "package": {
  37153. "allOf": [
  37154. { "$ref": "#/definitions/package-base" },
  37155. {
  37156. "properties": {
  37157. "dist": { "type": "object" },
  37158. "source": { "type": "object" }
  37159. }
  37160. },
  37161. { "oneOf": [
  37162. { "required": [ "name", "version", "source" ] },
  37163. { "required": [ "name", "version", "dist" ] }
  37164. ] }
  37165. ]
  37166. },
  37167. "metapackage": {
  37168. "allOf": [
  37169. { "$ref": "#/definitions/package-base" },
  37170. {
  37171. "properties": {
  37172. "type": { "type": "string", "enum": [ "metapackage" ] }
  37173. },
  37174. "required": [ "name", "version", "type" ]
  37175. }
  37176. ]
  37177. },
  37178. "provider": {
  37179. "type": "object",
  37180. "properties": {
  37181. "sha256": {
  37182. "type": "string",
  37183. "description": "Hash value that can be used to validate the resource."
  37184. }
  37185. }
  37186. }
  37187. }
  37188. }
  37189. {
  37190. "$schema": "https://json-schema.org/draft-04/schema#",
  37191. "title": "Package",
  37192. "type": "object",
  37193. "properties": {
  37194. "name": {
  37195. "type": "string",
  37196. "description": "Package name, including 'vendor-name/' prefix.",
  37197. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  37198. },
  37199. "description": {
  37200. "type": "string",
  37201. "description": "Short package description."
  37202. },
  37203. "license": {
  37204. "type": ["string", "array"],
  37205. "description": "License name. Or an array of license names."
  37206. },
  37207. "type": {
  37208. "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.",
  37209. "type": "string",
  37210. "pattern": "^[a-z0-9-]+$"
  37211. },
  37212. "abandoned": {
  37213. "type": ["boolean", "string"],
  37214. "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."
  37215. },
  37216. "version": {
  37217. "type": "string",
  37218. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  37219. "pattern": "^v?\\d+(\\.\\d+){0,3}|^dev-"
  37220. },
  37221. "default-branch": {
  37222. "type": ["boolean"],
  37223. "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."
  37224. },
  37225. "non-feature-branches": {
  37226. "type": ["array"],
  37227. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  37228. "items": {
  37229. "type": "string"
  37230. }
  37231. },
  37232. "keywords": {
  37233. "type": "array",
  37234. "items": {
  37235. "type": "string",
  37236. "description": "A tag/keyword that this package relates to."
  37237. }
  37238. },
  37239. "readme": {
  37240. "type": "string",
  37241. "description": "Relative path to the readme document."
  37242. },
  37243. "time": {
  37244. "type": "string",
  37245. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  37246. },
  37247. "authors": {
  37248. "$ref": "#/definitions/authors"
  37249. },
  37250. "homepage": {
  37251. "type": "string",
  37252. "description": "Homepage URL for the project.",
  37253. "format": "uri"
  37254. },
  37255. "support": {
  37256. "type": "object",
  37257. "properties": {
  37258. "email": {
  37259. "type": "string",
  37260. "description": "Email address for support.",
  37261. "format": "email"
  37262. },
  37263. "issues": {
  37264. "type": "string",
  37265. "description": "URL to the issue tracker.",
  37266. "format": "uri"
  37267. },
  37268. "forum": {
  37269. "type": "string",
  37270. "description": "URL to the forum.",
  37271. "format": "uri"
  37272. },
  37273. "wiki": {
  37274. "type": "string",
  37275. "description": "URL to the wiki.",
  37276. "format": "uri"
  37277. },
  37278. "irc": {
  37279. "type": "string",
  37280. "description": "IRC channel for support, as irc://server/channel.",
  37281. "format": "uri"
  37282. },
  37283. "chat": {
  37284. "type": "string",
  37285. "description": "URL to the support chat.",
  37286. "format": "uri"
  37287. },
  37288. "source": {
  37289. "type": "string",
  37290. "description": "URL to browse or download the sources.",
  37291. "format": "uri"
  37292. },
  37293. "docs": {
  37294. "type": "string",
  37295. "description": "URL to the documentation.",
  37296. "format": "uri"
  37297. },
  37298. "rss": {
  37299. "type": "string",
  37300. "description": "URL to the RSS feed.",
  37301. "format": "uri"
  37302. }
  37303. }
  37304. },
  37305. "funding": {
  37306. "type": "array",
  37307. "description": "A list of options to fund the development and maintenance of the package.",
  37308. "items": {
  37309. "type": "object",
  37310. "properties": {
  37311. "type": {
  37312. "type": "string",
  37313. "description": "Type of funding or platform through which funding is possible."
  37314. },
  37315. "url": {
  37316. "type": "string",
  37317. "description": "URL to a website with details on funding and a way to fund the package.",
  37318. "format": "uri"
  37319. }
  37320. }
  37321. }
  37322. },
  37323. "_comment": {
  37324. "type": ["array", "string"],
  37325. "description": "A key to store comments in"
  37326. },
  37327. "require": {
  37328. "type": "object",
  37329. "description": "This is an object of package name (keys) and version constraints (values) that are required to run this package.",
  37330. "additionalProperties": {
  37331. "type": "string"
  37332. }
  37333. },
  37334. "require-dev": {
  37335. "type": "object",
  37336. "description": "This is an object of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  37337. "additionalProperties": {
  37338. "type": "string"
  37339. }
  37340. },
  37341. "replace": {
  37342. "type": "object",
  37343. "description": "This is an object of package name (keys) and version constraints (values) that can be replaced by this package.",
  37344. "additionalProperties": {
  37345. "type": "string"
  37346. }
  37347. },
  37348. "conflict": {
  37349. "type": "object",
  37350. "description": "This is an object of package name (keys) and version constraints (values) that conflict with this package.",
  37351. "additionalProperties": {
  37352. "type": "string"
  37353. }
  37354. },
  37355. "provide": {
  37356. "type": "object",
  37357. "description": "This is an object of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  37358. "additionalProperties": {
  37359. "type": "string"
  37360. }
  37361. },
  37362. "suggest": {
  37363. "type": "object",
  37364. "description": "This is an object of package name (keys) and descriptions (values) that this package suggests work well with it (this will be suggested to the user during installation).",
  37365. "additionalProperties": {
  37366. "type": "string"
  37367. }
  37368. },
  37369. "repositories": {
  37370. "type": ["object", "array"],
  37371. "description": "A set of additional repositories where packages can be found.",
  37372. "additionalProperties": {
  37373. "anyOf": [
  37374. { "$ref": "#/definitions/repository" },
  37375. { "type": "boolean", "enum": [false] }
  37376. ]
  37377. },
  37378. "items": {
  37379. "anyOf": [
  37380. { "$ref": "#/definitions/repository" },
  37381. {
  37382. "type": "object",
  37383. "additionalProperties": { "type": "boolean", "enum": [false] },
  37384. "minProperties": 1,
  37385. "maxProperties": 1
  37386. }
  37387. ]
  37388. }
  37389. },
  37390. "minimum-stability": {
  37391. "type": ["string"],
  37392. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  37393. "enum": ["dev", "alpha", "beta", "rc", "RC", "stable"]
  37394. },
  37395. "prefer-stable": {
  37396. "type": ["boolean"],
  37397. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  37398. },
  37399. "autoload": {
  37400. "$ref": "#/definitions/autoload"
  37401. },
  37402. "autoload-dev": {
  37403. "type": "object",
  37404. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  37405. "properties": {
  37406. "psr-0": {
  37407. "type": "object",
  37408. "description": "This is an object of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
  37409. "additionalProperties": {
  37410. "type": ["string", "array"],
  37411. "items": {
  37412. "type": "string"
  37413. }
  37414. }
  37415. },
  37416. "psr-4": {
  37417. "type": "object",
  37418. "description": "This is an object of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  37419. "additionalProperties": {
  37420. "type": ["string", "array"],
  37421. "items": {
  37422. "type": "string"
  37423. }
  37424. }
  37425. },
  37426. "classmap": {
  37427. "type": "array",
  37428. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  37429. },
  37430. "files": {
  37431. "type": "array",
  37432. "description": "This is an array of files that are always required on every request."
  37433. }
  37434. }
  37435. },
  37436. "target-dir": {
  37437. "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.",
  37438. "type": "string"
  37439. },
  37440. "include-path": {
  37441. "type": ["array"],
  37442. "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.",
  37443. "items": {
  37444. "type": "string"
  37445. }
  37446. },
  37447. "bin": {
  37448. "type": ["string", "array"],
  37449. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  37450. "items": {
  37451. "type": "string"
  37452. }
  37453. },
  37454. "archive": {
  37455. "type": ["object"],
  37456. "description": "Options for creating package archives for distribution.",
  37457. "properties": {
  37458. "name": {
  37459. "type": "string",
  37460. "description": "A base name for archive."
  37461. },
  37462. "exclude": {
  37463. "type": "array",
  37464. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  37465. }
  37466. }
  37467. },
  37468. "config": {
  37469. "type": "object",
  37470. "description": "Composer options.",
  37471. "properties": {
  37472. "platform": {
  37473. "type": "object",
  37474. "description": "This is an object of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  37475. "additionalProperties": {
  37476. "type": ["string", "boolean"]
  37477. }
  37478. },
  37479. "allow-plugins": {
  37480. "type": ["object", "boolean"],
  37481. "description": "This is an object of {\"pattern\": true|false} with packages which are allowed to be loaded as plugins, or true to allow all, false to allow none. Defaults to {} which prompts when an unknown plugin is added.",
  37482. "additionalProperties": {
  37483. "type": ["boolean"]
  37484. }
  37485. },
  37486. "process-timeout": {
  37487. "type": "integer",
  37488. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  37489. },
  37490. "use-include-path": {
  37491. "type": "boolean",
  37492. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  37493. },
  37494. "use-parent-dir": {
  37495. "type": ["string", "boolean"],
  37496. "description": "When running Composer in a directory where there is no composer.json, if there is one present in a directory above Composer will by default ask you whether you want to use that directory's composer.json instead. One of: true (always use parent if needed), false (never ask or use it) or \"prompt\" (ask every time), defaults to prompt."
  37497. },
  37498. "preferred-install": {
  37499. "type": ["string", "object"],
  37500. "description": "The install method Composer will prefer to use, defaults to auto and can be any of source, dist, auto, or an object of {\"pattern\": \"preference\"}.",
  37501. "additionalProperties": {
  37502. "type": ["string"]
  37503. }
  37504. },
  37505. "notify-on-install": {
  37506. "type": "boolean",
  37507. "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."
  37508. },
  37509. "github-protocols": {
  37510. "type": "array",
  37511. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  37512. "items": {
  37513. "type": "string"
  37514. }
  37515. },
  37516. "github-oauth": {
  37517. "type": "object",
  37518. "description": "An object of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  37519. "additionalProperties": {
  37520. "type": "string"
  37521. }
  37522. },
  37523. "gitlab-oauth": {
  37524. "type": "object",
  37525. "description": "An object of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  37526. "additionalProperties": {
  37527. "type": "string"
  37528. }
  37529. },
  37530. "gitlab-token": {
  37531. "type": "object",
  37532. "description": "An object of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  37533. "additionalProperties": {
  37534. "type": "string"
  37535. }
  37536. },
  37537. "gitlab-protocol": {
  37538. "enum": ["git", "http", "https"],
  37539. "description": "A protocol to force use of when creating a repository URL for the `source` value of the package metadata. One of `git` or `http`. By default, Composer will generate a git URL for private repositories and http one for public repos."
  37540. },
  37541. "bearer": {
  37542. "type": "object",
  37543. "description": "An object of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  37544. "additionalProperties": {
  37545. "type": "string"
  37546. }
  37547. },
  37548. "disable-tls": {
  37549. "type": "boolean",
  37550. "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."
  37551. },
  37552. "secure-http": {
  37553. "type": "boolean",
  37554. "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."
  37555. },
  37556. "secure-svn-domains": {
  37557. "type": "array",
  37558. "description": "A list of domains which should be trusted/marked as using a secure Subversion/SVN transport. By default svn:// protocol is seen as insecure and will throw. This is a better/safer alternative to disabling `secure-http` altogether.",
  37559. "items": {
  37560. "type": "string"
  37561. }
  37562. },
  37563. "cafile": {
  37564. "type": "string",
  37565. "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."
  37566. },
  37567. "capath": {
  37568. "type": "string",
  37569. "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."
  37570. },
  37571. "http-basic": {
  37572. "type": "object",
  37573. "description": "An object of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  37574. "additionalProperties": {
  37575. "type": "object",
  37576. "required": ["username", "password"],
  37577. "properties": {
  37578. "username": {
  37579. "type": "string",
  37580. "description": "The username used for HTTP Basic authentication"
  37581. },
  37582. "password": {
  37583. "type": "string",
  37584. "description": "The password used for HTTP Basic authentication"
  37585. }
  37586. }
  37587. }
  37588. },
  37589. "store-auths": {
  37590. "type": ["string", "boolean"],
  37591. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  37592. },
  37593. "vendor-dir": {
  37594. "type": "string",
  37595. "description": "The location where all packages are installed, defaults to \"vendor\"."
  37596. },
  37597. "bin-dir": {
  37598. "type": "string",
  37599. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  37600. },
  37601. "data-dir": {
  37602. "type": "string",
  37603. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  37604. },
  37605. "cache-dir": {
  37606. "type": "string",
  37607. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  37608. },
  37609. "cache-files-dir": {
  37610. "type": "string",
  37611. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  37612. },
  37613. "cache-repo-dir": {
  37614. "type": "string",
  37615. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  37616. },
  37617. "cache-vcs-dir": {
  37618. "type": "string",
  37619. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  37620. },
  37621. "cache-ttl": {
  37622. "type": "integer",
  37623. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  37624. },
  37625. "cache-files-ttl": {
  37626. "type": "integer",
  37627. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  37628. },
  37629. "cache-files-maxsize": {
  37630. "type": ["string", "integer"],
  37631. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  37632. },
  37633. "cache-read-only": {
  37634. "type": ["boolean"],
  37635. "description": "Whether to use the Composer cache in read-only mode."
  37636. },
  37637. "bin-compat": {
  37638. "enum": ["auto", "full", "proxy", "symlink"],
  37639. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed), can be \"full\" (compatible with both Windows and Unix-based systems) and \"proxy\" (only bash-style proxy)."
  37640. },
  37641. "discard-changes": {
  37642. "type": ["string", "boolean"],
  37643. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  37644. },
  37645. "autoloader-suffix": {
  37646. "type": "string",
  37647. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  37648. },
  37649. "optimize-autoloader": {
  37650. "type": "boolean",
  37651. "description": "Always optimize when dumping the autoloader."
  37652. },
  37653. "prepend-autoloader": {
  37654. "type": "boolean",
  37655. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  37656. },
  37657. "classmap-authoritative": {
  37658. "type": "boolean",
  37659. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  37660. },
  37661. "apcu-autoloader": {
  37662. "type": "boolean",
  37663. "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."
  37664. },
  37665. "github-domains": {
  37666. "type": "array",
  37667. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  37668. "items": {
  37669. "type": "string"
  37670. }
  37671. },
  37672. "github-expose-hostname": {
  37673. "type": "boolean",
  37674. "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."
  37675. },
  37676. "gitlab-domains": {
  37677. "type": "array",
  37678. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  37679. "items": {
  37680. "type": "string"
  37681. }
  37682. },
  37683. "use-github-api": {
  37684. "type": "boolean",
  37685. "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."
  37686. },
  37687. "archive-format": {
  37688. "type": "string",
  37689. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  37690. },
  37691. "archive-dir": {
  37692. "type": "string",
  37693. "description": "The default archive path when not provided on cli, defaults to \".\"."
  37694. },
  37695. "htaccess-protect": {
  37696. "type": "boolean",
  37697. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  37698. },
  37699. "sort-packages": {
  37700. "type": "boolean",
  37701. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  37702. },
  37703. "lock": {
  37704. "type": "boolean",
  37705. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  37706. },
  37707. "platform-check": {
  37708. "type": ["boolean", "string"],
  37709. "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."
  37710. }
  37711. }
  37712. },
  37713. "extra": {
  37714. "type": ["object", "array"],
  37715. "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.",
  37716. "additionalProperties": true
  37717. },
  37718. "scripts": {
  37719. "type": ["object"],
  37720. "description": "Script listeners that will be executed before/after some events.",
  37721. "properties": {
  37722. "pre-install-cmd": {
  37723. "type": ["array", "string"],
  37724. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  37725. },
  37726. "post-install-cmd": {
  37727. "type": ["array", "string"],
  37728. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  37729. },
  37730. "pre-update-cmd": {
  37731. "type": ["array", "string"],
  37732. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  37733. },
  37734. "post-update-cmd": {
  37735. "type": ["array", "string"],
  37736. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  37737. },
  37738. "pre-status-cmd": {
  37739. "type": ["array", "string"],
  37740. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  37741. },
  37742. "post-status-cmd": {
  37743. "type": ["array", "string"],
  37744. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  37745. },
  37746. "pre-package-install": {
  37747. "type": ["array", "string"],
  37748. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  37749. },
  37750. "post-package-install": {
  37751. "type": ["array", "string"],
  37752. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  37753. },
  37754. "pre-package-update": {
  37755. "type": ["array", "string"],
  37756. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  37757. },
  37758. "post-package-update": {
  37759. "type": ["array", "string"],
  37760. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  37761. },
  37762. "pre-package-uninstall": {
  37763. "type": ["array", "string"],
  37764. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  37765. },
  37766. "post-package-uninstall": {
  37767. "type": ["array", "string"],
  37768. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  37769. },
  37770. "pre-autoload-dump": {
  37771. "type": ["array", "string"],
  37772. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  37773. },
  37774. "post-autoload-dump": {
  37775. "type": ["array", "string"],
  37776. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  37777. },
  37778. "post-root-package-install": {
  37779. "type": ["array", "string"],
  37780. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  37781. },
  37782. "post-create-project-cmd": {
  37783. "type": ["array", "string"],
  37784. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  37785. }
  37786. }
  37787. },
  37788. "scripts-descriptions": {
  37789. "type": ["object"],
  37790. "description": "Descriptions for custom commands, shown in console help.",
  37791. "additionalProperties": {
  37792. "type": "string"
  37793. }
  37794. }
  37795. },
  37796. "definitions": {
  37797. "authors": {
  37798. "type": "array",
  37799. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  37800. "items": {
  37801. "type": "object",
  37802. "additionalProperties": false,
  37803. "required": [ "name"],
  37804. "properties": {
  37805. "name": {
  37806. "type": "string",
  37807. "description": "Full name of the author."
  37808. },
  37809. "email": {
  37810. "type": "string",
  37811. "description": "Email address of the author.",
  37812. "format": "email"
  37813. },
  37814. "homepage": {
  37815. "type": "string",
  37816. "description": "Homepage URL for the author.",
  37817. "format": "uri"
  37818. },
  37819. "role": {
  37820. "type": "string",
  37821. "description": "Author's role in the project."
  37822. }
  37823. }
  37824. }
  37825. },
  37826. "autoload": {
  37827. "type": "object",
  37828. "description": "Description of how the package can be autoloaded.",
  37829. "properties": {
  37830. "psr-0": {
  37831. "type": "object",
  37832. "description": "This is an object of namespaces (keys) and the directories they can be found in (values, can be arrays of paths) by the autoloader.",
  37833. "additionalProperties": {
  37834. "type": ["string", "array"],
  37835. "items": {
  37836. "type": "string"
  37837. }
  37838. }
  37839. },
  37840. "psr-4": {
  37841. "type": "object",
  37842. "description": "This is an object of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  37843. "additionalProperties": {
  37844. "type": ["string", "array"],
  37845. "items": {
  37846. "type": "string"
  37847. }
  37848. }
  37849. },
  37850. "classmap": {
  37851. "type": "array",
  37852. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  37853. },
  37854. "files": {
  37855. "type": "array",
  37856. "description": "This is an array of files that are always required on every request."
  37857. },
  37858. "exclude-from-classmap": {
  37859. "type": "array",
  37860. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  37861. }
  37862. }
  37863. },
  37864. "repository": {
  37865. "type": "object",
  37866. "anyOf": [
  37867. { "$ref": "#/definitions/composer-repository" },
  37868. { "$ref": "#/definitions/vcs-repository" },
  37869. { "$ref": "#/definitions/path-repository" },
  37870. { "$ref": "#/definitions/artifact-repository" },
  37871. { "$ref": "#/definitions/pear-repository" },
  37872. { "$ref": "#/definitions/package-repository" }
  37873. ]
  37874. },
  37875. "composer-repository": {
  37876. "type": "object",
  37877. "required": ["type", "url"],
  37878. "properties": {
  37879. "type": { "type": "string", "enum": ["composer"] },
  37880. "url": { "type": "string" },
  37881. "canonical": { "type": "boolean" },
  37882. "only": {
  37883. "type": "array",
  37884. "items": {
  37885. "type": "string"
  37886. }
  37887. },
  37888. "exclude": {
  37889. "type": "array",
  37890. "items": {
  37891. "type": "string"
  37892. }
  37893. },
  37894. "options": {
  37895. "type": "object",
  37896. "additionalProperties": true
  37897. },
  37898. "allow_ssl_downgrade": { "type": "boolean" },
  37899. "force-lazy-providers": { "type": "boolean" }
  37900. }
  37901. },
  37902. "vcs-repository": {
  37903. "type": "object",
  37904. "required": ["type", "url"],
  37905. "properties": {
  37906. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "bitbucket", "git-bitbucket", "hg", "fossil", "perforce", "svn"] },
  37907. "url": { "type": "string" },
  37908. "canonical": { "type": "boolean" },
  37909. "only": {
  37910. "type": "array",
  37911. "items": {
  37912. "type": "string"
  37913. }
  37914. },
  37915. "exclude": {
  37916. "type": "array",
  37917. "items": {
  37918. "type": "string"
  37919. }
  37920. },
  37921. "no-api": { "type": "boolean" },
  37922. "secure-http": { "type": "boolean" },
  37923. "svn-cache-credentials": { "type": "boolean" },
  37924. "trunk-path": { "type": ["string", "boolean"] },
  37925. "branches-path": { "type": ["string", "boolean"] },
  37926. "tags-path": { "type": ["string", "boolean"] },
  37927. "package-path": { "type": "string" },
  37928. "depot": { "type": "string" },
  37929. "branch": { "type": "string" },
  37930. "unique_perforce_client_name": { "type": "string" },
  37931. "p4user": { "type": "string" },
  37932. "p4password": { "type": "string" }
  37933. }
  37934. },
  37935. "path-repository": {
  37936. "type": "object",
  37937. "required": ["type", "url"],
  37938. "properties": {
  37939. "type": { "type": "string", "enum": ["path"] },
  37940. "url": { "type": "string" },
  37941. "canonical": { "type": "boolean" },
  37942. "only": {
  37943. "type": "array",
  37944. "items": {
  37945. "type": "string"
  37946. }
  37947. },
  37948. "exclude": {
  37949. "type": "array",
  37950. "items": {
  37951. "type": "string"
  37952. }
  37953. },
  37954. "options": {
  37955. "type": "object",
  37956. "properties": {
  37957. "symlink": { "type": ["boolean", "null"] }
  37958. },
  37959. "additionalProperties": true
  37960. }
  37961. }
  37962. },
  37963. "artifact-repository": {
  37964. "type": "object",
  37965. "required": ["type", "url"],
  37966. "properties": {
  37967. "type": { "type": "string", "enum": ["artifact"] },
  37968. "url": { "type": "string" },
  37969. "canonical": { "type": "boolean" },
  37970. "only": {
  37971. "type": "array",
  37972. "items": {
  37973. "type": "string"
  37974. }
  37975. },
  37976. "exclude": {
  37977. "type": "array",
  37978. "items": {
  37979. "type": "string"
  37980. }
  37981. }
  37982. }
  37983. },
  37984. "pear-repository": {
  37985. "type": "object",
  37986. "required": ["type", "url"],
  37987. "properties": {
  37988. "type": { "type": "string", "enum": ["pear"] },
  37989. "url": { "type": "string" },
  37990. "canonical": { "type": "boolean" },
  37991. "only": {
  37992. "type": "array",
  37993. "items": {
  37994. "type": "string"
  37995. }
  37996. },
  37997. "exclude": {
  37998. "type": "array",
  37999. "items": {
  38000. "type": "string"
  38001. }
  38002. },
  38003. "vendor-alias": { "type": "string" }
  38004. }
  38005. },
  38006. "package-repository": {
  38007. "type": "object",
  38008. "required": ["type", "package"],
  38009. "properties": {
  38010. "type": { "type": "string", "enum": ["package"] },
  38011. "canonical": { "type": "boolean" },
  38012. "only": {
  38013. "type": "array",
  38014. "items": {
  38015. "type": "string"
  38016. }
  38017. },
  38018. "exclude": {
  38019. "type": "array",
  38020. "items": {
  38021. "type": "string"
  38022. }
  38023. },
  38024. "package": {
  38025. "oneOf": [
  38026. { "$ref": "#/definitions/inline-package" },
  38027. {
  38028. "type": "array",
  38029. "items": { "$ref": "#/definitions/inline-package" }
  38030. }
  38031. ]
  38032. }
  38033. }
  38034. },
  38035. "inline-package": {
  38036. "type": "object",
  38037. "required": ["name", "version"],
  38038. "properties": {
  38039. "name": {
  38040. "type": "string",
  38041. "description": "Package name, including 'vendor-name/' prefix."
  38042. },
  38043. "type": {
  38044. "type": "string"
  38045. },
  38046. "target-dir": {
  38047. "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.",
  38048. "type": "string"
  38049. },
  38050. "description": {
  38051. "type": "string"
  38052. },
  38053. "keywords": {
  38054. "type": "array",
  38055. "items": {
  38056. "type": "string"
  38057. }
  38058. },
  38059. "homepage": {
  38060. "type": "string",
  38061. "format": "uri"
  38062. },
  38063. "version": {
  38064. "type": "string"
  38065. },
  38066. "time": {
  38067. "type": "string"
  38068. },
  38069. "license": {
  38070. "type": [
  38071. "string",
  38072. "array"
  38073. ]
  38074. },
  38075. "authors": {
  38076. "$ref": "#/definitions/authors"
  38077. },
  38078. "require": {
  38079. "type": "object",
  38080. "additionalProperties": {
  38081. "type": "string"
  38082. }
  38083. },
  38084. "replace": {
  38085. "type": "object",
  38086. "additionalProperties": {
  38087. "type": "string"
  38088. }
  38089. },
  38090. "conflict": {
  38091. "type": "object",
  38092. "additionalProperties": {
  38093. "type": "string"
  38094. }
  38095. },
  38096. "provide": {
  38097. "type": "object",
  38098. "additionalProperties": {
  38099. "type": "string"
  38100. }
  38101. },
  38102. "require-dev": {
  38103. "type": "object",
  38104. "additionalProperties": {
  38105. "type": "string"
  38106. }
  38107. },
  38108. "suggest": {
  38109. "type": "object",
  38110. "additionalProperties": {
  38111. "type": "string"
  38112. }
  38113. },
  38114. "extra": {
  38115. "type": ["object", "array"],
  38116. "additionalProperties": true
  38117. },
  38118. "autoload": {
  38119. "$ref": "#/definitions/autoload"
  38120. },
  38121. "archive": {
  38122. "type": ["object"],
  38123. "properties": {
  38124. "exclude": {
  38125. "type": "array"
  38126. }
  38127. }
  38128. },
  38129. "bin": {
  38130. "type": ["string", "array"],
  38131. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  38132. "items": {
  38133. "type": "string"
  38134. }
  38135. },
  38136. "include-path": {
  38137. "type": ["array"],
  38138. "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.",
  38139. "items": {
  38140. "type": "string"
  38141. }
  38142. },
  38143. "source": {
  38144. "type": "object",
  38145. "required": ["type", "url", "reference"],
  38146. "properties": {
  38147. "type": {
  38148. "type": "string"
  38149. },
  38150. "url": {
  38151. "type": "string"
  38152. },
  38153. "reference": {
  38154. "type": "string"
  38155. },
  38156. "mirrors": {
  38157. "type": "array"
  38158. }
  38159. }
  38160. },
  38161. "dist": {
  38162. "type": "object",
  38163. "required": ["type", "url"],
  38164. "properties": {
  38165. "type": {
  38166. "type": "string"
  38167. },
  38168. "url": {
  38169. "type": "string"
  38170. },
  38171. "reference": {
  38172. "type": "string"
  38173. },
  38174. "shasum": {
  38175. "type": "string"
  38176. },
  38177. "mirrors": {
  38178. "type": "array"
  38179. }
  38180. }
  38181. }
  38182. },
  38183. "additionalProperties": true
  38184. }
  38185. }
  38186. }
  38187. <?php
  38188. require_once __DIR__ . '/composer/autoload_real.php';
  38189. return ComposerAutoloaderInitComposerPhar1643990438::getLoader();
  38190. <?php
  38191. namespace Composer\Autoload;
  38192. class ClassLoader
  38193. {
  38194. private $vendorDir;
  38195. private $prefixLengthsPsr4 = array();
  38196. private $prefixDirsPsr4 = array();
  38197. private $fallbackDirsPsr4 = array();
  38198. private $prefixesPsr0 = array();
  38199. private $fallbackDirsPsr0 = array();
  38200. private $useIncludePath = false;
  38201. private $classMap = array();
  38202. private $classMapAuthoritative = false;
  38203. private $missingClasses = array();
  38204. private $apcuPrefix;
  38205. private static $registeredLoaders = array();
  38206. public function __construct($vendorDir = null)
  38207. {
  38208. $this->vendorDir = $vendorDir;
  38209. }
  38210. public function getPrefixes()
  38211. {
  38212. if (!empty($this->prefixesPsr0)) {
  38213. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  38214. }
  38215. return array();
  38216. }
  38217. public function getPrefixesPsr4()
  38218. {
  38219. return $this->prefixDirsPsr4;
  38220. }
  38221. public function getFallbackDirs()
  38222. {
  38223. return $this->fallbackDirsPsr0;
  38224. }
  38225. public function getFallbackDirsPsr4()
  38226. {
  38227. return $this->fallbackDirsPsr4;
  38228. }
  38229. public function getClassMap()
  38230. {
  38231. return $this->classMap;
  38232. }
  38233. public function addClassMap(array $classMap)
  38234. {
  38235. if ($this->classMap) {
  38236. $this->classMap = array_merge($this->classMap, $classMap);
  38237. } else {
  38238. $this->classMap = $classMap;
  38239. }
  38240. }
  38241. public function add($prefix, $paths, $prepend = false)
  38242. {
  38243. if (!$prefix) {
  38244. if ($prepend) {
  38245. $this->fallbackDirsPsr0 = array_merge(
  38246. (array) $paths,
  38247. $this->fallbackDirsPsr0
  38248. );
  38249. } else {
  38250. $this->fallbackDirsPsr0 = array_merge(
  38251. $this->fallbackDirsPsr0,
  38252. (array) $paths
  38253. );
  38254. }
  38255. return;
  38256. }
  38257. $first = $prefix[0];
  38258. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  38259. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  38260. return;
  38261. }
  38262. if ($prepend) {
  38263. $this->prefixesPsr0[$first][$prefix] = array_merge(
  38264. (array) $paths,
  38265. $this->prefixesPsr0[$first][$prefix]
  38266. );
  38267. } else {
  38268. $this->prefixesPsr0[$first][$prefix] = array_merge(
  38269. $this->prefixesPsr0[$first][$prefix],
  38270. (array) $paths
  38271. );
  38272. }
  38273. }
  38274. public function addPsr4($prefix, $paths, $prepend = false)
  38275. {
  38276. if (!$prefix) {
  38277. if ($prepend) {
  38278. $this->fallbackDirsPsr4 = array_merge(
  38279. (array) $paths,
  38280. $this->fallbackDirsPsr4
  38281. );
  38282. } else {
  38283. $this->fallbackDirsPsr4 = array_merge(
  38284. $this->fallbackDirsPsr4,
  38285. (array) $paths
  38286. );
  38287. }
  38288. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  38289. $length = strlen($prefix);
  38290. if ('\\' !== $prefix[$length - 1]) {
  38291. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  38292. }
  38293. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  38294. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  38295. } elseif ($prepend) {
  38296. $this->prefixDirsPsr4[$prefix] = array_merge(
  38297. (array) $paths,
  38298. $this->prefixDirsPsr4[$prefix]
  38299. );
  38300. } else {
  38301. $this->prefixDirsPsr4[$prefix] = array_merge(
  38302. $this->prefixDirsPsr4[$prefix],
  38303. (array) $paths
  38304. );
  38305. }
  38306. }
  38307. public function set($prefix, $paths)
  38308. {
  38309. if (!$prefix) {
  38310. $this->fallbackDirsPsr0 = (array) $paths;
  38311. } else {
  38312. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  38313. }
  38314. }
  38315. public function setPsr4($prefix, $paths)
  38316. {
  38317. if (!$prefix) {
  38318. $this->fallbackDirsPsr4 = (array) $paths;
  38319. } else {
  38320. $length = strlen($prefix);
  38321. if ('\\' !== $prefix[$length - 1]) {
  38322. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  38323. }
  38324. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  38325. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  38326. }
  38327. }
  38328. public function setUseIncludePath($useIncludePath)
  38329. {
  38330. $this->useIncludePath = $useIncludePath;
  38331. }
  38332. public function getUseIncludePath()
  38333. {
  38334. return $this->useIncludePath;
  38335. }
  38336. public function setClassMapAuthoritative($classMapAuthoritative)
  38337. {
  38338. $this->classMapAuthoritative = $classMapAuthoritative;
  38339. }
  38340. public function isClassMapAuthoritative()
  38341. {
  38342. return $this->classMapAuthoritative;
  38343. }
  38344. public function setApcuPrefix($apcuPrefix)
  38345. {
  38346. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  38347. }
  38348. public function getApcuPrefix()
  38349. {
  38350. return $this->apcuPrefix;
  38351. }
  38352. public function register($prepend = false)
  38353. {
  38354. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  38355. if (null === $this->vendorDir) {
  38356. return;
  38357. }
  38358. if ($prepend) {
  38359. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  38360. } else {
  38361. unset(self::$registeredLoaders[$this->vendorDir]);
  38362. self::$registeredLoaders[$this->vendorDir] = $this;
  38363. }
  38364. }
  38365. public function unregister()
  38366. {
  38367. spl_autoload_unregister(array($this, 'loadClass'));
  38368. if (null !== $this->vendorDir) {
  38369. unset(self::$registeredLoaders[$this->vendorDir]);
  38370. }
  38371. }
  38372. public function loadClass($class)
  38373. {
  38374. if ($file = $this->findFile($class)) {
  38375. includeFile($file);
  38376. return true;
  38377. }
  38378. return null;
  38379. }
  38380. public function findFile($class)
  38381. {
  38382. if (isset($this->classMap[$class])) {
  38383. return $this->classMap[$class];
  38384. }
  38385. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  38386. return false;
  38387. }
  38388. if (null !== $this->apcuPrefix) {
  38389. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  38390. if ($hit) {
  38391. return $file;
  38392. }
  38393. }
  38394. $file = $this->findFileWithExtension($class, '.php');
  38395. if (false === $file && defined('HHVM_VERSION')) {
  38396. $file = $this->findFileWithExtension($class, '.hh');
  38397. }
  38398. if (null !== $this->apcuPrefix) {
  38399. apcu_add($this->apcuPrefix.$class, $file);
  38400. }
  38401. if (false === $file) {
  38402. $this->missingClasses[$class] = true;
  38403. }
  38404. return $file;
  38405. }
  38406. public static function getRegisteredLoaders()
  38407. {
  38408. return self::$registeredLoaders;
  38409. }
  38410. private function findFileWithExtension($class, $ext)
  38411. {
  38412. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  38413. $first = $class[0];
  38414. if (isset($this->prefixLengthsPsr4[$first])) {
  38415. $subPath = $class;
  38416. while (false !== $lastPos = strrpos($subPath, '\\')) {
  38417. $subPath = substr($subPath, 0, $lastPos);
  38418. $search = $subPath . '\\';
  38419. if (isset($this->prefixDirsPsr4[$search])) {
  38420. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  38421. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  38422. if (file_exists($file = $dir . $pathEnd)) {
  38423. return $file;
  38424. }
  38425. }
  38426. }
  38427. }
  38428. }
  38429. foreach ($this->fallbackDirsPsr4 as $dir) {
  38430. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  38431. return $file;
  38432. }
  38433. }
  38434. if (false !== $pos = strrpos($class, '\\')) {
  38435. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  38436. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  38437. } else {
  38438. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  38439. }
  38440. if (isset($this->prefixesPsr0[$first])) {
  38441. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  38442. if (0 === strpos($class, $prefix)) {
  38443. foreach ($dirs as $dir) {
  38444. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  38445. return $file;
  38446. }
  38447. }
  38448. }
  38449. }
  38450. }
  38451. foreach ($this->fallbackDirsPsr0 as $dir) {
  38452. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  38453. return $file;
  38454. }
  38455. }
  38456. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  38457. return $file;
  38458. }
  38459. return false;
  38460. }
  38461. }
  38462. function includeFile($file)
  38463. {
  38464. include $file;
  38465. }
  38466. <?php
  38467. namespace Composer;
  38468. use Composer\Autoload\ClassLoader;
  38469. use Composer\Semver\VersionParser;
  38470. class InstalledVersions
  38471. {
  38472. private static $installed;
  38473. private static $canGetVendors;
  38474. private static $installedByVendor = array();
  38475. public static function getInstalledPackages()
  38476. {
  38477. $packages = array();
  38478. foreach (self::getInstalled() as $installed) {
  38479. $packages[] = array_keys($installed['versions']);
  38480. }
  38481. if (1 === \count($packages)) {
  38482. return $packages[0];
  38483. }
  38484. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  38485. }
  38486. public static function getInstalledPackagesByType($type)
  38487. {
  38488. $packagesByType = array();
  38489. foreach (self::getInstalled() as $installed) {
  38490. foreach ($installed['versions'] as $name => $package) {
  38491. if (isset($package['type']) && $package['type'] === $type) {
  38492. $packagesByType[] = $name;
  38493. }
  38494. }
  38495. }
  38496. return $packagesByType;
  38497. }
  38498. public static function isInstalled($packageName, $includeDevRequirements = true)
  38499. {
  38500. foreach (self::getInstalled() as $installed) {
  38501. if (isset($installed['versions'][$packageName])) {
  38502. return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
  38503. }
  38504. }
  38505. return false;
  38506. }
  38507. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  38508. {
  38509. $constraint = $parser->parseConstraints($constraint);
  38510. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  38511. return $provided->matches($constraint);
  38512. }
  38513. public static function getVersionRanges($packageName)
  38514. {
  38515. foreach (self::getInstalled() as $installed) {
  38516. if (!isset($installed['versions'][$packageName])) {
  38517. continue;
  38518. }
  38519. $ranges = array();
  38520. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  38521. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  38522. }
  38523. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  38524. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  38525. }
  38526. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  38527. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  38528. }
  38529. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  38530. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  38531. }
  38532. return implode(' || ', $ranges);
  38533. }
  38534. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38535. }
  38536. public static function getVersion($packageName)
  38537. {
  38538. foreach (self::getInstalled() as $installed) {
  38539. if (!isset($installed['versions'][$packageName])) {
  38540. continue;
  38541. }
  38542. if (!isset($installed['versions'][$packageName]['version'])) {
  38543. return null;
  38544. }
  38545. return $installed['versions'][$packageName]['version'];
  38546. }
  38547. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38548. }
  38549. public static function getPrettyVersion($packageName)
  38550. {
  38551. foreach (self::getInstalled() as $installed) {
  38552. if (!isset($installed['versions'][$packageName])) {
  38553. continue;
  38554. }
  38555. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  38556. return null;
  38557. }
  38558. return $installed['versions'][$packageName]['pretty_version'];
  38559. }
  38560. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38561. }
  38562. public static function getReference($packageName)
  38563. {
  38564. foreach (self::getInstalled() as $installed) {
  38565. if (!isset($installed['versions'][$packageName])) {
  38566. continue;
  38567. }
  38568. if (!isset($installed['versions'][$packageName]['reference'])) {
  38569. return null;
  38570. }
  38571. return $installed['versions'][$packageName]['reference'];
  38572. }
  38573. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38574. }
  38575. public static function getInstallPath($packageName)
  38576. {
  38577. foreach (self::getInstalled() as $installed) {
  38578. if (!isset($installed['versions'][$packageName])) {
  38579. continue;
  38580. }
  38581. return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
  38582. }
  38583. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  38584. }
  38585. public static function getRootPackage()
  38586. {
  38587. $installed = self::getInstalled();
  38588. return $installed[0]['root'];
  38589. }
  38590. public static function getRawData()
  38591. {
  38592. @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
  38593. if (null === self::$installed) {
  38594. if (substr(__DIR__, -8, 1) !== 'C') {
  38595. self::$installed = include __DIR__ . '/installed.php';
  38596. } else {
  38597. self::$installed = array();
  38598. }
  38599. }
  38600. return self::$installed;
  38601. }
  38602. public static function getAllRawData()
  38603. {
  38604. return self::getInstalled();
  38605. }
  38606. public static function reload($data)
  38607. {
  38608. self::$installed = $data;
  38609. self::$installedByVendor = array();
  38610. }
  38611. private static function getInstalled()
  38612. {
  38613. if (null === self::$canGetVendors) {
  38614. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  38615. }
  38616. $installed = array();
  38617. if (self::$canGetVendors) {
  38618. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  38619. if (isset(self::$installedByVendor[$vendorDir])) {
  38620. $installed[] = self::$installedByVendor[$vendorDir];
  38621. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  38622. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  38623. if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
  38624. self::$installed = $installed[count($installed) - 1];
  38625. }
  38626. }
  38627. }
  38628. }
  38629. if (null === self::$installed) {
  38630. if (substr(__DIR__, -8, 1) !== 'C') {
  38631. self::$installed = require __DIR__ . '/installed.php';
  38632. } else {
  38633. self::$installed = array();
  38634. }
  38635. }
  38636. $installed[] = self::$installed;
  38637. return $installed;
  38638. }
  38639. }
  38640. <?php
  38641. $vendorDir = dirname(dirname(__FILE__));
  38642. $baseDir = dirname($vendorDir);
  38643. return array(
  38644. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  38645. );
  38646. <?php
  38647. $vendorDir = dirname(dirname(__FILE__));
  38648. $baseDir = dirname($vendorDir);
  38649. return array(
  38650. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  38651. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  38652. '7844cce90d4037f1a077c08319eef109' => $vendorDir . '/react/promise/src/React/Promise/functions_include.php',
  38653. );
  38654. <?php
  38655. $vendorDir = dirname(dirname(__FILE__));
  38656. $baseDir = dirname($vendorDir);
  38657. return array(
  38658. 'React\\Promise' => array($vendorDir . '/react/promise/src'),
  38659. );
  38660. <?php
  38661. $vendorDir = dirname(dirname(__FILE__));
  38662. $baseDir = dirname($vendorDir);
  38663. return array(
  38664. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  38665. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  38666. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  38667. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  38668. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  38669. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  38670. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  38671. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  38672. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  38673. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  38674. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  38675. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  38676. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  38677. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  38678. 'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'),
  38679. 'Composer\\MetadataMinifier\\' => array($vendorDir . '/composer/metadata-minifier/src'),
  38680. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  38681. 'Composer\\' => array($baseDir . '/src/Composer'),
  38682. );
  38683. <?php
  38684. class ComposerAutoloaderInitComposerPhar1643990438
  38685. {
  38686. private static $loader;
  38687. public static function loadClassLoader($class)
  38688. {
  38689. if ('Composer\Autoload\ClassLoader' === $class) {
  38690. require __DIR__ . '/ClassLoader.php';
  38691. }
  38692. }
  38693. public static function getLoader()
  38694. {
  38695. if (null !== self::$loader) {
  38696. return self::$loader;
  38697. }
  38698. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1643990438', 'loadClassLoader'), true, true);
  38699. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
  38700. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1643990438', 'loadClassLoader'));
  38701. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  38702. if ($useStaticLoader) {
  38703. require __DIR__ . '/autoload_static.php';
  38704. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1643990438::getInitializer($loader));
  38705. } else {
  38706. $map = require __DIR__ . '/autoload_namespaces.php';
  38707. foreach ($map as $namespace => $path) {
  38708. $loader->set($namespace, $path);
  38709. }
  38710. $map = require __DIR__ . '/autoload_psr4.php';
  38711. foreach ($map as $namespace => $path) {
  38712. $loader->setPsr4($namespace, $path);
  38713. }
  38714. $classMap = require __DIR__ . '/autoload_classmap.php';
  38715. if ($classMap) {
  38716. $loader->addClassMap($classMap);
  38717. }
  38718. }
  38719. $loader->register(true);
  38720. if ($useStaticLoader) {
  38721. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1643990438::$files;
  38722. } else {
  38723. $includeFiles = require __DIR__ . '/autoload_files.php';
  38724. }
  38725. foreach ($includeFiles as $fileIdentifier => $file) {
  38726. composerRequireComposerPhar1643990438($fileIdentifier, $file);
  38727. }
  38728. return $loader;
  38729. }
  38730. }
  38731. function composerRequireComposerPhar1643990438($fileIdentifier, $file)
  38732. {
  38733. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  38734. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  38735. require $file;
  38736. }
  38737. }
  38738. <?php
  38739. namespace Composer\Autoload;
  38740. class ComposerStaticInitComposerPhar1643990438
  38741. {
  38742. public static $files = array (
  38743. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  38744. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  38745. '7844cce90d4037f1a077c08319eef109' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions_include.php',
  38746. );
  38747. public static $prefixLengthsPsr4 = array (
  38748. 'S' =>
  38749. array (
  38750. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  38751. 'Symfony\\Polyfill\\Ctype\\' => 23,
  38752. 'Symfony\\Component\\Process\\' => 26,
  38753. 'Symfony\\Component\\Finder\\' => 25,
  38754. 'Symfony\\Component\\Filesystem\\' => 29,
  38755. 'Symfony\\Component\\Debug\\' => 24,
  38756. 'Symfony\\Component\\Console\\' => 26,
  38757. 'Seld\\PharUtils\\' => 15,
  38758. 'Seld\\JsonLint\\' => 14,
  38759. ),
  38760. 'P' =>
  38761. array (
  38762. 'Psr\\Log\\' => 8,
  38763. ),
  38764. 'J' =>
  38765. array (
  38766. 'JsonSchema\\' => 11,
  38767. ),
  38768. 'C' =>
  38769. array (
  38770. 'Composer\\XdebugHandler\\' => 23,
  38771. 'Composer\\Spdx\\' => 14,
  38772. 'Composer\\Semver\\' => 16,
  38773. 'Composer\\Pcre\\' => 14,
  38774. 'Composer\\MetadataMinifier\\' => 26,
  38775. 'Composer\\CaBundle\\' => 18,
  38776. 'Composer\\' => 9,
  38777. ),
  38778. );
  38779. public static $prefixDirsPsr4 = array (
  38780. 'Symfony\\Polyfill\\Mbstring\\' =>
  38781. array (
  38782. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  38783. ),
  38784. 'Symfony\\Polyfill\\Ctype\\' =>
  38785. array (
  38786. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  38787. ),
  38788. 'Symfony\\Component\\Process\\' =>
  38789. array (
  38790. 0 => __DIR__ . '/..' . '/symfony/process',
  38791. ),
  38792. 'Symfony\\Component\\Finder\\' =>
  38793. array (
  38794. 0 => __DIR__ . '/..' . '/symfony/finder',
  38795. ),
  38796. 'Symfony\\Component\\Filesystem\\' =>
  38797. array (
  38798. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  38799. ),
  38800. 'Symfony\\Component\\Debug\\' =>
  38801. array (
  38802. 0 => __DIR__ . '/..' . '/symfony/debug',
  38803. ),
  38804. 'Symfony\\Component\\Console\\' =>
  38805. array (
  38806. 0 => __DIR__ . '/..' . '/symfony/console',
  38807. ),
  38808. 'Seld\\PharUtils\\' =>
  38809. array (
  38810. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  38811. ),
  38812. 'Seld\\JsonLint\\' =>
  38813. array (
  38814. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  38815. ),
  38816. 'Psr\\Log\\' =>
  38817. array (
  38818. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  38819. ),
  38820. 'JsonSchema\\' =>
  38821. array (
  38822. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  38823. ),
  38824. 'Composer\\XdebugHandler\\' =>
  38825. array (
  38826. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  38827. ),
  38828. 'Composer\\Spdx\\' =>
  38829. array (
  38830. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  38831. ),
  38832. 'Composer\\Semver\\' =>
  38833. array (
  38834. 0 => __DIR__ . '/..' . '/composer/semver/src',
  38835. ),
  38836. 'Composer\\Pcre\\' =>
  38837. array (
  38838. 0 => __DIR__ . '/..' . '/composer/pcre/src',
  38839. ),
  38840. 'Composer\\MetadataMinifier\\' =>
  38841. array (
  38842. 0 => __DIR__ . '/..' . '/composer/metadata-minifier/src',
  38843. ),
  38844. 'Composer\\CaBundle\\' =>
  38845. array (
  38846. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  38847. ),
  38848. 'Composer\\' =>
  38849. array (
  38850. 0 => __DIR__ . '/../..' . '/src/Composer',
  38851. ),
  38852. );
  38853. public static $prefixesPsr0 = array (
  38854. 'R' =>
  38855. array (
  38856. 'React\\Promise' =>
  38857. array (
  38858. 0 => __DIR__ . '/..' . '/react/promise/src',
  38859. ),
  38860. ),
  38861. );
  38862. public static $classMap = array (
  38863. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  38864. );
  38865. public static function getInitializer(ClassLoader $loader)
  38866. {
  38867. return \Closure::bind(function () use ($loader) {
  38868. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1643990438::$prefixLengthsPsr4;
  38869. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1643990438::$prefixDirsPsr4;
  38870. $loader->prefixesPsr0 = ComposerStaticInitComposerPhar1643990438::$prefixesPsr0;
  38871. $loader->classMap = ComposerStaticInitComposerPhar1643990438::$classMap;
  38872. }, null, ClassLoader::class);
  38873. }
  38874. }
  38875. Copyright (C) 2016 Composer
  38876. Permission is hereby granted, free of charge, to any person obtaining a copy of
  38877. this software and associated documentation files (the "Software"), to deal in
  38878. the Software without restriction, including without limitation the rights to
  38879. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  38880. of the Software, and to permit persons to whom the Software is furnished to do
  38881. so, subject to the following conditions:
  38882. The above copyright notice and this permission notice shall be included in all
  38883. copies or substantial portions of the Software.
  38884. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  38885. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  38886. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  38887. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  38888. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  38889. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  38890. SOFTWARE.
  38891. ##
  38892. ## Bundle of CA Root Certificates
  38893. ##
  38894. ## Certificate data from Mozilla as of: Tue Oct 26 03:12:05 2021 GMT
  38895. ##
  38896. ## This is a bundle of X.509 certificates of public Certificate Authorities
  38897. ## (CA). These were automatically extracted from Mozilla's root certificates
  38898. ## file (certdata.txt). This file can be found in the mozilla source tree:
  38899. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  38900. ##
  38901. ## It contains the certificates in PEM format and therefore
  38902. ## can be directly used with curl / libcurl / php_curl, or with
  38903. ## an Apache+mod_ssl webserver for SSL client authentication.
  38904. ## Just configure this file as the SSLCACertificateFile.
  38905. ##
  38906. ## Conversion done with mk-ca-bundle.pl version 1.28.
  38907. ## SHA256: bb36818a81feaa4cca61101e6d6276cd09e972efcb08112dfed846918ca41d7f
  38908. ##
  38909. GlobalSign Root CA
  38910. ==================
  38911. -----BEGIN CERTIFICATE-----
  38912. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  38913. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  38914. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  38915. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  38916. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  38917. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  38918. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  38919. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  38920. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  38921. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  38922. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  38923. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  38924. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  38925. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  38926. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  38927. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  38928. -----END CERTIFICATE-----
  38929. GlobalSign Root CA - R2
  38930. =======================
  38931. -----BEGIN CERTIFICATE-----
  38932. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  38933. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  38934. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  38935. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  38936. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  38937. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  38938. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  38939. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  38940. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  38941. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  38942. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  38943. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  38944. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  38945. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  38946. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  38947. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  38948. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  38949. -----END CERTIFICATE-----
  38950. Entrust.net Premium 2048 Secure Server CA
  38951. =========================================
  38952. -----BEGIN CERTIFICATE-----
  38953. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  38954. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  38955. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  38956. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  38957. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  38958. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  38959. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  38960. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  38961. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  38962. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  38963. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  38964. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  38965. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  38966. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  38967. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  38968. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  38969. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  38970. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  38971. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  38972. -----END CERTIFICATE-----
  38973. Baltimore CyberTrust Root
  38974. =========================
  38975. -----BEGIN CERTIFICATE-----
  38976. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  38977. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  38978. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  38979. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  38980. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  38981. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  38982. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  38983. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  38984. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  38985. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  38986. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  38987. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  38988. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  38989. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  38990. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  38991. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  38992. -----END CERTIFICATE-----
  38993. Entrust Root Certification Authority
  38994. ====================================
  38995. -----BEGIN CERTIFICATE-----
  38996. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  38997. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  38998. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  38999. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  39000. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  39001. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  39002. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  39003. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  39004. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  39005. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  39006. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  39007. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  39008. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  39009. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  39010. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  39011. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  39012. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  39013. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  39014. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  39015. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  39016. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  39017. -----END CERTIFICATE-----
  39018. Comodo AAA Services root
  39019. ========================
  39020. -----BEGIN CERTIFICATE-----
  39021. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  39022. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  39023. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  39024. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  39025. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  39026. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  39027. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  39028. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  39029. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  39030. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  39031. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  39032. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  39033. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  39034. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  39035. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  39036. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  39037. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  39038. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  39039. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  39040. -----END CERTIFICATE-----
  39041. QuoVadis Root CA 2
  39042. ==================
  39043. -----BEGIN CERTIFICATE-----
  39044. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  39045. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  39046. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  39047. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  39048. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  39049. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  39050. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  39051. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  39052. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  39053. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  39054. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  39055. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  39056. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  39057. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  39058. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  39059. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  39060. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  39061. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  39062. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  39063. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  39064. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  39065. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  39066. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  39067. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  39068. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  39069. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  39070. -----END CERTIFICATE-----
  39071. QuoVadis Root CA 3
  39072. ==================
  39073. -----BEGIN CERTIFICATE-----
  39074. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  39075. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  39076. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  39077. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  39078. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  39079. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  39080. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  39081. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  39082. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  39083. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  39084. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  39085. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  39086. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  39087. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  39088. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  39089. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  39090. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  39091. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  39092. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  39093. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  39094. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  39095. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  39096. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  39097. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  39098. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  39099. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  39100. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  39101. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  39102. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  39103. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  39104. -----END CERTIFICATE-----
  39105. Security Communication Root CA
  39106. ==============================
  39107. -----BEGIN CERTIFICATE-----
  39108. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  39109. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  39110. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  39111. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  39112. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  39113. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  39114. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  39115. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  39116. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  39117. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  39118. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  39119. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  39120. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  39121. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  39122. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  39123. FL39vmwLAw==
  39124. -----END CERTIFICATE-----
  39125. XRamp Global CA Root
  39126. ====================
  39127. -----BEGIN CERTIFICATE-----
  39128. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  39129. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  39130. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  39131. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  39132. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  39133. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  39134. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  39135. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  39136. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  39137. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  39138. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  39139. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  39140. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  39141. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  39142. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  39143. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  39144. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  39145. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  39146. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  39147. -----END CERTIFICATE-----
  39148. Go Daddy Class 2 CA
  39149. ===================
  39150. -----BEGIN CERTIFICATE-----
  39151. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  39152. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  39153. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  39154. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  39155. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  39156. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  39157. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  39158. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  39159. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  39160. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  39161. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  39162. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  39163. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  39164. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  39165. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  39166. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  39167. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  39168. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  39169. vZ8=
  39170. -----END CERTIFICATE-----
  39171. Starfield Class 2 CA
  39172. ====================
  39173. -----BEGIN CERTIFICATE-----
  39174. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  39175. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  39176. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  39177. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  39178. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  39179. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  39180. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  39181. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  39182. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  39183. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  39184. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  39185. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  39186. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  39187. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  39188. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  39189. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  39190. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  39191. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  39192. QBFGmh95DmK/D5fs4C8fF5Q=
  39193. -----END CERTIFICATE-----
  39194. DigiCert Assured ID Root CA
  39195. ===========================
  39196. -----BEGIN CERTIFICATE-----
  39197. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  39198. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  39199. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  39200. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  39201. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  39202. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  39203. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  39204. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  39205. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  39206. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  39207. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  39208. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  39209. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  39210. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  39211. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  39212. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  39213. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  39214. -----END CERTIFICATE-----
  39215. DigiCert Global Root CA
  39216. =======================
  39217. -----BEGIN CERTIFICATE-----
  39218. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  39219. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  39220. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  39221. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  39222. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  39223. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  39224. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  39225. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  39226. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  39227. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  39228. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  39229. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  39230. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  39231. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  39232. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  39233. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  39234. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  39235. -----END CERTIFICATE-----
  39236. DigiCert High Assurance EV Root CA
  39237. ==================================
  39238. -----BEGIN CERTIFICATE-----
  39239. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  39240. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  39241. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  39242. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  39243. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  39244. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  39245. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  39246. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  39247. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  39248. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  39249. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  39250. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  39251. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  39252. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  39253. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  39254. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  39255. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  39256. -----END CERTIFICATE-----
  39257. SwissSign Gold CA - G2
  39258. ======================
  39259. -----BEGIN CERTIFICATE-----
  39260. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  39261. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  39262. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  39263. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  39264. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  39265. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  39266. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  39267. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  39268. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  39269. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  39270. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  39271. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  39272. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  39273. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  39274. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  39275. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  39276. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  39277. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  39278. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  39279. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  39280. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  39281. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  39282. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  39283. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  39284. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  39285. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  39286. -----END CERTIFICATE-----
  39287. SwissSign Silver CA - G2
  39288. ========================
  39289. -----BEGIN CERTIFICATE-----
  39290. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  39291. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  39292. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  39293. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  39294. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  39295. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  39296. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  39297. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  39298. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  39299. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  39300. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  39301. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  39302. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  39303. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  39304. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  39305. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  39306. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  39307. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  39308. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  39309. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  39310. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  39311. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  39312. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  39313. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  39314. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  39315. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  39316. -----END CERTIFICATE-----
  39317. SecureTrust CA
  39318. ==============
  39319. -----BEGIN CERTIFICATE-----
  39320. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  39321. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  39322. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  39323. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  39324. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  39325. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  39326. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  39327. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  39328. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  39329. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  39330. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  39331. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  39332. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  39333. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  39334. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  39335. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  39336. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  39337. -----END CERTIFICATE-----
  39338. Secure Global CA
  39339. ================
  39340. -----BEGIN CERTIFICATE-----
  39341. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  39342. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  39343. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  39344. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  39345. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  39346. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  39347. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  39348. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  39349. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  39350. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  39351. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  39352. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  39353. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  39354. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  39355. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  39356. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  39357. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  39358. -----END CERTIFICATE-----
  39359. COMODO Certification Authority
  39360. ==============================
  39361. -----BEGIN CERTIFICATE-----
  39362. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  39363. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  39364. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  39365. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  39366. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  39367. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  39368. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  39369. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  39370. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  39371. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  39372. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  39373. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  39374. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  39375. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  39376. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  39377. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  39378. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  39379. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  39380. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  39381. -----END CERTIFICATE-----
  39382. Network Solutions Certificate Authority
  39383. =======================================
  39384. -----BEGIN CERTIFICATE-----
  39385. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  39386. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  39387. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  39388. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  39389. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  39390. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  39391. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  39392. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  39393. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  39394. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  39395. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  39396. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  39397. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  39398. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  39399. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  39400. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  39401. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  39402. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  39403. -----END CERTIFICATE-----
  39404. COMODO ECC Certification Authority
  39405. ==================================
  39406. -----BEGIN CERTIFICATE-----
  39407. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  39408. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  39409. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  39410. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  39411. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  39412. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  39413. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  39414. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  39415. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  39416. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  39417. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  39418. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  39419. -----END CERTIFICATE-----
  39420. Certigna
  39421. ========
  39422. -----BEGIN CERTIFICATE-----
  39423. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  39424. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  39425. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  39426. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  39427. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  39428. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  39429. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  39430. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  39431. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  39432. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  39433. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  39434. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  39435. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  39436. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  39437. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  39438. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  39439. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  39440. -----END CERTIFICATE-----
  39441. Cybertrust Global Root
  39442. ======================
  39443. -----BEGIN CERTIFICATE-----
  39444. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  39445. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  39446. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  39447. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  39448. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  39449. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  39450. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  39451. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  39452. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  39453. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  39454. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  39455. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  39456. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  39457. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  39458. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  39459. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  39460. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  39461. -----END CERTIFICATE-----
  39462. ePKI Root Certification Authority
  39463. =================================
  39464. -----BEGIN CERTIFICATE-----
  39465. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  39466. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  39467. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  39468. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  39469. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  39470. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  39471. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  39472. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  39473. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  39474. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  39475. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  39476. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  39477. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  39478. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  39479. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  39480. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  39481. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  39482. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  39483. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  39484. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  39485. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  39486. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  39487. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  39488. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  39489. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  39490. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  39491. -----END CERTIFICATE-----
  39492. certSIGN ROOT CA
  39493. ================
  39494. -----BEGIN CERTIFICATE-----
  39495. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  39496. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  39497. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  39498. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  39499. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  39500. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  39501. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  39502. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  39503. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  39504. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  39505. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  39506. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  39507. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  39508. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  39509. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  39510. -----END CERTIFICATE-----
  39511. NetLock Arany (Class Gold) Főtanúsítvány
  39512. ========================================
  39513. -----BEGIN CERTIFICATE-----
  39514. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  39515. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  39516. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  39517. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  39518. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  39519. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  39520. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  39521. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  39522. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  39523. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  39524. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  39525. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  39526. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  39527. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  39528. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  39529. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  39530. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  39531. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  39532. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  39533. -----END CERTIFICATE-----
  39534. Hongkong Post Root CA 1
  39535. =======================
  39536. -----BEGIN CERTIFICATE-----
  39537. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  39538. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  39539. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  39540. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  39541. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  39542. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  39543. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  39544. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  39545. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  39546. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  39547. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  39548. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  39549. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  39550. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  39551. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  39552. -----END CERTIFICATE-----
  39553. SecureSign RootCA11
  39554. ===================
  39555. -----BEGIN CERTIFICATE-----
  39556. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  39557. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  39558. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  39559. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  39560. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  39561. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  39562. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  39563. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  39564. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  39565. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  39566. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  39567. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  39568. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  39569. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  39570. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  39571. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  39572. -----END CERTIFICATE-----
  39573. Microsec e-Szigno Root CA 2009
  39574. ==============================
  39575. -----BEGIN CERTIFICATE-----
  39576. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  39577. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  39578. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  39579. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  39580. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  39581. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  39582. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  39583. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  39584. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  39585. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  39586. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  39587. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  39588. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  39589. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  39590. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  39591. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  39592. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  39593. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  39594. LXpUq3DDfSJlgnCW
  39595. -----END CERTIFICATE-----
  39596. GlobalSign Root CA - R3
  39597. =======================
  39598. -----BEGIN CERTIFICATE-----
  39599. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  39600. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  39601. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  39602. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  39603. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  39604. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  39605. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  39606. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  39607. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  39608. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  39609. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  39610. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  39611. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  39612. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  39613. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  39614. kpeDMdmztcpHWD9f
  39615. -----END CERTIFICATE-----
  39616. Autoridad de Certificacion Firmaprofesional CIF A62634068
  39617. =========================================================
  39618. -----BEGIN CERTIFICATE-----
  39619. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  39620. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  39621. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  39622. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  39623. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  39624. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  39625. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  39626. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  39627. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  39628. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  39629. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  39630. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  39631. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  39632. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  39633. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  39634. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  39635. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  39636. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  39637. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  39638. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  39639. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  39640. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  39641. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  39642. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  39643. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  39644. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  39645. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  39646. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  39647. -----END CERTIFICATE-----
  39648. Izenpe.com
  39649. ==========
  39650. -----BEGIN CERTIFICATE-----
  39651. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  39652. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  39653. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  39654. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  39655. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  39656. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  39657. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  39658. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  39659. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  39660. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  39661. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  39662. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  39663. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  39664. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  39665. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  39666. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  39667. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  39668. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  39669. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  39670. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  39671. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  39672. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  39673. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  39674. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  39675. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  39676. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  39677. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  39678. -----END CERTIFICATE-----
  39679. Go Daddy Root Certificate Authority - G2
  39680. ========================================
  39681. -----BEGIN CERTIFICATE-----
  39682. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  39683. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  39684. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  39685. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  39686. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  39687. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  39688. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  39689. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  39690. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  39691. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  39692. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  39693. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  39694. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  39695. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  39696. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  39697. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  39698. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  39699. -----END CERTIFICATE-----
  39700. Starfield Root Certificate Authority - G2
  39701. =========================================
  39702. -----BEGIN CERTIFICATE-----
  39703. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  39704. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  39705. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  39706. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  39707. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  39708. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  39709. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  39710. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  39711. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  39712. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  39713. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  39714. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  39715. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  39716. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  39717. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  39718. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  39719. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  39720. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  39721. -----END CERTIFICATE-----
  39722. Starfield Services Root Certificate Authority - G2
  39723. ==================================================
  39724. -----BEGIN CERTIFICATE-----
  39725. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  39726. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  39727. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  39728. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  39729. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  39730. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  39731. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  39732. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  39733. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  39734. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  39735. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  39736. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  39737. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  39738. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  39739. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  39740. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  39741. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  39742. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  39743. -----END CERTIFICATE-----
  39744. AffirmTrust Commercial
  39745. ======================
  39746. -----BEGIN CERTIFICATE-----
  39747. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  39748. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  39749. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  39750. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  39751. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  39752. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  39753. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  39754. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  39755. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  39756. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  39757. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  39758. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  39759. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  39760. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  39761. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  39762. -----END CERTIFICATE-----
  39763. AffirmTrust Networking
  39764. ======================
  39765. -----BEGIN CERTIFICATE-----
  39766. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  39767. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  39768. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  39769. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  39770. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  39771. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  39772. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  39773. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  39774. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  39775. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  39776. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  39777. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  39778. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  39779. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  39780. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  39781. -----END CERTIFICATE-----
  39782. AffirmTrust Premium
  39783. ===================
  39784. -----BEGIN CERTIFICATE-----
  39785. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  39786. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  39787. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  39788. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  39789. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  39790. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  39791. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  39792. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  39793. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  39794. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  39795. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  39796. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  39797. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  39798. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  39799. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  39800. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  39801. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  39802. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  39803. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  39804. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  39805. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  39806. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  39807. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  39808. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  39809. -----END CERTIFICATE-----
  39810. AffirmTrust Premium ECC
  39811. =======================
  39812. -----BEGIN CERTIFICATE-----
  39813. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  39814. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  39815. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  39816. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  39817. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  39818. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  39819. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  39820. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  39821. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  39822. eQ==
  39823. -----END CERTIFICATE-----
  39824. Certum Trusted Network CA
  39825. =========================
  39826. -----BEGIN CERTIFICATE-----
  39827. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  39828. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  39829. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  39830. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  39831. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  39832. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  39833. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  39834. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  39835. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  39836. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  39837. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  39838. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  39839. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  39840. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  39841. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  39842. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  39843. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  39844. -----END CERTIFICATE-----
  39845. TWCA Root Certification Authority
  39846. =================================
  39847. -----BEGIN CERTIFICATE-----
  39848. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  39849. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  39850. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  39851. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  39852. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  39853. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  39854. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  39855. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  39856. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  39857. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  39858. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  39859. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  39860. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  39861. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  39862. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  39863. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  39864. -----END CERTIFICATE-----
  39865. Security Communication RootCA2
  39866. ==============================
  39867. -----BEGIN CERTIFICATE-----
  39868. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  39869. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  39870. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  39871. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  39872. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  39873. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  39874. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  39875. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  39876. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  39877. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  39878. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  39879. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  39880. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  39881. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  39882. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  39883. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  39884. -----END CERTIFICATE-----
  39885. EC-ACC
  39886. ======
  39887. -----BEGIN CERTIFICATE-----
  39888. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  39889. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  39890. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  39891. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  39892. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  39893. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  39894. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  39895. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  39896. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  39897. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  39898. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  39899. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  39900. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  39901. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  39902. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  39903. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  39904. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  39905. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  39906. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  39907. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  39908. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  39909. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  39910. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  39911. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  39912. 5EI=
  39913. -----END CERTIFICATE-----
  39914. Hellenic Academic and Research Institutions RootCA 2011
  39915. =======================================================
  39916. -----BEGIN CERTIFICATE-----
  39917. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  39918. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  39919. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  39920. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  39921. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  39922. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  39923. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  39924. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  39925. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  39926. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  39927. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  39928. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  39929. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  39930. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  39931. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  39932. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  39933. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  39934. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  39935. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  39936. -----END CERTIFICATE-----
  39937. Actalis Authentication Root CA
  39938. ==============================
  39939. -----BEGIN CERTIFICATE-----
  39940. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  39941. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  39942. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  39943. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  39944. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  39945. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  39946. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  39947. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  39948. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  39949. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  39950. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  39951. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  39952. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  39953. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  39954. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  39955. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  39956. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  39957. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  39958. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  39959. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  39960. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  39961. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  39962. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  39963. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  39964. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  39965. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  39966. -----END CERTIFICATE-----
  39967. Buypass Class 2 Root CA
  39968. =======================
  39969. -----BEGIN CERTIFICATE-----
  39970. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  39971. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  39972. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  39973. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  39974. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  39975. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  39976. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  39977. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  39978. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  39979. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  39980. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  39981. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  39982. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  39983. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  39984. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  39985. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  39986. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  39987. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  39988. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  39989. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  39990. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  39991. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  39992. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  39993. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  39994. rJgWVqA=
  39995. -----END CERTIFICATE-----
  39996. Buypass Class 3 Root CA
  39997. =======================
  39998. -----BEGIN CERTIFICATE-----
  39999. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  40000. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  40001. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  40002. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  40003. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  40004. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  40005. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  40006. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  40007. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  40008. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  40009. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  40010. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  40011. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  40012. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  40013. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  40014. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  40015. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  40016. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  40017. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  40018. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  40019. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  40020. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  40021. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  40022. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  40023. Cp/HuZc=
  40024. -----END CERTIFICATE-----
  40025. T-TeleSec GlobalRoot Class 3
  40026. ============================
  40027. -----BEGIN CERTIFICATE-----
  40028. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  40029. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  40030. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  40031. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  40032. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  40033. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  40034. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  40035. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  40036. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  40037. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  40038. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  40039. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  40040. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  40041. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  40042. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  40043. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  40044. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  40045. -----END CERTIFICATE-----
  40046. D-TRUST Root Class 3 CA 2 2009
  40047. ==============================
  40048. -----BEGIN CERTIFICATE-----
  40049. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  40050. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  40051. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  40052. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  40053. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  40054. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  40055. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  40056. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  40057. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  40058. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  40059. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  40060. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  40061. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  40062. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  40063. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  40064. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  40065. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  40066. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  40067. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  40068. -----END CERTIFICATE-----
  40069. D-TRUST Root Class 3 CA 2 EV 2009
  40070. =================================
  40071. -----BEGIN CERTIFICATE-----
  40072. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  40073. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  40074. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  40075. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  40076. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  40077. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  40078. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  40079. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  40080. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  40081. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  40082. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  40083. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  40084. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  40085. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  40086. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  40087. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  40088. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  40089. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  40090. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  40091. w9y4AyHqnxbxLFS1
  40092. -----END CERTIFICATE-----
  40093. CA Disig Root R2
  40094. ================
  40095. -----BEGIN CERTIFICATE-----
  40096. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  40097. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  40098. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  40099. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  40100. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  40101. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  40102. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  40103. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  40104. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  40105. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  40106. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  40107. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  40108. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  40109. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  40110. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  40111. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  40112. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  40113. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  40114. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  40115. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  40116. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  40117. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  40118. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  40119. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  40120. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  40121. -----END CERTIFICATE-----
  40122. ACCVRAIZ1
  40123. =========
  40124. -----BEGIN CERTIFICATE-----
  40125. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  40126. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  40127. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  40128. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  40129. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  40130. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  40131. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  40132. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  40133. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  40134. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  40135. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  40136. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  40137. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  40138. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  40139. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  40140. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  40141. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  40142. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  40143. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  40144. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  40145. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  40146. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  40147. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  40148. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  40149. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  40150. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  40151. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  40152. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  40153. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  40154. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  40155. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  40156. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  40157. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  40158. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  40159. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  40160. EfbRD0tVNEYqi4Y7
  40161. -----END CERTIFICATE-----
  40162. TWCA Global Root CA
  40163. ===================
  40164. -----BEGIN CERTIFICATE-----
  40165. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  40166. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  40167. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  40168. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  40169. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  40170. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  40171. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  40172. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  40173. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  40174. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  40175. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  40176. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  40177. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  40178. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  40179. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  40180. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  40181. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  40182. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  40183. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  40184. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  40185. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  40186. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  40187. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  40188. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  40189. -----END CERTIFICATE-----
  40190. TeliaSonera Root CA v1
  40191. ======================
  40192. -----BEGIN CERTIFICATE-----
  40193. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  40194. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  40195. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  40196. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  40197. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  40198. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  40199. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  40200. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  40201. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  40202. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  40203. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  40204. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  40205. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  40206. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  40207. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  40208. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  40209. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  40210. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  40211. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  40212. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  40213. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  40214. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  40215. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  40216. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  40217. -----END CERTIFICATE-----
  40218. E-Tugra Certification Authority
  40219. ===============================
  40220. -----BEGIN CERTIFICATE-----
  40221. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  40222. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  40223. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  40224. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  40225. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  40226. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  40227. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  40228. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  40229. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  40230. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  40231. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  40232. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  40233. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  40234. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  40235. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  40236. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  40237. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  40238. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  40239. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  40240. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  40241. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  40242. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  40243. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  40244. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  40245. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  40246. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  40247. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  40248. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  40249. C7TbO6Orb1wdtn7os4I07QZcJA==
  40250. -----END CERTIFICATE-----
  40251. T-TeleSec GlobalRoot Class 2
  40252. ============================
  40253. -----BEGIN CERTIFICATE-----
  40254. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  40255. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  40256. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  40257. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  40258. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  40259. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  40260. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  40261. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  40262. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  40263. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  40264. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  40265. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  40266. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  40267. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  40268. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  40269. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  40270. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  40271. -----END CERTIFICATE-----
  40272. Atos TrustedRoot 2011
  40273. =====================
  40274. -----BEGIN CERTIFICATE-----
  40275. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  40276. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  40277. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  40278. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  40279. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  40280. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  40281. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  40282. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  40283. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  40284. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  40285. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  40286. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  40287. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  40288. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  40289. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  40290. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  40291. -----END CERTIFICATE-----
  40292. QuoVadis Root CA 1 G3
  40293. =====================
  40294. -----BEGIN CERTIFICATE-----
  40295. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  40296. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  40297. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  40298. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  40299. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  40300. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  40301. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  40302. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  40303. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  40304. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  40305. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  40306. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  40307. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  40308. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40309. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  40310. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  40311. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  40312. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  40313. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  40314. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  40315. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  40316. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  40317. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  40318. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  40319. hMJKzRwuJIczYOXD
  40320. -----END CERTIFICATE-----
  40321. QuoVadis Root CA 2 G3
  40322. =====================
  40323. -----BEGIN CERTIFICATE-----
  40324. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  40325. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  40326. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  40327. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  40328. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  40329. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  40330. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  40331. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  40332. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  40333. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  40334. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  40335. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  40336. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  40337. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40338. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  40339. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  40340. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  40341. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  40342. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  40343. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  40344. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  40345. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  40346. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  40347. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  40348. O3jtZsSOeWmD3n+M
  40349. -----END CERTIFICATE-----
  40350. QuoVadis Root CA 3 G3
  40351. =====================
  40352. -----BEGIN CERTIFICATE-----
  40353. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  40354. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  40355. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  40356. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  40357. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  40358. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  40359. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  40360. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  40361. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  40362. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  40363. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  40364. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  40365. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  40366. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40367. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  40368. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  40369. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  40370. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  40371. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  40372. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  40373. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  40374. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  40375. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  40376. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  40377. PpxxVJkES/1Y+Zj0
  40378. -----END CERTIFICATE-----
  40379. DigiCert Assured ID Root G2
  40380. ===========================
  40381. -----BEGIN CERTIFICATE-----
  40382. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  40383. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  40384. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  40385. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  40386. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  40387. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  40388. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  40389. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  40390. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  40391. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  40392. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  40393. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  40394. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  40395. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  40396. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  40397. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  40398. IhNzbM8m9Yop5w==
  40399. -----END CERTIFICATE-----
  40400. DigiCert Assured ID Root G3
  40401. ===========================
  40402. -----BEGIN CERTIFICATE-----
  40403. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  40404. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  40405. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  40406. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  40407. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  40408. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  40409. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  40410. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  40411. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  40412. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  40413. 1vUhZscv6pZjamVFkpUBtA==
  40414. -----END CERTIFICATE-----
  40415. DigiCert Global Root G2
  40416. =======================
  40417. -----BEGIN CERTIFICATE-----
  40418. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  40419. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  40420. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  40421. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  40422. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  40423. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  40424. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  40425. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  40426. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  40427. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  40428. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  40429. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  40430. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  40431. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  40432. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  40433. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  40434. MrY=
  40435. -----END CERTIFICATE-----
  40436. DigiCert Global Root G3
  40437. =======================
  40438. -----BEGIN CERTIFICATE-----
  40439. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  40440. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  40441. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  40442. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  40443. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  40444. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  40445. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  40446. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  40447. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  40448. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  40449. VOKa5Vt8sycX
  40450. -----END CERTIFICATE-----
  40451. DigiCert Trusted Root G4
  40452. ========================
  40453. -----BEGIN CERTIFICATE-----
  40454. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  40455. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  40456. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  40457. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  40458. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  40459. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  40460. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  40461. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  40462. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  40463. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  40464. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  40465. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  40466. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  40467. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  40468. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  40469. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  40470. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  40471. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  40472. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  40473. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  40474. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  40475. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  40476. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  40477. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  40478. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  40479. 82Z+
  40480. -----END CERTIFICATE-----
  40481. COMODO RSA Certification Authority
  40482. ==================================
  40483. -----BEGIN CERTIFICATE-----
  40484. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  40485. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  40486. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  40487. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  40488. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  40489. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  40490. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  40491. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  40492. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  40493. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  40494. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  40495. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  40496. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  40497. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  40498. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  40499. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  40500. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  40501. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  40502. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  40503. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  40504. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  40505. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  40506. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  40507. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  40508. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  40509. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  40510. LaZRfyHBNVOFBkpdn627G190
  40511. -----END CERTIFICATE-----
  40512. USERTrust RSA Certification Authority
  40513. =====================================
  40514. -----BEGIN CERTIFICATE-----
  40515. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  40516. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  40517. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  40518. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  40519. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  40520. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  40521. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  40522. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  40523. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  40524. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  40525. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  40526. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  40527. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  40528. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  40529. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  40530. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  40531. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  40532. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  40533. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  40534. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  40535. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  40536. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  40537. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  40538. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  40539. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  40540. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  40541. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  40542. -----END CERTIFICATE-----
  40543. USERTrust ECC Certification Authority
  40544. =====================================
  40545. -----BEGIN CERTIFICATE-----
  40546. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  40547. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  40548. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  40549. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  40550. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  40551. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  40552. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  40553. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  40554. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  40555. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  40556. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  40557. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  40558. -----END CERTIFICATE-----
  40559. GlobalSign ECC Root CA - R4
  40560. ===========================
  40561. -----BEGIN CERTIFICATE-----
  40562. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  40563. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40564. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  40565. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40566. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  40567. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  40568. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  40569. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  40570. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  40571. -----END CERTIFICATE-----
  40572. GlobalSign ECC Root CA - R5
  40573. ===========================
  40574. -----BEGIN CERTIFICATE-----
  40575. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  40576. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40577. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  40578. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  40579. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  40580. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  40581. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  40582. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  40583. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  40584. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  40585. -----END CERTIFICATE-----
  40586. Staat der Nederlanden EV Root CA
  40587. ================================
  40588. -----BEGIN CERTIFICATE-----
  40589. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  40590. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  40591. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  40592. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  40593. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  40594. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  40595. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  40596. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  40597. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  40598. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  40599. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  40600. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  40601. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  40602. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  40603. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  40604. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  40605. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  40606. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  40607. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  40608. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  40609. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  40610. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  40611. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  40612. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  40613. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  40614. -----END CERTIFICATE-----
  40615. IdenTrust Commercial Root CA 1
  40616. ==============================
  40617. -----BEGIN CERTIFICATE-----
  40618. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  40619. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  40620. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  40621. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  40622. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  40623. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  40624. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  40625. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  40626. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  40627. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  40628. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  40629. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  40630. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  40631. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  40632. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  40633. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  40634. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  40635. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  40636. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  40637. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  40638. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  40639. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  40640. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  40641. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  40642. cGzM7vRX+Bi6hG6H
  40643. -----END CERTIFICATE-----
  40644. IdenTrust Public Sector Root CA 1
  40645. =================================
  40646. -----BEGIN CERTIFICATE-----
  40647. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  40648. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  40649. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  40650. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  40651. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  40652. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  40653. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  40654. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  40655. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  40656. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  40657. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  40658. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  40659. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  40660. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  40661. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  40662. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  40663. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  40664. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  40665. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  40666. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  40667. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  40668. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  40669. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  40670. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  40671. 3Wl9af0AVqW3rLatt8o+Ae+c
  40672. -----END CERTIFICATE-----
  40673. Entrust Root Certification Authority - G2
  40674. =========================================
  40675. -----BEGIN CERTIFICATE-----
  40676. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  40677. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  40678. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  40679. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  40680. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  40681. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  40682. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  40683. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  40684. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  40685. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  40686. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  40687. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  40688. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  40689. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  40690. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  40691. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  40692. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  40693. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  40694. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  40695. e4pIb4tF9g==
  40696. -----END CERTIFICATE-----
  40697. Entrust Root Certification Authority - EC1
  40698. ==========================================
  40699. -----BEGIN CERTIFICATE-----
  40700. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  40701. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  40702. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  40703. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  40704. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  40705. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  40706. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  40707. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  40708. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  40709. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  40710. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  40711. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  40712. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  40713. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  40714. -----END CERTIFICATE-----
  40715. CFCA EV ROOT
  40716. ============
  40717. -----BEGIN CERTIFICATE-----
  40718. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  40719. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  40720. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  40721. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  40722. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  40723. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  40724. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  40725. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  40726. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  40727. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  40728. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  40729. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  40730. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  40731. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  40732. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  40733. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  40734. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  40735. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  40736. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  40737. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  40738. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  40739. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  40740. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  40741. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  40742. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  40743. -----END CERTIFICATE-----
  40744. OISTE WISeKey Global Root GB CA
  40745. ===============================
  40746. -----BEGIN CERTIFICATE-----
  40747. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  40748. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  40749. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  40750. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  40751. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  40752. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  40753. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  40754. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  40755. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  40756. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  40757. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  40758. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  40759. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  40760. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  40761. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  40762. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  40763. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  40764. -----END CERTIFICATE-----
  40765. SZAFIR ROOT CA2
  40766. ===============
  40767. -----BEGIN CERTIFICATE-----
  40768. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  40769. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  40770. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  40771. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  40772. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  40773. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  40774. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  40775. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  40776. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  40777. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  40778. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  40779. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  40780. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  40781. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  40782. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  40783. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  40784. -----END CERTIFICATE-----
  40785. Certum Trusted Network CA 2
  40786. ===========================
  40787. -----BEGIN CERTIFICATE-----
  40788. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  40789. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  40790. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  40791. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  40792. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  40793. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  40794. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  40795. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  40796. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  40797. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  40798. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  40799. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  40800. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  40801. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  40802. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  40803. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40804. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  40805. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  40806. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  40807. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  40808. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  40809. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  40810. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  40811. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  40812. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  40813. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  40814. zAYspsbiDrW5viSP
  40815. -----END CERTIFICATE-----
  40816. Hellenic Academic and Research Institutions RootCA 2015
  40817. =======================================================
  40818. -----BEGIN CERTIFICATE-----
  40819. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  40820. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  40821. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  40822. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  40823. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  40824. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  40825. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  40826. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  40827. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  40828. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  40829. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  40830. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  40831. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  40832. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  40833. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  40834. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  40835. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  40836. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  40837. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  40838. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  40839. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  40840. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  40841. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  40842. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  40843. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  40844. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  40845. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  40846. p/UsQu0yrbYhnr68
  40847. -----END CERTIFICATE-----
  40848. Hellenic Academic and Research Institutions ECC RootCA 2015
  40849. ===========================================================
  40850. -----BEGIN CERTIFICATE-----
  40851. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  40852. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  40853. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  40854. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  40855. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  40856. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  40857. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  40858. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  40859. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  40860. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  40861. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  40862. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  40863. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  40864. -----END CERTIFICATE-----
  40865. ISRG Root X1
  40866. ============
  40867. -----BEGIN CERTIFICATE-----
  40868. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  40869. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  40870. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  40871. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  40872. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  40873. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  40874. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  40875. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  40876. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  40877. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  40878. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  40879. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  40880. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  40881. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  40882. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  40883. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  40884. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  40885. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  40886. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  40887. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  40888. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  40889. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  40890. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  40891. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  40892. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  40893. -----END CERTIFICATE-----
  40894. AC RAIZ FNMT-RCM
  40895. ================
  40896. -----BEGIN CERTIFICATE-----
  40897. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  40898. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  40899. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  40900. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  40901. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  40902. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  40903. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  40904. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  40905. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  40906. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  40907. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  40908. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  40909. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  40910. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  40911. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  40912. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  40913. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  40914. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  40915. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  40916. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  40917. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  40918. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  40919. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  40920. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  40921. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  40922. -----END CERTIFICATE-----
  40923. Amazon Root CA 1
  40924. ================
  40925. -----BEGIN CERTIFICATE-----
  40926. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  40927. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  40928. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  40929. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  40930. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  40931. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  40932. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  40933. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  40934. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  40935. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  40936. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  40937. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  40938. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  40939. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  40940. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  40941. -----END CERTIFICATE-----
  40942. Amazon Root CA 2
  40943. ================
  40944. -----BEGIN CERTIFICATE-----
  40945. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  40946. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  40947. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  40948. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  40949. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  40950. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  40951. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  40952. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  40953. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  40954. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  40955. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  40956. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  40957. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  40958. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  40959. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  40960. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  40961. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  40962. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  40963. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  40964. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  40965. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  40966. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  40967. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  40968. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  40969. -----END CERTIFICATE-----
  40970. Amazon Root CA 3
  40971. ================
  40972. -----BEGIN CERTIFICATE-----
  40973. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  40974. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  40975. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  40976. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  40977. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  40978. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  40979. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  40980. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  40981. -----END CERTIFICATE-----
  40982. Amazon Root CA 4
  40983. ================
  40984. -----BEGIN CERTIFICATE-----
  40985. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  40986. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  40987. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  40988. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  40989. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  40990. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  40991. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  40992. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  40993. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  40994. -----END CERTIFICATE-----
  40995. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  40996. =============================================
  40997. -----BEGIN CERTIFICATE-----
  40998. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  40999. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  41000. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  41001. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  41002. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  41003. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  41004. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  41005. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  41006. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  41007. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  41008. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  41009. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  41010. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  41011. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  41012. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  41013. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  41014. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  41015. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  41016. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  41017. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  41018. -----END CERTIFICATE-----
  41019. GDCA TrustAUTH R5 ROOT
  41020. ======================
  41021. -----BEGIN CERTIFICATE-----
  41022. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  41023. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  41024. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  41025. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  41026. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  41027. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  41028. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  41029. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  41030. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  41031. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  41032. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  41033. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  41034. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  41035. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  41036. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  41037. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  41038. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  41039. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  41040. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  41041. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  41042. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  41043. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  41044. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  41045. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  41046. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  41047. -----END CERTIFICATE-----
  41048. TrustCor RootCert CA-1
  41049. ======================
  41050. -----BEGIN CERTIFICATE-----
  41051. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  41052. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  41053. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  41054. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  41055. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  41056. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  41057. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  41058. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  41059. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  41060. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  41061. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  41062. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  41063. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  41064. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  41065. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  41066. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  41067. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  41068. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  41069. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  41070. -----END CERTIFICATE-----
  41071. TrustCor RootCert CA-2
  41072. ======================
  41073. -----BEGIN CERTIFICATE-----
  41074. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  41075. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  41076. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  41077. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  41078. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  41079. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  41080. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  41081. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  41082. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  41083. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  41084. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  41085. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  41086. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  41087. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  41088. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  41089. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  41090. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  41091. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  41092. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  41093. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  41094. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  41095. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  41096. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  41097. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  41098. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  41099. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  41100. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  41101. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  41102. -----END CERTIFICATE-----
  41103. TrustCor ECA-1
  41104. ==============
  41105. -----BEGIN CERTIFICATE-----
  41106. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  41107. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  41108. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  41109. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  41110. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  41111. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  41112. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  41113. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  41114. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  41115. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  41116. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  41117. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  41118. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  41119. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  41120. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  41121. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  41122. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  41123. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  41124. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  41125. -----END CERTIFICATE-----
  41126. SSL.com Root Certification Authority RSA
  41127. ========================================
  41128. -----BEGIN CERTIFICATE-----
  41129. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  41130. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  41131. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  41132. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  41133. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  41134. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  41135. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  41136. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  41137. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  41138. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  41139. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  41140. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  41141. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  41142. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  41143. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  41144. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  41145. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  41146. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  41147. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  41148. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  41149. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  41150. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  41151. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  41152. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  41153. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  41154. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  41155. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  41156. -----END CERTIFICATE-----
  41157. SSL.com Root Certification Authority ECC
  41158. ========================================
  41159. -----BEGIN CERTIFICATE-----
  41160. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  41161. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  41162. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  41163. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  41164. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  41165. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  41166. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  41167. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  41168. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  41169. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  41170. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  41171. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  41172. -----END CERTIFICATE-----
  41173. SSL.com EV Root Certification Authority RSA R2
  41174. ==============================================
  41175. -----BEGIN CERTIFICATE-----
  41176. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  41177. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  41178. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  41179. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  41180. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  41181. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  41182. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  41183. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  41184. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  41185. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  41186. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  41187. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  41188. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  41189. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  41190. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  41191. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  41192. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  41193. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  41194. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  41195. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  41196. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  41197. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  41198. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  41199. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  41200. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  41201. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  41202. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  41203. -----END CERTIFICATE-----
  41204. SSL.com EV Root Certification Authority ECC
  41205. ===========================================
  41206. -----BEGIN CERTIFICATE-----
  41207. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  41208. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  41209. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  41210. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  41211. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  41212. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  41213. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  41214. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  41215. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  41216. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  41217. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  41218. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  41219. -----END CERTIFICATE-----
  41220. GlobalSign Root CA - R6
  41221. =======================
  41222. -----BEGIN CERTIFICATE-----
  41223. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  41224. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  41225. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  41226. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  41227. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  41228. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  41229. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  41230. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  41231. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  41232. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  41233. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  41234. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  41235. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  41236. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  41237. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  41238. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  41239. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  41240. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  41241. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  41242. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  41243. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  41244. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  41245. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  41246. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  41247. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  41248. -----END CERTIFICATE-----
  41249. OISTE WISeKey Global Root GC CA
  41250. ===============================
  41251. -----BEGIN CERTIFICATE-----
  41252. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  41253. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  41254. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  41255. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  41256. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  41257. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  41258. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  41259. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  41260. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  41261. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  41262. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  41263. -----END CERTIFICATE-----
  41264. GTS Root R1
  41265. ===========
  41266. -----BEGIN CERTIFICATE-----
  41267. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  41268. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  41269. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  41270. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  41271. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  41272. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  41273. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  41274. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  41275. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  41276. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  41277. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  41278. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  41279. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  41280. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  41281. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  41282. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  41283. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  41284. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  41285. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  41286. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  41287. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  41288. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  41289. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  41290. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  41291. CFF1pkgl
  41292. -----END CERTIFICATE-----
  41293. GTS Root R2
  41294. ===========
  41295. -----BEGIN CERTIFICATE-----
  41296. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  41297. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  41298. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  41299. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  41300. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  41301. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  41302. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  41303. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  41304. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  41305. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  41306. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  41307. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  41308. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  41309. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  41310. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  41311. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  41312. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  41313. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  41314. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  41315. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  41316. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  41317. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  41318. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  41319. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  41320. o/DUhgkC
  41321. -----END CERTIFICATE-----
  41322. GTS Root R3
  41323. ===========
  41324. -----BEGIN CERTIFICATE-----
  41325. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  41326. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  41327. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  41328. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  41329. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  41330. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  41331. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  41332. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  41333. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  41334. KaqW04MjyaR7YbPMAuhd
  41335. -----END CERTIFICATE-----
  41336. GTS Root R4
  41337. ===========
  41338. -----BEGIN CERTIFICATE-----
  41339. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  41340. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  41341. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  41342. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  41343. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  41344. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  41345. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  41346. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  41347. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  41348. zPKwTdb+mciUqXWi4w==
  41349. -----END CERTIFICATE-----
  41350. UCA Global G2 Root
  41351. ==================
  41352. -----BEGIN CERTIFICATE-----
  41353. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  41354. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  41355. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  41356. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  41357. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  41358. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  41359. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  41360. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  41361. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  41362. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  41363. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  41364. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  41365. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  41366. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  41367. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  41368. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  41369. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  41370. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  41371. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  41372. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  41373. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  41374. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  41375. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  41376. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  41377. -----END CERTIFICATE-----
  41378. UCA Extended Validation Root
  41379. ============================
  41380. -----BEGIN CERTIFICATE-----
  41381. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  41382. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  41383. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  41384. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  41385. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  41386. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  41387. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  41388. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  41389. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  41390. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  41391. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  41392. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  41393. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  41394. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  41395. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  41396. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  41397. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  41398. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  41399. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  41400. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  41401. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  41402. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  41403. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  41404. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  41405. dhh2n1ax
  41406. -----END CERTIFICATE-----
  41407. Certigna Root CA
  41408. ================
  41409. -----BEGIN CERTIFICATE-----
  41410. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  41411. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  41412. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  41413. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  41414. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  41415. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  41416. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  41417. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  41418. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  41419. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  41420. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  41421. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  41422. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  41423. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  41424. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  41425. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  41426. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  41427. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  41428. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  41429. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  41430. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  41431. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  41432. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  41433. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  41434. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  41435. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  41436. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  41437. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  41438. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  41439. -----END CERTIFICATE-----
  41440. emSign Root CA - G1
  41441. ===================
  41442. -----BEGIN CERTIFICATE-----
  41443. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  41444. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  41445. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  41446. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  41447. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  41448. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  41449. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  41450. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  41451. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  41452. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  41453. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  41454. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  41455. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  41456. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  41457. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  41458. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  41459. iN66zB+Afko=
  41460. -----END CERTIFICATE-----
  41461. emSign ECC Root CA - G3
  41462. =======================
  41463. -----BEGIN CERTIFICATE-----
  41464. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  41465. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  41466. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  41467. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  41468. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  41469. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  41470. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  41471. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  41472. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  41473. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  41474. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  41475. -----END CERTIFICATE-----
  41476. emSign Root CA - C1
  41477. ===================
  41478. -----BEGIN CERTIFICATE-----
  41479. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  41480. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  41481. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  41482. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  41483. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  41484. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  41485. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  41486. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  41487. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  41488. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  41489. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  41490. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  41491. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  41492. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  41493. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  41494. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  41495. -----END CERTIFICATE-----
  41496. emSign ECC Root CA - C3
  41497. =======================
  41498. -----BEGIN CERTIFICATE-----
  41499. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  41500. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  41501. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  41502. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  41503. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  41504. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  41505. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  41506. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  41507. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  41508. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  41509. -----END CERTIFICATE-----
  41510. Hongkong Post Root CA 3
  41511. =======================
  41512. -----BEGIN CERTIFICATE-----
  41513. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  41514. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  41515. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  41516. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  41517. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  41518. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  41519. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  41520. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  41521. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  41522. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  41523. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  41524. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  41525. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  41526. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  41527. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  41528. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  41529. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  41530. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  41531. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  41532. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  41533. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  41534. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  41535. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  41536. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  41537. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  41538. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  41539. dBb9HxEGmpv0
  41540. -----END CERTIFICATE-----
  41541. Entrust Root Certification Authority - G4
  41542. =========================================
  41543. -----BEGIN CERTIFICATE-----
  41544. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  41545. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  41546. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  41547. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  41548. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  41549. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  41550. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  41551. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  41552. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  41553. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  41554. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  41555. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  41556. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  41557. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  41558. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  41559. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  41560. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  41561. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  41562. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  41563. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  41564. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  41565. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  41566. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  41567. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  41568. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  41569. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  41570. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  41571. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  41572. kcpG2om3PVODLAgfi49T3f+sHw==
  41573. -----END CERTIFICATE-----
  41574. Microsoft ECC Root Certificate Authority 2017
  41575. =============================================
  41576. -----BEGIN CERTIFICATE-----
  41577. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  41578. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  41579. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  41580. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  41581. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  41582. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  41583. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  41584. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  41585. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  41586. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  41587. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  41588. -----END CERTIFICATE-----
  41589. Microsoft RSA Root Certificate Authority 2017
  41590. =============================================
  41591. -----BEGIN CERTIFICATE-----
  41592. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  41593. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  41594. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  41595. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  41596. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  41597. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  41598. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  41599. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  41600. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  41601. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  41602. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  41603. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  41604. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  41605. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  41606. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  41607. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  41608. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  41609. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  41610. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  41611. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  41612. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  41613. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  41614. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  41615. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  41616. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  41617. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  41618. -----END CERTIFICATE-----
  41619. e-Szigno Root CA 2017
  41620. =====================
  41621. -----BEGIN CERTIFICATE-----
  41622. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  41623. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  41624. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  41625. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  41626. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  41627. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  41628. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  41629. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  41630. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  41631. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  41632. svxyqltZ+efcMQ==
  41633. -----END CERTIFICATE-----
  41634. certSIGN Root CA G2
  41635. ===================
  41636. -----BEGIN CERTIFICATE-----
  41637. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  41638. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  41639. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  41640. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  41641. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  41642. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  41643. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  41644. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  41645. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  41646. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  41647. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  41648. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  41649. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  41650. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  41651. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  41652. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  41653. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  41654. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  41655. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  41656. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  41657. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  41658. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  41659. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  41660. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  41661. -----END CERTIFICATE-----
  41662. Trustwave Global Certification Authority
  41663. ========================================
  41664. -----BEGIN CERTIFICATE-----
  41665. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  41666. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  41667. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  41668. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  41669. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  41670. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  41671. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  41672. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  41673. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  41674. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  41675. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  41676. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  41677. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  41678. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  41679. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  41680. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  41681. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  41682. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  41683. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  41684. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  41685. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  41686. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  41687. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  41688. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  41689. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  41690. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  41691. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  41692. -----END CERTIFICATE-----
  41693. Trustwave Global ECC P256 Certification Authority
  41694. =================================================
  41695. -----BEGIN CERTIFICATE-----
  41696. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  41697. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  41698. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  41699. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  41700. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  41701. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  41702. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  41703. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  41704. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  41705. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  41706. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  41707. -----END CERTIFICATE-----
  41708. Trustwave Global ECC P384 Certification Authority
  41709. =================================================
  41710. -----BEGIN CERTIFICATE-----
  41711. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  41712. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  41713. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  41714. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  41715. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  41716. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  41717. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  41718. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  41719. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  41720. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  41721. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  41722. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  41723. -----END CERTIFICATE-----
  41724. NAVER Global Root Certification Authority
  41725. =========================================
  41726. -----BEGIN CERTIFICATE-----
  41727. MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEMBQAwaTELMAkG
  41728. A1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRGT1JNIENvcnAuMTIwMAYDVQQD
  41729. DClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4
  41730. NDJaFw0zNzA4MTgyMzU5NTlaMGkxCzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVT
  41731. UyBQTEFURk9STSBDb3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlv
  41732. biBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVAiQqrDZBb
  41733. UGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH38dq6SZeWYp34+hInDEW
  41734. +j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lEHoSTGEq0n+USZGnQJoViAbbJAh2+g1G7
  41735. XNr4rRVqmfeSVPc0W+m/6imBEtRTkZazkVrd/pBzKPswRrXKCAfHcXLJZtM0l/aM9BhK4dA9WkW2
  41736. aacp+yPOiNgSnABIqKYPszuSjXEOdMWLyEz59JuOuDxp7W87UC9Y7cSw0BwbagzivESq2M0UXZR4
  41737. Yb8ObtoqvC8MC3GmsxY/nOb5zJ9TNeIDoKAYv7vxvvTWjIcNQvcGufFt7QSUqP620wbGQGHfnZ3z
  41738. VHbOUzoBppJB7ASjjw2i1QnK1sua8e9DXcCrpUHPXFNwcMmIpi3Ua2FzUCaGYQ5fG8Ir4ozVu53B
  41739. A0K6lNpfqbDKzE0K70dpAy8i+/Eozr9dUGWokG2zdLAIx6yo0es+nPxdGoMuK8u180SdOqcXYZai
  41740. cdNwlhVNt0xz7hlcxVs+Qf6sdWA7G2POAN3aCJBitOUt7kinaxeZVL6HSuOpXgRM6xBtVNbv8ejy
  41741. YhbLgGvtPe31HzClrkvJE+2KAQHJuFFYwGY6sWZLxNUxAmLpdIQM201GLQIDAQABo0IwQDAdBgNV
  41742. HQ4EFgQU0p+I36HNLL3s9TsBAZMzJ7LrYEswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMB
  41743. Af8wDQYJKoZIhvcNAQEMBQADggIBADLKgLOdPVQG3dLSLvCkASELZ0jKbY7gyKoNqo0hV4/GPnrK
  41744. 21HUUrPUloSlWGB/5QuOH/XcChWB5Tu2tyIvCZwTFrFsDDUIbatjcu3cvuzHV+YwIHHW1xDBE1UB
  41745. jCpD5EHxzzp6U5LOogMFDTjfArsQLtk70pt6wKGm+LUx5vR1yblTmXVHIloUFcd4G7ad6Qz4G3bx
  41746. hYTeodoS76TiEJd6eN4MUZeoIUCLhr0N8F5OSza7OyAfikJW4Qsav3vQIkMsRIz75Sq0bBwcupTg
  41747. E34h5prCy8VCZLQelHsIJchxzIdFV4XTnyliIoNRlwAYl3dqmJLJfGBs32x9SuRwTMKeuB330DTH
  41748. D8z7p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8piKCk5XQ
  41749. A76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLRLBT/DShycpWbXgnbiUSY
  41750. qqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oG
  41751. I/hGoiLtk/bdmuYqh7GYVPEi92tF4+KOdh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmg
  41752. kpzNNIaRkPpkUZ3+/uul9XXeifdy
  41753. -----END CERTIFICATE-----
  41754. AC RAIZ FNMT-RCM SERVIDORES SEGUROS
  41755. ===================================
  41756. -----BEGIN CERTIFICATE-----
  41757. MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQswCQYDVQQGEwJF
  41758. UzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgwFgYDVQRhDA9WQVRFUy1RMjgy
  41759. NjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1SQ00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4
  41760. MTIyMDA5MzczM1oXDTQzMTIyMDA5MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQt
  41761. UkNNMQ4wDAYDVQQLDAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNB
  41762. QyBSQUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  41763. BPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LHsbI6GA60XYyzZl2hNPk2
  41764. LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oKUm8BA06Oi6NCMEAwDwYDVR0TAQH/BAUw
  41765. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFAG5L++/EYZg8k/QQW6rcx/n0m5JMAoGCCqG
  41766. SM49BAMDA2kAMGYCMQCuSuMrQMN0EfKVrRYj3k4MGuZdpSRea0R7/DjiT8ucRRcRTBQnJlU5dUoD
  41767. zBOQn5ICMQD6SmxgiHPz7riYYqnOK8LZiqZwMR2vsJRM60/G49HzYqc8/5MuB1xJAWdpEgJyv+c=
  41768. -----END CERTIFICATE-----
  41769. GlobalSign Root R46
  41770. ===================
  41771. -----BEGIN CERTIFICATE-----
  41772. MIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUAMEYxCzAJBgNV
  41773. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJv
  41774. b3QgUjQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAX
  41775. BgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBSNDYwggIi
  41776. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCsrHQy6LNl5brtQyYdpokNRbopiLKkHWPd08Es
  41777. CVeJOaFV6Wc0dwxu5FUdUiXSE2te4R2pt32JMl8Nnp8semNgQB+msLZ4j5lUlghYruQGvGIFAha/
  41778. r6gjA7aUD7xubMLL1aa7DOn2wQL7Id5m3RerdELv8HQvJfTqa1VbkNud316HCkD7rRlr+/fKYIje
  41779. 2sGP1q7Vf9Q8g+7XFkyDRTNrJ9CG0Bwta/OrffGFqfUo0q3v84RLHIf8E6M6cqJaESvWJ3En7YEt
  41780. bWaBkoe0G1h6zD8K+kZPTXhc+CtI4wSEy132tGqzZfxCnlEmIyDLPRT5ge1lFgBPGmSXZgjPjHvj
  41781. K8Cd+RTyG/FWaha/LIWFzXg4mutCagI0GIMXTpRW+LaCtfOW3T3zvn8gdz57GSNrLNRyc0NXfeD4
  41782. 12lPFzYE+cCQYDdF3uYM2HSNrpyibXRdQr4G9dlkbgIQrImwTDsHTUB+JMWKmIJ5jqSngiCNI/on
  41783. ccnfxkF0oE32kRbcRoxfKWMxWXEM2G/CtjJ9++ZdU6Z+Ffy7dXxd7Pj2Fxzsx2sZy/N78CsHpdls
  41784. eVR2bJ0cpm4O6XkMqCNqo98bMDGfsVR7/mrLZqrcZdCinkqaByFrgY/bxFn63iLABJzjqls2k+g9
  41785. vXqhnQt2sQvHnf3PmKgGwvgqo6GDoLclcqUC4wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYD
  41786. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA1yrc4GHqMywptWU4jaWSf8FmSwwDQYJKoZIhvcNAQEM
  41787. BQADggIBAHx47PYCLLtbfpIrXTncvtgdokIzTfnvpCo7RGkerNlFo048p9gkUbJUHJNOxO97k4Vg
  41788. JuoJSOD1u8fpaNK7ajFxzHmuEajwmf3lH7wvqMxX63bEIaZHU1VNaL8FpO7XJqti2kM3S+LGteWy
  41789. gxk6x9PbTZ4IevPuzz5i+6zoYMzRx6Fcg0XERczzF2sUyQQCPtIkpnnpHs6i58FZFZ8d4kuaPp92
  41790. CC1r2LpXFNqD6v6MVenQTqnMdzGxRBF6XLE+0xRFFRhiJBPSy03OXIPBNvIQtQ6IbbjhVp+J3pZm
  41791. OUdkLG5NrmJ7v2B0GbhWrJKsFjLtrWhV/pi60zTe9Mlhww6G9kuEYO4Ne7UyWHmRVSyBQ7N0H3qq
  41792. JZ4d16GLuc1CLgSkZoNNiTW2bKg2SnkheCLQQrzRQDGQob4Ez8pn7fXwgNNgyYMqIgXQBztSvwye
  41793. qiv5u+YfjyW6hY0XHgL+XVAEV8/+LbzvXMAaq7afJMbfc2hIkCwU9D9SGuTSyxTDYWnP4vkYxboz
  41794. nxSjBF25cfe1lNj2M8FawTSLfJvdkzrnE6JwYZ+vj+vYxXX4M2bUdGc6N3ec592kD3ZDZopD8p/7
  41795. DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3vouXsXgxT7PntgMTzlSdriVZzH81Xwj3
  41796. QEUxeCp6
  41797. -----END CERTIFICATE-----
  41798. GlobalSign Root E46
  41799. ===================
  41800. -----BEGIN CERTIFICATE-----
  41801. MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYxCzAJBgNVBAYT
  41802. AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQDExNHbG9iYWxTaWduIFJvb3Qg
  41803. RTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNV
  41804. BAoTEEdsb2JhbFNpZ24gbnYtc2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcq
  41805. hkjOPQIBBgUrgQQAIgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkB
  41806. jtjqR+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGddyXqBPCCj
  41807. QjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBQxCpCPtsad0kRL
  41808. gLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZk
  41809. vLtoURMMA/cVi4RguYv/Uo7njLwcAjA8+RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+
  41810. CAezNIm8BZ/3Hobui3A=
  41811. -----END CERTIFICATE-----
  41812. GLOBALTRUST 2020
  41813. ================
  41814. -----BEGIN CERTIFICATE-----
  41815. MIIFgjCCA2qgAwIBAgILWku9WvtPilv6ZeUwDQYJKoZIhvcNAQELBQAwTTELMAkGA1UEBhMCQVQx
  41816. IzAhBgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVT
  41817. VCAyMDIwMB4XDTIwMDIxMDAwMDAwMFoXDTQwMDYxMDAwMDAwMFowTTELMAkGA1UEBhMCQVQxIzAh
  41818. BgNVBAoTGmUtY29tbWVyY2UgbW9uaXRvcmluZyBHbWJIMRkwFwYDVQQDExBHTE9CQUxUUlVTVCAy
  41819. MDIwMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAri5WrRsc7/aVj6B3GyvTY4+ETUWi
  41820. D59bRatZe1E0+eyLinjF3WuvvcTfk0Uev5E4C64OFudBc/jbu9G4UeDLgztzOG53ig9ZYybNpyrO
  41821. VPu44sB8R85gfD+yc/LAGbaKkoc1DZAoouQVBGM+uq/ufF7MpotQsjj3QWPKzv9pj2gOlTblzLmM
  41822. CcpL3TGQlsjMH/1WljTbjhzqLL6FLmPdqqmV0/0plRPwyJiT2S0WR5ARg6I6IqIoV6Lr/sCMKKCm
  41823. fecqQjuCgGOlYx8ZzHyyZqjC0203b+J+BlHZRYQfEs4kUmSFC0iAToexIiIwquuuvuAC4EDosEKA
  41824. A1GqtH6qRNdDYfOiaxaJSaSjpCuKAsR49GiKweR6NrFvG5Ybd0mN1MkGco/PU+PcF4UgStyYJ9OR
  41825. JitHHmkHr96i5OTUawuzXnzUJIBHKWk7buis/UDr2O1xcSvy6Fgd60GXIsUf1DnQJ4+H4xj04KlG
  41826. DfV0OoIu0G4skaMxXDtG6nsEEFZegB31pWXogvziB4xiRfUg3kZwhqG8k9MedKZssCz3AwyIDMvU
  41827. clOGvGBG85hqwvG/Q/lwIHfKN0F5VVJjjVsSn8VoxIidrPIwq7ejMZdnrY8XD2zHc+0klGvIg5rQ
  41828. mjdJBKuxFshsSUktq6HQjJLyQUp5ISXbY9e2nKd+Qmn7OmMCAwEAAaNjMGEwDwYDVR0TAQH/BAUw
  41829. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFNwuH9FhN3nkq9XVsxJxaD1qaJwiMB8GA1Ud
  41830. IwQYMBaAFNwuH9FhN3nkq9XVsxJxaD1qaJwiMA0GCSqGSIb3DQEBCwUAA4ICAQCR8EICaEDuw2jA
  41831. VC/f7GLDw56KoDEoqoOOpFaWEhCGVrqXctJUMHytGdUdaG/7FELYjQ7ztdGl4wJCXtzoRlgHNQIw
  41832. 4Lx0SsFDKv/bGtCwr2zD/cuz9X9tAy5ZVp0tLTWMstZDFyySCstd6IwPS3BD0IL/qMy/pJTAvoe9
  41833. iuOTe8aPmxadJ2W8esVCgmxcB9CpwYhgROmYhRZf+I/KARDOJcP5YBugxZfD0yyIMaK9MOzQ0MAS
  41834. 8cE54+X1+NZK3TTN+2/BT+MAi1bikvcoskJ3ciNnxz8RFbLEAwW+uxF7Cr+obuf/WEPPm2eggAe2
  41835. HcqtbepBEX4tdJP7wry+UUTF72glJ4DjyKDUEuzZpTcdN3y0kcra1LGWge9oXHYQSa9+pTeAsRxS
  41836. vTOBTI/53WXZFM2KJVj04sWDpQmQ1GwUY7VA3+vA/MRYfg0UFodUJ25W5HCEuGwyEn6CMUO+1918
  41837. oa2u1qsgEu8KwxCMSZY13At1XrFP1U80DhEgB3VDRemjEdqso5nCtnkn4rnvyOL2NSl6dPrFf4IF
  41838. YqYK6miyeUcGbvJXqBUzxvd4Sj1Ce2t+/vdG6tHrju+IaFvowdlxfv1k7/9nR4hYJS8+hge9+6jl
  41839. gqispdNpQ80xiEmEU5LAsTkbOYMBMMTyqfrQA71yN2BWHzZ8vTmR9W0Nv3vXkg==
  41840. -----END CERTIFICATE-----
  41841. ANF Secure Server Root CA
  41842. =========================
  41843. -----BEGIN CERTIFICATE-----
  41844. MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNVBAUTCUc2MzI4
  41845. NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lv
  41846. bjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNVBAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3Qg
  41847. Q0EwHhcNMTkwOTA0MTAwMDM4WhcNMzkwODMwMTAwMDM4WjCBhDESMBAGA1UEBRMJRzYzMjg3NTEw
  41848. MQswCQYDVQQGEwJFUzEnMCUGA1UEChMeQU5GIEF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uMRQw
  41849. EgYDVQQLEwtBTkYgQ0EgUmFpejEiMCAGA1UEAxMZQU5GIFNlY3VyZSBTZXJ2ZXIgUm9vdCBDQTCC
  41850. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANvrayvmZFSVgpCjcqQZAZ2cC4Ffc0m6p6zz
  41851. BE57lgvsEeBbphzOG9INgxwruJ4dfkUyYA8H6XdYfp9qyGFOtibBTI3/TO80sh9l2Ll49a2pcbnv
  41852. T1gdpd50IJeh7WhM3pIXS7yr/2WanvtH2Vdy8wmhrnZEE26cLUQ5vPnHO6RYPUG9tMJJo8gN0pcv
  41853. B2VSAKduyK9o7PQUlrZXH1bDOZ8rbeTzPvY1ZNoMHKGESy9LS+IsJJ1tk0DrtSOOMspvRdOoiXse
  41854. zx76W0OLzc2oD2rKDF65nkeP8Nm2CgtYZRczuSPkdxl9y0oukntPLxB3sY0vaJxizOBQ+OyRp1RM
  41855. VwnVdmPF6GUe7m1qzwmd+nxPrWAI/VaZDxUse6mAq4xhj0oHdkLePfTdsiQzW7i1o0TJrH93PB0j
  41856. 7IKppuLIBkwC/qxcmZkLLxCKpvR/1Yd0DVlJRfbwcVw5Kda/SiOL9V8BY9KHcyi1Swr1+KuCLH5z
  41857. JTIdC2MKF4EA/7Z2Xue0sUDKIbvVgFHlSFJnLNJhiQcND85Cd8BEc5xEUKDbEAotlRyBr+Qc5RQe
  41858. 8TZBAQIvfXOn3kLMTOmJDVb3n5HUA8ZsyY/b2BzgQJhdZpmYgG4t/wHFzstGH6wCxkPmrqKEPMVO
  41859. Hj1tyRRM4y5Bu8o5vzY8KhmqQYdOpc5LMnndkEl/AgMBAAGjYzBhMB8GA1UdIwQYMBaAFJxf0Gxj
  41860. o1+TypOYCK2Mh6UsXME3MB0GA1UdDgQWBBScX9BsY6Nfk8qTmAitjIelLFzBNzAOBgNVHQ8BAf8E
  41861. BAMCAYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEATh65isagmD9uw2nAalxJ
  41862. UqzLK114OMHVVISfk/CHGT0sZonrDUL8zPB1hT+L9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzx
  41863. j6ptBZNscsdW699QIyjlRRA96Gejrw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDt
  41864. dD+4E5UGUcjohybKpFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM
  41865. 5gf0vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjqOknkJjCb
  41866. 5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ/zo1PqVUSlJZS2Db7v54
  41867. EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ92zg/LFis6ELhDtjTO0wugumDLmsx2d1H
  41868. hk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI+PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGy
  41869. g77FGr8H6lnco4g175x2MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3
  41870. r5+qPeoott7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw=
  41871. -----END CERTIFICATE-----
  41872. Certum EC-384 CA
  41873. ================
  41874. -----BEGIN CERTIFICATE-----
  41875. MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQswCQYDVQQGEwJQ
  41876. TDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2Vy
  41877. dGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2
  41878. MDcyNDU0WhcNNDMwMzI2MDcyNDU0WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERh
  41879. dGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkx
  41880. GTAXBgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATEKI6rGFtq
  41881. vm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7TmFy8as10CW4kjPMIRBSqn
  41882. iBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68KjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  41883. VR0OBBYEFI0GZnQkdjrzife81r1HfS+8EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNo
  41884. ADBlAjADVS2m5hjEfO/JUG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0
  41885. QoSZ/6vnnvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k=
  41886. -----END CERTIFICATE-----
  41887. Certum Trusted Root CA
  41888. ======================
  41889. -----BEGIN CERTIFICATE-----
  41890. MIIFwDCCA6igAwIBAgIQHr9ZULjJgDdMBvfrVU+17TANBgkqhkiG9w0BAQ0FADB6MQswCQYDVQQG
  41891. EwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0g
  41892. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0Ew
  41893. HhcNMTgwMzE2MTIxMDEzWhcNNDMwMzE2MTIxMDEzWjB6MQswCQYDVQQGEwJQTDEhMB8GA1UEChMY
  41894. QXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBB
  41895. dXRob3JpdHkxHzAdBgNVBAMTFkNlcnR1bSBUcnVzdGVkIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEB
  41896. AQUAA4ICDwAwggIKAoICAQDRLY67tzbqbTeRn06TpwXkKQMlzhyC93yZn0EGze2jusDbCSzBfN8p
  41897. fktlL5On1AFrAygYo9idBcEq2EXxkd7fO9CAAozPOA/qp1x4EaTByIVcJdPTsuclzxFUl6s1wB52
  41898. HO8AU5853BSlLCIls3Jy/I2z5T4IHhQqNwuIPMqw9MjCoa68wb4pZ1Xi/K1ZXP69VyywkI3C7Te2
  41899. fJmItdUDmj0VDT06qKhF8JVOJVkdzZhpu9PMMsmN74H+rX2Ju7pgE8pllWeg8xn2A1bUatMn4qGt
  41900. g/BKEiJ3HAVz4hlxQsDsdUaakFjgao4rpUYwBI4Zshfjvqm6f1bxJAPXsiEodg42MEx51UGamqi4
  41901. NboMOvJEGyCI98Ul1z3G4z5D3Yf+xOr1Uz5MZf87Sst4WmsXXw3Hw09Omiqi7VdNIuJGmj8PkTQk
  41902. fVXjjJU30xrwCSss0smNtA0Aq2cpKNgB9RkEth2+dv5yXMSFytKAQd8FqKPVhJBPC/PgP5sZ0jeJ
  41903. P/J7UhyM9uH3PAeXjA6iWYEMspA90+NZRu0PqafegGtaqge2Gcu8V/OXIXoMsSt0Puvap2ctTMSY
  41904. njYJdmZm/Bo/6khUHL4wvYBQv3y1zgD2DGHZ5yQD4OMBgQ692IU0iL2yNqh7XAjlRICMb/gv1SHK
  41905. HRzQ+8S1h9E6Tsd2tTVItQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSM+xx1
  41906. vALTn04uSNn5YFSqxLNP+jAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQENBQADggIBAEii1QAL
  41907. LtA/vBzVtVRJHlpr9OTy4EA34MwUe7nJ+jW1dReTagVphZzNTxl4WxmB82M+w85bj/UvXgF2Ez8s
  41908. ALnNllI5SW0ETsXpD4YN4fqzX4IS8TrOZgYkNCvozMrnadyHncI013nR03e4qllY/p0m+jiGPp2K
  41909. h2RX5Rc64vmNueMzeMGQ2Ljdt4NR5MTMI9UGfOZR0800McD2RrsLrfw9EAUqO0qRJe6M1ISHgCq8
  41910. CYyqOhNf6DR5UMEQGfnTKB7U0VEwKbOukGfWHwpjscWpxkIxYxeU72nLL/qMFH3EQxiJ2fAyQOaA
  41911. 4kZf5ePBAFmo+eggvIksDkc0C+pXwlM2/KfUrzHN/gLldfq5Jwn58/U7yn2fqSLLiMmq0Uc9Nneo
  41912. WWRrJ8/vJ8HjJLWG965+Mk2weWjROeiQWMODvA8s1pfrzgzhIMfatz7DP78v3DSk+yshzWePS/Tj
  41913. 6tQ/50+6uaWTRRxmHyH6ZF5v4HaUMst19W7l9o/HuKTMqJZ9ZPskWkoDbGs4xugDQ5r3V7mzKWmT
  41914. OPQD8rv7gmsHINFSH5pkAnuYZttcTVoP0ISVoDwUQwbKytu4QTbaakRnh6+v40URFWkIsr4WOZck
  41915. bxJF0WddCajJFdr60qZfE2Efv4WstK2tBZQIgx51F9NxO5NQI1mg7TyRVJ12AMXDuDjb
  41916. -----END CERTIFICATE-----
  41917. TunTrust Root CA
  41918. ================
  41919. -----BEGIN CERTIFICATE-----
  41920. MIIFszCCA5ugAwIBAgIUEwLV4kBMkkaGFmddtLu7sms+/BMwDQYJKoZIhvcNAQELBQAwYTELMAkG
  41921. A1UEBhMCVE4xNzA1BgNVBAoMLkFnZW5jZSBOYXRpb25hbGUgZGUgQ2VydGlmaWNhdGlvbiBFbGVj
  41922. dHJvbmlxdWUxGTAXBgNVBAMMEFR1blRydXN0IFJvb3QgQ0EwHhcNMTkwNDI2MDg1NzU2WhcNNDQw
  41923. NDI2MDg1NzU2WjBhMQswCQYDVQQGEwJUTjE3MDUGA1UECgwuQWdlbmNlIE5hdGlvbmFsZSBkZSBD
  41924. ZXJ0aWZpY2F0aW9uIEVsZWN0cm9uaXF1ZTEZMBcGA1UEAwwQVHVuVHJ1c3QgUm9vdCBDQTCCAiIw
  41925. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMPN0/y9BFPdDCA61YguBUtB9YOCfvdZn56eY+hz
  41926. 2vYGqU8ftPkLHzmMmiDQfgbU7DTZhrx1W4eI8NLZ1KMKsmwb60ksPqxd2JQDoOw05TDENX37Jk0b
  41927. bjBU2PWARZw5rZzJJQRNmpA+TkBuimvNKWfGzC3gdOgFVwpIUPp6Q9p+7FuaDmJ2/uqdHYVy7BG7
  41928. NegfJ7/Boce7SBbdVtfMTqDhuazb1YMZGoXRlJfXyqNlC/M4+QKu3fZnz8k/9YosRxqZbwUN/dAd
  41929. gjH8KcwAWJeRTIAAHDOFli/LQcKLEITDCSSJH7UP2dl3RxiSlGBcx5kDPP73lad9UKGAwqmDrViW
  41930. VSHbhlnUr8a83YFuB9tgYv7sEG7aaAH0gxupPqJbI9dkxt/con3YS7qC0lH4Zr8GRuR5KiY2eY8f
  41931. Tpkdso8MDhz/yV3A/ZAQprE38806JG60hZC/gLkMjNWb1sjxVj8agIl6qeIbMlEsPvLfe/ZdeikZ
  41932. juXIvTZxi11Mwh0/rViizz1wTaZQmCXcI/m4WEEIcb9PuISgjwBUFfyRbVinljvrS5YnzWuioYas
  41933. DXxU5mZMZl+QviGaAkYt5IPCgLnPSz7ofzwB7I9ezX/SKEIBlYrilz0QIX32nRzFNKHsLA4KUiwS
  41934. VXAkPcvCFDVDXSdOvsC9qnyW5/yeYa1E0wCXAgMBAAGjYzBhMB0GA1UdDgQWBBQGmpsfU33x9aTI
  41935. 04Y+oXNZtPdEITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFAaamx9TffH1pMjThj6hc1m0
  41936. 90QhMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAqgVutt0Vyb+zxiD2BkewhpMl
  41937. 0425yAA/l/VSJ4hxyXT968pk21vvHl26v9Hr7lxpuhbI87mP0zYuQEkHDVneixCwSQXi/5E/S7fd
  41938. Ao74gShczNxtr18UnH1YeA32gAm56Q6XKRm4t+v4FstVEuTGfbvE7Pi1HE4+Z7/FXxttbUcoqgRY
  41939. YdZ2vyJ/0Adqp2RT8JeNnYA/u8EH22Wv5psymsNUk8QcCMNE+3tjEUPRahphanltkE8pjkcFwRJp
  41940. adbGNjHh/PqAulxPxOu3Mqz4dWEX1xAZufHSCe96Qp1bWgvUxpVOKs7/B9dPfhgGiPEZtdmYu65x
  41941. xBzndFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5Xc0yGYuP
  41942. jCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7bnV2UqL1g52KAdoGDDIzM
  41943. MEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQCvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9z
  41944. ZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZHu/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3r
  41945. AZ3r2OvEhJn7wAzMMujjd9qDRIueVSjAi1jTkD5OGwDxFa2DK5o=
  41946. -----END CERTIFICATE-----
  41947. HARICA TLS RSA Root CA 2021
  41948. ===========================
  41949. -----BEGIN CERTIFICATE-----
  41950. MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQG
  41951. EwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  41952. cyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0EgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUz
  41953. OFoXDTQ1MDIxMzEwNTUzN1owbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRl
  41954. bWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNB
  41955. IFJvb3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569lmwVnlskN
  41956. JLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE4VGC/6zStGndLuwRo0Xu
  41957. a2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uva9of08WRiFukiZLRgeaMOVig1mlDqa2Y
  41958. Ulhu2wr7a89o+uOkXjpFc5gH6l8Cct4MpbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K
  41959. 5FrZx40d/JiZ+yykgmvwKh+OC19xXFyuQnspiYHLA6OZyoieC0AJQTPb5lh6/a6ZcMBaD9YThnEv
  41960. dmn8kN3bLW7R8pv1GmuebxWMevBLKKAiOIAkbDakO/IwkfN4E8/BPzWr8R0RI7VDIp4BkrcYAuUR
  41961. 0YLbFQDMYTfBKnya4dC6s1BG7oKsnTH4+yPiAwBIcKMJJnkVU2DzOFytOOqBAGMUuTNe3QvboEUH
  41962. GjMJ+E20pwKmafTCWQWIZYVWrkvL4N48fS0ayOn7H6NhStYqE613TBoYm5EPWNgGVMWX+Ko/IIqm
  41963. haZ39qb8HOLubpQzKoNQhArlT4b4UEV4AIHrW2jjJo3Me1xR9BQsQL4aYB16cmEdH2MtiKrOokWQ
  41964. CPxrvrNQKlr9qEgYRtaQQJKQCoReaDH46+0N0x3GfZkYVVYnZS6NRcUk7M7jAgMBAAGjQjBAMA8G
  41965. A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFApII6ZgpJIKM+qTW8VX6iVNvRLuMA4GA1UdDwEB/wQE
  41966. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAPpBIqm5iFSVmewzVjIuJndftTgfvnNAUX15QvWiWkKQU
  41967. EapobQk1OUAJ2vQJLDSle1mESSmXdMgHHkdt8s4cUCbjnj1AUz/3f5Z2EMVGpdAgS1D0NTsY9FVq
  41968. QRtHBmg8uwkIYtlfVUKqrFOFrJVWNlar5AWMxajaH6NpvVMPxP/cyuN+8kyIhkdGGvMA9YCRotxD
  41969. QpSbIPDRzbLrLFPCU3hKTwSUQZqPJzLB5UkZv/HywouoCjkxKLR9YjYsTewfM7Z+d21+UPCfDtcR
  41970. j88YxeMn/ibvBZ3PzzfF0HvaO7AWhAw6k9a+F9sPPg4ZeAnHqQJyIkv3N3a6dcSFA1pj1bF1BcK5
  41971. vZStjBWZp5N99sXzqnTPBIWUmAD04vnKJGW/4GKvyMX6ssmeVkjaef2WdhW+o45WxLM0/L5H9MG0
  41972. qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pTBGIBnfHAT+7hOtSLIBD6
  41973. Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79aPib8qXPMThcFarmlwDB31qlpzmq6YR/
  41974. PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YWxw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnn
  41975. kf3/W9b3raYvAwtt41dU63ZTGI0RmLo=
  41976. -----END CERTIFICATE-----
  41977. HARICA TLS ECC Root CA 2021
  41978. ===========================
  41979. -----BEGIN CERTIFICATE-----
  41980. MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQswCQYDVQQGEwJH
  41981. UjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBD
  41982. QTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9vdCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoX
  41983. DTQ1MDIxMzExMDEwOVowbDELMAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWlj
  41984. IGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJv
  41985. b3QgQ0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7KKrxcm1l
  41986. AEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9YSTHMmE5gEYd103KUkE+b
  41987. ECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW
  41988. 0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAi
  41989. rcJRQO9gcS3ujwLEXQNwSaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/Qw
  41990. CZ61IygNnxS2PFOiTAZpffpskcYqSUXm7LcT4Tps
  41991. -----END CERTIFICATE-----
  41992. <?php
  41993. namespace Composer\CaBundle;
  41994. use Psr\Log\LoggerInterface;
  41995. use Symfony\Component\Process\PhpProcess;
  41996. class CaBundle
  41997. {
  41998. private static $caPath;
  41999. private static $caFileValidity = array();
  42000. private static $useOpensslParse;
  42001. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  42002. {
  42003. if (self::$caPath !== null) {
  42004. return self::$caPath;
  42005. }
  42006. $caBundlePaths = array();
  42007. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  42008. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  42009. $caBundlePaths[] = ini_get('openssl.cafile');
  42010. $caBundlePaths[] = ini_get('openssl.capath');
  42011. $otherLocations = array(
  42012. '/etc/pki/tls/certs/ca-bundle.crt',
  42013. '/etc/ssl/certs/ca-certificates.crt',
  42014. '/etc/ssl/ca-bundle.pem',
  42015. '/usr/local/share/certs/ca-root-nss.crt',
  42016. '/usr/ssl/certs/ca-bundle.crt',
  42017. '/opt/local/share/curl/curl-ca-bundle.crt',
  42018. '/usr/local/share/curl/curl-ca-bundle.crt',
  42019. '/usr/share/ssl/certs/ca-bundle.crt',
  42020. '/etc/ssl/cert.pem',
  42021. '/usr/local/etc/ssl/cert.pem',
  42022. '/usr/local/etc/openssl/cert.pem',
  42023. '/usr/local/etc/openssl@1.1/cert.pem',
  42024. );
  42025. foreach($otherLocations as $location) {
  42026. $otherLocations[] = dirname($location);
  42027. }
  42028. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  42029. foreach ($caBundlePaths as $caBundle) {
  42030. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  42031. return self::$caPath = $caBundle;
  42032. }
  42033. if ($caBundle && self::caDirUsable($caBundle, $logger)) {
  42034. return self::$caPath = $caBundle;
  42035. }
  42036. }
  42037. return self::$caPath = static::getBundledCaBundlePath();
  42038. }
  42039. public static function getBundledCaBundlePath()
  42040. {
  42041. $caBundleFile = __DIR__.'/../res/cacert.pem';
  42042. if (0 === strpos($caBundleFile, 'phar://')) {
  42043. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  42044. if (false === $tempCaBundleFile) {
  42045. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  42046. }
  42047. file_put_contents(
  42048. $tempCaBundleFile,
  42049. file_get_contents($caBundleFile)
  42050. );
  42051. register_shutdown_function(function() use ($tempCaBundleFile) {
  42052. @unlink($tempCaBundleFile);
  42053. });
  42054. $caBundleFile = $tempCaBundleFile;
  42055. }
  42056. return $caBundleFile;
  42057. }
  42058. public static function validateCaFile($filename, LoggerInterface $logger = null)
  42059. {
  42060. static $warned = false;
  42061. if (isset(self::$caFileValidity[$filename])) {
  42062. return self::$caFileValidity[$filename];
  42063. }
  42064. $contents = file_get_contents($filename);
  42065. if (!static::isOpensslParseSafe()) {
  42066. if (!$warned && $logger) {
  42067. $logger->warning(sprintf(
  42068. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  42069. PHP_VERSION
  42070. ));
  42071. $warned = true;
  42072. }
  42073. $isValid = !empty($contents);
  42074. } elseif (is_string($contents) && strlen($contents) > 0) {
  42075. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  42076. if (null === $contents) {
  42077. $isValid = false;
  42078. } else {
  42079. $isValid = (bool) openssl_x509_parse($contents);
  42080. }
  42081. } else {
  42082. $isValid = false;
  42083. }
  42084. if ($logger) {
  42085. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  42086. }
  42087. return self::$caFileValidity[$filename] = $isValid;
  42088. }
  42089. public static function isOpensslParseSafe()
  42090. {
  42091. if (null !== self::$useOpensslParse) {
  42092. return self::$useOpensslParse;
  42093. }
  42094. if (PHP_VERSION_ID >= 50600) {
  42095. return self::$useOpensslParse = true;
  42096. }
  42097. if (
  42098. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  42099. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  42100. || PHP_VERSION_ID >= 50507
  42101. ) {
  42102. return self::$useOpensslParse = true;
  42103. }
  42104. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  42105. return self::$useOpensslParse = false;
  42106. }
  42107. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  42108. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  42109. if (preg_match($regex, PHP_VERSION, $m)) {
  42110. return ((int) $m[1]) >= $fixedVersion;
  42111. }
  42112. return false;
  42113. };
  42114. if (
  42115. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  42116. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  42117. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  42118. ) {
  42119. return self::$useOpensslParse = true;
  42120. }
  42121. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  42122. return self::$useOpensslParse = false;
  42123. }
  42124. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  42125. $script = <<<'EOT'
  42126. error_reporting(-1);
  42127. $info = openssl_x509_parse(base64_decode('%s'));
  42128. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  42129. EOT;
  42130. $script = '<'."?php\n".sprintf($script, $cert);
  42131. try {
  42132. $process = new PhpProcess($script);
  42133. $process->mustRun();
  42134. } catch (\Exception $e) {
  42135. return self::$useOpensslParse = false;
  42136. }
  42137. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  42138. $errorOutput = trim($process->getErrorOutput());
  42139. if (
  42140. is_array($output)
  42141. && count($output) === 3
  42142. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  42143. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  42144. && $output[2] === 'int(-1)'
  42145. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  42146. ) {
  42147. return self::$useOpensslParse = true;
  42148. }
  42149. return self::$useOpensslParse = false;
  42150. }
  42151. public static function reset()
  42152. {
  42153. self::$caFileValidity = array();
  42154. self::$caPath = null;
  42155. self::$useOpensslParse = null;
  42156. }
  42157. private static function getEnvVariable($name)
  42158. {
  42159. if (isset($_SERVER[$name])) {
  42160. return (string) $_SERVER[$name];
  42161. }
  42162. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  42163. return (string) $value;
  42164. }
  42165. return false;
  42166. }
  42167. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  42168. {
  42169. return $certFile
  42170. && static::isFile($certFile, $logger)
  42171. && static::isReadable($certFile, $logger)
  42172. && static::validateCaFile($certFile, $logger);
  42173. }
  42174. private static function caDirUsable($certDir, LoggerInterface $logger = null)
  42175. {
  42176. return $certDir
  42177. && static::isDir($certDir, $logger)
  42178. && static::isReadable($certDir, $logger)
  42179. && static::glob($certDir . '/*', $logger);
  42180. }
  42181. private static function isFile($certFile, LoggerInterface $logger = null)
  42182. {
  42183. $isFile = @is_file($certFile);
  42184. if (!$isFile && $logger) {
  42185. $logger->debug(sprintf('Checked CA file %s does not exist or it is not a file.', $certFile));
  42186. }
  42187. return $isFile;
  42188. }
  42189. private static function isDir($certDir, LoggerInterface $logger = null)
  42190. {
  42191. $isDir = @is_dir($certDir);
  42192. if (!$isDir && $logger) {
  42193. $logger->debug(sprintf('Checked directory %s does not exist or it is not a directory.', $certDir));
  42194. }
  42195. return $isDir;
  42196. }
  42197. private static function isReadable($certFileOrDir, LoggerInterface $logger = null)
  42198. {
  42199. $isReadable = @is_readable($certFileOrDir);
  42200. if (!$isReadable && $logger) {
  42201. $logger->debug(sprintf('Checked file or directory %s is not readable.', $certFileOrDir));
  42202. }
  42203. return $isReadable;
  42204. }
  42205. private static function glob($pattern, LoggerInterface $logger = null)
  42206. {
  42207. $certs = glob($pattern);
  42208. if ($certs === false) {
  42209. if ($logger) {
  42210. $logger->debug(sprintf("An error occurred while trying to find certificates for pattern: %s", $pattern));
  42211. }
  42212. return false;
  42213. }
  42214. if (count($certs) === 0) {
  42215. if ($logger) {
  42216. $logger->debug(sprintf("No CA files found for pattern: %s", $pattern));
  42217. }
  42218. return false;
  42219. }
  42220. return true;
  42221. }
  42222. }
  42223. <?php return array(
  42224. 'root' => array(
  42225. 'pretty_version' => '2.2.6',
  42226. 'version' => '2.2.6.0',
  42227. 'type' => 'library',
  42228. 'install_path' => __DIR__ . '/../../',
  42229. 'aliases' => array(),
  42230. 'reference' => 'ce785a18c0fb472421e52d958bab339247cb0e82',
  42231. 'name' => 'composer/composer',
  42232. 'dev' => false,
  42233. ),
  42234. 'versions' => array(
  42235. 'composer/ca-bundle' => array(
  42236. 'pretty_version' => '1.3.1',
  42237. 'version' => '1.3.1.0',
  42238. 'type' => 'library',
  42239. 'install_path' => __DIR__ . '/./ca-bundle',
  42240. 'aliases' => array(),
  42241. 'reference' => '4c679186f2aca4ab6a0f1b0b9cf9252decb44d0b',
  42242. 'dev_requirement' => false,
  42243. ),
  42244. 'composer/composer' => array(
  42245. 'pretty_version' => '2.2.6',
  42246. 'version' => '2.2.6.0',
  42247. 'type' => 'library',
  42248. 'install_path' => __DIR__ . '/../../',
  42249. 'aliases' => array(),
  42250. 'reference' => 'ce785a18c0fb472421e52d958bab339247cb0e82',
  42251. 'dev_requirement' => false,
  42252. ),
  42253. 'composer/metadata-minifier' => array(
  42254. 'pretty_version' => '1.0.0',
  42255. 'version' => '1.0.0.0',
  42256. 'type' => 'library',
  42257. 'install_path' => __DIR__ . '/./metadata-minifier',
  42258. 'aliases' => array(),
  42259. 'reference' => 'c549d23829536f0d0e984aaabbf02af91f443207',
  42260. 'dev_requirement' => false,
  42261. ),
  42262. 'composer/pcre' => array(
  42263. 'pretty_version' => '1.0.1',
  42264. 'version' => '1.0.1.0',
  42265. 'type' => 'library',
  42266. 'install_path' => __DIR__ . '/./pcre',
  42267. 'aliases' => array(),
  42268. 'reference' => '67a32d7d6f9f560b726ab25a061b38ff3a80c560',
  42269. 'dev_requirement' => false,
  42270. ),
  42271. 'composer/semver' => array(
  42272. 'pretty_version' => '3.2.9',
  42273. 'version' => '3.2.9.0',
  42274. 'type' => 'library',
  42275. 'install_path' => __DIR__ . '/./semver',
  42276. 'aliases' => array(),
  42277. 'reference' => 'a951f614bd64dcd26137bc9b7b2637ddcfc57649',
  42278. 'dev_requirement' => false,
  42279. ),
  42280. 'composer/spdx-licenses' => array(
  42281. 'pretty_version' => '1.5.6',
  42282. 'version' => '1.5.6.0',
  42283. 'type' => 'library',
  42284. 'install_path' => __DIR__ . '/./spdx-licenses',
  42285. 'aliases' => array(),
  42286. 'reference' => 'a30d487169d799745ca7280bc90fdfa693536901',
  42287. 'dev_requirement' => false,
  42288. ),
  42289. 'composer/xdebug-handler' => array(
  42290. 'pretty_version' => '2.0.4',
  42291. 'version' => '2.0.4.0',
  42292. 'type' => 'library',
  42293. 'install_path' => __DIR__ . '/./xdebug-handler',
  42294. 'aliases' => array(),
  42295. 'reference' => '0c1a3925ec58a4ec98e992b9c7d171e9e184be0a',
  42296. 'dev_requirement' => false,
  42297. ),
  42298. 'justinrainbow/json-schema' => array(
  42299. 'pretty_version' => '5.2.11',
  42300. 'version' => '5.2.11.0',
  42301. 'type' => 'library',
  42302. 'install_path' => __DIR__ . '/../justinrainbow/json-schema',
  42303. 'aliases' => array(),
  42304. 'reference' => '2ab6744b7296ded80f8cc4f9509abbff393399aa',
  42305. 'dev_requirement' => false,
  42306. ),
  42307. 'psr/log' => array(
  42308. 'pretty_version' => '1.1.4',
  42309. 'version' => '1.1.4.0',
  42310. 'type' => 'library',
  42311. 'install_path' => __DIR__ . '/../psr/log',
  42312. 'aliases' => array(),
  42313. 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
  42314. 'dev_requirement' => false,
  42315. ),
  42316. 'react/promise' => array(
  42317. 'pretty_version' => 'v1.2.1',
  42318. 'version' => '1.2.1.0',
  42319. 'type' => 'library',
  42320. 'install_path' => __DIR__ . '/../react/promise',
  42321. 'aliases' => array(),
  42322. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  42323. 'dev_requirement' => false,
  42324. ),
  42325. 'seld/jsonlint' => array(
  42326. 'pretty_version' => '1.8.3',
  42327. 'version' => '1.8.3.0',
  42328. 'type' => 'library',
  42329. 'install_path' => __DIR__ . '/../seld/jsonlint',
  42330. 'aliases' => array(),
  42331. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  42332. 'dev_requirement' => false,
  42333. ),
  42334. 'seld/phar-utils' => array(
  42335. 'pretty_version' => '1.2.0',
  42336. 'version' => '1.2.0.0',
  42337. 'type' => 'library',
  42338. 'install_path' => __DIR__ . '/../seld/phar-utils',
  42339. 'aliases' => array(),
  42340. 'reference' => '9f3452c93ff423469c0d56450431562ca423dcee',
  42341. 'dev_requirement' => false,
  42342. ),
  42343. 'symfony/console' => array(
  42344. 'pretty_version' => 'v2.8.52',
  42345. 'version' => '2.8.52.0',
  42346. 'type' => 'library',
  42347. 'install_path' => __DIR__ . '/../symfony/console',
  42348. 'aliases' => array(),
  42349. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  42350. 'dev_requirement' => false,
  42351. ),
  42352. 'symfony/debug' => array(
  42353. 'pretty_version' => 'v2.8.52',
  42354. 'version' => '2.8.52.0',
  42355. 'type' => 'library',
  42356. 'install_path' => __DIR__ . '/../symfony/debug',
  42357. 'aliases' => array(),
  42358. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  42359. 'dev_requirement' => false,
  42360. ),
  42361. 'symfony/filesystem' => array(
  42362. 'pretty_version' => 'v2.8.52',
  42363. 'version' => '2.8.52.0',
  42364. 'type' => 'library',
  42365. 'install_path' => __DIR__ . '/../symfony/filesystem',
  42366. 'aliases' => array(),
  42367. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  42368. 'dev_requirement' => false,
  42369. ),
  42370. 'symfony/finder' => array(
  42371. 'pretty_version' => 'v2.8.52',
  42372. 'version' => '2.8.52.0',
  42373. 'type' => 'library',
  42374. 'install_path' => __DIR__ . '/../symfony/finder',
  42375. 'aliases' => array(),
  42376. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  42377. 'dev_requirement' => false,
  42378. ),
  42379. 'symfony/polyfill-ctype' => array(
  42380. 'pretty_version' => 'v1.19.0',
  42381. 'version' => '1.19.0.0',
  42382. 'type' => 'library',
  42383. 'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
  42384. 'aliases' => array(),
  42385. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  42386. 'dev_requirement' => false,
  42387. ),
  42388. 'symfony/polyfill-mbstring' => array(
  42389. 'pretty_version' => 'v1.19.0',
  42390. 'version' => '1.19.0.0',
  42391. 'type' => 'library',
  42392. 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
  42393. 'aliases' => array(),
  42394. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  42395. 'dev_requirement' => false,
  42396. ),
  42397. 'symfony/process' => array(
  42398. 'pretty_version' => 'v2.8.52',
  42399. 'version' => '2.8.52.0',
  42400. 'type' => 'library',
  42401. 'install_path' => __DIR__ . '/../symfony/process',
  42402. 'aliases' => array(),
  42403. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  42404. 'dev_requirement' => false,
  42405. ),
  42406. ),
  42407. );
  42408. Copyright (C) 2021 Composer
  42409. Permission is hereby granted, free of charge, to any person obtaining a copy of
  42410. this software and associated documentation files (the "Software"), to deal in
  42411. the Software without restriction, including without limitation the rights to
  42412. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  42413. of the Software, and to permit persons to whom the Software is furnished to do
  42414. so, subject to the following conditions:
  42415. The above copyright notice and this permission notice shall be included in all
  42416. copies or substantial portions of the Software.
  42417. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42418. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42419. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42420. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42421. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42422. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42423. SOFTWARE.
  42424. <?php
  42425. namespace Composer\MetadataMinifier;
  42426. class MetadataMinifier
  42427. {
  42428. public static function expand(array $versions)
  42429. {
  42430. $expanded = array();
  42431. $expandedVersion = null;
  42432. foreach ($versions as $versionData) {
  42433. if (!$expandedVersion) {
  42434. $expandedVersion = $versionData;
  42435. $expanded[] = $expandedVersion;
  42436. continue;
  42437. }
  42438. foreach ($versionData as $key => $val) {
  42439. if ($val === '__unset') {
  42440. unset($expandedVersion[$key]);
  42441. } else {
  42442. $expandedVersion[$key] = $val;
  42443. }
  42444. }
  42445. $expanded[] = $expandedVersion;
  42446. }
  42447. return $expanded;
  42448. }
  42449. public static function minify(array $versions)
  42450. {
  42451. $minifiedVersions = array();
  42452. $lastKnownVersionData = null;
  42453. foreach ($versions as $version) {
  42454. if (!$lastKnownVersionData) {
  42455. $lastKnownVersionData = $version;
  42456. $minifiedVersions[] = $version;
  42457. continue;
  42458. }
  42459. $minifiedVersion = array();
  42460. foreach ($version as $key => $val) {
  42461. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  42462. $minifiedVersion[$key] = $val;
  42463. $lastKnownVersionData[$key] = $val;
  42464. }
  42465. }
  42466. foreach ($lastKnownVersionData as $key => $val) {
  42467. if (!isset($version[$key])) {
  42468. $minifiedVersion[$key] = "__unset";
  42469. unset($lastKnownVersionData[$key]);
  42470. }
  42471. }
  42472. $minifiedVersions[] = $minifiedVersion;
  42473. }
  42474. return $minifiedVersions;
  42475. }
  42476. }
  42477. Copyright (C) 2021 Composer
  42478. Permission is hereby granted, free of charge, to any person obtaining a copy of
  42479. this software and associated documentation files (the "Software"), to deal in
  42480. the Software without restriction, including without limitation the rights to
  42481. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  42482. of the Software, and to permit persons to whom the Software is furnished to do
  42483. so, subject to the following conditions:
  42484. The above copyright notice and this permission notice shall be included in all
  42485. copies or substantial portions of the Software.
  42486. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42487. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42488. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42489. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42490. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42491. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42492. SOFTWARE.
  42493. <?php
  42494. namespace Composer\Pcre;
  42495. final class MatchAllResult
  42496. {
  42497. public $matches;
  42498. public $count;
  42499. public $matched;
  42500. public function __construct($count, array $matches)
  42501. {
  42502. $this->matches = $matches;
  42503. $this->matched = (bool) $count;
  42504. $this->count = $count;
  42505. }
  42506. }
  42507. <?php
  42508. namespace Composer\Pcre;
  42509. final class MatchAllWithOffsetsResult
  42510. {
  42511. public $matches;
  42512. public $count;
  42513. public $matched;
  42514. public function __construct($count, array $matches)
  42515. {
  42516. $this->matches = $matches;
  42517. $this->matched = (bool) $count;
  42518. $this->count = $count;
  42519. }
  42520. }
  42521. <?php
  42522. namespace Composer\Pcre;
  42523. final class MatchResult
  42524. {
  42525. public $matches;
  42526. public $matched;
  42527. public function __construct($count, array $matches)
  42528. {
  42529. $this->matches = $matches;
  42530. $this->matched = (bool) $count;
  42531. }
  42532. }
  42533. <?php
  42534. namespace Composer\Pcre;
  42535. final class MatchWithOffsetsResult
  42536. {
  42537. public $matches;
  42538. public $matched;
  42539. public function __construct($count, array $matches)
  42540. {
  42541. $this->matches = $matches;
  42542. $this->matched = (bool) $count;
  42543. }
  42544. }
  42545. <?php
  42546. namespace Composer\Pcre;
  42547. class PcreException extends \RuntimeException
  42548. {
  42549. public static function fromFunction($function, $pattern)
  42550. {
  42551. $code = preg_last_error();
  42552. if (is_array($pattern)) {
  42553. $pattern = implode(', ', $pattern);
  42554. }
  42555. return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code);
  42556. }
  42557. private static function pcreLastErrorMessage($code)
  42558. {
  42559. if (PHP_VERSION_ID >= 80000) {
  42560. return preg_last_error_msg();
  42561. }
  42562. if (PHP_VERSION_ID < 70201 && $code === 0) {
  42563. return 'UNDEFINED_ERROR';
  42564. }
  42565. $constants = get_defined_constants(true);
  42566. if (!isset($constants['pcre'])) {
  42567. return 'UNDEFINED_ERROR';
  42568. }
  42569. foreach ($constants['pcre'] as $const => $val) {
  42570. if ($val === $code && substr($const, -6) === '_ERROR') {
  42571. return $const;
  42572. }
  42573. }
  42574. return 'UNDEFINED_ERROR';
  42575. }
  42576. }
  42577. <?php
  42578. namespace Composer\Pcre;
  42579. class Preg
  42580. {
  42581. const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.';
  42582. public static function match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
  42583. {
  42584. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  42585. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchWithOffsets() instead');
  42586. }
  42587. $result = preg_match($pattern, $subject, $matches, $flags, $offset);
  42588. if ($result === false) {
  42589. throw PcreException::fromFunction('preg_match', $pattern);
  42590. }
  42591. return $result;
  42592. }
  42593. public static function matchWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
  42594. {
  42595. $result = preg_match($pattern, $subject, $matches, $flags | PREG_OFFSET_CAPTURE, $offset);
  42596. if ($result === false) {
  42597. throw PcreException::fromFunction('preg_match', $pattern);
  42598. }
  42599. return $result;
  42600. }
  42601. public static function matchAll($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
  42602. {
  42603. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  42604. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use matchAllWithOffsets() instead');
  42605. }
  42606. if (($flags & PREG_SET_ORDER) !== 0) {
  42607. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches');
  42608. }
  42609. $result = preg_match_all($pattern, $subject, $matches, $flags, $offset);
  42610. if ($result === false || $result === null) {
  42611. throw PcreException::fromFunction('preg_match_all', $pattern);
  42612. }
  42613. return $result;
  42614. }
  42615. public static function matchAllWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
  42616. {
  42617. $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_OFFSET_CAPTURE, $offset);
  42618. if ($result === false || $result === null) {
  42619. throw PcreException::fromFunction('preg_match_all', $pattern);
  42620. }
  42621. return $result;
  42622. }
  42623. public static function replace($pattern, $replacement, $subject, $limit = -1, &$count = null)
  42624. {
  42625. if (is_array($subject)) {
  42626. throw new \InvalidArgumentException(static::ARRAY_MSG);
  42627. }
  42628. $result = preg_replace($pattern, $replacement, $subject, $limit, $count);
  42629. if ($result === null) {
  42630. throw PcreException::fromFunction('preg_replace', $pattern);
  42631. }
  42632. return $result;
  42633. }
  42634. public static function replaceCallback($pattern, $replacement, $subject, $limit = -1, &$count = null, $flags = 0)
  42635. {
  42636. if (is_array($subject)) {
  42637. throw new \InvalidArgumentException(static::ARRAY_MSG);
  42638. }
  42639. if (PHP_VERSION_ID >= 70400) {
  42640. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags);
  42641. } else {
  42642. $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count);
  42643. }
  42644. if ($result === null) {
  42645. throw PcreException::fromFunction('preg_replace_callback', $pattern);
  42646. }
  42647. return $result;
  42648. }
  42649. public static function replaceCallbackArray(array $pattern, $subject, $limit = -1, &$count = null, $flags = 0)
  42650. {
  42651. if (is_array($subject)) {
  42652. throw new \InvalidArgumentException(static::ARRAY_MSG);
  42653. }
  42654. if (PHP_VERSION_ID >= 70400) {
  42655. $result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags);
  42656. } else {
  42657. $result = preg_replace_callback_array($pattern, $subject, $limit, $count);
  42658. }
  42659. if ($result === null) {
  42660. $pattern = array_keys($pattern);
  42661. throw PcreException::fromFunction('preg_replace_callback_array', $pattern);
  42662. }
  42663. return $result;
  42664. }
  42665. public static function split($pattern, $subject, $limit = -1, $flags = 0)
  42666. {
  42667. if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) {
  42668. throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead');
  42669. }
  42670. $result = preg_split($pattern, $subject, $limit, $flags);
  42671. if ($result === false) {
  42672. throw PcreException::fromFunction('preg_split', $pattern);
  42673. }
  42674. return $result;
  42675. }
  42676. public static function splitWithOffsets($pattern, $subject, $limit = -1, $flags = 0)
  42677. {
  42678. $result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE);
  42679. if ($result === false) {
  42680. throw PcreException::fromFunction('preg_split', $pattern);
  42681. }
  42682. return $result;
  42683. }
  42684. public static function grep($pattern, array $array, $flags = 0)
  42685. {
  42686. $result = preg_grep($pattern, $array, $flags);
  42687. if ($result === false) {
  42688. throw PcreException::fromFunction('preg_grep', $pattern);
  42689. }
  42690. return $result;
  42691. }
  42692. public static function isMatch($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
  42693. {
  42694. return (bool) static::match($pattern, $subject, $matches, $flags, $offset);
  42695. }
  42696. public static function isMatchAll($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
  42697. {
  42698. return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset);
  42699. }
  42700. public static function isMatchWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
  42701. {
  42702. return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  42703. }
  42704. public static function isMatchAllWithOffsets($pattern, $subject, &$matches, $flags = 0, $offset = 0)
  42705. {
  42706. return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  42707. }
  42708. }
  42709. <?php
  42710. namespace Composer\Pcre;
  42711. class Regex
  42712. {
  42713. public static function isMatch($pattern, $subject, $offset = 0)
  42714. {
  42715. return (bool) Preg::match($pattern, $subject, $matches, 0, $offset);
  42716. }
  42717. public static function match($pattern, $subject, $flags = 0, $offset = 0)
  42718. {
  42719. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  42720. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchWithOffsets() instead');
  42721. }
  42722. $count = Preg::match($pattern, $subject, $matches, $flags, $offset);
  42723. return new MatchResult($count, $matches);
  42724. }
  42725. public static function matchWithOffsets($pattern, $subject, $flags = 0, $offset = 0)
  42726. {
  42727. $count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset);
  42728. return new MatchWithOffsetsResult($count, $matches);
  42729. }
  42730. public static function matchAll($pattern, $subject, $flags = 0, $offset = 0)
  42731. {
  42732. if (($flags & PREG_OFFSET_CAPTURE) !== 0) {
  42733. throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use matchAllWithOffsets() instead');
  42734. }
  42735. if (($flags & PREG_SET_ORDER) !== 0) {
  42736. throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type');
  42737. }
  42738. $count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset);
  42739. return new MatchAllResult($count, $matches);
  42740. }
  42741. public static function matchAllWithOffsets($pattern, $subject, $flags = 0, $offset = 0)
  42742. {
  42743. $count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset);
  42744. return new MatchAllWithOffsetsResult($count, $matches);
  42745. }
  42746. public static function replace($pattern, $replacement, $subject, $limit = -1)
  42747. {
  42748. $result = Preg::replace($pattern, $replacement, $subject, $limit, $count);
  42749. return new ReplaceResult($count, $result);
  42750. }
  42751. public static function replaceCallback($pattern, $replacement, $subject, $limit = -1, $flags = 0)
  42752. {
  42753. $result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags);
  42754. return new ReplaceResult($count, $result);
  42755. }
  42756. public static function replaceCallbackArray($pattern, $subject, $limit = -1, $flags = 0)
  42757. {
  42758. $result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags);
  42759. return new ReplaceResult($count, $result);
  42760. }
  42761. }
  42762. <?php
  42763. namespace Composer\Pcre;
  42764. final class ReplaceResult
  42765. {
  42766. public $result;
  42767. public $count;
  42768. public $matched;
  42769. public function __construct($count, $result)
  42770. {
  42771. $this->count = $count;
  42772. $this->matched = (bool) $count;
  42773. $this->result = $result;
  42774. }
  42775. }
  42776. Copyright (C) 2015 Composer
  42777. Permission is hereby granted, free of charge, to any person obtaining a copy of
  42778. this software and associated documentation files (the "Software"), to deal in
  42779. the Software without restriction, including without limitation the rights to
  42780. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  42781. of the Software, and to permit persons to whom the Software is furnished to do
  42782. so, subject to the following conditions:
  42783. The above copyright notice and this permission notice shall be included in all
  42784. copies or substantial portions of the Software.
  42785. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42786. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42787. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42788. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42789. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42790. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42791. SOFTWARE.
  42792. <?php
  42793. namespace Composer\Semver;
  42794. use Composer\Semver\Constraint\Constraint;
  42795. class Comparator
  42796. {
  42797. public static function greaterThan($version1, $version2)
  42798. {
  42799. return self::compare($version1, '>', $version2);
  42800. }
  42801. public static function greaterThanOrEqualTo($version1, $version2)
  42802. {
  42803. return self::compare($version1, '>=', $version2);
  42804. }
  42805. public static function lessThan($version1, $version2)
  42806. {
  42807. return self::compare($version1, '<', $version2);
  42808. }
  42809. public static function lessThanOrEqualTo($version1, $version2)
  42810. {
  42811. return self::compare($version1, '<=', $version2);
  42812. }
  42813. public static function equalTo($version1, $version2)
  42814. {
  42815. return self::compare($version1, '==', $version2);
  42816. }
  42817. public static function notEqualTo($version1, $version2)
  42818. {
  42819. return self::compare($version1, '!=', $version2);
  42820. }
  42821. public static function compare($version1, $operator, $version2)
  42822. {
  42823. $constraint = new Constraint($operator, $version2);
  42824. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  42825. }
  42826. }
  42827. <?php
  42828. namespace Composer\Semver;
  42829. use Composer\Semver\Constraint\Constraint;
  42830. use Composer\Semver\Constraint\ConstraintInterface;
  42831. class CompilingMatcher
  42832. {
  42833. private static $compiledCheckerCache = array();
  42834. private static $enabled;
  42835. private static $transOpInt = array(
  42836. Constraint::OP_EQ => Constraint::STR_OP_EQ,
  42837. Constraint::OP_LT => Constraint::STR_OP_LT,
  42838. Constraint::OP_LE => Constraint::STR_OP_LE,
  42839. Constraint::OP_GT => Constraint::STR_OP_GT,
  42840. Constraint::OP_GE => Constraint::STR_OP_GE,
  42841. Constraint::OP_NE => Constraint::STR_OP_NE,
  42842. );
  42843. public static function match(ConstraintInterface $constraint, $operator, $version)
  42844. {
  42845. if (self::$enabled === null) {
  42846. self::$enabled = !\in_array('eval', explode(',', (string) ini_get('disable_functions')), true);
  42847. }
  42848. if (!self::$enabled) {
  42849. return $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  42850. }
  42851. $cacheKey = $operator.$constraint;
  42852. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  42853. $code = $constraint->compile($operator);
  42854. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  42855. } else {
  42856. $function = self::$compiledCheckerCache[$cacheKey];
  42857. }
  42858. return $function($version, strpos($version, 'dev-') === 0);
  42859. }
  42860. }
  42861. <?php
  42862. namespace Composer\Semver\Constraint;
  42863. class Bound
  42864. {
  42865. private $version;
  42866. private $isInclusive;
  42867. public function __construct($version, $isInclusive)
  42868. {
  42869. $this->version = $version;
  42870. $this->isInclusive = $isInclusive;
  42871. }
  42872. public function getVersion()
  42873. {
  42874. return $this->version;
  42875. }
  42876. public function isInclusive()
  42877. {
  42878. return $this->isInclusive;
  42879. }
  42880. public function isZero()
  42881. {
  42882. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  42883. }
  42884. public function isPositiveInfinity()
  42885. {
  42886. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  42887. }
  42888. public function compareTo(Bound $other, $operator)
  42889. {
  42890. if (!\in_array($operator, array('<', '>'), true)) {
  42891. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  42892. }
  42893. if ($this == $other) {
  42894. return false;
  42895. }
  42896. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  42897. if (0 !== $compareResult) {
  42898. return (('>' === $operator) ? 1 : -1) === $compareResult;
  42899. }
  42900. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  42901. }
  42902. public function __toString()
  42903. {
  42904. return sprintf(
  42905. '%s [%s]',
  42906. $this->getVersion(),
  42907. $this->isInclusive() ? 'inclusive' : 'exclusive'
  42908. );
  42909. }
  42910. public static function zero()
  42911. {
  42912. return new Bound('0.0.0.0-dev', true);
  42913. }
  42914. public static function positiveInfinity()
  42915. {
  42916. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  42917. }
  42918. }
  42919. <?php
  42920. namespace Composer\Semver\Constraint;
  42921. class Constraint implements ConstraintInterface
  42922. {
  42923. const OP_EQ = 0;
  42924. const OP_LT = 1;
  42925. const OP_LE = 2;
  42926. const OP_GT = 3;
  42927. const OP_GE = 4;
  42928. const OP_NE = 5;
  42929. const STR_OP_EQ = '==';
  42930. const STR_OP_EQ_ALT = '=';
  42931. const STR_OP_LT = '<';
  42932. const STR_OP_LE = '<=';
  42933. const STR_OP_GT = '>';
  42934. const STR_OP_GE = '>=';
  42935. const STR_OP_NE = '!=';
  42936. const STR_OP_NE_ALT = '<>';
  42937. private static $transOpStr = array(
  42938. '=' => self::OP_EQ,
  42939. '==' => self::OP_EQ,
  42940. '<' => self::OP_LT,
  42941. '<=' => self::OP_LE,
  42942. '>' => self::OP_GT,
  42943. '>=' => self::OP_GE,
  42944. '<>' => self::OP_NE,
  42945. '!=' => self::OP_NE,
  42946. );
  42947. private static $transOpInt = array(
  42948. self::OP_EQ => '==',
  42949. self::OP_LT => '<',
  42950. self::OP_LE => '<=',
  42951. self::OP_GT => '>',
  42952. self::OP_GE => '>=',
  42953. self::OP_NE => '!=',
  42954. );
  42955. protected $operator;
  42956. protected $version;
  42957. protected $prettyString;
  42958. protected $lowerBound;
  42959. protected $upperBound;
  42960. public function __construct($operator, $version)
  42961. {
  42962. if (!isset(self::$transOpStr[$operator])) {
  42963. throw new \InvalidArgumentException(sprintf(
  42964. 'Invalid operator "%s" given, expected one of: %s',
  42965. $operator,
  42966. implode(', ', self::getSupportedOperators())
  42967. ));
  42968. }
  42969. $this->operator = self::$transOpStr[$operator];
  42970. $this->version = $version;
  42971. }
  42972. public function getVersion()
  42973. {
  42974. return $this->version;
  42975. }
  42976. public function getOperator()
  42977. {
  42978. return self::$transOpInt[$this->operator];
  42979. }
  42980. public function matches(ConstraintInterface $provider)
  42981. {
  42982. if ($provider instanceof self) {
  42983. return $this->matchSpecific($provider);
  42984. }
  42985. return $provider->matches($this);
  42986. }
  42987. public function setPrettyString($prettyString)
  42988. {
  42989. $this->prettyString = $prettyString;
  42990. }
  42991. public function getPrettyString()
  42992. {
  42993. if ($this->prettyString) {
  42994. return $this->prettyString;
  42995. }
  42996. return $this->__toString();
  42997. }
  42998. public static function getSupportedOperators()
  42999. {
  43000. return array_keys(self::$transOpStr);
  43001. }
  43002. public static function getOperatorConstant($operator)
  43003. {
  43004. return self::$transOpStr[$operator];
  43005. }
  43006. public function versionCompare($a, $b, $operator, $compareBranches = false)
  43007. {
  43008. if (!isset(self::$transOpStr[$operator])) {
  43009. throw new \InvalidArgumentException(sprintf(
  43010. 'Invalid operator "%s" given, expected one of: %s',
  43011. $operator,
  43012. implode(', ', self::getSupportedOperators())
  43013. ));
  43014. }
  43015. $aIsBranch = strpos($a, 'dev-') === 0;
  43016. $bIsBranch = strpos($b, 'dev-') === 0;
  43017. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  43018. return $a !== $b;
  43019. }
  43020. if ($aIsBranch && $bIsBranch) {
  43021. return $operator === '==' && $a === $b;
  43022. }
  43023. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  43024. return false;
  43025. }
  43026. return \version_compare($a, $b, $operator);
  43027. }
  43028. public function compile($otherOperator)
  43029. {
  43030. if (strpos($this->version, 'dev-') === 0) {
  43031. if (self::OP_EQ === $this->operator) {
  43032. if (self::OP_EQ === $otherOperator) {
  43033. return sprintf('$b && $v === %s', \var_export($this->version, true));
  43034. }
  43035. if (self::OP_NE === $otherOperator) {
  43036. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  43037. }
  43038. return 'false';
  43039. }
  43040. if (self::OP_NE === $this->operator) {
  43041. if (self::OP_EQ === $otherOperator) {
  43042. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  43043. }
  43044. if (self::OP_NE === $otherOperator) {
  43045. return 'true';
  43046. }
  43047. return '!$b';
  43048. }
  43049. return 'false';
  43050. }
  43051. if (self::OP_EQ === $this->operator) {
  43052. if (self::OP_EQ === $otherOperator) {
  43053. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  43054. }
  43055. if (self::OP_NE === $otherOperator) {
  43056. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  43057. }
  43058. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  43059. }
  43060. if (self::OP_NE === $this->operator) {
  43061. if (self::OP_EQ === $otherOperator) {
  43062. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  43063. }
  43064. if (self::OP_NE === $otherOperator) {
  43065. return 'true';
  43066. }
  43067. return '!$b';
  43068. }
  43069. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  43070. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  43071. return '!$b';
  43072. }
  43073. } else {
  43074. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  43075. return '!$b';
  43076. }
  43077. }
  43078. if (self::OP_NE === $otherOperator) {
  43079. return 'true';
  43080. }
  43081. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  43082. if ($this->operator === self::OP_LE) {
  43083. if ($otherOperator === self::OP_GT) {
  43084. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  43085. }
  43086. } elseif ($this->operator === self::OP_GE) {
  43087. if ($otherOperator === self::OP_LT) {
  43088. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  43089. }
  43090. }
  43091. return sprintf('!$b && %s', $codeComparison);
  43092. }
  43093. public function matchSpecific(Constraint $provider, $compareBranches = false)
  43094. {
  43095. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  43096. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  43097. $isEqualOp = self::OP_EQ === $this->operator;
  43098. $isNonEqualOp = self::OP_NE === $this->operator;
  43099. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  43100. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  43101. if ($isNonEqualOp || $isProviderNonEqualOp) {
  43102. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  43103. return false;
  43104. }
  43105. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  43106. return false;
  43107. }
  43108. if (!$isEqualOp && !$isProviderEqualOp) {
  43109. return true;
  43110. }
  43111. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  43112. }
  43113. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  43114. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  43115. }
  43116. $version1 = $isEqualOp ? $this->version : $provider->version;
  43117. $version2 = $isEqualOp ? $provider->version : $this->version;
  43118. $operator = $isEqualOp ? $provider->operator : $this->operator;
  43119. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  43120. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  43121. && self::$transOpInt[$this->operator] !== $noEqualOp
  43122. && \version_compare($provider->version, $this->version, '=='));
  43123. }
  43124. return false;
  43125. }
  43126. public function __toString()
  43127. {
  43128. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  43129. }
  43130. public function getLowerBound()
  43131. {
  43132. $this->extractBounds();
  43133. return $this->lowerBound;
  43134. }
  43135. public function getUpperBound()
  43136. {
  43137. $this->extractBounds();
  43138. return $this->upperBound;
  43139. }
  43140. private function extractBounds()
  43141. {
  43142. if (null !== $this->lowerBound) {
  43143. return;
  43144. }
  43145. if (strpos($this->version, 'dev-') === 0) {
  43146. $this->lowerBound = Bound::zero();
  43147. $this->upperBound = Bound::positiveInfinity();
  43148. return;
  43149. }
  43150. switch ($this->operator) {
  43151. case self::OP_EQ:
  43152. $this->lowerBound = new Bound($this->version, true);
  43153. $this->upperBound = new Bound($this->version, true);
  43154. break;
  43155. case self::OP_LT:
  43156. $this->lowerBound = Bound::zero();
  43157. $this->upperBound = new Bound($this->version, false);
  43158. break;
  43159. case self::OP_LE:
  43160. $this->lowerBound = Bound::zero();
  43161. $this->upperBound = new Bound($this->version, true);
  43162. break;
  43163. case self::OP_GT:
  43164. $this->lowerBound = new Bound($this->version, false);
  43165. $this->upperBound = Bound::positiveInfinity();
  43166. break;
  43167. case self::OP_GE:
  43168. $this->lowerBound = new Bound($this->version, true);
  43169. $this->upperBound = Bound::positiveInfinity();
  43170. break;
  43171. case self::OP_NE:
  43172. $this->lowerBound = Bound::zero();
  43173. $this->upperBound = Bound::positiveInfinity();
  43174. break;
  43175. }
  43176. }
  43177. }
  43178. <?php
  43179. namespace Composer\Semver\Constraint;
  43180. interface ConstraintInterface
  43181. {
  43182. public function matches(ConstraintInterface $provider);
  43183. public function compile($otherOperator);
  43184. public function getUpperBound();
  43185. public function getLowerBound();
  43186. public function getPrettyString();
  43187. public function setPrettyString($prettyString);
  43188. public function __toString();
  43189. }
  43190. <?php
  43191. namespace Composer\Semver\Constraint;
  43192. class MatchAllConstraint implements ConstraintInterface
  43193. {
  43194. protected $prettyString;
  43195. public function matches(ConstraintInterface $provider)
  43196. {
  43197. return true;
  43198. }
  43199. public function compile($otherOperator)
  43200. {
  43201. return 'true';
  43202. }
  43203. public function setPrettyString($prettyString)
  43204. {
  43205. $this->prettyString = $prettyString;
  43206. }
  43207. public function getPrettyString()
  43208. {
  43209. if ($this->prettyString) {
  43210. return $this->prettyString;
  43211. }
  43212. return (string) $this;
  43213. }
  43214. public function __toString()
  43215. {
  43216. return '*';
  43217. }
  43218. public function getUpperBound()
  43219. {
  43220. return Bound::positiveInfinity();
  43221. }
  43222. public function getLowerBound()
  43223. {
  43224. return Bound::zero();
  43225. }
  43226. }
  43227. <?php
  43228. namespace Composer\Semver\Constraint;
  43229. class MatchNoneConstraint implements ConstraintInterface
  43230. {
  43231. protected $prettyString;
  43232. public function matches(ConstraintInterface $provider)
  43233. {
  43234. return false;
  43235. }
  43236. public function compile($otherOperator)
  43237. {
  43238. return 'false';
  43239. }
  43240. public function setPrettyString($prettyString)
  43241. {
  43242. $this->prettyString = $prettyString;
  43243. }
  43244. public function getPrettyString()
  43245. {
  43246. if ($this->prettyString) {
  43247. return $this->prettyString;
  43248. }
  43249. return (string) $this;
  43250. }
  43251. public function __toString()
  43252. {
  43253. return '[]';
  43254. }
  43255. public function getUpperBound()
  43256. {
  43257. return new Bound('0.0.0.0-dev', false);
  43258. }
  43259. public function getLowerBound()
  43260. {
  43261. return new Bound('0.0.0.0-dev', false);
  43262. }
  43263. }
  43264. <?php
  43265. namespace Composer\Semver\Constraint;
  43266. class MultiConstraint implements ConstraintInterface
  43267. {
  43268. protected $constraints;
  43269. protected $prettyString;
  43270. protected $string;
  43271. protected $conjunctive;
  43272. protected $lowerBound;
  43273. protected $upperBound;
  43274. public function __construct(array $constraints, $conjunctive = true)
  43275. {
  43276. if (\count($constraints) < 2) {
  43277. throw new \InvalidArgumentException(
  43278. 'Must provide at least two constraints for a MultiConstraint. Use '.
  43279. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  43280. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  43281. );
  43282. }
  43283. $this->constraints = $constraints;
  43284. $this->conjunctive = $conjunctive;
  43285. }
  43286. public function getConstraints()
  43287. {
  43288. return $this->constraints;
  43289. }
  43290. public function isConjunctive()
  43291. {
  43292. return $this->conjunctive;
  43293. }
  43294. public function isDisjunctive()
  43295. {
  43296. return !$this->conjunctive;
  43297. }
  43298. public function compile($otherOperator)
  43299. {
  43300. $parts = array();
  43301. foreach ($this->constraints as $constraint) {
  43302. $code = $constraint->compile($otherOperator);
  43303. if ($code === 'true') {
  43304. if (!$this->conjunctive) {
  43305. return 'true';
  43306. }
  43307. } elseif ($code === 'false') {
  43308. if ($this->conjunctive) {
  43309. return 'false';
  43310. }
  43311. } else {
  43312. $parts[] = '('.$code.')';
  43313. }
  43314. }
  43315. if (!$parts) {
  43316. return $this->conjunctive ? 'true' : 'false';
  43317. }
  43318. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  43319. }
  43320. public function matches(ConstraintInterface $provider)
  43321. {
  43322. if (false === $this->conjunctive) {
  43323. foreach ($this->constraints as $constraint) {
  43324. if ($provider->matches($constraint)) {
  43325. return true;
  43326. }
  43327. }
  43328. return false;
  43329. }
  43330. if ($provider instanceof MultiConstraint && $provider->isDisjunctive()) {
  43331. return $provider->matches($this);
  43332. }
  43333. foreach ($this->constraints as $constraint) {
  43334. if (!$provider->matches($constraint)) {
  43335. return false;
  43336. }
  43337. }
  43338. return true;
  43339. }
  43340. public function setPrettyString($prettyString)
  43341. {
  43342. $this->prettyString = $prettyString;
  43343. }
  43344. public function getPrettyString()
  43345. {
  43346. if ($this->prettyString) {
  43347. return $this->prettyString;
  43348. }
  43349. return (string) $this;
  43350. }
  43351. public function __toString()
  43352. {
  43353. if ($this->string !== null) {
  43354. return $this->string;
  43355. }
  43356. $constraints = array();
  43357. foreach ($this->constraints as $constraint) {
  43358. $constraints[] = (string) $constraint;
  43359. }
  43360. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  43361. }
  43362. public function getLowerBound()
  43363. {
  43364. $this->extractBounds();
  43365. if (null === $this->lowerBound) {
  43366. throw new \LogicException('extractBounds should have populated the lowerBound property');
  43367. }
  43368. return $this->lowerBound;
  43369. }
  43370. public function getUpperBound()
  43371. {
  43372. $this->extractBounds();
  43373. if (null === $this->upperBound) {
  43374. throw new \LogicException('extractBounds should have populated the upperBound property');
  43375. }
  43376. return $this->upperBound;
  43377. }
  43378. public static function create(array $constraints, $conjunctive = true)
  43379. {
  43380. if (0 === \count($constraints)) {
  43381. return new MatchAllConstraint();
  43382. }
  43383. if (1 === \count($constraints)) {
  43384. return $constraints[0];
  43385. }
  43386. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  43387. if ($optimized !== null) {
  43388. list($constraints, $conjunctive) = $optimized;
  43389. if (\count($constraints) === 1) {
  43390. return $constraints[0];
  43391. }
  43392. }
  43393. return new self($constraints, $conjunctive);
  43394. }
  43395. private static function optimizeConstraints(array $constraints, $conjunctive)
  43396. {
  43397. if (!$conjunctive) {
  43398. $left = $constraints[0];
  43399. $mergedConstraints = array();
  43400. $optimized = false;
  43401. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  43402. $right = $constraints[$i];
  43403. if (
  43404. $left instanceof self
  43405. && $left->conjunctive
  43406. && $right instanceof self
  43407. && $right->conjunctive
  43408. && \count($left->constraints) === 2
  43409. && \count($right->constraints) === 2
  43410. && ($left0 = (string) $left->constraints[0])
  43411. && $left0[0] === '>' && $left0[1] === '='
  43412. && ($left1 = (string) $left->constraints[1])
  43413. && $left1[0] === '<'
  43414. && ($right0 = (string) $right->constraints[0])
  43415. && $right0[0] === '>' && $right0[1] === '='
  43416. && ($right1 = (string) $right->constraints[1])
  43417. && $right1[0] === '<'
  43418. && substr($left1, 2) === substr($right0, 3)
  43419. ) {
  43420. $optimized = true;
  43421. $left = new MultiConstraint(
  43422. array(
  43423. $left->constraints[0],
  43424. $right->constraints[1],
  43425. ),
  43426. true);
  43427. } else {
  43428. $mergedConstraints[] = $left;
  43429. $left = $right;
  43430. }
  43431. }
  43432. if ($optimized) {
  43433. $mergedConstraints[] = $left;
  43434. return array($mergedConstraints, false);
  43435. }
  43436. }
  43437. return null;
  43438. }
  43439. private function extractBounds()
  43440. {
  43441. if (null !== $this->lowerBound) {
  43442. return;
  43443. }
  43444. foreach ($this->constraints as $constraint) {
  43445. if (null === $this->lowerBound || null === $this->upperBound) {
  43446. $this->lowerBound = $constraint->getLowerBound();
  43447. $this->upperBound = $constraint->getUpperBound();
  43448. continue;
  43449. }
  43450. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  43451. $this->lowerBound = $constraint->getLowerBound();
  43452. }
  43453. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  43454. $this->upperBound = $constraint->getUpperBound();
  43455. }
  43456. }
  43457. }
  43458. }
  43459. <?php
  43460. namespace Composer\Semver;
  43461. use Composer\Semver\Constraint\Constraint;
  43462. class Interval
  43463. {
  43464. private $start;
  43465. private $end;
  43466. public function __construct(Constraint $start, Constraint $end)
  43467. {
  43468. $this->start = $start;
  43469. $this->end = $end;
  43470. }
  43471. public function getStart()
  43472. {
  43473. return $this->start;
  43474. }
  43475. public function getEnd()
  43476. {
  43477. return $this->end;
  43478. }
  43479. public static function fromZero()
  43480. {
  43481. static $zero;
  43482. if (null === $zero) {
  43483. $zero = new Constraint('>=', '0.0.0.0-dev');
  43484. }
  43485. return $zero;
  43486. }
  43487. public static function untilPositiveInfinity()
  43488. {
  43489. static $positiveInfinity;
  43490. if (null === $positiveInfinity) {
  43491. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  43492. }
  43493. return $positiveInfinity;
  43494. }
  43495. public static function any()
  43496. {
  43497. return new self(self::fromZero(), self::untilPositiveInfinity());
  43498. }
  43499. public static function anyDev()
  43500. {
  43501. return array('names' => array(), 'exclude' => true);
  43502. }
  43503. public static function noDev()
  43504. {
  43505. return array('names' => array(), 'exclude' => false);
  43506. }
  43507. }
  43508. <?php
  43509. namespace Composer\Semver;
  43510. use Composer\Semver\Constraint\Constraint;
  43511. use Composer\Semver\Constraint\ConstraintInterface;
  43512. use Composer\Semver\Constraint\MatchAllConstraint;
  43513. use Composer\Semver\Constraint\MatchNoneConstraint;
  43514. use Composer\Semver\Constraint\MultiConstraint;
  43515. class Intervals
  43516. {
  43517. private static $intervalsCache = array();
  43518. private static $opSortOrder = array(
  43519. '>=' => -3,
  43520. '<' => -2,
  43521. '>' => 2,
  43522. '<=' => 3,
  43523. );
  43524. public static function clear()
  43525. {
  43526. self::$intervalsCache = array();
  43527. }
  43528. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  43529. {
  43530. if ($constraint instanceof MatchAllConstraint) {
  43531. return true;
  43532. }
  43533. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  43534. return false;
  43535. }
  43536. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  43537. $candidateIntervals = self::get($candidate);
  43538. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  43539. return false;
  43540. }
  43541. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  43542. if (!isset($candidateIntervals['numeric'][$index])) {
  43543. return false;
  43544. }
  43545. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  43546. return false;
  43547. }
  43548. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  43549. return false;
  43550. }
  43551. }
  43552. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  43553. return false;
  43554. }
  43555. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  43556. return false;
  43557. }
  43558. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  43559. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  43560. return false;
  43561. }
  43562. }
  43563. return true;
  43564. }
  43565. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  43566. {
  43567. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  43568. return true;
  43569. }
  43570. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  43571. return false;
  43572. }
  43573. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  43574. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  43575. }
  43576. public static function compactConstraint(ConstraintInterface $constraint)
  43577. {
  43578. if (!$constraint instanceof MultiConstraint) {
  43579. return $constraint;
  43580. }
  43581. $intervals = self::generateIntervals($constraint);
  43582. $constraints = array();
  43583. $hasNumericMatchAll = false;
  43584. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  43585. $constraints[] = $intervals['numeric'][0]->getStart();
  43586. $hasNumericMatchAll = true;
  43587. } else {
  43588. $unEqualConstraints = array();
  43589. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  43590. $interval = $intervals['numeric'][$i];
  43591. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  43592. $nextInterval = $intervals['numeric'][$i+1];
  43593. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  43594. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  43595. $unEqualConstraints[] = $interval->getStart();
  43596. }
  43597. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  43598. continue;
  43599. }
  43600. }
  43601. if (\count($unEqualConstraints) > 0) {
  43602. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  43603. $unEqualConstraints[] = $interval->getEnd();
  43604. }
  43605. if (\count($unEqualConstraints) > 1) {
  43606. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  43607. } else {
  43608. $constraints[] = $unEqualConstraints[0];
  43609. }
  43610. $unEqualConstraints = array();
  43611. continue;
  43612. }
  43613. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  43614. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  43615. continue;
  43616. }
  43617. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  43618. $constraints[] = $interval->getEnd();
  43619. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  43620. $constraints[] = $interval->getStart();
  43621. } else {
  43622. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  43623. }
  43624. }
  43625. }
  43626. $devConstraints = array();
  43627. if (0 === \count($intervals['branches']['names'])) {
  43628. if ($intervals['branches']['exclude']) {
  43629. if ($hasNumericMatchAll) {
  43630. return new MatchAllConstraint;
  43631. }
  43632. }
  43633. } else {
  43634. foreach ($intervals['branches']['names'] as $branchName) {
  43635. if ($intervals['branches']['exclude']) {
  43636. $devConstraints[] = new Constraint('!=', $branchName);
  43637. } else {
  43638. $devConstraints[] = new Constraint('==', $branchName);
  43639. }
  43640. }
  43641. if ($intervals['branches']['exclude']) {
  43642. if (\count($constraints) > 1) {
  43643. return new MultiConstraint(array_merge(
  43644. array(new MultiConstraint($constraints, false)),
  43645. $devConstraints
  43646. ), true);
  43647. }
  43648. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  43649. if (\count($devConstraints) > 1) {
  43650. return new MultiConstraint($devConstraints, true);
  43651. }
  43652. return $devConstraints[0];
  43653. }
  43654. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  43655. }
  43656. $constraints = array_merge($constraints, $devConstraints);
  43657. }
  43658. if (\count($constraints) > 1) {
  43659. return new MultiConstraint($constraints, false);
  43660. }
  43661. if (\count($constraints) === 1) {
  43662. return $constraints[0];
  43663. }
  43664. return new MatchNoneConstraint;
  43665. }
  43666. public static function get(ConstraintInterface $constraint)
  43667. {
  43668. $key = (string) $constraint;
  43669. if (!isset(self::$intervalsCache[$key])) {
  43670. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  43671. }
  43672. return self::$intervalsCache[$key];
  43673. }
  43674. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  43675. {
  43676. if ($constraint instanceof MatchAllConstraint) {
  43677. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  43678. }
  43679. if ($constraint instanceof MatchNoneConstraint) {
  43680. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  43681. }
  43682. if ($constraint instanceof Constraint) {
  43683. return self::generateSingleConstraintIntervals($constraint);
  43684. }
  43685. if (!$constraint instanceof MultiConstraint) {
  43686. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  43687. }
  43688. $constraints = $constraint->getConstraints();
  43689. $numericGroups = array();
  43690. $constraintBranches = array();
  43691. foreach ($constraints as $c) {
  43692. $res = self::get($c);
  43693. $numericGroups[] = $res['numeric'];
  43694. $constraintBranches[] = $res['branches'];
  43695. }
  43696. if ($constraint->isDisjunctive()) {
  43697. $branches = Interval::noDev();
  43698. foreach ($constraintBranches as $b) {
  43699. if ($b['exclude']) {
  43700. if ($branches['exclude']) {
  43701. $branches['names'] = array_intersect($branches['names'], $b['names']);
  43702. } else {
  43703. $branches['exclude'] = true;
  43704. $branches['names'] = array_diff($b['names'], $branches['names']);
  43705. }
  43706. } else {
  43707. if ($branches['exclude']) {
  43708. $branches['names'] = array_diff($branches['names'], $b['names']);
  43709. } else {
  43710. $branches['names'] = array_merge($branches['names'], $b['names']);
  43711. }
  43712. }
  43713. }
  43714. } else {
  43715. $branches = Interval::anyDev();
  43716. foreach ($constraintBranches as $b) {
  43717. if ($b['exclude']) {
  43718. if ($branches['exclude']) {
  43719. $branches['names'] = array_merge($branches['names'], $b['names']);
  43720. } else {
  43721. $branches['names'] = array_diff($branches['names'], $b['names']);
  43722. }
  43723. } else {
  43724. if ($branches['exclude']) {
  43725. $branches['names'] = array_diff($b['names'], $branches['names']);
  43726. $branches['exclude'] = false;
  43727. } else {
  43728. $branches['names'] = array_intersect($branches['names'], $b['names']);
  43729. }
  43730. }
  43731. }
  43732. }
  43733. $branches['names'] = array_unique($branches['names']);
  43734. if (\count($numericGroups) === 1) {
  43735. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  43736. }
  43737. $borders = array();
  43738. foreach ($numericGroups as $group) {
  43739. foreach ($group as $interval) {
  43740. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  43741. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  43742. }
  43743. }
  43744. $opSortOrder = self::$opSortOrder;
  43745. usort($borders, function ($a, $b) use ($opSortOrder) {
  43746. $order = version_compare($a['version'], $b['version']);
  43747. if ($order === 0) {
  43748. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  43749. }
  43750. return $order;
  43751. });
  43752. $activeIntervals = 0;
  43753. $intervals = array();
  43754. $index = 0;
  43755. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  43756. $start = null;
  43757. foreach ($borders as $border) {
  43758. if ($border['side'] === 'start') {
  43759. $activeIntervals++;
  43760. } else {
  43761. $activeIntervals--;
  43762. }
  43763. if (!$start && $activeIntervals >= $activationThreshold) {
  43764. $start = new Constraint($border['operator'], $border['version']);
  43765. } elseif ($start && $activeIntervals < $activationThreshold) {
  43766. if (
  43767. version_compare($start->getVersion(), $border['version'], '=')
  43768. && (
  43769. ($start->getOperator() === '>' && $border['operator'] === '<=')
  43770. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  43771. )
  43772. ) {
  43773. unset($intervals[$index]);
  43774. } else {
  43775. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  43776. $index++;
  43777. if ($stopOnFirstValidInterval) {
  43778. break;
  43779. }
  43780. }
  43781. $start = null;
  43782. }
  43783. }
  43784. return array('numeric' => $intervals, 'branches' => $branches);
  43785. }
  43786. private static function generateSingleConstraintIntervals(Constraint $constraint)
  43787. {
  43788. $op = $constraint->getOperator();
  43789. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  43790. $intervals = array();
  43791. $branches = array('names' => array(), 'exclude' => false);
  43792. if ($op === '!=') {
  43793. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  43794. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  43795. } elseif ($op === '==') {
  43796. $branches['names'][] = $constraint->getVersion();
  43797. }
  43798. return array(
  43799. 'numeric' => $intervals,
  43800. 'branches' => $branches,
  43801. );
  43802. }
  43803. if ($op[0] === '>') {
  43804. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  43805. }
  43806. if ($op[0] === '<') {
  43807. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  43808. }
  43809. if ($op === '!=') {
  43810. return array('numeric' => array(
  43811. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  43812. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  43813. ), 'branches' => Interval::anyDev());
  43814. }
  43815. return array('numeric' => array(
  43816. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  43817. ), 'branches' => Interval::noDev());
  43818. }
  43819. }
  43820. <?php
  43821. namespace Composer\Semver;
  43822. use Composer\Semver\Constraint\Constraint;
  43823. class Semver
  43824. {
  43825. const SORT_ASC = 1;
  43826. const SORT_DESC = -1;
  43827. private static $versionParser;
  43828. public static function satisfies($version, $constraints)
  43829. {
  43830. if (null === self::$versionParser) {
  43831. self::$versionParser = new VersionParser();
  43832. }
  43833. $versionParser = self::$versionParser;
  43834. $provider = new Constraint('==', $versionParser->normalize($version));
  43835. $parsedConstraints = $versionParser->parseConstraints($constraints);
  43836. return $parsedConstraints->matches($provider);
  43837. }
  43838. public static function satisfiedBy(array $versions, $constraints)
  43839. {
  43840. $versions = array_filter($versions, function ($version) use ($constraints) {
  43841. return Semver::satisfies($version, $constraints);
  43842. });
  43843. return array_values($versions);
  43844. }
  43845. public static function sort(array $versions)
  43846. {
  43847. return self::usort($versions, self::SORT_ASC);
  43848. }
  43849. public static function rsort(array $versions)
  43850. {
  43851. return self::usort($versions, self::SORT_DESC);
  43852. }
  43853. private static function usort(array $versions, $direction)
  43854. {
  43855. if (null === self::$versionParser) {
  43856. self::$versionParser = new VersionParser();
  43857. }
  43858. $versionParser = self::$versionParser;
  43859. $normalized = array();
  43860. foreach ($versions as $key => $version) {
  43861. $normalizedVersion = $versionParser->normalize($version);
  43862. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  43863. $normalized[] = array($normalizedVersion, $key);
  43864. }
  43865. usort($normalized, function (array $left, array $right) use ($direction) {
  43866. if ($left[0] === $right[0]) {
  43867. return 0;
  43868. }
  43869. if (Comparator::lessThan($left[0], $right[0])) {
  43870. return -$direction;
  43871. }
  43872. return $direction;
  43873. });
  43874. $sorted = array();
  43875. foreach ($normalized as $item) {
  43876. $sorted[] = $versions[$item[1]];
  43877. }
  43878. return $sorted;
  43879. }
  43880. }
  43881. <?php
  43882. namespace Composer\Semver;
  43883. use Composer\Semver\Constraint\ConstraintInterface;
  43884. use Composer\Semver\Constraint\MatchAllConstraint;
  43885. use Composer\Semver\Constraint\MultiConstraint;
  43886. use Composer\Semver\Constraint\Constraint;
  43887. class VersionParser
  43888. {
  43889. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  43890. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  43891. public static function parseStability($version)
  43892. {
  43893. $version = (string) preg_replace('{#.+$}', '', $version);
  43894. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  43895. return 'dev';
  43896. }
  43897. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  43898. if (!empty($match[3])) {
  43899. return 'dev';
  43900. }
  43901. if (!empty($match[1])) {
  43902. if ('beta' === $match[1] || 'b' === $match[1]) {
  43903. return 'beta';
  43904. }
  43905. if ('alpha' === $match[1] || 'a' === $match[1]) {
  43906. return 'alpha';
  43907. }
  43908. if ('rc' === $match[1]) {
  43909. return 'RC';
  43910. }
  43911. }
  43912. return 'stable';
  43913. }
  43914. public static function normalizeStability($stability)
  43915. {
  43916. $stability = strtolower($stability);
  43917. return $stability === 'rc' ? 'RC' : $stability;
  43918. }
  43919. public function normalize($version, $fullVersion = null)
  43920. {
  43921. $version = trim($version);
  43922. $origVersion = $version;
  43923. if (null === $fullVersion) {
  43924. $fullVersion = $version;
  43925. }
  43926. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  43927. $version = $match[1];
  43928. }
  43929. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  43930. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  43931. }
  43932. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  43933. $version = 'dev-' . $version;
  43934. }
  43935. if (stripos($version, 'dev-') === 0) {
  43936. return 'dev-' . substr($version, 4);
  43937. }
  43938. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  43939. $version = $match[1];
  43940. }
  43941. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  43942. $version = $matches[1]
  43943. . (!empty($matches[2]) ? $matches[2] : '.0')
  43944. . (!empty($matches[3]) ? $matches[3] : '.0')
  43945. . (!empty($matches[4]) ? $matches[4] : '.0');
  43946. $index = 5;
  43947. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  43948. $version = preg_replace('{\D}', '.', $matches[1]);
  43949. $index = 2;
  43950. }
  43951. if (isset($index)) {
  43952. if (!empty($matches[$index])) {
  43953. if ('stable' === $matches[$index]) {
  43954. return $version;
  43955. }
  43956. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  43957. }
  43958. if (!empty($matches[$index + 2])) {
  43959. $version .= '-dev';
  43960. }
  43961. return $version;
  43962. }
  43963. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  43964. try {
  43965. $normalized = $this->normalizeBranch($match[1]);
  43966. if (strpos($normalized, 'dev-') === false) {
  43967. return $normalized;
  43968. }
  43969. } catch (\Exception $e) {
  43970. }
  43971. }
  43972. $extraMessage = '';
  43973. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  43974. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  43975. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  43976. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  43977. }
  43978. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  43979. }
  43980. public function parseNumericAliasPrefix($branch)
  43981. {
  43982. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  43983. return $matches['version'] . '.';
  43984. }
  43985. return false;
  43986. }
  43987. public function normalizeBranch($name)
  43988. {
  43989. $name = trim($name);
  43990. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  43991. $version = '';
  43992. for ($i = 1; $i < 5; ++$i) {
  43993. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  43994. }
  43995. return str_replace('x', '9999999', $version) . '-dev';
  43996. }
  43997. return 'dev-' . $name;
  43998. }
  43999. public function normalizeDefaultBranch($name)
  44000. {
  44001. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  44002. return '9999999-dev';
  44003. }
  44004. return $name;
  44005. }
  44006. public function parseConstraints($constraints)
  44007. {
  44008. $prettyConstraint = $constraints;
  44009. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  44010. if (false === $orConstraints) {
  44011. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  44012. }
  44013. $orGroups = array();
  44014. foreach ($orConstraints as $constraints) {
  44015. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  44016. if (false === $andConstraints) {
  44017. throw new \RuntimeException('Failed to preg_split string: '.$constraints);
  44018. }
  44019. if (\count($andConstraints) > 1) {
  44020. $constraintObjects = array();
  44021. foreach ($andConstraints as $constraint) {
  44022. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  44023. $constraintObjects[] = $parsedConstraint;
  44024. }
  44025. }
  44026. } else {
  44027. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  44028. }
  44029. if (1 === \count($constraintObjects)) {
  44030. $constraint = $constraintObjects[0];
  44031. } else {
  44032. $constraint = new MultiConstraint($constraintObjects);
  44033. }
  44034. $orGroups[] = $constraint;
  44035. }
  44036. $constraint = MultiConstraint::create($orGroups, false);
  44037. $constraint->setPrettyString($prettyConstraint);
  44038. return $constraint;
  44039. }
  44040. private function parseConstraint($constraint)
  44041. {
  44042. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  44043. $constraint = $match[1];
  44044. }
  44045. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  44046. $constraint = '' !== $match[1] ? $match[1] : '*';
  44047. if ($match[2] !== 'stable') {
  44048. $stabilityModifier = $match[2];
  44049. }
  44050. }
  44051. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  44052. $constraint = $match[1];
  44053. }
  44054. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  44055. if (!empty($match[1]) || !empty($match[2])) {
  44056. return array(new Constraint('>=', '0.0.0.0-dev'));
  44057. }
  44058. return array(new MatchAllConstraint());
  44059. }
  44060. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  44061. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  44062. if (strpos($constraint, '~>') === 0) {
  44063. throw new \UnexpectedValueException(
  44064. 'Could not parse version constraint ' . $constraint . ': ' .
  44065. 'Invalid operator "~>", you probably meant to use the "~" operator'
  44066. );
  44067. }
  44068. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  44069. $position = 4;
  44070. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  44071. $position = 3;
  44072. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  44073. $position = 2;
  44074. } else {
  44075. $position = 1;
  44076. }
  44077. if (!empty($matches[8])) {
  44078. $position++;
  44079. }
  44080. $stabilitySuffix = '';
  44081. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  44082. $stabilitySuffix .= '-dev';
  44083. }
  44084. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  44085. $lowerBound = new Constraint('>=', $lowVersion);
  44086. $highPosition = max(1, $position - 1);
  44087. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  44088. $upperBound = new Constraint('<', $highVersion);
  44089. return array(
  44090. $lowerBound,
  44091. $upperBound,
  44092. );
  44093. }
  44094. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  44095. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  44096. $position = 1;
  44097. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  44098. $position = 2;
  44099. } else {
  44100. $position = 3;
  44101. }
  44102. $stabilitySuffix = '';
  44103. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  44104. $stabilitySuffix .= '-dev';
  44105. }
  44106. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  44107. $lowerBound = new Constraint('>=', $lowVersion);
  44108. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  44109. $upperBound = new Constraint('<', $highVersion);
  44110. return array(
  44111. $lowerBound,
  44112. $upperBound,
  44113. );
  44114. }
  44115. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  44116. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  44117. $position = 3;
  44118. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  44119. $position = 2;
  44120. } else {
  44121. $position = 1;
  44122. }
  44123. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  44124. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  44125. if ($lowVersion === '0.0.0.0-dev') {
  44126. return array(new Constraint('<', $highVersion));
  44127. }
  44128. return array(
  44129. new Constraint('>=', $lowVersion),
  44130. new Constraint('<', $highVersion),
  44131. );
  44132. }
  44133. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  44134. $lowStabilitySuffix = '';
  44135. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  44136. $lowStabilitySuffix = '-dev';
  44137. }
  44138. $lowVersion = $this->normalize($matches['from']);
  44139. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  44140. $empty = function ($x) {
  44141. return ($x === 0 || $x === '0') ? false : empty($x);
  44142. };
  44143. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  44144. $highVersion = $this->normalize($matches['to']);
  44145. $upperBound = new Constraint('<=', $highVersion);
  44146. } else {
  44147. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  44148. $this->normalize($matches['to']);
  44149. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  44150. $upperBound = new Constraint('<', $highVersion);
  44151. }
  44152. return array(
  44153. $lowerBound,
  44154. $upperBound,
  44155. );
  44156. }
  44157. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  44158. try {
  44159. try {
  44160. $version = $this->normalize($matches[2]);
  44161. } catch (\UnexpectedValueException $e) {
  44162. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  44163. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  44164. } else {
  44165. throw $e;
  44166. }
  44167. }
  44168. $op = $matches[1] ?: '=';
  44169. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  44170. $version .= '-' . $stabilityModifier;
  44171. } elseif ('<' === $op || '>=' === $op) {
  44172. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  44173. if (strpos($matches[2], 'dev-') !== 0) {
  44174. $version .= '-dev';
  44175. }
  44176. }
  44177. }
  44178. return array(new Constraint($matches[1] ?: '=', $version));
  44179. } catch (\Exception $e) {
  44180. }
  44181. }
  44182. $message = 'Could not parse version constraint ' . $constraint;
  44183. if (isset($e)) {
  44184. $message .= ': ' . $e->getMessage();
  44185. }
  44186. throw new \UnexpectedValueException($message);
  44187. }
  44188. private function manipulateVersionString(array $matches, $position, $increment = 0, $pad = '0')
  44189. {
  44190. for ($i = 4; $i > 0; --$i) {
  44191. if ($i > $position) {
  44192. $matches[$i] = $pad;
  44193. } elseif ($i === $position && $increment) {
  44194. $matches[$i] += $increment;
  44195. if ($matches[$i] < 0) {
  44196. $matches[$i] = $pad;
  44197. --$position;
  44198. if ($i === 1) {
  44199. return null;
  44200. }
  44201. }
  44202. }
  44203. }
  44204. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  44205. }
  44206. private function expandStability($stability)
  44207. {
  44208. $stability = strtolower($stability);
  44209. switch ($stability) {
  44210. case 'a':
  44211. return 'alpha';
  44212. case 'b':
  44213. return 'beta';
  44214. case 'p':
  44215. case 'pl':
  44216. return 'patch';
  44217. case 'rc':
  44218. return 'RC';
  44219. default:
  44220. return $stability;
  44221. }
  44222. }
  44223. }
  44224. Copyright (C) 2015 Composer
  44225. Permission is hereby granted, free of charge, to any person obtaining a copy of
  44226. this software and associated documentation files (the "Software"), to deal in
  44227. the Software without restriction, including without limitation the rights to
  44228. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  44229. of the Software, and to permit persons to whom the Software is furnished to do
  44230. so, subject to the following conditions:
  44231. The above copyright notice and this permission notice shall be included in all
  44232. copies or substantial portions of the Software.
  44233. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  44234. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  44235. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  44236. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  44237. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  44238. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  44239. SOFTWARE.
  44240. {
  44241. "389-exception": [
  44242. "389 Directory Server Exception"
  44243. ],
  44244. "Autoconf-exception-2.0": [
  44245. "Autoconf exception 2.0"
  44246. ],
  44247. "Autoconf-exception-3.0": [
  44248. "Autoconf exception 3.0"
  44249. ],
  44250. "Bison-exception-2.2": [
  44251. "Bison exception 2.2"
  44252. ],
  44253. "Bootloader-exception": [
  44254. "Bootloader Distribution Exception"
  44255. ],
  44256. "Classpath-exception-2.0": [
  44257. "Classpath exception 2.0"
  44258. ],
  44259. "CLISP-exception-2.0": [
  44260. "CLISP exception 2.0"
  44261. ],
  44262. "DigiRule-FOSS-exception": [
  44263. "DigiRule FOSS License Exception"
  44264. ],
  44265. "eCos-exception-2.0": [
  44266. "eCos exception 2.0"
  44267. ],
  44268. "Fawkes-Runtime-exception": [
  44269. "Fawkes Runtime Exception"
  44270. ],
  44271. "FLTK-exception": [
  44272. "FLTK exception"
  44273. ],
  44274. "Font-exception-2.0": [
  44275. "Font exception 2.0"
  44276. ],
  44277. "freertos-exception-2.0": [
  44278. "FreeRTOS Exception 2.0"
  44279. ],
  44280. "GCC-exception-2.0": [
  44281. "GCC Runtime Library exception 2.0"
  44282. ],
  44283. "GCC-exception-3.1": [
  44284. "GCC Runtime Library exception 3.1"
  44285. ],
  44286. "gnu-javamail-exception": [
  44287. "GNU JavaMail exception"
  44288. ],
  44289. "GPL-3.0-linking-exception": [
  44290. "GPL-3.0 Linking Exception"
  44291. ],
  44292. "GPL-3.0-linking-source-exception": [
  44293. "GPL-3.0 Linking Exception (with Corresponding Source)"
  44294. ],
  44295. "GPL-CC-1.0": [
  44296. "GPL Cooperation Commitment 1.0"
  44297. ],
  44298. "i2p-gpl-java-exception": [
  44299. "i2p GPL+Java Exception"
  44300. ],
  44301. "LGPL-3.0-linking-exception": [
  44302. "LGPL-3.0 Linking Exception"
  44303. ],
  44304. "Libtool-exception": [
  44305. "Libtool Exception"
  44306. ],
  44307. "Linux-syscall-note": [
  44308. "Linux Syscall Note"
  44309. ],
  44310. "LLVM-exception": [
  44311. "LLVM Exception"
  44312. ],
  44313. "LZMA-exception": [
  44314. "LZMA exception"
  44315. ],
  44316. "mif-exception": [
  44317. "Macros and Inline Functions Exception"
  44318. ],
  44319. "Nokia-Qt-exception-1.1": [
  44320. "Nokia Qt LGPL exception 1.1"
  44321. ],
  44322. "OCaml-LGPL-linking-exception": [
  44323. "OCaml LGPL Linking Exception"
  44324. ],
  44325. "OCCT-exception-1.0": [
  44326. "Open CASCADE Exception 1.0"
  44327. ],
  44328. "OpenJDK-assembly-exception-1.0": [
  44329. "OpenJDK Assembly exception 1.0"
  44330. ],
  44331. "openvpn-openssl-exception": [
  44332. "OpenVPN OpenSSL Exception"
  44333. ],
  44334. "PS-or-PDF-font-exception-20170817": [
  44335. "PS/PDF font exception (2017-08-17)"
  44336. ],
  44337. "Qt-GPL-exception-1.0": [
  44338. "Qt GPL exception 1.0"
  44339. ],
  44340. "Qt-LGPL-exception-1.1": [
  44341. "Qt LGPL exception 1.1"
  44342. ],
  44343. "Qwt-exception-1.0": [
  44344. "Qwt exception 1.0"
  44345. ],
  44346. "SHL-2.0": [
  44347. "Solderpad Hardware License v2.0"
  44348. ],
  44349. "SHL-2.1": [
  44350. "Solderpad Hardware License v2.1"
  44351. ],
  44352. "Swift-exception": [
  44353. "Swift Exception"
  44354. ],
  44355. "u-boot-exception-2.0": [
  44356. "U-Boot exception 2.0"
  44357. ],
  44358. "Universal-FOSS-exception-1.0": [
  44359. "Universal FOSS Exception, Version 1.0"
  44360. ],
  44361. "WxWindows-exception-3.1": [
  44362. "WxWindows Library Exception 3.1"
  44363. ]
  44364. }{
  44365. "0BSD": [
  44366. "BSD Zero Clause License",
  44367. true,
  44368. false
  44369. ],
  44370. "AAL": [
  44371. "Attribution Assurance License",
  44372. true,
  44373. false
  44374. ],
  44375. "Abstyles": [
  44376. "Abstyles License",
  44377. false,
  44378. false
  44379. ],
  44380. "Adobe-2006": [
  44381. "Adobe Systems Incorporated Source Code License Agreement",
  44382. false,
  44383. false
  44384. ],
  44385. "Adobe-Glyph": [
  44386. "Adobe Glyph List License",
  44387. false,
  44388. false
  44389. ],
  44390. "ADSL": [
  44391. "Amazon Digital Services License",
  44392. false,
  44393. false
  44394. ],
  44395. "AFL-1.1": [
  44396. "Academic Free License v1.1",
  44397. true,
  44398. false
  44399. ],
  44400. "AFL-1.2": [
  44401. "Academic Free License v1.2",
  44402. true,
  44403. false
  44404. ],
  44405. "AFL-2.0": [
  44406. "Academic Free License v2.0",
  44407. true,
  44408. false
  44409. ],
  44410. "AFL-2.1": [
  44411. "Academic Free License v2.1",
  44412. true,
  44413. false
  44414. ],
  44415. "AFL-3.0": [
  44416. "Academic Free License v3.0",
  44417. true,
  44418. false
  44419. ],
  44420. "Afmparse": [
  44421. "Afmparse License",
  44422. false,
  44423. false
  44424. ],
  44425. "AGPL-1.0": [
  44426. "Affero General Public License v1.0",
  44427. false,
  44428. true
  44429. ],
  44430. "AGPL-1.0-only": [
  44431. "Affero General Public License v1.0 only",
  44432. false,
  44433. false
  44434. ],
  44435. "AGPL-1.0-or-later": [
  44436. "Affero General Public License v1.0 or later",
  44437. false,
  44438. false
  44439. ],
  44440. "AGPL-3.0": [
  44441. "GNU Affero General Public License v3.0",
  44442. true,
  44443. true
  44444. ],
  44445. "AGPL-3.0-only": [
  44446. "GNU Affero General Public License v3.0 only",
  44447. true,
  44448. false
  44449. ],
  44450. "AGPL-3.0-or-later": [
  44451. "GNU Affero General Public License v3.0 or later",
  44452. true,
  44453. false
  44454. ],
  44455. "Aladdin": [
  44456. "Aladdin Free Public License",
  44457. false,
  44458. false
  44459. ],
  44460. "AMDPLPA": [
  44461. "AMD's plpa_map.c License",
  44462. false,
  44463. false
  44464. ],
  44465. "AML": [
  44466. "Apple MIT License",
  44467. false,
  44468. false
  44469. ],
  44470. "AMPAS": [
  44471. "Academy of Motion Picture Arts and Sciences BSD",
  44472. false,
  44473. false
  44474. ],
  44475. "ANTLR-PD": [
  44476. "ANTLR Software Rights Notice",
  44477. false,
  44478. false
  44479. ],
  44480. "ANTLR-PD-fallback": [
  44481. "ANTLR Software Rights Notice with license fallback",
  44482. false,
  44483. false
  44484. ],
  44485. "Apache-1.0": [
  44486. "Apache License 1.0",
  44487. false,
  44488. false
  44489. ],
  44490. "Apache-1.1": [
  44491. "Apache License 1.1",
  44492. true,
  44493. false
  44494. ],
  44495. "Apache-2.0": [
  44496. "Apache License 2.0",
  44497. true,
  44498. false
  44499. ],
  44500. "APAFML": [
  44501. "Adobe Postscript AFM License",
  44502. false,
  44503. false
  44504. ],
  44505. "APL-1.0": [
  44506. "Adaptive Public License 1.0",
  44507. true,
  44508. false
  44509. ],
  44510. "APSL-1.0": [
  44511. "Apple Public Source License 1.0",
  44512. true,
  44513. false
  44514. ],
  44515. "APSL-1.1": [
  44516. "Apple Public Source License 1.1",
  44517. true,
  44518. false
  44519. ],
  44520. "APSL-1.2": [
  44521. "Apple Public Source License 1.2",
  44522. true,
  44523. false
  44524. ],
  44525. "APSL-2.0": [
  44526. "Apple Public Source License 2.0",
  44527. true,
  44528. false
  44529. ],
  44530. "Artistic-1.0": [
  44531. "Artistic License 1.0",
  44532. true,
  44533. false
  44534. ],
  44535. "Artistic-1.0-cl8": [
  44536. "Artistic License 1.0 w/clause 8",
  44537. true,
  44538. false
  44539. ],
  44540. "Artistic-1.0-Perl": [
  44541. "Artistic License 1.0 (Perl)",
  44542. true,
  44543. false
  44544. ],
  44545. "Artistic-2.0": [
  44546. "Artistic License 2.0",
  44547. true,
  44548. false
  44549. ],
  44550. "Bahyph": [
  44551. "Bahyph License",
  44552. false,
  44553. false
  44554. ],
  44555. "Barr": [
  44556. "Barr License",
  44557. false,
  44558. false
  44559. ],
  44560. "Beerware": [
  44561. "Beerware License",
  44562. false,
  44563. false
  44564. ],
  44565. "BitTorrent-1.0": [
  44566. "BitTorrent Open Source License v1.0",
  44567. false,
  44568. false
  44569. ],
  44570. "BitTorrent-1.1": [
  44571. "BitTorrent Open Source License v1.1",
  44572. false,
  44573. false
  44574. ],
  44575. "blessing": [
  44576. "SQLite Blessing",
  44577. false,
  44578. false
  44579. ],
  44580. "BlueOak-1.0.0": [
  44581. "Blue Oak Model License 1.0.0",
  44582. false,
  44583. false
  44584. ],
  44585. "Borceux": [
  44586. "Borceux license",
  44587. false,
  44588. false
  44589. ],
  44590. "BSD-1-Clause": [
  44591. "BSD 1-Clause License",
  44592. true,
  44593. false
  44594. ],
  44595. "BSD-2-Clause": [
  44596. "BSD 2-Clause \"Simplified\" License",
  44597. true,
  44598. false
  44599. ],
  44600. "BSD-2-Clause-FreeBSD": [
  44601. "BSD 2-Clause FreeBSD License",
  44602. false,
  44603. true
  44604. ],
  44605. "BSD-2-Clause-NetBSD": [
  44606. "BSD 2-Clause NetBSD License",
  44607. false,
  44608. true
  44609. ],
  44610. "BSD-2-Clause-Patent": [
  44611. "BSD-2-Clause Plus Patent License",
  44612. true,
  44613. false
  44614. ],
  44615. "BSD-2-Clause-Views": [
  44616. "BSD 2-Clause with views sentence",
  44617. false,
  44618. false
  44619. ],
  44620. "BSD-3-Clause": [
  44621. "BSD 3-Clause \"New\" or \"Revised\" License",
  44622. true,
  44623. false
  44624. ],
  44625. "BSD-3-Clause-Attribution": [
  44626. "BSD with attribution",
  44627. false,
  44628. false
  44629. ],
  44630. "BSD-3-Clause-Clear": [
  44631. "BSD 3-Clause Clear License",
  44632. false,
  44633. false
  44634. ],
  44635. "BSD-3-Clause-LBNL": [
  44636. "Lawrence Berkeley National Labs BSD variant license",
  44637. true,
  44638. false
  44639. ],
  44640. "BSD-3-Clause-Modification": [
  44641. "BSD 3-Clause Modification",
  44642. false,
  44643. false
  44644. ],
  44645. "BSD-3-Clause-No-Military-License": [
  44646. "BSD 3-Clause No Military License",
  44647. false,
  44648. false
  44649. ],
  44650. "BSD-3-Clause-No-Nuclear-License": [
  44651. "BSD 3-Clause No Nuclear License",
  44652. false,
  44653. false
  44654. ],
  44655. "BSD-3-Clause-No-Nuclear-License-2014": [
  44656. "BSD 3-Clause No Nuclear License 2014",
  44657. false,
  44658. false
  44659. ],
  44660. "BSD-3-Clause-No-Nuclear-Warranty": [
  44661. "BSD 3-Clause No Nuclear Warranty",
  44662. false,
  44663. false
  44664. ],
  44665. "BSD-3-Clause-Open-MPI": [
  44666. "BSD 3-Clause Open MPI variant",
  44667. false,
  44668. false
  44669. ],
  44670. "BSD-4-Clause": [
  44671. "BSD 4-Clause \"Original\" or \"Old\" License",
  44672. false,
  44673. false
  44674. ],
  44675. "BSD-4-Clause-Shortened": [
  44676. "BSD 4 Clause Shortened",
  44677. false,
  44678. false
  44679. ],
  44680. "BSD-4-Clause-UC": [
  44681. "BSD-4-Clause (University of California-Specific)",
  44682. false,
  44683. false
  44684. ],
  44685. "BSD-Protection": [
  44686. "BSD Protection License",
  44687. false,
  44688. false
  44689. ],
  44690. "BSD-Source-Code": [
  44691. "BSD Source Code Attribution",
  44692. false,
  44693. false
  44694. ],
  44695. "BSL-1.0": [
  44696. "Boost Software License 1.0",
  44697. true,
  44698. false
  44699. ],
  44700. "BUSL-1.1": [
  44701. "Business Source License 1.1",
  44702. false,
  44703. false
  44704. ],
  44705. "bzip2-1.0.5": [
  44706. "bzip2 and libbzip2 License v1.0.5",
  44707. false,
  44708. false
  44709. ],
  44710. "bzip2-1.0.6": [
  44711. "bzip2 and libbzip2 License v1.0.6",
  44712. false,
  44713. false
  44714. ],
  44715. "C-UDA-1.0": [
  44716. "Computational Use of Data Agreement v1.0",
  44717. false,
  44718. false
  44719. ],
  44720. "CAL-1.0": [
  44721. "Cryptographic Autonomy License 1.0",
  44722. true,
  44723. false
  44724. ],
  44725. "CAL-1.0-Combined-Work-Exception": [
  44726. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  44727. true,
  44728. false
  44729. ],
  44730. "Caldera": [
  44731. "Caldera License",
  44732. false,
  44733. false
  44734. ],
  44735. "CATOSL-1.1": [
  44736. "Computer Associates Trusted Open Source License 1.1",
  44737. true,
  44738. false
  44739. ],
  44740. "CC-BY-1.0": [
  44741. "Creative Commons Attribution 1.0 Generic",
  44742. false,
  44743. false
  44744. ],
  44745. "CC-BY-2.0": [
  44746. "Creative Commons Attribution 2.0 Generic",
  44747. false,
  44748. false
  44749. ],
  44750. "CC-BY-2.5": [
  44751. "Creative Commons Attribution 2.5 Generic",
  44752. false,
  44753. false
  44754. ],
  44755. "CC-BY-2.5-AU": [
  44756. "Creative Commons Attribution 2.5 Australia",
  44757. false,
  44758. false
  44759. ],
  44760. "CC-BY-3.0": [
  44761. "Creative Commons Attribution 3.0 Unported",
  44762. false,
  44763. false
  44764. ],
  44765. "CC-BY-3.0-AT": [
  44766. "Creative Commons Attribution 3.0 Austria",
  44767. false,
  44768. false
  44769. ],
  44770. "CC-BY-3.0-DE": [
  44771. "Creative Commons Attribution 3.0 Germany",
  44772. false,
  44773. false
  44774. ],
  44775. "CC-BY-3.0-NL": [
  44776. "Creative Commons Attribution 3.0 Netherlands",
  44777. false,
  44778. false
  44779. ],
  44780. "CC-BY-3.0-US": [
  44781. "Creative Commons Attribution 3.0 United States",
  44782. false,
  44783. false
  44784. ],
  44785. "CC-BY-4.0": [
  44786. "Creative Commons Attribution 4.0 International",
  44787. false,
  44788. false
  44789. ],
  44790. "CC-BY-NC-1.0": [
  44791. "Creative Commons Attribution Non Commercial 1.0 Generic",
  44792. false,
  44793. false
  44794. ],
  44795. "CC-BY-NC-2.0": [
  44796. "Creative Commons Attribution Non Commercial 2.0 Generic",
  44797. false,
  44798. false
  44799. ],
  44800. "CC-BY-NC-2.5": [
  44801. "Creative Commons Attribution Non Commercial 2.5 Generic",
  44802. false,
  44803. false
  44804. ],
  44805. "CC-BY-NC-3.0": [
  44806. "Creative Commons Attribution Non Commercial 3.0 Unported",
  44807. false,
  44808. false
  44809. ],
  44810. "CC-BY-NC-3.0-DE": [
  44811. "Creative Commons Attribution Non Commercial 3.0 Germany",
  44812. false,
  44813. false
  44814. ],
  44815. "CC-BY-NC-4.0": [
  44816. "Creative Commons Attribution Non Commercial 4.0 International",
  44817. false,
  44818. false
  44819. ],
  44820. "CC-BY-NC-ND-1.0": [
  44821. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  44822. false,
  44823. false
  44824. ],
  44825. "CC-BY-NC-ND-2.0": [
  44826. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  44827. false,
  44828. false
  44829. ],
  44830. "CC-BY-NC-ND-2.5": [
  44831. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  44832. false,
  44833. false
  44834. ],
  44835. "CC-BY-NC-ND-3.0": [
  44836. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  44837. false,
  44838. false
  44839. ],
  44840. "CC-BY-NC-ND-3.0-DE": [
  44841. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Germany",
  44842. false,
  44843. false
  44844. ],
  44845. "CC-BY-NC-ND-3.0-IGO": [
  44846. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  44847. false,
  44848. false
  44849. ],
  44850. "CC-BY-NC-ND-4.0": [
  44851. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  44852. false,
  44853. false
  44854. ],
  44855. "CC-BY-NC-SA-1.0": [
  44856. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  44857. false,
  44858. false
  44859. ],
  44860. "CC-BY-NC-SA-2.0": [
  44861. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  44862. false,
  44863. false
  44864. ],
  44865. "CC-BY-NC-SA-2.0-FR": [
  44866. "Creative Commons Attribution-NonCommercial-ShareAlike 2.0 France",
  44867. false,
  44868. false
  44869. ],
  44870. "CC-BY-NC-SA-2.0-UK": [
  44871. "Creative Commons Attribution Non Commercial Share Alike 2.0 England and Wales",
  44872. false,
  44873. false
  44874. ],
  44875. "CC-BY-NC-SA-2.5": [
  44876. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  44877. false,
  44878. false
  44879. ],
  44880. "CC-BY-NC-SA-3.0": [
  44881. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  44882. false,
  44883. false
  44884. ],
  44885. "CC-BY-NC-SA-3.0-DE": [
  44886. "Creative Commons Attribution Non Commercial Share Alike 3.0 Germany",
  44887. false,
  44888. false
  44889. ],
  44890. "CC-BY-NC-SA-3.0-IGO": [
  44891. "Creative Commons Attribution Non Commercial Share Alike 3.0 IGO",
  44892. false,
  44893. false
  44894. ],
  44895. "CC-BY-NC-SA-4.0": [
  44896. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  44897. false,
  44898. false
  44899. ],
  44900. "CC-BY-ND-1.0": [
  44901. "Creative Commons Attribution No Derivatives 1.0 Generic",
  44902. false,
  44903. false
  44904. ],
  44905. "CC-BY-ND-2.0": [
  44906. "Creative Commons Attribution No Derivatives 2.0 Generic",
  44907. false,
  44908. false
  44909. ],
  44910. "CC-BY-ND-2.5": [
  44911. "Creative Commons Attribution No Derivatives 2.5 Generic",
  44912. false,
  44913. false
  44914. ],
  44915. "CC-BY-ND-3.0": [
  44916. "Creative Commons Attribution No Derivatives 3.0 Unported",
  44917. false,
  44918. false
  44919. ],
  44920. "CC-BY-ND-3.0-DE": [
  44921. "Creative Commons Attribution No Derivatives 3.0 Germany",
  44922. false,
  44923. false
  44924. ],
  44925. "CC-BY-ND-4.0": [
  44926. "Creative Commons Attribution No Derivatives 4.0 International",
  44927. false,
  44928. false
  44929. ],
  44930. "CC-BY-SA-1.0": [
  44931. "Creative Commons Attribution Share Alike 1.0 Generic",
  44932. false,
  44933. false
  44934. ],
  44935. "CC-BY-SA-2.0": [
  44936. "Creative Commons Attribution Share Alike 2.0 Generic",
  44937. false,
  44938. false
  44939. ],
  44940. "CC-BY-SA-2.0-UK": [
  44941. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  44942. false,
  44943. false
  44944. ],
  44945. "CC-BY-SA-2.1-JP": [
  44946. "Creative Commons Attribution Share Alike 2.1 Japan",
  44947. false,
  44948. false
  44949. ],
  44950. "CC-BY-SA-2.5": [
  44951. "Creative Commons Attribution Share Alike 2.5 Generic",
  44952. false,
  44953. false
  44954. ],
  44955. "CC-BY-SA-3.0": [
  44956. "Creative Commons Attribution Share Alike 3.0 Unported",
  44957. false,
  44958. false
  44959. ],
  44960. "CC-BY-SA-3.0-AT": [
  44961. "Creative Commons Attribution Share Alike 3.0 Austria",
  44962. false,
  44963. false
  44964. ],
  44965. "CC-BY-SA-3.0-DE": [
  44966. "Creative Commons Attribution Share Alike 3.0 Germany",
  44967. false,
  44968. false
  44969. ],
  44970. "CC-BY-SA-4.0": [
  44971. "Creative Commons Attribution Share Alike 4.0 International",
  44972. false,
  44973. false
  44974. ],
  44975. "CC-PDDC": [
  44976. "Creative Commons Public Domain Dedication and Certification",
  44977. false,
  44978. false
  44979. ],
  44980. "CC0-1.0": [
  44981. "Creative Commons Zero v1.0 Universal",
  44982. false,
  44983. false
  44984. ],
  44985. "CDDL-1.0": [
  44986. "Common Development and Distribution License 1.0",
  44987. true,
  44988. false
  44989. ],
  44990. "CDDL-1.1": [
  44991. "Common Development and Distribution License 1.1",
  44992. false,
  44993. false
  44994. ],
  44995. "CDL-1.0": [
  44996. "Common Documentation License 1.0",
  44997. false,
  44998. false
  44999. ],
  45000. "CDLA-Permissive-1.0": [
  45001. "Community Data License Agreement Permissive 1.0",
  45002. false,
  45003. false
  45004. ],
  45005. "CDLA-Permissive-2.0": [
  45006. "Community Data License Agreement Permissive 2.0",
  45007. false,
  45008. false
  45009. ],
  45010. "CDLA-Sharing-1.0": [
  45011. "Community Data License Agreement Sharing 1.0",
  45012. false,
  45013. false
  45014. ],
  45015. "CECILL-1.0": [
  45016. "CeCILL Free Software License Agreement v1.0",
  45017. false,
  45018. false
  45019. ],
  45020. "CECILL-1.1": [
  45021. "CeCILL Free Software License Agreement v1.1",
  45022. false,
  45023. false
  45024. ],
  45025. "CECILL-2.0": [
  45026. "CeCILL Free Software License Agreement v2.0",
  45027. false,
  45028. false
  45029. ],
  45030. "CECILL-2.1": [
  45031. "CeCILL Free Software License Agreement v2.1",
  45032. true,
  45033. false
  45034. ],
  45035. "CECILL-B": [
  45036. "CeCILL-B Free Software License Agreement",
  45037. false,
  45038. false
  45039. ],
  45040. "CECILL-C": [
  45041. "CeCILL-C Free Software License Agreement",
  45042. false,
  45043. false
  45044. ],
  45045. "CERN-OHL-1.1": [
  45046. "CERN Open Hardware Licence v1.1",
  45047. false,
  45048. false
  45049. ],
  45050. "CERN-OHL-1.2": [
  45051. "CERN Open Hardware Licence v1.2",
  45052. false,
  45053. false
  45054. ],
  45055. "CERN-OHL-P-2.0": [
  45056. "CERN Open Hardware Licence Version 2 - Permissive",
  45057. true,
  45058. false
  45059. ],
  45060. "CERN-OHL-S-2.0": [
  45061. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  45062. true,
  45063. false
  45064. ],
  45065. "CERN-OHL-W-2.0": [
  45066. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  45067. true,
  45068. false
  45069. ],
  45070. "ClArtistic": [
  45071. "Clarified Artistic License",
  45072. false,
  45073. false
  45074. ],
  45075. "CNRI-Jython": [
  45076. "CNRI Jython License",
  45077. false,
  45078. false
  45079. ],
  45080. "CNRI-Python": [
  45081. "CNRI Python License",
  45082. true,
  45083. false
  45084. ],
  45085. "CNRI-Python-GPL-Compatible": [
  45086. "CNRI Python Open Source GPL Compatible License Agreement",
  45087. false,
  45088. false
  45089. ],
  45090. "COIL-1.0": [
  45091. "Copyfree Open Innovation License",
  45092. false,
  45093. false
  45094. ],
  45095. "Community-Spec-1.0": [
  45096. "Community Specification License 1.0",
  45097. false,
  45098. false
  45099. ],
  45100. "Condor-1.1": [
  45101. "Condor Public License v1.1",
  45102. false,
  45103. false
  45104. ],
  45105. "copyleft-next-0.3.0": [
  45106. "copyleft-next 0.3.0",
  45107. false,
  45108. false
  45109. ],
  45110. "copyleft-next-0.3.1": [
  45111. "copyleft-next 0.3.1",
  45112. false,
  45113. false
  45114. ],
  45115. "CPAL-1.0": [
  45116. "Common Public Attribution License 1.0",
  45117. true,
  45118. false
  45119. ],
  45120. "CPL-1.0": [
  45121. "Common Public License 1.0",
  45122. true,
  45123. false
  45124. ],
  45125. "CPOL-1.02": [
  45126. "Code Project Open License 1.02",
  45127. false,
  45128. false
  45129. ],
  45130. "Crossword": [
  45131. "Crossword License",
  45132. false,
  45133. false
  45134. ],
  45135. "CrystalStacker": [
  45136. "CrystalStacker License",
  45137. false,
  45138. false
  45139. ],
  45140. "CUA-OPL-1.0": [
  45141. "CUA Office Public License v1.0",
  45142. true,
  45143. false
  45144. ],
  45145. "Cube": [
  45146. "Cube License",
  45147. false,
  45148. false
  45149. ],
  45150. "curl": [
  45151. "curl License",
  45152. false,
  45153. false
  45154. ],
  45155. "D-FSL-1.0": [
  45156. "Deutsche Freie Software Lizenz",
  45157. false,
  45158. false
  45159. ],
  45160. "diffmark": [
  45161. "diffmark license",
  45162. false,
  45163. false
  45164. ],
  45165. "DOC": [
  45166. "DOC License",
  45167. false,
  45168. false
  45169. ],
  45170. "Dotseqn": [
  45171. "Dotseqn License",
  45172. false,
  45173. false
  45174. ],
  45175. "DRL-1.0": [
  45176. "Detection Rule License 1.0",
  45177. false,
  45178. false
  45179. ],
  45180. "DSDP": [
  45181. "DSDP License",
  45182. false,
  45183. false
  45184. ],
  45185. "dvipdfm": [
  45186. "dvipdfm License",
  45187. false,
  45188. false
  45189. ],
  45190. "ECL-1.0": [
  45191. "Educational Community License v1.0",
  45192. true,
  45193. false
  45194. ],
  45195. "ECL-2.0": [
  45196. "Educational Community License v2.0",
  45197. true,
  45198. false
  45199. ],
  45200. "eCos-2.0": [
  45201. "eCos license version 2.0",
  45202. false,
  45203. true
  45204. ],
  45205. "EFL-1.0": [
  45206. "Eiffel Forum License v1.0",
  45207. true,
  45208. false
  45209. ],
  45210. "EFL-2.0": [
  45211. "Eiffel Forum License v2.0",
  45212. true,
  45213. false
  45214. ],
  45215. "eGenix": [
  45216. "eGenix.com Public License 1.1.0",
  45217. false,
  45218. false
  45219. ],
  45220. "Entessa": [
  45221. "Entessa Public License v1.0",
  45222. true,
  45223. false
  45224. ],
  45225. "EPICS": [
  45226. "EPICS Open License",
  45227. false,
  45228. false
  45229. ],
  45230. "EPL-1.0": [
  45231. "Eclipse Public License 1.0",
  45232. true,
  45233. false
  45234. ],
  45235. "EPL-2.0": [
  45236. "Eclipse Public License 2.0",
  45237. true,
  45238. false
  45239. ],
  45240. "ErlPL-1.1": [
  45241. "Erlang Public License v1.1",
  45242. false,
  45243. false
  45244. ],
  45245. "etalab-2.0": [
  45246. "Etalab Open License 2.0",
  45247. false,
  45248. false
  45249. ],
  45250. "EUDatagrid": [
  45251. "EU DataGrid Software License",
  45252. true,
  45253. false
  45254. ],
  45255. "EUPL-1.0": [
  45256. "European Union Public License 1.0",
  45257. false,
  45258. false
  45259. ],
  45260. "EUPL-1.1": [
  45261. "European Union Public License 1.1",
  45262. true,
  45263. false
  45264. ],
  45265. "EUPL-1.2": [
  45266. "European Union Public License 1.2",
  45267. true,
  45268. false
  45269. ],
  45270. "Eurosym": [
  45271. "Eurosym License",
  45272. false,
  45273. false
  45274. ],
  45275. "Fair": [
  45276. "Fair License",
  45277. true,
  45278. false
  45279. ],
  45280. "FDK-AAC": [
  45281. "Fraunhofer FDK AAC Codec Library",
  45282. false,
  45283. false
  45284. ],
  45285. "Frameworx-1.0": [
  45286. "Frameworx Open License 1.0",
  45287. true,
  45288. false
  45289. ],
  45290. "FreeBSD-DOC": [
  45291. "FreeBSD Documentation License",
  45292. false,
  45293. false
  45294. ],
  45295. "FreeImage": [
  45296. "FreeImage Public License v1.0",
  45297. false,
  45298. false
  45299. ],
  45300. "FSFAP": [
  45301. "FSF All Permissive License",
  45302. false,
  45303. false
  45304. ],
  45305. "FSFUL": [
  45306. "FSF Unlimited License",
  45307. false,
  45308. false
  45309. ],
  45310. "FSFULLR": [
  45311. "FSF Unlimited License (with License Retention)",
  45312. false,
  45313. false
  45314. ],
  45315. "FTL": [
  45316. "Freetype Project License",
  45317. false,
  45318. false
  45319. ],
  45320. "GD": [
  45321. "GD License",
  45322. false,
  45323. false
  45324. ],
  45325. "GFDL-1.1": [
  45326. "GNU Free Documentation License v1.1",
  45327. false,
  45328. true
  45329. ],
  45330. "GFDL-1.1-invariants-only": [
  45331. "GNU Free Documentation License v1.1 only - invariants",
  45332. false,
  45333. false
  45334. ],
  45335. "GFDL-1.1-invariants-or-later": [
  45336. "GNU Free Documentation License v1.1 or later - invariants",
  45337. false,
  45338. false
  45339. ],
  45340. "GFDL-1.1-no-invariants-only": [
  45341. "GNU Free Documentation License v1.1 only - no invariants",
  45342. false,
  45343. false
  45344. ],
  45345. "GFDL-1.1-no-invariants-or-later": [
  45346. "GNU Free Documentation License v1.1 or later - no invariants",
  45347. false,
  45348. false
  45349. ],
  45350. "GFDL-1.1-only": [
  45351. "GNU Free Documentation License v1.1 only",
  45352. false,
  45353. false
  45354. ],
  45355. "GFDL-1.1-or-later": [
  45356. "GNU Free Documentation License v1.1 or later",
  45357. false,
  45358. false
  45359. ],
  45360. "GFDL-1.2": [
  45361. "GNU Free Documentation License v1.2",
  45362. false,
  45363. true
  45364. ],
  45365. "GFDL-1.2-invariants-only": [
  45366. "GNU Free Documentation License v1.2 only - invariants",
  45367. false,
  45368. false
  45369. ],
  45370. "GFDL-1.2-invariants-or-later": [
  45371. "GNU Free Documentation License v1.2 or later - invariants",
  45372. false,
  45373. false
  45374. ],
  45375. "GFDL-1.2-no-invariants-only": [
  45376. "GNU Free Documentation License v1.2 only - no invariants",
  45377. false,
  45378. false
  45379. ],
  45380. "GFDL-1.2-no-invariants-or-later": [
  45381. "GNU Free Documentation License v1.2 or later - no invariants",
  45382. false,
  45383. false
  45384. ],
  45385. "GFDL-1.2-only": [
  45386. "GNU Free Documentation License v1.2 only",
  45387. false,
  45388. false
  45389. ],
  45390. "GFDL-1.2-or-later": [
  45391. "GNU Free Documentation License v1.2 or later",
  45392. false,
  45393. false
  45394. ],
  45395. "GFDL-1.3": [
  45396. "GNU Free Documentation License v1.3",
  45397. false,
  45398. true
  45399. ],
  45400. "GFDL-1.3-invariants-only": [
  45401. "GNU Free Documentation License v1.3 only - invariants",
  45402. false,
  45403. false
  45404. ],
  45405. "GFDL-1.3-invariants-or-later": [
  45406. "GNU Free Documentation License v1.3 or later - invariants",
  45407. false,
  45408. false
  45409. ],
  45410. "GFDL-1.3-no-invariants-only": [
  45411. "GNU Free Documentation License v1.3 only - no invariants",
  45412. false,
  45413. false
  45414. ],
  45415. "GFDL-1.3-no-invariants-or-later": [
  45416. "GNU Free Documentation License v1.3 or later - no invariants",
  45417. false,
  45418. false
  45419. ],
  45420. "GFDL-1.3-only": [
  45421. "GNU Free Documentation License v1.3 only",
  45422. false,
  45423. false
  45424. ],
  45425. "GFDL-1.3-or-later": [
  45426. "GNU Free Documentation License v1.3 or later",
  45427. false,
  45428. false
  45429. ],
  45430. "Giftware": [
  45431. "Giftware License",
  45432. false,
  45433. false
  45434. ],
  45435. "GL2PS": [
  45436. "GL2PS License",
  45437. false,
  45438. false
  45439. ],
  45440. "Glide": [
  45441. "3dfx Glide License",
  45442. false,
  45443. false
  45444. ],
  45445. "Glulxe": [
  45446. "Glulxe License",
  45447. false,
  45448. false
  45449. ],
  45450. "GLWTPL": [
  45451. "Good Luck With That Public License",
  45452. false,
  45453. false
  45454. ],
  45455. "gnuplot": [
  45456. "gnuplot License",
  45457. false,
  45458. false
  45459. ],
  45460. "GPL-1.0": [
  45461. "GNU General Public License v1.0 only",
  45462. false,
  45463. true
  45464. ],
  45465. "GPL-1.0+": [
  45466. "GNU General Public License v1.0 or later",
  45467. false,
  45468. true
  45469. ],
  45470. "GPL-1.0-only": [
  45471. "GNU General Public License v1.0 only",
  45472. false,
  45473. false
  45474. ],
  45475. "GPL-1.0-or-later": [
  45476. "GNU General Public License v1.0 or later",
  45477. false,
  45478. false
  45479. ],
  45480. "GPL-2.0": [
  45481. "GNU General Public License v2.0 only",
  45482. true,
  45483. true
  45484. ],
  45485. "GPL-2.0+": [
  45486. "GNU General Public License v2.0 or later",
  45487. true,
  45488. true
  45489. ],
  45490. "GPL-2.0-only": [
  45491. "GNU General Public License v2.0 only",
  45492. true,
  45493. false
  45494. ],
  45495. "GPL-2.0-or-later": [
  45496. "GNU General Public License v2.0 or later",
  45497. true,
  45498. false
  45499. ],
  45500. "GPL-2.0-with-autoconf-exception": [
  45501. "GNU General Public License v2.0 w/Autoconf exception",
  45502. false,
  45503. true
  45504. ],
  45505. "GPL-2.0-with-bison-exception": [
  45506. "GNU General Public License v2.0 w/Bison exception",
  45507. false,
  45508. true
  45509. ],
  45510. "GPL-2.0-with-classpath-exception": [
  45511. "GNU General Public License v2.0 w/Classpath exception",
  45512. false,
  45513. true
  45514. ],
  45515. "GPL-2.0-with-font-exception": [
  45516. "GNU General Public License v2.0 w/Font exception",
  45517. false,
  45518. true
  45519. ],
  45520. "GPL-2.0-with-GCC-exception": [
  45521. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  45522. false,
  45523. true
  45524. ],
  45525. "GPL-3.0": [
  45526. "GNU General Public License v3.0 only",
  45527. true,
  45528. true
  45529. ],
  45530. "GPL-3.0+": [
  45531. "GNU General Public License v3.0 or later",
  45532. true,
  45533. true
  45534. ],
  45535. "GPL-3.0-only": [
  45536. "GNU General Public License v3.0 only",
  45537. true,
  45538. false
  45539. ],
  45540. "GPL-3.0-or-later": [
  45541. "GNU General Public License v3.0 or later",
  45542. true,
  45543. false
  45544. ],
  45545. "GPL-3.0-with-autoconf-exception": [
  45546. "GNU General Public License v3.0 w/Autoconf exception",
  45547. false,
  45548. true
  45549. ],
  45550. "GPL-3.0-with-GCC-exception": [
  45551. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  45552. true,
  45553. true
  45554. ],
  45555. "gSOAP-1.3b": [
  45556. "gSOAP Public License v1.3b",
  45557. false,
  45558. false
  45559. ],
  45560. "HaskellReport": [
  45561. "Haskell Language Report License",
  45562. false,
  45563. false
  45564. ],
  45565. "Hippocratic-2.1": [
  45566. "Hippocratic License 2.1",
  45567. false,
  45568. false
  45569. ],
  45570. "HPND": [
  45571. "Historical Permission Notice and Disclaimer",
  45572. true,
  45573. false
  45574. ],
  45575. "HPND-sell-variant": [
  45576. "Historical Permission Notice and Disclaimer - sell variant",
  45577. false,
  45578. false
  45579. ],
  45580. "HTMLTIDY": [
  45581. "HTML Tidy License",
  45582. false,
  45583. false
  45584. ],
  45585. "IBM-pibs": [
  45586. "IBM PowerPC Initialization and Boot Software",
  45587. false,
  45588. false
  45589. ],
  45590. "ICU": [
  45591. "ICU License",
  45592. false,
  45593. false
  45594. ],
  45595. "IJG": [
  45596. "Independent JPEG Group License",
  45597. false,
  45598. false
  45599. ],
  45600. "ImageMagick": [
  45601. "ImageMagick License",
  45602. false,
  45603. false
  45604. ],
  45605. "iMatix": [
  45606. "iMatix Standard Function Library Agreement",
  45607. false,
  45608. false
  45609. ],
  45610. "Imlib2": [
  45611. "Imlib2 License",
  45612. false,
  45613. false
  45614. ],
  45615. "Info-ZIP": [
  45616. "Info-ZIP License",
  45617. false,
  45618. false
  45619. ],
  45620. "Intel": [
  45621. "Intel Open Source License",
  45622. true,
  45623. false
  45624. ],
  45625. "Intel-ACPI": [
  45626. "Intel ACPI Software License Agreement",
  45627. false,
  45628. false
  45629. ],
  45630. "Interbase-1.0": [
  45631. "Interbase Public License v1.0",
  45632. false,
  45633. false
  45634. ],
  45635. "IPA": [
  45636. "IPA Font License",
  45637. true,
  45638. false
  45639. ],
  45640. "IPL-1.0": [
  45641. "IBM Public License v1.0",
  45642. true,
  45643. false
  45644. ],
  45645. "ISC": [
  45646. "ISC License",
  45647. true,
  45648. false
  45649. ],
  45650. "JasPer-2.0": [
  45651. "JasPer License",
  45652. false,
  45653. false
  45654. ],
  45655. "JPNIC": [
  45656. "Japan Network Information Center License",
  45657. false,
  45658. false
  45659. ],
  45660. "JSON": [
  45661. "JSON License",
  45662. false,
  45663. false
  45664. ],
  45665. "LAL-1.2": [
  45666. "Licence Art Libre 1.2",
  45667. false,
  45668. false
  45669. ],
  45670. "LAL-1.3": [
  45671. "Licence Art Libre 1.3",
  45672. false,
  45673. false
  45674. ],
  45675. "Latex2e": [
  45676. "Latex2e License",
  45677. false,
  45678. false
  45679. ],
  45680. "Leptonica": [
  45681. "Leptonica License",
  45682. false,
  45683. false
  45684. ],
  45685. "LGPL-2.0": [
  45686. "GNU Library General Public License v2 only",
  45687. true,
  45688. true
  45689. ],
  45690. "LGPL-2.0+": [
  45691. "GNU Library General Public License v2 or later",
  45692. true,
  45693. true
  45694. ],
  45695. "LGPL-2.0-only": [
  45696. "GNU Library General Public License v2 only",
  45697. true,
  45698. false
  45699. ],
  45700. "LGPL-2.0-or-later": [
  45701. "GNU Library General Public License v2 or later",
  45702. true,
  45703. false
  45704. ],
  45705. "LGPL-2.1": [
  45706. "GNU Lesser General Public License v2.1 only",
  45707. true,
  45708. true
  45709. ],
  45710. "LGPL-2.1+": [
  45711. "GNU Library General Public License v2.1 or later",
  45712. true,
  45713. true
  45714. ],
  45715. "LGPL-2.1-only": [
  45716. "GNU Lesser General Public License v2.1 only",
  45717. true,
  45718. false
  45719. ],
  45720. "LGPL-2.1-or-later": [
  45721. "GNU Lesser General Public License v2.1 or later",
  45722. true,
  45723. false
  45724. ],
  45725. "LGPL-3.0": [
  45726. "GNU Lesser General Public License v3.0 only",
  45727. true,
  45728. true
  45729. ],
  45730. "LGPL-3.0+": [
  45731. "GNU Lesser General Public License v3.0 or later",
  45732. true,
  45733. true
  45734. ],
  45735. "LGPL-3.0-only": [
  45736. "GNU Lesser General Public License v3.0 only",
  45737. true,
  45738. false
  45739. ],
  45740. "LGPL-3.0-or-later": [
  45741. "GNU Lesser General Public License v3.0 or later",
  45742. true,
  45743. false
  45744. ],
  45745. "LGPLLR": [
  45746. "Lesser General Public License For Linguistic Resources",
  45747. false,
  45748. false
  45749. ],
  45750. "Libpng": [
  45751. "libpng License",
  45752. false,
  45753. false
  45754. ],
  45755. "libpng-2.0": [
  45756. "PNG Reference Library version 2",
  45757. false,
  45758. false
  45759. ],
  45760. "libselinux-1.0": [
  45761. "libselinux public domain notice",
  45762. false,
  45763. false
  45764. ],
  45765. "libtiff": [
  45766. "libtiff License",
  45767. false,
  45768. false
  45769. ],
  45770. "LiLiQ-P-1.1": [
  45771. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  45772. true,
  45773. false
  45774. ],
  45775. "LiLiQ-R-1.1": [
  45776. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  45777. true,
  45778. false
  45779. ],
  45780. "LiLiQ-Rplus-1.1": [
  45781. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  45782. true,
  45783. false
  45784. ],
  45785. "Linux-man-pages-copyleft": [
  45786. "Linux man-pages Copyleft",
  45787. false,
  45788. false
  45789. ],
  45790. "Linux-OpenIB": [
  45791. "Linux Kernel Variant of OpenIB.org license",
  45792. false,
  45793. false
  45794. ],
  45795. "LPL-1.0": [
  45796. "Lucent Public License Version 1.0",
  45797. true,
  45798. false
  45799. ],
  45800. "LPL-1.02": [
  45801. "Lucent Public License v1.02",
  45802. true,
  45803. false
  45804. ],
  45805. "LPPL-1.0": [
  45806. "LaTeX Project Public License v1.0",
  45807. false,
  45808. false
  45809. ],
  45810. "LPPL-1.1": [
  45811. "LaTeX Project Public License v1.1",
  45812. false,
  45813. false
  45814. ],
  45815. "LPPL-1.2": [
  45816. "LaTeX Project Public License v1.2",
  45817. false,
  45818. false
  45819. ],
  45820. "LPPL-1.3a": [
  45821. "LaTeX Project Public License v1.3a",
  45822. false,
  45823. false
  45824. ],
  45825. "LPPL-1.3c": [
  45826. "LaTeX Project Public License v1.3c",
  45827. true,
  45828. false
  45829. ],
  45830. "MakeIndex": [
  45831. "MakeIndex License",
  45832. false,
  45833. false
  45834. ],
  45835. "MirOS": [
  45836. "The MirOS Licence",
  45837. true,
  45838. false
  45839. ],
  45840. "MIT": [
  45841. "MIT License",
  45842. true,
  45843. false
  45844. ],
  45845. "MIT-0": [
  45846. "MIT No Attribution",
  45847. true,
  45848. false
  45849. ],
  45850. "MIT-advertising": [
  45851. "Enlightenment License (e16)",
  45852. false,
  45853. false
  45854. ],
  45855. "MIT-CMU": [
  45856. "CMU License",
  45857. false,
  45858. false
  45859. ],
  45860. "MIT-enna": [
  45861. "enna License",
  45862. false,
  45863. false
  45864. ],
  45865. "MIT-feh": [
  45866. "feh License",
  45867. false,
  45868. false
  45869. ],
  45870. "MIT-Modern-Variant": [
  45871. "MIT License Modern Variant",
  45872. true,
  45873. false
  45874. ],
  45875. "MIT-open-group": [
  45876. "MIT Open Group variant",
  45877. false,
  45878. false
  45879. ],
  45880. "MITNFA": [
  45881. "MIT +no-false-attribs license",
  45882. false,
  45883. false
  45884. ],
  45885. "Motosoto": [
  45886. "Motosoto License",
  45887. true,
  45888. false
  45889. ],
  45890. "mpich2": [
  45891. "mpich2 License",
  45892. false,
  45893. false
  45894. ],
  45895. "MPL-1.0": [
  45896. "Mozilla Public License 1.0",
  45897. true,
  45898. false
  45899. ],
  45900. "MPL-1.1": [
  45901. "Mozilla Public License 1.1",
  45902. true,
  45903. false
  45904. ],
  45905. "MPL-2.0": [
  45906. "Mozilla Public License 2.0",
  45907. true,
  45908. false
  45909. ],
  45910. "MPL-2.0-no-copyleft-exception": [
  45911. "Mozilla Public License 2.0 (no copyleft exception)",
  45912. true,
  45913. false
  45914. ],
  45915. "MS-PL": [
  45916. "Microsoft Public License",
  45917. true,
  45918. false
  45919. ],
  45920. "MS-RL": [
  45921. "Microsoft Reciprocal License",
  45922. true,
  45923. false
  45924. ],
  45925. "MTLL": [
  45926. "Matrix Template Library License",
  45927. false,
  45928. false
  45929. ],
  45930. "MulanPSL-1.0": [
  45931. "Mulan Permissive Software License, Version 1",
  45932. false,
  45933. false
  45934. ],
  45935. "MulanPSL-2.0": [
  45936. "Mulan Permissive Software License, Version 2",
  45937. true,
  45938. false
  45939. ],
  45940. "Multics": [
  45941. "Multics License",
  45942. true,
  45943. false
  45944. ],
  45945. "Mup": [
  45946. "Mup License",
  45947. false,
  45948. false
  45949. ],
  45950. "NAIST-2003": [
  45951. "Nara Institute of Science and Technology License (2003)",
  45952. false,
  45953. false
  45954. ],
  45955. "NASA-1.3": [
  45956. "NASA Open Source Agreement 1.3",
  45957. true,
  45958. false
  45959. ],
  45960. "Naumen": [
  45961. "Naumen Public License",
  45962. true,
  45963. false
  45964. ],
  45965. "NBPL-1.0": [
  45966. "Net Boolean Public License v1",
  45967. false,
  45968. false
  45969. ],
  45970. "NCGL-UK-2.0": [
  45971. "Non-Commercial Government Licence",
  45972. false,
  45973. false
  45974. ],
  45975. "NCSA": [
  45976. "University of Illinois/NCSA Open Source License",
  45977. true,
  45978. false
  45979. ],
  45980. "Net-SNMP": [
  45981. "Net-SNMP License",
  45982. false,
  45983. false
  45984. ],
  45985. "NetCDF": [
  45986. "NetCDF license",
  45987. false,
  45988. false
  45989. ],
  45990. "Newsletr": [
  45991. "Newsletr License",
  45992. false,
  45993. false
  45994. ],
  45995. "NGPL": [
  45996. "Nethack General Public License",
  45997. true,
  45998. false
  45999. ],
  46000. "NIST-PD": [
  46001. "NIST Public Domain Notice",
  46002. false,
  46003. false
  46004. ],
  46005. "NIST-PD-fallback": [
  46006. "NIST Public Domain Notice with license fallback",
  46007. false,
  46008. false
  46009. ],
  46010. "NLOD-1.0": [
  46011. "Norwegian Licence for Open Government Data (NLOD) 1.0",
  46012. false,
  46013. false
  46014. ],
  46015. "NLOD-2.0": [
  46016. "Norwegian Licence for Open Government Data (NLOD) 2.0",
  46017. false,
  46018. false
  46019. ],
  46020. "NLPL": [
  46021. "No Limit Public License",
  46022. false,
  46023. false
  46024. ],
  46025. "Nokia": [
  46026. "Nokia Open Source License",
  46027. true,
  46028. false
  46029. ],
  46030. "NOSL": [
  46031. "Netizen Open Source License",
  46032. false,
  46033. false
  46034. ],
  46035. "Noweb": [
  46036. "Noweb License",
  46037. false,
  46038. false
  46039. ],
  46040. "NPL-1.0": [
  46041. "Netscape Public License v1.0",
  46042. false,
  46043. false
  46044. ],
  46045. "NPL-1.1": [
  46046. "Netscape Public License v1.1",
  46047. false,
  46048. false
  46049. ],
  46050. "NPOSL-3.0": [
  46051. "Non-Profit Open Software License 3.0",
  46052. true,
  46053. false
  46054. ],
  46055. "NRL": [
  46056. "NRL License",
  46057. false,
  46058. false
  46059. ],
  46060. "NTP": [
  46061. "NTP License",
  46062. true,
  46063. false
  46064. ],
  46065. "NTP-0": [
  46066. "NTP No Attribution",
  46067. false,
  46068. false
  46069. ],
  46070. "Nunit": [
  46071. "Nunit License",
  46072. false,
  46073. true
  46074. ],
  46075. "O-UDA-1.0": [
  46076. "Open Use of Data Agreement v1.0",
  46077. false,
  46078. false
  46079. ],
  46080. "OCCT-PL": [
  46081. "Open CASCADE Technology Public License",
  46082. false,
  46083. false
  46084. ],
  46085. "OCLC-2.0": [
  46086. "OCLC Research Public License 2.0",
  46087. true,
  46088. false
  46089. ],
  46090. "ODbL-1.0": [
  46091. "Open Data Commons Open Database License v1.0",
  46092. false,
  46093. false
  46094. ],
  46095. "ODC-By-1.0": [
  46096. "Open Data Commons Attribution License v1.0",
  46097. false,
  46098. false
  46099. ],
  46100. "OFL-1.0": [
  46101. "SIL Open Font License 1.0",
  46102. false,
  46103. false
  46104. ],
  46105. "OFL-1.0-no-RFN": [
  46106. "SIL Open Font License 1.0 with no Reserved Font Name",
  46107. false,
  46108. false
  46109. ],
  46110. "OFL-1.0-RFN": [
  46111. "SIL Open Font License 1.0 with Reserved Font Name",
  46112. false,
  46113. false
  46114. ],
  46115. "OFL-1.1": [
  46116. "SIL Open Font License 1.1",
  46117. true,
  46118. false
  46119. ],
  46120. "OFL-1.1-no-RFN": [
  46121. "SIL Open Font License 1.1 with no Reserved Font Name",
  46122. true,
  46123. false
  46124. ],
  46125. "OFL-1.1-RFN": [
  46126. "SIL Open Font License 1.1 with Reserved Font Name",
  46127. true,
  46128. false
  46129. ],
  46130. "OGC-1.0": [
  46131. "OGC Software License, Version 1.0",
  46132. false,
  46133. false
  46134. ],
  46135. "OGDL-Taiwan-1.0": [
  46136. "Taiwan Open Government Data License, version 1.0",
  46137. false,
  46138. false
  46139. ],
  46140. "OGL-Canada-2.0": [
  46141. "Open Government Licence - Canada",
  46142. false,
  46143. false
  46144. ],
  46145. "OGL-UK-1.0": [
  46146. "Open Government Licence v1.0",
  46147. false,
  46148. false
  46149. ],
  46150. "OGL-UK-2.0": [
  46151. "Open Government Licence v2.0",
  46152. false,
  46153. false
  46154. ],
  46155. "OGL-UK-3.0": [
  46156. "Open Government Licence v3.0",
  46157. false,
  46158. false
  46159. ],
  46160. "OGTSL": [
  46161. "Open Group Test Suite License",
  46162. true,
  46163. false
  46164. ],
  46165. "OLDAP-1.1": [
  46166. "Open LDAP Public License v1.1",
  46167. false,
  46168. false
  46169. ],
  46170. "OLDAP-1.2": [
  46171. "Open LDAP Public License v1.2",
  46172. false,
  46173. false
  46174. ],
  46175. "OLDAP-1.3": [
  46176. "Open LDAP Public License v1.3",
  46177. false,
  46178. false
  46179. ],
  46180. "OLDAP-1.4": [
  46181. "Open LDAP Public License v1.4",
  46182. false,
  46183. false
  46184. ],
  46185. "OLDAP-2.0": [
  46186. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  46187. false,
  46188. false
  46189. ],
  46190. "OLDAP-2.0.1": [
  46191. "Open LDAP Public License v2.0.1",
  46192. false,
  46193. false
  46194. ],
  46195. "OLDAP-2.1": [
  46196. "Open LDAP Public License v2.1",
  46197. false,
  46198. false
  46199. ],
  46200. "OLDAP-2.2": [
  46201. "Open LDAP Public License v2.2",
  46202. false,
  46203. false
  46204. ],
  46205. "OLDAP-2.2.1": [
  46206. "Open LDAP Public License v2.2.1",
  46207. false,
  46208. false
  46209. ],
  46210. "OLDAP-2.2.2": [
  46211. "Open LDAP Public License 2.2.2",
  46212. false,
  46213. false
  46214. ],
  46215. "OLDAP-2.3": [
  46216. "Open LDAP Public License v2.3",
  46217. false,
  46218. false
  46219. ],
  46220. "OLDAP-2.4": [
  46221. "Open LDAP Public License v2.4",
  46222. false,
  46223. false
  46224. ],
  46225. "OLDAP-2.5": [
  46226. "Open LDAP Public License v2.5",
  46227. false,
  46228. false
  46229. ],
  46230. "OLDAP-2.6": [
  46231. "Open LDAP Public License v2.6",
  46232. false,
  46233. false
  46234. ],
  46235. "OLDAP-2.7": [
  46236. "Open LDAP Public License v2.7",
  46237. false,
  46238. false
  46239. ],
  46240. "OLDAP-2.8": [
  46241. "Open LDAP Public License v2.8",
  46242. true,
  46243. false
  46244. ],
  46245. "OML": [
  46246. "Open Market License",
  46247. false,
  46248. false
  46249. ],
  46250. "OpenSSL": [
  46251. "OpenSSL License",
  46252. false,
  46253. false
  46254. ],
  46255. "OPL-1.0": [
  46256. "Open Public License v1.0",
  46257. false,
  46258. false
  46259. ],
  46260. "OPUBL-1.0": [
  46261. "Open Publication License v1.0",
  46262. false,
  46263. false
  46264. ],
  46265. "OSET-PL-2.1": [
  46266. "OSET Public License version 2.1",
  46267. true,
  46268. false
  46269. ],
  46270. "OSL-1.0": [
  46271. "Open Software License 1.0",
  46272. true,
  46273. false
  46274. ],
  46275. "OSL-1.1": [
  46276. "Open Software License 1.1",
  46277. false,
  46278. false
  46279. ],
  46280. "OSL-2.0": [
  46281. "Open Software License 2.0",
  46282. true,
  46283. false
  46284. ],
  46285. "OSL-2.1": [
  46286. "Open Software License 2.1",
  46287. true,
  46288. false
  46289. ],
  46290. "OSL-3.0": [
  46291. "Open Software License 3.0",
  46292. true,
  46293. false
  46294. ],
  46295. "Parity-6.0.0": [
  46296. "The Parity Public License 6.0.0",
  46297. false,
  46298. false
  46299. ],
  46300. "Parity-7.0.0": [
  46301. "The Parity Public License 7.0.0",
  46302. false,
  46303. false
  46304. ],
  46305. "PDDL-1.0": [
  46306. "Open Data Commons Public Domain Dedication & License 1.0",
  46307. false,
  46308. false
  46309. ],
  46310. "PHP-3.0": [
  46311. "PHP License v3.0",
  46312. true,
  46313. false
  46314. ],
  46315. "PHP-3.01": [
  46316. "PHP License v3.01",
  46317. true,
  46318. false
  46319. ],
  46320. "Plexus": [
  46321. "Plexus Classworlds License",
  46322. false,
  46323. false
  46324. ],
  46325. "PolyForm-Noncommercial-1.0.0": [
  46326. "PolyForm Noncommercial License 1.0.0",
  46327. false,
  46328. false
  46329. ],
  46330. "PolyForm-Small-Business-1.0.0": [
  46331. "PolyForm Small Business License 1.0.0",
  46332. false,
  46333. false
  46334. ],
  46335. "PostgreSQL": [
  46336. "PostgreSQL License",
  46337. true,
  46338. false
  46339. ],
  46340. "PSF-2.0": [
  46341. "Python Software Foundation License 2.0",
  46342. false,
  46343. false
  46344. ],
  46345. "psfrag": [
  46346. "psfrag License",
  46347. false,
  46348. false
  46349. ],
  46350. "psutils": [
  46351. "psutils License",
  46352. false,
  46353. false
  46354. ],
  46355. "Python-2.0": [
  46356. "Python License 2.0",
  46357. true,
  46358. false
  46359. ],
  46360. "Qhull": [
  46361. "Qhull License",
  46362. false,
  46363. false
  46364. ],
  46365. "QPL-1.0": [
  46366. "Q Public License 1.0",
  46367. true,
  46368. false
  46369. ],
  46370. "Rdisc": [
  46371. "Rdisc License",
  46372. false,
  46373. false
  46374. ],
  46375. "RHeCos-1.1": [
  46376. "Red Hat eCos Public License v1.1",
  46377. false,
  46378. false
  46379. ],
  46380. "RPL-1.1": [
  46381. "Reciprocal Public License 1.1",
  46382. true,
  46383. false
  46384. ],
  46385. "RPL-1.5": [
  46386. "Reciprocal Public License 1.5",
  46387. true,
  46388. false
  46389. ],
  46390. "RPSL-1.0": [
  46391. "RealNetworks Public Source License v1.0",
  46392. true,
  46393. false
  46394. ],
  46395. "RSA-MD": [
  46396. "RSA Message-Digest License",
  46397. false,
  46398. false
  46399. ],
  46400. "RSCPL": [
  46401. "Ricoh Source Code Public License",
  46402. true,
  46403. false
  46404. ],
  46405. "Ruby": [
  46406. "Ruby License",
  46407. false,
  46408. false
  46409. ],
  46410. "SAX-PD": [
  46411. "Sax Public Domain Notice",
  46412. false,
  46413. false
  46414. ],
  46415. "Saxpath": [
  46416. "Saxpath License",
  46417. false,
  46418. false
  46419. ],
  46420. "SCEA": [
  46421. "SCEA Shared Source License",
  46422. false,
  46423. false
  46424. ],
  46425. "Sendmail": [
  46426. "Sendmail License",
  46427. false,
  46428. false
  46429. ],
  46430. "Sendmail-8.23": [
  46431. "Sendmail License 8.23",
  46432. false,
  46433. false
  46434. ],
  46435. "SGI-B-1.0": [
  46436. "SGI Free Software License B v1.0",
  46437. false,
  46438. false
  46439. ],
  46440. "SGI-B-1.1": [
  46441. "SGI Free Software License B v1.1",
  46442. false,
  46443. false
  46444. ],
  46445. "SGI-B-2.0": [
  46446. "SGI Free Software License B v2.0",
  46447. false,
  46448. false
  46449. ],
  46450. "SHL-0.5": [
  46451. "Solderpad Hardware License v0.5",
  46452. false,
  46453. false
  46454. ],
  46455. "SHL-0.51": [
  46456. "Solderpad Hardware License, Version 0.51",
  46457. false,
  46458. false
  46459. ],
  46460. "SimPL-2.0": [
  46461. "Simple Public License 2.0",
  46462. true,
  46463. false
  46464. ],
  46465. "SISSL": [
  46466. "Sun Industry Standards Source License v1.1",
  46467. true,
  46468. false
  46469. ],
  46470. "SISSL-1.2": [
  46471. "Sun Industry Standards Source License v1.2",
  46472. false,
  46473. false
  46474. ],
  46475. "Sleepycat": [
  46476. "Sleepycat License",
  46477. true,
  46478. false
  46479. ],
  46480. "SMLNJ": [
  46481. "Standard ML of New Jersey License",
  46482. false,
  46483. false
  46484. ],
  46485. "SMPPL": [
  46486. "Secure Messaging Protocol Public License",
  46487. false,
  46488. false
  46489. ],
  46490. "SNIA": [
  46491. "SNIA Public License 1.1",
  46492. false,
  46493. false
  46494. ],
  46495. "Spencer-86": [
  46496. "Spencer License 86",
  46497. false,
  46498. false
  46499. ],
  46500. "Spencer-94": [
  46501. "Spencer License 94",
  46502. false,
  46503. false
  46504. ],
  46505. "Spencer-99": [
  46506. "Spencer License 99",
  46507. false,
  46508. false
  46509. ],
  46510. "SPL-1.0": [
  46511. "Sun Public License v1.0",
  46512. true,
  46513. false
  46514. ],
  46515. "SSH-OpenSSH": [
  46516. "SSH OpenSSH license",
  46517. false,
  46518. false
  46519. ],
  46520. "SSH-short": [
  46521. "SSH short notice",
  46522. false,
  46523. false
  46524. ],
  46525. "SSPL-1.0": [
  46526. "Server Side Public License, v 1",
  46527. false,
  46528. false
  46529. ],
  46530. "StandardML-NJ": [
  46531. "Standard ML of New Jersey License",
  46532. false,
  46533. true
  46534. ],
  46535. "SugarCRM-1.1.3": [
  46536. "SugarCRM Public License v1.1.3",
  46537. false,
  46538. false
  46539. ],
  46540. "SWL": [
  46541. "Scheme Widget Library (SWL) Software License Agreement",
  46542. false,
  46543. false
  46544. ],
  46545. "TAPR-OHL-1.0": [
  46546. "TAPR Open Hardware License v1.0",
  46547. false,
  46548. false
  46549. ],
  46550. "TCL": [
  46551. "TCL/TK License",
  46552. false,
  46553. false
  46554. ],
  46555. "TCP-wrappers": [
  46556. "TCP Wrappers License",
  46557. false,
  46558. false
  46559. ],
  46560. "TMate": [
  46561. "TMate Open Source License",
  46562. false,
  46563. false
  46564. ],
  46565. "TORQUE-1.1": [
  46566. "TORQUE v2.5+ Software License v1.1",
  46567. false,
  46568. false
  46569. ],
  46570. "TOSL": [
  46571. "Trusster Open Source License",
  46572. false,
  46573. false
  46574. ],
  46575. "TU-Berlin-1.0": [
  46576. "Technische Universitaet Berlin License 1.0",
  46577. false,
  46578. false
  46579. ],
  46580. "TU-Berlin-2.0": [
  46581. "Technische Universitaet Berlin License 2.0",
  46582. false,
  46583. false
  46584. ],
  46585. "UCL-1.0": [
  46586. "Upstream Compatibility License v1.0",
  46587. true,
  46588. false
  46589. ],
  46590. "Unicode-DFS-2015": [
  46591. "Unicode License Agreement - Data Files and Software (2015)",
  46592. false,
  46593. false
  46594. ],
  46595. "Unicode-DFS-2016": [
  46596. "Unicode License Agreement - Data Files and Software (2016)",
  46597. true,
  46598. false
  46599. ],
  46600. "Unicode-TOU": [
  46601. "Unicode Terms of Use",
  46602. false,
  46603. false
  46604. ],
  46605. "Unlicense": [
  46606. "The Unlicense",
  46607. true,
  46608. false
  46609. ],
  46610. "UPL-1.0": [
  46611. "Universal Permissive License v1.0",
  46612. true,
  46613. false
  46614. ],
  46615. "Vim": [
  46616. "Vim License",
  46617. false,
  46618. false
  46619. ],
  46620. "VOSTROM": [
  46621. "VOSTROM Public License for Open Source",
  46622. false,
  46623. false
  46624. ],
  46625. "VSL-1.0": [
  46626. "Vovida Software License v1.0",
  46627. true,
  46628. false
  46629. ],
  46630. "W3C": [
  46631. "W3C Software Notice and License (2002-12-31)",
  46632. true,
  46633. false
  46634. ],
  46635. "W3C-19980720": [
  46636. "W3C Software Notice and License (1998-07-20)",
  46637. false,
  46638. false
  46639. ],
  46640. "W3C-20150513": [
  46641. "W3C Software Notice and Document License (2015-05-13)",
  46642. false,
  46643. false
  46644. ],
  46645. "Watcom-1.0": [
  46646. "Sybase Open Watcom Public License 1.0",
  46647. true,
  46648. false
  46649. ],
  46650. "Wsuipa": [
  46651. "Wsuipa License",
  46652. false,
  46653. false
  46654. ],
  46655. "WTFPL": [
  46656. "Do What The F*ck You Want To Public License",
  46657. false,
  46658. false
  46659. ],
  46660. "wxWindows": [
  46661. "wxWindows Library License",
  46662. true,
  46663. true
  46664. ],
  46665. "X11": [
  46666. "X11 License",
  46667. false,
  46668. false
  46669. ],
  46670. "Xerox": [
  46671. "Xerox License",
  46672. false,
  46673. false
  46674. ],
  46675. "XFree86-1.1": [
  46676. "XFree86 License 1.1",
  46677. false,
  46678. false
  46679. ],
  46680. "xinetd": [
  46681. "xinetd License",
  46682. false,
  46683. false
  46684. ],
  46685. "Xnet": [
  46686. "X.Net License",
  46687. true,
  46688. false
  46689. ],
  46690. "xpp": [
  46691. "XPP License",
  46692. false,
  46693. false
  46694. ],
  46695. "XSkat": [
  46696. "XSkat License",
  46697. false,
  46698. false
  46699. ],
  46700. "YPL-1.0": [
  46701. "Yahoo! Public License v1.0",
  46702. false,
  46703. false
  46704. ],
  46705. "YPL-1.1": [
  46706. "Yahoo! Public License v1.1",
  46707. false,
  46708. false
  46709. ],
  46710. "Zed": [
  46711. "Zed License",
  46712. false,
  46713. false
  46714. ],
  46715. "Zend-2.0": [
  46716. "Zend License v2.0",
  46717. false,
  46718. false
  46719. ],
  46720. "Zimbra-1.3": [
  46721. "Zimbra Public License v1.3",
  46722. false,
  46723. false
  46724. ],
  46725. "Zimbra-1.4": [
  46726. "Zimbra Public License v1.4",
  46727. false,
  46728. false
  46729. ],
  46730. "Zlib": [
  46731. "zlib License",
  46732. true,
  46733. false
  46734. ],
  46735. "zlib-acknowledgement": [
  46736. "zlib/libpng License with Acknowledgement",
  46737. false,
  46738. false
  46739. ],
  46740. "ZPL-1.1": [
  46741. "Zope Public License 1.1",
  46742. false,
  46743. false
  46744. ],
  46745. "ZPL-2.0": [
  46746. "Zope Public License 2.0",
  46747. true,
  46748. false
  46749. ],
  46750. "ZPL-2.1": [
  46751. "Zope Public License 2.1",
  46752. true,
  46753. false
  46754. ]
  46755. }<?php
  46756. namespace Composer\Spdx;
  46757. class SpdxLicenses
  46758. {
  46759. const LICENSES_FILE = 'spdx-licenses.json';
  46760. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  46761. private $licenses;
  46762. private $licensesExpression;
  46763. private $exceptions;
  46764. private $exceptionsExpression;
  46765. public function __construct()
  46766. {
  46767. $this->loadLicenses();
  46768. $this->loadExceptions();
  46769. }
  46770. public function getLicenseByIdentifier($identifier)
  46771. {
  46772. $key = strtolower($identifier);
  46773. if (!isset($this->licenses[$key])) {
  46774. return null;
  46775. }
  46776. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  46777. return array(
  46778. $name,
  46779. $isOsiApproved,
  46780. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  46781. $isDeprecatedLicenseId,
  46782. );
  46783. }
  46784. public function getLicenses()
  46785. {
  46786. return $this->licenses;
  46787. }
  46788. public function getExceptionByIdentifier($identifier)
  46789. {
  46790. $key = strtolower($identifier);
  46791. if (!isset($this->exceptions[$key])) {
  46792. return null;
  46793. }
  46794. list($identifier, $name) = $this->exceptions[$key];
  46795. return array(
  46796. $name,
  46797. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  46798. );
  46799. }
  46800. public function getIdentifierByName($name)
  46801. {
  46802. foreach ($this->licenses as $licenseData) {
  46803. if ($licenseData[1] === $name) {
  46804. return $licenseData[0];
  46805. }
  46806. }
  46807. foreach ($this->exceptions as $licenseData) {
  46808. if ($licenseData[1] === $name) {
  46809. return $licenseData[0];
  46810. }
  46811. }
  46812. return null;
  46813. }
  46814. public function isOsiApprovedByIdentifier($identifier)
  46815. {
  46816. return $this->licenses[strtolower($identifier)][2];
  46817. }
  46818. public function isDeprecatedByIdentifier($identifier)
  46819. {
  46820. return $this->licenses[strtolower($identifier)][3];
  46821. }
  46822. public function validate($license)
  46823. {
  46824. if (is_array($license)) {
  46825. $count = count($license);
  46826. if ($count !== count(array_filter($license, 'is_string'))) {
  46827. throw new \InvalidArgumentException('Array of strings expected.');
  46828. }
  46829. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  46830. }
  46831. if (!is_string($license)) {
  46832. throw new \InvalidArgumentException(sprintf(
  46833. 'Array or String expected, %s given.',
  46834. gettype($license)
  46835. ));
  46836. }
  46837. return $this->isValidLicenseString($license);
  46838. }
  46839. public static function getResourcesDir()
  46840. {
  46841. return dirname(__DIR__) . '/res';
  46842. }
  46843. private function loadLicenses()
  46844. {
  46845. if (null !== $this->licenses) {
  46846. return;
  46847. }
  46848. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  46849. if (false === $json) {
  46850. throw new \RuntimeException('Missing license file in ' . self::getResourcesDir() . '/' . self::LICENSES_FILE);
  46851. }
  46852. $this->licenses = array();
  46853. foreach (json_decode($json, true) as $identifier => $license) {
  46854. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  46855. }
  46856. }
  46857. private function loadExceptions()
  46858. {
  46859. if (null !== $this->exceptions) {
  46860. return;
  46861. }
  46862. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  46863. if (false === $json) {
  46864. throw new \RuntimeException('Missing exceptions file in ' . self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  46865. }
  46866. $this->exceptions = array();
  46867. foreach (json_decode($json, true) as $identifier => $exception) {
  46868. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  46869. }
  46870. }
  46871. private function getLicensesExpression()
  46872. {
  46873. if (null === $this->licensesExpression) {
  46874. $licenses = array_map('preg_quote', array_keys($this->licenses));
  46875. rsort($licenses);
  46876. $licenses = implode('|', $licenses);
  46877. $this->licensesExpression = $licenses;
  46878. }
  46879. return $this->licensesExpression;
  46880. }
  46881. private function getExceptionsExpression()
  46882. {
  46883. if (null === $this->exceptionsExpression) {
  46884. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  46885. rsort($exceptions);
  46886. $exceptions = implode('|', $exceptions);
  46887. $this->exceptionsExpression = $exceptions;
  46888. }
  46889. return $this->exceptionsExpression;
  46890. }
  46891. private function isValidLicenseString($license)
  46892. {
  46893. if (isset($this->licenses[strtolower($license)])) {
  46894. return true;
  46895. }
  46896. $licenses = $this->getLicensesExpression();
  46897. $exceptions = $this->getExceptionsExpression();
  46898. $regex = <<<REGEX
  46899. {
  46900. (?(DEFINE)
  46901. # idstring: 1*( ALPHA / DIGIT / - / . )
  46902. (?<idstring>[\pL\pN.-]{1,})
  46903. # license-id: taken from list
  46904. (?<licenseid>${licenses})
  46905. # license-exception-id: taken from list
  46906. (?<licenseexceptionid>${exceptions})
  46907. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  46908. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  46909. # simple-expresssion: license-id / license-id+ / license-ref
  46910. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  46911. # compound-expression: 1*(
  46912. # simple-expression /
  46913. # simple-expression WITH license-exception-id /
  46914. # compound-expression AND compound-expression /
  46915. # compound-expression OR compound-expression
  46916. # ) / ( compound-expression ) )
  46917. (?<compound_head>
  46918. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  46919. | \( \s* (?&compound_expression) \s* \)
  46920. )
  46921. (?<compound_expression>
  46922. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  46923. )
  46924. # license-expression: 1*1(simple-expression / compound-expression)
  46925. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  46926. ) # end of define
  46927. ^(NONE | NOASSERTION | (?&license_expression))$
  46928. }xi
  46929. REGEX;
  46930. $match = preg_match($regex, $license);
  46931. if (0 === $match) {
  46932. return false;
  46933. }
  46934. if (false === $match) {
  46935. throw new \RuntimeException('Regex failed to compile/run.');
  46936. }
  46937. return true;
  46938. }
  46939. }
  46940. MIT License
  46941. Copyright (c) 2017 Composer
  46942. Permission is hereby granted, free of charge, to any person obtaining a copy
  46943. of this software and associated documentation files (the "Software"), to deal
  46944. in the Software without restriction, including without limitation the rights
  46945. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46946. copies of the Software, and to permit persons to whom the Software is
  46947. furnished to do so, subject to the following conditions:
  46948. The above copyright notice and this permission notice shall be included in all
  46949. copies or substantial portions of the Software.
  46950. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46951. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46952. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46953. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46954. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46955. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  46956. SOFTWARE.
  46957. <?php
  46958. namespace Composer\XdebugHandler;
  46959. class PhpConfig
  46960. {
  46961. public function useOriginal()
  46962. {
  46963. $this->getDataAndReset();
  46964. return array();
  46965. }
  46966. public function useStandard()
  46967. {
  46968. $data = $this->getDataAndReset();
  46969. if ($data !== null) {
  46970. return array('-n', '-c', $data['tmpIni']);
  46971. }
  46972. return array();
  46973. }
  46974. public function usePersistent()
  46975. {
  46976. $data = $this->getDataAndReset();
  46977. if ($data !== null) {
  46978. $this->updateEnv('PHPRC', $data['tmpIni']);
  46979. $this->updateEnv('PHP_INI_SCAN_DIR', '');
  46980. }
  46981. return array();
  46982. }
  46983. private function getDataAndReset()
  46984. {
  46985. $data = XdebugHandler::getRestartSettings();
  46986. if ($data !== null) {
  46987. $this->updateEnv('PHPRC', $data['phprc']);
  46988. $this->updateEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  46989. }
  46990. return $data;
  46991. }
  46992. private function updateEnv($name, $value)
  46993. {
  46994. Process::setEnv($name, false !== $value ? $value : null);
  46995. }
  46996. }
  46997. <?php
  46998. namespace Composer\XdebugHandler;
  46999. use Composer\Pcre\Preg;
  47000. class Process
  47001. {
  47002. public static function escape($arg, $meta = true, $module = false)
  47003. {
  47004. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  47005. return "'".str_replace("'", "'\\''", $arg)."'";
  47006. }
  47007. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  47008. $arg = Preg::replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  47009. if ($meta) {
  47010. $meta = $dquotes || Preg::isMatch('/%[^%]+%/', $arg);
  47011. if (!$meta) {
  47012. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  47013. } elseif ($module && !$dquotes && $quote) {
  47014. $meta = false;
  47015. }
  47016. }
  47017. if ($quote) {
  47018. $arg = '"'.(Preg::replace('/(\\\\*)$/', '$1$1', $arg)).'"';
  47019. }
  47020. if ($meta) {
  47021. $arg = Preg::replace('/(["^&|<>()%])/', '^$1', $arg);
  47022. }
  47023. return $arg;
  47024. }
  47025. public static function escapeShellCommand(array $args)
  47026. {
  47027. $command = '';
  47028. $module = array_shift($args);
  47029. if ($module !== null) {
  47030. $command = self::escape($module, true, true);
  47031. foreach ($args as $arg) {
  47032. $command .= ' '.self::escape($arg);
  47033. }
  47034. }
  47035. return $command;
  47036. }
  47037. public static function setEnv($name, $value = null)
  47038. {
  47039. $unset = null === $value;
  47040. if (!putenv($unset ? $name : $name.'='.$value)) {
  47041. return false;
  47042. }
  47043. if ($unset) {
  47044. unset($_SERVER[$name]);
  47045. } else {
  47046. $_SERVER[$name] = $value;
  47047. }
  47048. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  47049. if ($unset) {
  47050. unset($_ENV[$name]);
  47051. } else {
  47052. $_ENV[$name] = $value;
  47053. }
  47054. }
  47055. return true;
  47056. }
  47057. }
  47058. <?php
  47059. namespace Composer\XdebugHandler;
  47060. use Psr\Log\LoggerInterface;
  47061. use Psr\Log\LogLevel;
  47062. class Status
  47063. {
  47064. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  47065. const CHECK = 'Check';
  47066. const ERROR = 'Error';
  47067. const INFO = 'Info';
  47068. const NORESTART = 'NoRestart';
  47069. const RESTART = 'Restart';
  47070. const RESTARTING = 'Restarting';
  47071. const RESTARTED = 'Restarted';
  47072. private $debug;
  47073. private $envAllowXdebug;
  47074. private $loaded;
  47075. private $logger;
  47076. private $modeOff;
  47077. private $time;
  47078. public function __construct($envAllowXdebug, $debug)
  47079. {
  47080. $start = getenv(self::ENV_RESTART);
  47081. Process::setEnv(self::ENV_RESTART);
  47082. $this->time = is_numeric($start) ? round((microtime(true) - $start) * 1000) : 0;
  47083. $this->envAllowXdebug = $envAllowXdebug;
  47084. $this->debug = $debug && defined('STDERR');
  47085. $this->modeOff = false;
  47086. }
  47087. public function setLogger(LoggerInterface $logger)
  47088. {
  47089. $this->logger = $logger;
  47090. }
  47091. public function report($op, $data)
  47092. {
  47093. if ($this->logger !== null || $this->debug) {
  47094. $callable = array($this, 'report'.$op);
  47095. if (!is_callable($callable)) {
  47096. throw new \InvalidArgumentException('Unknown op handler: '.$op);
  47097. }
  47098. $params = $data !== null ? $data : array();
  47099. call_user_func_array($callable, array($params));
  47100. }
  47101. }
  47102. private function output($text, $level = null)
  47103. {
  47104. if ($this->logger !== null) {
  47105. $this->logger->log($level !== null ? $level: LogLevel::DEBUG, $text);
  47106. }
  47107. if ($this->debug) {
  47108. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  47109. }
  47110. }
  47111. private function reportCheck($loaded)
  47112. {
  47113. list($version, $mode) = explode('|', $loaded);
  47114. if ($version !== '') {
  47115. $this->loaded = '('.$version.')'.($mode !== '' ? ' mode='.$mode : '');
  47116. }
  47117. $this->modeOff = $mode === 'off';
  47118. $this->output('Checking '.$this->envAllowXdebug);
  47119. }
  47120. private function reportError($error)
  47121. {
  47122. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  47123. }
  47124. private function reportInfo($info)
  47125. {
  47126. $this->output($info);
  47127. }
  47128. private function reportNoRestart()
  47129. {
  47130. $this->output($this->getLoadedMessage());
  47131. if ($this->loaded !== null) {
  47132. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  47133. if (!((bool) getenv($this->envAllowXdebug))) {
  47134. $text .= ' Allowed by '.($this->modeOff ? 'mode' : 'application');
  47135. }
  47136. $this->output($text);
  47137. }
  47138. }
  47139. private function reportRestart()
  47140. {
  47141. $this->output($this->getLoadedMessage());
  47142. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  47143. }
  47144. private function reportRestarted()
  47145. {
  47146. $loaded = $this->getLoadedMessage();
  47147. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  47148. $level = $this->loaded !== null ? LogLevel::WARNING : null;
  47149. $this->output($text, $level);
  47150. }
  47151. private function reportRestarting($command)
  47152. {
  47153. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  47154. $this->output($text);
  47155. $text = 'Running '.$command;
  47156. $this->output($text);
  47157. }
  47158. private function getEnvAllow()
  47159. {
  47160. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  47161. }
  47162. private function getLoadedMessage()
  47163. {
  47164. $loaded = $this->loaded !== null ? sprintf('loaded %s', $this->loaded) : 'not loaded';
  47165. return 'The Xdebug extension is '.$loaded;
  47166. }
  47167. }
  47168. <?php
  47169. namespace Composer\XdebugHandler;
  47170. use Composer\Pcre\Preg;
  47171. use Psr\Log\LoggerInterface;
  47172. class XdebugHandler
  47173. {
  47174. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  47175. const SUFFIX_INIS = '_ORIGINAL_INIS';
  47176. const RESTART_ID = 'internal';
  47177. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  47178. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  47179. protected $tmpIni;
  47180. private static $inRestart;
  47181. private static $name;
  47182. private static $skipped;
  47183. private static $xdebugActive;
  47184. private static $xdebugMode;
  47185. private static $xdebugVersion;
  47186. private $cli;
  47187. private $debug;
  47188. private $envAllowXdebug;
  47189. private $envOriginalInis;
  47190. private $persistent;
  47191. private $script;
  47192. private $statusWriter;
  47193. public function __construct($envPrefix)
  47194. {
  47195. if (!is_string($envPrefix) || $envPrefix === '') {
  47196. throw new \RuntimeException('Invalid constructor parameter');
  47197. }
  47198. self::$name = strtoupper($envPrefix);
  47199. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  47200. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  47201. self::setXdebugDetails();
  47202. self::$inRestart = false;
  47203. if ($this->cli = PHP_SAPI === 'cli') {
  47204. $this->debug = (string) getenv(self::DEBUG);
  47205. }
  47206. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  47207. }
  47208. public function setLogger(LoggerInterface $logger)
  47209. {
  47210. $this->statusWriter->setLogger($logger);
  47211. return $this;
  47212. }
  47213. public function setMainScript($script)
  47214. {
  47215. $this->script = $script;
  47216. return $this;
  47217. }
  47218. public function setPersistent()
  47219. {
  47220. $this->persistent = true;
  47221. return $this;
  47222. }
  47223. public function check()
  47224. {
  47225. $this->notify(Status::CHECK, self::$xdebugVersion.'|'.self::$xdebugMode);
  47226. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  47227. if (!((bool) $envArgs[0]) && $this->requiresRestart(self::$xdebugActive)) {
  47228. $this->notify(Status::RESTART);
  47229. if ($this->prepareRestart()) {
  47230. $command = $this->getCommand();
  47231. $this->restart($command);
  47232. }
  47233. return;
  47234. }
  47235. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  47236. $this->notify(Status::RESTARTED);
  47237. Process::setEnv($this->envAllowXdebug);
  47238. self::$inRestart = true;
  47239. if (self::$xdebugVersion === null) {
  47240. self::$skipped = $envArgs[1];
  47241. }
  47242. $this->tryEnableSignals();
  47243. $this->setEnvRestartSettings($envArgs);
  47244. return;
  47245. }
  47246. $this->notify(Status::NORESTART);
  47247. $settings = self::getRestartSettings();
  47248. if ($settings !== null) {
  47249. $this->syncSettings($settings);
  47250. }
  47251. }
  47252. public static function getAllIniFiles()
  47253. {
  47254. if (self::$name !== null) {
  47255. $env = getenv(self::$name.self::SUFFIX_INIS);
  47256. if (false !== $env) {
  47257. return explode(PATH_SEPARATOR, $env);
  47258. }
  47259. }
  47260. $paths = array((string) php_ini_loaded_file());
  47261. $scanned = php_ini_scanned_files();
  47262. if ($scanned !== false) {
  47263. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  47264. }
  47265. return $paths;
  47266. }
  47267. public static function getRestartSettings()
  47268. {
  47269. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  47270. if (count($envArgs) !== 6
  47271. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  47272. return null;
  47273. }
  47274. return array(
  47275. 'tmpIni' => $envArgs[0],
  47276. 'scannedInis' => (bool) $envArgs[1],
  47277. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  47278. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  47279. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  47280. 'skipped' => $envArgs[5],
  47281. );
  47282. }
  47283. public static function getSkippedVersion()
  47284. {
  47285. return (string) self::$skipped;
  47286. }
  47287. public static function isXdebugActive()
  47288. {
  47289. self::setXdebugDetails();
  47290. return self::$xdebugActive;
  47291. }
  47292. protected function requiresRestart($default)
  47293. {
  47294. return $default;
  47295. }
  47296. protected function restart($command)
  47297. {
  47298. $this->doRestart($command);
  47299. }
  47300. private function doRestart(array $command)
  47301. {
  47302. $this->tryEnableSignals();
  47303. $this->notify(Status::RESTARTING, implode(' ', $command));
  47304. if (PHP_VERSION_ID >= 70400) {
  47305. $cmd = $command;
  47306. } else {
  47307. $cmd = Process::escapeShellCommand($command);
  47308. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  47309. $cmd = '"'.$cmd.'"';
  47310. }
  47311. }
  47312. $process = proc_open($cmd, array(), $pipes);
  47313. if (is_resource($process)) {
  47314. $exitCode = proc_close($process);
  47315. }
  47316. if (!isset($exitCode)) {
  47317. $this->notify(Status::ERROR, 'Unable to restart process');
  47318. $exitCode = -1;
  47319. } else {
  47320. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  47321. }
  47322. if ($this->debug === '2') {
  47323. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  47324. } else {
  47325. @unlink((string) $this->tmpIni);
  47326. }
  47327. exit($exitCode);
  47328. }
  47329. private function prepareRestart()
  47330. {
  47331. $error = null;
  47332. $iniFiles = self::getAllIniFiles();
  47333. $scannedInis = count($iniFiles) > 1;
  47334. $tmpDir = sys_get_temp_dir();
  47335. if (!$this->cli) {
  47336. $error = 'Unsupported SAPI: '.PHP_SAPI;
  47337. } elseif (!defined('PHP_BINARY')) {
  47338. $error = 'PHP version is too old: '.PHP_VERSION;
  47339. } elseif (!$this->checkConfiguration($info)) {
  47340. $error = $info;
  47341. } elseif (!$this->checkScanDirConfig()) {
  47342. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  47343. } elseif (!$this->checkMainScript()) {
  47344. $error = 'Unable to access main script: '.$this->script;
  47345. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  47346. $error = $error !== null ? $error : 'Unable to create temp ini file at: '.$tmpDir;
  47347. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  47348. $error = 'Unable to set environment variables';
  47349. }
  47350. if ($error !== null) {
  47351. $this->notify(Status::ERROR, $error);
  47352. }
  47353. return $error === null;
  47354. }
  47355. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  47356. {
  47357. if (($tmpfile = @tempnam($tmpDir, '')) === false) {
  47358. return false;
  47359. }
  47360. $this->tmpIni = $tmpfile;
  47361. if ($iniFiles[0] === '') {
  47362. array_shift($iniFiles);
  47363. }
  47364. $content = '';
  47365. $sectionRegex = '/^\s*\[(?:PATH|HOST)\s*=/mi';
  47366. $xdebugRegex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  47367. foreach ($iniFiles as $file) {
  47368. if (($data = @file_get_contents($file)) === false) {
  47369. $error = 'Unable to read ini: '.$file;
  47370. return false;
  47371. }
  47372. if (Preg::isMatchWithOffsets($sectionRegex, $data, $matches, PREG_OFFSET_CAPTURE)) {
  47373. $data = substr($data, 0, $matches[0][1]);
  47374. }
  47375. $content .= Preg::replace($xdebugRegex, ';$1', $data).PHP_EOL;
  47376. }
  47377. $config = parse_ini_string($content);
  47378. $loaded = ini_get_all(null, false);
  47379. if (false === $config || false === $loaded) {
  47380. $error = 'Unable to parse ini data';
  47381. return false;
  47382. }
  47383. $content .= $this->mergeLoadedConfig($loaded, $config);
  47384. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  47385. return (bool) @file_put_contents($this->tmpIni, $content);
  47386. }
  47387. private function getCommand()
  47388. {
  47389. $php = array(PHP_BINARY);
  47390. $args = array_slice($_SERVER['argv'], 1);
  47391. if (!$this->persistent) {
  47392. array_push($php, '-n', '-c', $this->tmpIni);
  47393. }
  47394. return array_merge($php, array($this->script), $args);
  47395. }
  47396. private function setEnvironment($scannedInis, array $iniFiles)
  47397. {
  47398. $scanDir = getenv('PHP_INI_SCAN_DIR');
  47399. $phprc = getenv('PHPRC');
  47400. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  47401. return false;
  47402. }
  47403. if ($this->persistent) {
  47404. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  47405. return false;
  47406. }
  47407. }
  47408. $envArgs = array(
  47409. self::RESTART_ID,
  47410. self::$xdebugVersion,
  47411. (int) $scannedInis,
  47412. false === $scanDir ? '*' : $scanDir,
  47413. false === $phprc ? '*' : $phprc,
  47414. );
  47415. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  47416. }
  47417. private function notify($op, $data = null)
  47418. {
  47419. $this->statusWriter->report($op, $data);
  47420. }
  47421. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  47422. {
  47423. $content = '';
  47424. foreach ($loadedConfig as $name => $value) {
  47425. if (!is_string($value)
  47426. || strpos($name, 'xdebug') === 0
  47427. || $name === 'apc.mmap_file_mask') {
  47428. continue;
  47429. }
  47430. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  47431. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  47432. }
  47433. }
  47434. return $content;
  47435. }
  47436. private function checkMainScript()
  47437. {
  47438. if (null !== $this->script) {
  47439. return file_exists($this->script) || '--' === $this->script;
  47440. }
  47441. if (file_exists($this->script = $_SERVER['argv'][0])) {
  47442. return true;
  47443. }
  47444. $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  47445. $main = end($trace);
  47446. if ($main !== false && isset($main['file'])) {
  47447. return file_exists($this->script = $main['file']);
  47448. }
  47449. return false;
  47450. }
  47451. private function setEnvRestartSettings($envArgs)
  47452. {
  47453. $settings = array(
  47454. php_ini_loaded_file(),
  47455. $envArgs[2],
  47456. $envArgs[3],
  47457. $envArgs[4],
  47458. getenv($this->envOriginalInis),
  47459. self::$skipped,
  47460. );
  47461. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  47462. }
  47463. private function syncSettings(array $settings)
  47464. {
  47465. if (false === getenv($this->envOriginalInis)) {
  47466. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  47467. }
  47468. self::$skipped = $settings['skipped'];
  47469. $this->notify(Status::INFO, 'Process called with existing restart settings');
  47470. }
  47471. private function checkScanDirConfig()
  47472. {
  47473. if (PHP_VERSION_ID >= 70113 && PHP_VERSION_ID !== 70200) {
  47474. return true;
  47475. }
  47476. return ((string) getenv('PHP_INI_SCAN_DIR') === '')
  47477. || PHP_CONFIG_FILE_SCAN_DIR !== '';
  47478. }
  47479. private function checkConfiguration(&$info)
  47480. {
  47481. if (!function_exists('proc_open')) {
  47482. $info = 'proc_open function is disabled';
  47483. return false;
  47484. }
  47485. if (extension_loaded('uopz') && !((bool) ini_get('uopz.disable'))) {
  47486. if (function_exists('uopz_allow_exit')) {
  47487. @uopz_allow_exit(true);
  47488. } else {
  47489. $info = 'uopz extension is not compatible';
  47490. return false;
  47491. }
  47492. }
  47493. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 70400) {
  47494. $workingDir = getcwd();
  47495. if ($workingDir === false) {
  47496. $info = 'unable to determine working directory';
  47497. return false;
  47498. }
  47499. if (0 === strpos($workingDir, '\\\\')) {
  47500. $info = 'cmd.exe does not support UNC paths: '.$workingDir;
  47501. return false;
  47502. }
  47503. }
  47504. return true;
  47505. }
  47506. private function tryEnableSignals()
  47507. {
  47508. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  47509. pcntl_async_signals(true);
  47510. $message = 'Async signals enabled';
  47511. if (!self::$inRestart) {
  47512. pcntl_signal(SIGINT, SIG_IGN);
  47513. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  47514. pcntl_signal(SIGINT, SIG_DFL);
  47515. }
  47516. }
  47517. if (!self::$inRestart && function_exists('sapi_windows_set_ctrl_handler')) {
  47518. sapi_windows_set_ctrl_handler(function ($evt) {});
  47519. }
  47520. }
  47521. private static function setXdebugDetails()
  47522. {
  47523. if (self::$xdebugActive !== null) {
  47524. return;
  47525. }
  47526. self::$xdebugActive = false;
  47527. if (!extension_loaded('xdebug')) {
  47528. return;
  47529. }
  47530. $version = phpversion('xdebug');
  47531. self::$xdebugVersion = $version !== false ? $version : 'unknown';
  47532. if (version_compare(self::$xdebugVersion, '3.1', '>=')) {
  47533. $modes = xdebug_info('mode');
  47534. self::$xdebugMode = count($modes) === 0 ? 'off' : implode(',', $modes);
  47535. self::$xdebugActive = self::$xdebugMode !== 'off';
  47536. return;
  47537. }
  47538. $iniMode = ini_get('xdebug.mode');
  47539. if ($iniMode === false) {
  47540. return;
  47541. }
  47542. $envMode = (string) getenv('XDEBUG_MODE');
  47543. if ($envMode !== '') {
  47544. self::$xdebugMode = $envMode;
  47545. } else {
  47546. self::$xdebugMode = $iniMode !== '' ? $iniMode : 'off';
  47547. }
  47548. if (Preg::isMatch('/^,+$/', str_replace(' ', '', self::$xdebugMode))) {
  47549. self::$xdebugMode = 'off';
  47550. }
  47551. self::$xdebugActive = self::$xdebugMode !== 'off';
  47552. }
  47553. }
  47554. MIT License
  47555. Copyright (c) 2016
  47556. Permission is hereby granted, free of charge, to any person obtaining a copy
  47557. of this software and associated documentation files (the "Software"), to deal
  47558. in the Software without restriction, including without limitation the rights
  47559. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47560. copies of the Software, and to permit persons to whom the Software is
  47561. furnished to do so, subject to the following conditions:
  47562. The above copyright notice and this permission notice shall be included in all
  47563. copies or substantial portions of the Software.
  47564. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47565. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47566. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47567. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47568. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47569. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  47570. SOFTWARE.
  47571. <?php
  47572. namespace JsonSchema\Constraints;
  47573. use JsonSchema\Entity\JsonPointer;
  47574. use JsonSchema\Exception\InvalidArgumentException;
  47575. use JsonSchema\Exception\ValidationException;
  47576. use JsonSchema\Validator;
  47577. class BaseConstraint
  47578. {
  47579. protected $errors = array();
  47580. protected $errorMask = Validator::ERROR_NONE;
  47581. protected $factory;
  47582. public function __construct(Factory $factory = null)
  47583. {
  47584. $this->factory = $factory ?: new Factory();
  47585. }
  47586. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  47587. {
  47588. $error = array(
  47589. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  47590. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  47591. 'message' => $message,
  47592. 'constraint' => $constraint,
  47593. 'context' => $this->factory->getErrorContext(),
  47594. );
  47595. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  47596. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  47597. }
  47598. if (is_array($more) && count($more) > 0) {
  47599. $error += $more;
  47600. }
  47601. $this->errors[] = $error;
  47602. $this->errorMask |= $error['context'];
  47603. }
  47604. public function addErrors(array $errors)
  47605. {
  47606. if ($errors) {
  47607. $this->errors = array_merge($this->errors, $errors);
  47608. $errorMask = &$this->errorMask;
  47609. array_walk($errors, function ($error) use (&$errorMask) {
  47610. if (isset($error['context'])) {
  47611. $errorMask |= $error['context'];
  47612. }
  47613. });
  47614. }
  47615. }
  47616. public function getErrors($errorContext = Validator::ERROR_ALL)
  47617. {
  47618. if ($errorContext === Validator::ERROR_ALL) {
  47619. return $this->errors;
  47620. }
  47621. return array_filter($this->errors, function ($error) use ($errorContext) {
  47622. if ($errorContext & $error['context']) {
  47623. return true;
  47624. }
  47625. });
  47626. }
  47627. public function numErrors($errorContext = Validator::ERROR_ALL)
  47628. {
  47629. if ($errorContext === Validator::ERROR_ALL) {
  47630. return count($this->errors);
  47631. }
  47632. return count($this->getErrors($errorContext));
  47633. }
  47634. public function isValid()
  47635. {
  47636. return !$this->getErrors();
  47637. }
  47638. public function reset()
  47639. {
  47640. $this->errors = array();
  47641. $this->errorMask = Validator::ERROR_NONE;
  47642. }
  47643. public function getErrorMask()
  47644. {
  47645. return $this->errorMask;
  47646. }
  47647. public static function arrayToObjectRecursive($array)
  47648. {
  47649. $json = json_encode($array);
  47650. if (json_last_error() !== \JSON_ERROR_NONE) {
  47651. $message = 'Unable to encode schema array as JSON';
  47652. if (function_exists('json_last_error_msg')) {
  47653. $message .= ': ' . json_last_error_msg();
  47654. }
  47655. throw new InvalidArgumentException($message);
  47656. }
  47657. return (object) json_decode($json);
  47658. }
  47659. }
  47660. <?php
  47661. namespace JsonSchema\Constraints;
  47662. use JsonSchema\Entity\JsonPointer;
  47663. class CollectionConstraint extends Constraint
  47664. {
  47665. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47666. {
  47667. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  47668. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  47669. }
  47670. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  47671. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  47672. }
  47673. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  47674. $unique = $value;
  47675. if (is_array($value) && count($value)) {
  47676. $unique = array_map(function ($e) {
  47677. return var_export($e, true);
  47678. }, $value);
  47679. }
  47680. if (count(array_unique($unique)) != count($value)) {
  47681. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  47682. }
  47683. }
  47684. if (isset($schema->items)) {
  47685. $this->validateItems($value, $schema, $path, $i);
  47686. }
  47687. }
  47688. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47689. {
  47690. if (is_object($schema->items)) {
  47691. foreach ($value as $k => &$v) {
  47692. $initErrors = $this->getErrors();
  47693. $this->checkUndefined($v, $schema->items, $path, $k);
  47694. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  47695. $secondErrors = $this->getErrors();
  47696. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  47697. }
  47698. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  47699. $this->errors = $secondErrors;
  47700. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  47701. $this->errors = $initErrors;
  47702. }
  47703. }
  47704. unset($v);
  47705. } else {
  47706. foreach ($value as $k => &$v) {
  47707. if (array_key_exists($k, $schema->items)) {
  47708. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  47709. } else {
  47710. if (property_exists($schema, 'additionalItems')) {
  47711. if ($schema->additionalItems !== false) {
  47712. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  47713. } else {
  47714. $this->addError(
  47715. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  47716. }
  47717. } else {
  47718. $this->checkUndefined($v, new \stdClass(), $path, $k);
  47719. }
  47720. }
  47721. }
  47722. unset($v);
  47723. if (count($value) > 0) {
  47724. for ($k = count($value); $k < count($schema->items); $k++) {
  47725. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  47726. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  47727. }
  47728. }
  47729. }
  47730. }
  47731. }
  47732. <?php
  47733. namespace JsonSchema\Constraints;
  47734. use JsonSchema\Entity\JsonPointer;
  47735. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  47736. {
  47737. protected $inlineSchemaProperty = '$schema';
  47738. const CHECK_MODE_NONE = 0x00000000;
  47739. const CHECK_MODE_NORMAL = 0x00000001;
  47740. const CHECK_MODE_TYPE_CAST = 0x00000002;
  47741. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  47742. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  47743. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  47744. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  47745. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  47746. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  47747. protected function incrementPath(JsonPointer $path = null, $i)
  47748. {
  47749. $path = $path ?: new JsonPointer('');
  47750. if ($i === null || $i === '') {
  47751. return $path;
  47752. }
  47753. $path = $path->withPropertyPaths(
  47754. array_merge(
  47755. $path->getPropertyPaths(),
  47756. array($i)
  47757. )
  47758. );
  47759. return $path;
  47760. }
  47761. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47762. {
  47763. $validator = $this->factory->createInstanceFor('collection');
  47764. $validator->check($value, $schema, $path, $i);
  47765. $this->addErrors($validator->getErrors());
  47766. }
  47767. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  47768. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  47769. {
  47770. $validator = $this->factory->createInstanceFor('object');
  47771. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  47772. $this->addErrors($validator->getErrors());
  47773. }
  47774. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47775. {
  47776. $validator = $this->factory->createInstanceFor('type');
  47777. $validator->check($value, $schema, $path, $i);
  47778. $this->addErrors($validator->getErrors());
  47779. }
  47780. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  47781. {
  47782. $validator = $this->factory->createInstanceFor('undefined');
  47783. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  47784. $this->addErrors($validator->getErrors());
  47785. }
  47786. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  47787. {
  47788. $validator = $this->factory->createInstanceFor('string');
  47789. $validator->check($value, $schema, $path, $i);
  47790. $this->addErrors($validator->getErrors());
  47791. }
  47792. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  47793. {
  47794. $validator = $this->factory->createInstanceFor('number');
  47795. $validator->check($value, $schema, $path, $i);
  47796. $this->addErrors($validator->getErrors());
  47797. }
  47798. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  47799. {
  47800. $validator = $this->factory->createInstanceFor('enum');
  47801. $validator->check($value, $schema, $path, $i);
  47802. $this->addErrors($validator->getErrors());
  47803. }
  47804. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  47805. {
  47806. $validator = $this->factory->createInstanceFor('format');
  47807. $validator->check($value, $schema, $path, $i);
  47808. $this->addErrors($validator->getErrors());
  47809. }
  47810. protected function getTypeCheck()
  47811. {
  47812. return $this->factory->getTypeCheck();
  47813. }
  47814. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  47815. {
  47816. $result = array_map(
  47817. function ($path) {
  47818. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  47819. },
  47820. $pointer->getPropertyPaths()
  47821. );
  47822. return trim(implode('', $result), '.');
  47823. }
  47824. }
  47825. <?php
  47826. namespace JsonSchema\Constraints;
  47827. use JsonSchema\Entity\JsonPointer;
  47828. interface ConstraintInterface
  47829. {
  47830. public function getErrors();
  47831. public function addErrors(array $errors);
  47832. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  47833. public function isValid();
  47834. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  47835. }
  47836. <?php
  47837. namespace JsonSchema\Constraints;
  47838. use JsonSchema\Entity\JsonPointer;
  47839. class EnumConstraint extends Constraint
  47840. {
  47841. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  47842. {
  47843. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  47844. return;
  47845. }
  47846. $type = gettype($element);
  47847. foreach ($schema->enum as $enum) {
  47848. $enumType = gettype($enum);
  47849. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  47850. if ((object) $element == $enum) {
  47851. return;
  47852. }
  47853. }
  47854. if ($type === gettype($enum)) {
  47855. if ($type == 'object') {
  47856. if ($element == $enum) {
  47857. return;
  47858. }
  47859. } elseif ($element === $enum) {
  47860. return;
  47861. }
  47862. }
  47863. }
  47864. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  47865. }
  47866. }
  47867. <?php
  47868. namespace JsonSchema\Constraints;
  47869. use JsonSchema\Exception\InvalidArgumentException;
  47870. use JsonSchema\SchemaStorage;
  47871. use JsonSchema\SchemaStorageInterface;
  47872. use JsonSchema\Uri\UriRetriever;
  47873. use JsonSchema\UriRetrieverInterface;
  47874. use JsonSchema\Validator;
  47875. class Factory
  47876. {
  47877. protected $schemaStorage;
  47878. protected $uriRetriever;
  47879. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  47880. private $typeCheck = array();
  47881. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  47882. protected $constraintMap = array(
  47883. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  47884. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  47885. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  47886. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  47887. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  47888. 'string' => 'JsonSchema\Constraints\StringConstraint',
  47889. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  47890. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  47891. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  47892. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  47893. 'validator' => 'JsonSchema\Validator'
  47894. );
  47895. private $instanceCache = array();
  47896. public function __construct(
  47897. SchemaStorageInterface $schemaStorage = null,
  47898. UriRetrieverInterface $uriRetriever = null,
  47899. $checkMode = Constraint::CHECK_MODE_NORMAL
  47900. ) {
  47901. $this->setConfig($checkMode);
  47902. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  47903. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  47904. }
  47905. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  47906. {
  47907. $this->checkMode = $checkMode;
  47908. }
  47909. public function addConfig($options)
  47910. {
  47911. $this->checkMode |= $options;
  47912. }
  47913. public function removeConfig($options)
  47914. {
  47915. $this->checkMode &= ~$options;
  47916. }
  47917. public function getConfig($options = null)
  47918. {
  47919. if ($options === null) {
  47920. return $this->checkMode;
  47921. }
  47922. return $this->checkMode & $options;
  47923. }
  47924. public function getUriRetriever()
  47925. {
  47926. return $this->uriRetriever;
  47927. }
  47928. public function getSchemaStorage()
  47929. {
  47930. return $this->schemaStorage;
  47931. }
  47932. public function getTypeCheck()
  47933. {
  47934. if (!isset($this->typeCheck[$this->checkMode])) {
  47935. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  47936. ? new TypeCheck\LooseTypeCheck()
  47937. : new TypeCheck\StrictTypeCheck();
  47938. }
  47939. return $this->typeCheck[$this->checkMode];
  47940. }
  47941. public function setConstraintClass($name, $class)
  47942. {
  47943. if (!class_exists($class)) {
  47944. throw new InvalidArgumentException('Unknown constraint ' . $name);
  47945. }
  47946. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  47947. throw new InvalidArgumentException('Invalid class ' . $name);
  47948. }
  47949. $this->constraintMap[$name] = $class;
  47950. return $this;
  47951. }
  47952. public function createInstanceFor($constraintName)
  47953. {
  47954. if (!isset($this->constraintMap[$constraintName])) {
  47955. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  47956. }
  47957. if (!isset($this->instanceCache[$constraintName])) {
  47958. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  47959. }
  47960. return clone $this->instanceCache[$constraintName];
  47961. }
  47962. public function getErrorContext()
  47963. {
  47964. return $this->errorContext;
  47965. }
  47966. public function setErrorContext($errorContext)
  47967. {
  47968. $this->errorContext = $errorContext;
  47969. }
  47970. }
  47971. <?php
  47972. namespace JsonSchema\Constraints;
  47973. use JsonSchema\Entity\JsonPointer;
  47974. use JsonSchema\Rfc3339;
  47975. class FormatConstraint extends Constraint
  47976. {
  47977. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  47978. {
  47979. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  47980. return;
  47981. }
  47982. switch ($schema->format) {
  47983. case 'date':
  47984. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  47985. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  47986. }
  47987. break;
  47988. case 'time':
  47989. if (!$this->validateDateTime($element, 'H:i:s')) {
  47990. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  47991. }
  47992. break;
  47993. case 'date-time':
  47994. if (null === Rfc3339::createFromString($element)) {
  47995. $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));
  47996. }
  47997. break;
  47998. case 'utc-millisec':
  47999. if (!$this->validateDateTime($element, 'U')) {
  48000. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  48001. }
  48002. break;
  48003. case 'regex':
  48004. if (!$this->validateRegex($element)) {
  48005. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  48006. }
  48007. break;
  48008. case 'color':
  48009. if (!$this->validateColor($element)) {
  48010. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  48011. }
  48012. break;
  48013. case 'style':
  48014. if (!$this->validateStyle($element)) {
  48015. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  48016. }
  48017. break;
  48018. case 'phone':
  48019. if (!$this->validatePhone($element)) {
  48020. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  48021. }
  48022. break;
  48023. case 'uri':
  48024. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  48025. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  48026. }
  48027. break;
  48028. case 'uriref':
  48029. case 'uri-reference':
  48030. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  48031. if (substr($element, 0, 2) === '//') {
  48032. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  48033. } elseif (substr($element, 0, 1) === '/') {
  48034. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  48035. } elseif (strlen($element)) {
  48036. $pathParts = explode('/', $element, 2);
  48037. if (strpos($pathParts[0], ':') !== false) {
  48038. $validURL = null;
  48039. } else {
  48040. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  48041. }
  48042. } else {
  48043. $validURL = null;
  48044. }
  48045. if ($validURL === null) {
  48046. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  48047. }
  48048. }
  48049. break;
  48050. case 'email':
  48051. $filterFlags = FILTER_NULL_ON_FAILURE;
  48052. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  48053. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  48054. }
  48055. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  48056. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  48057. }
  48058. break;
  48059. case 'ip-address':
  48060. case 'ipv4':
  48061. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  48062. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  48063. }
  48064. break;
  48065. case 'ipv6':
  48066. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  48067. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  48068. }
  48069. break;
  48070. case 'host-name':
  48071. case 'hostname':
  48072. if (!$this->validateHostname($element)) {
  48073. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  48074. }
  48075. break;
  48076. default:
  48077. break;
  48078. }
  48079. }
  48080. protected function validateDateTime($datetime, $format)
  48081. {
  48082. $dt = \DateTime::createFromFormat($format, $datetime);
  48083. if (!$dt) {
  48084. return false;
  48085. }
  48086. if ($datetime === $dt->format($format)) {
  48087. return true;
  48088. }
  48089. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  48090. return true;
  48091. }
  48092. return false;
  48093. }
  48094. protected function validateRegex($regex)
  48095. {
  48096. return false !== @preg_match('/' . $regex . '/u', '');
  48097. }
  48098. protected function validateColor($color)
  48099. {
  48100. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  48101. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  48102. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  48103. return true;
  48104. }
  48105. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  48106. }
  48107. protected function validateStyle($style)
  48108. {
  48109. $properties = explode(';', rtrim($style, ';'));
  48110. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  48111. return empty($invalidEntries);
  48112. }
  48113. protected function validatePhone($phone)
  48114. {
  48115. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  48116. }
  48117. protected function validateHostname($host)
  48118. {
  48119. $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';
  48120. return preg_match($hostnameRegex, $host);
  48121. }
  48122. }
  48123. <?php
  48124. namespace JsonSchema\Constraints;
  48125. use JsonSchema\Entity\JsonPointer;
  48126. class NumberConstraint extends Constraint
  48127. {
  48128. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48129. {
  48130. if (isset($schema->exclusiveMinimum)) {
  48131. if (isset($schema->minimum)) {
  48132. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  48133. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  48134. } elseif ($element < $schema->minimum) {
  48135. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  48136. }
  48137. } else {
  48138. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  48139. }
  48140. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  48141. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  48142. }
  48143. if (isset($schema->exclusiveMaximum)) {
  48144. if (isset($schema->maximum)) {
  48145. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  48146. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  48147. } elseif ($element > $schema->maximum) {
  48148. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  48149. }
  48150. } else {
  48151. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  48152. }
  48153. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  48154. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  48155. }
  48156. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  48157. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  48158. }
  48159. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  48160. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  48161. }
  48162. $this->checkFormat($element, $schema, $path, $i);
  48163. }
  48164. private function fmod($number1, $number2)
  48165. {
  48166. $modulus = ($number1 - round($number1 / $number2) * $number2);
  48167. $precision = 0.0000000001;
  48168. if (-$precision < $modulus && $modulus < $precision) {
  48169. return 0.0;
  48170. }
  48171. return $modulus;
  48172. }
  48173. }
  48174. <?php
  48175. namespace JsonSchema\Constraints;
  48176. use JsonSchema\Entity\JsonPointer;
  48177. class ObjectConstraint extends Constraint
  48178. {
  48179. protected $appliedDefaults = array();
  48180. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  48181. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  48182. {
  48183. if ($element instanceof UndefinedConstraint) {
  48184. return;
  48185. }
  48186. $this->appliedDefaults = $appliedDefaults;
  48187. $matches = array();
  48188. if ($patternProperties) {
  48189. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  48190. }
  48191. if ($properties) {
  48192. $this->validateProperties($element, $properties, $path);
  48193. }
  48194. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  48195. }
  48196. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  48197. {
  48198. $try = array('/', '#', '+', '~', '%');
  48199. $matches = array();
  48200. foreach ($patternProperties as $pregex => $schema) {
  48201. $delimiter = '/';
  48202. foreach ($try as $delimiter) {
  48203. if (strpos($pregex, $delimiter) === false) {
  48204. break;
  48205. }
  48206. }
  48207. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  48208. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  48209. continue;
  48210. }
  48211. foreach ($element as $i => $value) {
  48212. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  48213. $matches[] = $i;
  48214. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  48215. }
  48216. }
  48217. }
  48218. return $matches;
  48219. }
  48220. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  48221. $properties = null, $additionalProp = null)
  48222. {
  48223. $this->validateMinMaxConstraint($element, $schema, $path);
  48224. foreach ($element as $i => $value) {
  48225. $definition = $this->getProperty($properties, $i);
  48226. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  48227. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  48228. }
  48229. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  48230. if ($additionalProp === true) {
  48231. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  48232. } else {
  48233. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  48234. }
  48235. }
  48236. $require = $this->getProperty($definition, 'requires');
  48237. if ($require && !$this->getProperty($element, $require)) {
  48238. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  48239. }
  48240. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  48241. if (is_object($property)) {
  48242. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  48243. }
  48244. }
  48245. }
  48246. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  48247. {
  48248. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  48249. foreach ($properties as $i => $value) {
  48250. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  48251. $definition = $this->getProperty($properties, $i);
  48252. if (is_object($definition)) {
  48253. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  48254. }
  48255. }
  48256. }
  48257. protected function &getProperty(&$element, $property, $fallback = null)
  48258. {
  48259. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  48260. return $element[$property];
  48261. } elseif (is_object($element) && property_exists($element, $property)) {
  48262. return $element->$property;
  48263. }
  48264. return $fallback;
  48265. }
  48266. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  48267. {
  48268. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  48269. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  48270. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  48271. }
  48272. }
  48273. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  48274. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  48275. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  48276. }
  48277. }
  48278. }
  48279. }
  48280. <?php
  48281. namespace JsonSchema\Constraints;
  48282. use JsonSchema\Entity\JsonPointer;
  48283. use JsonSchema\Exception\InvalidArgumentException;
  48284. use JsonSchema\Exception\InvalidSchemaException;
  48285. use JsonSchema\Exception\RuntimeException;
  48286. use JsonSchema\Validator;
  48287. class SchemaConstraint extends Constraint
  48288. {
  48289. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  48290. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48291. {
  48292. if ($schema !== null) {
  48293. $validationSchema = $schema;
  48294. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  48295. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  48296. } else {
  48297. throw new InvalidArgumentException('no schema found to verify against');
  48298. }
  48299. if (is_array($validationSchema)) {
  48300. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  48301. }
  48302. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  48303. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  48304. throw new RuntimeException('Cannot validate the schema of a non-object');
  48305. }
  48306. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  48307. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  48308. } else {
  48309. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  48310. }
  48311. $schemaStorage = $this->factory->getSchemaStorage();
  48312. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  48313. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  48314. }
  48315. $initialErrorCount = $this->numErrors();
  48316. $initialConfig = $this->factory->getConfig();
  48317. $initialContext = $this->factory->getErrorContext();
  48318. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  48319. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  48320. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  48321. try {
  48322. $this->check($validationSchema, $schemaSpec);
  48323. } catch (\Exception $e) {
  48324. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  48325. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  48326. }
  48327. }
  48328. if ($this->numErrors() > $initialErrorCount) {
  48329. $this->addError($path, 'Schema is not valid', 'schema');
  48330. }
  48331. $this->factory->setConfig($initialConfig);
  48332. $this->factory->setErrorContext($initialContext);
  48333. }
  48334. $this->checkUndefined($element, $validationSchema, $path, $i);
  48335. }
  48336. }
  48337. <?php
  48338. namespace JsonSchema\Constraints;
  48339. use JsonSchema\Entity\JsonPointer;
  48340. class StringConstraint extends Constraint
  48341. {
  48342. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48343. {
  48344. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  48345. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  48346. 'maxLength' => $schema->maxLength,
  48347. ));
  48348. }
  48349. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  48350. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  48351. 'minLength' => $schema->minLength,
  48352. ));
  48353. }
  48354. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  48355. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  48356. 'pattern' => $schema->pattern,
  48357. ));
  48358. }
  48359. $this->checkFormat($element, $schema, $path, $i);
  48360. }
  48361. private function strlen($string)
  48362. {
  48363. if (extension_loaded('mbstring')) {
  48364. return mb_strlen($string, mb_detect_encoding($string));
  48365. }
  48366. return strlen($string);
  48367. }
  48368. }
  48369. <?php
  48370. namespace JsonSchema\Constraints\TypeCheck;
  48371. class LooseTypeCheck implements TypeCheckInterface
  48372. {
  48373. public static function isObject($value)
  48374. {
  48375. return
  48376. is_object($value) ||
  48377. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  48378. }
  48379. public static function isArray($value)
  48380. {
  48381. return
  48382. is_array($value) &&
  48383. (count($value) == 0 || !self::isAssociativeArray($value));
  48384. }
  48385. public static function propertyGet($value, $property)
  48386. {
  48387. if (is_object($value)) {
  48388. return $value->{$property};
  48389. }
  48390. return $value[$property];
  48391. }
  48392. public static function propertySet(&$value, $property, $data)
  48393. {
  48394. if (is_object($value)) {
  48395. $value->{$property} = $data;
  48396. } else {
  48397. $value[$property] = $data;
  48398. }
  48399. }
  48400. public static function propertyExists($value, $property)
  48401. {
  48402. if (is_object($value)) {
  48403. return property_exists($value, $property);
  48404. }
  48405. return array_key_exists($property, $value);
  48406. }
  48407. public static function propertyCount($value)
  48408. {
  48409. if (is_object($value)) {
  48410. return count(get_object_vars($value));
  48411. }
  48412. return count($value);
  48413. }
  48414. private static function isAssociativeArray($arr)
  48415. {
  48416. return array_keys($arr) !== range(0, count($arr) - 1);
  48417. }
  48418. }
  48419. <?php
  48420. namespace JsonSchema\Constraints\TypeCheck;
  48421. class StrictTypeCheck implements TypeCheckInterface
  48422. {
  48423. public static function isObject($value)
  48424. {
  48425. return is_object($value);
  48426. }
  48427. public static function isArray($value)
  48428. {
  48429. return is_array($value);
  48430. }
  48431. public static function propertyGet($value, $property)
  48432. {
  48433. return $value->{$property};
  48434. }
  48435. public static function propertySet(&$value, $property, $data)
  48436. {
  48437. $value->{$property} = $data;
  48438. }
  48439. public static function propertyExists($value, $property)
  48440. {
  48441. return property_exists($value, $property);
  48442. }
  48443. public static function propertyCount($value)
  48444. {
  48445. if (!is_object($value)) {
  48446. return 0;
  48447. }
  48448. return count(get_object_vars($value));
  48449. }
  48450. }
  48451. <?php
  48452. namespace JsonSchema\Constraints\TypeCheck;
  48453. interface TypeCheckInterface
  48454. {
  48455. public static function isObject($value);
  48456. public static function isArray($value);
  48457. public static function propertyGet($value, $property);
  48458. public static function propertySet(&$value, $property, $data);
  48459. public static function propertyExists($value, $property);
  48460. public static function propertyCount($value);
  48461. }
  48462. <?php
  48463. namespace JsonSchema\Constraints;
  48464. use JsonSchema\Entity\JsonPointer;
  48465. use JsonSchema\Exception\InvalidArgumentException;
  48466. use UnexpectedValueException as StandardUnexpectedValueException;
  48467. class TypeConstraint extends Constraint
  48468. {
  48469. public static $wording = array(
  48470. 'integer' => 'an integer',
  48471. 'number' => 'a number',
  48472. 'boolean' => 'a boolean',
  48473. 'object' => 'an object',
  48474. 'array' => 'an array',
  48475. 'string' => 'a string',
  48476. 'null' => 'a null',
  48477. 'any' => null,
  48478. 0 => null,
  48479. );
  48480. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  48481. {
  48482. $type = isset($schema->type) ? $schema->type : null;
  48483. $isValid = false;
  48484. $wording = array();
  48485. if (is_array($type)) {
  48486. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  48487. } elseif (is_object($type)) {
  48488. $this->checkUndefined($value, $type, $path);
  48489. return;
  48490. } else {
  48491. $isValid = $this->validateType($value, $type);
  48492. }
  48493. if ($isValid === false) {
  48494. if (!is_array($type)) {
  48495. $this->validateTypeNameWording($type);
  48496. $wording[] = self::$wording[$type];
  48497. }
  48498. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  48499. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  48500. }
  48501. }
  48502. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  48503. {
  48504. foreach ($type as $tp) {
  48505. if (is_object($tp)) {
  48506. if (!$isValid) {
  48507. $validator = $this->factory->createInstanceFor('type');
  48508. $subSchema = new \stdClass();
  48509. $subSchema->type = $tp;
  48510. $validator->check($value, $subSchema, $path, null);
  48511. $error = $validator->getErrors();
  48512. $isValid = !(bool) $error;
  48513. $validTypesWording[] = self::$wording['object'];
  48514. }
  48515. } else {
  48516. $this->validateTypeNameWording($tp);
  48517. $validTypesWording[] = self::$wording[$tp];
  48518. if (!$isValid) {
  48519. $isValid = $this->validateType($value, $tp);
  48520. }
  48521. }
  48522. }
  48523. }
  48524. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  48525. {
  48526. if ($listEnd === false || !isset($elements[1])) {
  48527. return implode($delimiter, $elements);
  48528. }
  48529. $lastElement = array_slice($elements, -1);
  48530. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  48531. $implodedElements = array_merge(array($firsElements), $lastElement);
  48532. return join(" $listEnd ", $implodedElements);
  48533. }
  48534. protected function validateTypeNameWording($type)
  48535. {
  48536. if (!isset(self::$wording[$type])) {
  48537. throw new StandardUnexpectedValueException(
  48538. sprintf(
  48539. 'No wording for %s available, expected wordings are: [%s]',
  48540. var_export($type, true),
  48541. implode(', ', array_filter(self::$wording)))
  48542. );
  48543. }
  48544. }
  48545. protected function validateType(&$value, $type)
  48546. {
  48547. if (!$type) {
  48548. return true;
  48549. }
  48550. if ('any' === $type) {
  48551. return true;
  48552. }
  48553. if ('object' === $type) {
  48554. return $this->getTypeCheck()->isObject($value);
  48555. }
  48556. if ('array' === $type) {
  48557. return $this->getTypeCheck()->isArray($value);
  48558. }
  48559. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  48560. if ('integer' === $type) {
  48561. if ($coerce) {
  48562. $value = $this->toInteger($value);
  48563. }
  48564. return is_int($value);
  48565. }
  48566. if ('number' === $type) {
  48567. if ($coerce) {
  48568. $value = $this->toNumber($value);
  48569. }
  48570. return is_numeric($value) && !is_string($value);
  48571. }
  48572. if ('boolean' === $type) {
  48573. if ($coerce) {
  48574. $value = $this->toBoolean($value);
  48575. }
  48576. return is_bool($value);
  48577. }
  48578. if ('string' === $type) {
  48579. return is_string($value);
  48580. }
  48581. if ('email' === $type) {
  48582. return is_string($value);
  48583. }
  48584. if ('null' === $type) {
  48585. return is_null($value);
  48586. }
  48587. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  48588. }
  48589. protected function toBoolean($value)
  48590. {
  48591. if ($value === 'true') {
  48592. return true;
  48593. }
  48594. if ($value === 'false') {
  48595. return false;
  48596. }
  48597. return $value;
  48598. }
  48599. protected function toNumber($value)
  48600. {
  48601. if (is_numeric($value)) {
  48602. return $value + 0;
  48603. }
  48604. return $value;
  48605. }
  48606. protected function toInteger($value)
  48607. {
  48608. if (is_numeric($value) && (int) $value == $value) {
  48609. return (int) $value;
  48610. }
  48611. return $value;
  48612. }
  48613. }
  48614. <?php
  48615. namespace JsonSchema\Constraints;
  48616. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  48617. use JsonSchema\Entity\JsonPointer;
  48618. use JsonSchema\Exception\ValidationException;
  48619. use JsonSchema\Uri\UriResolver;
  48620. class UndefinedConstraint extends Constraint
  48621. {
  48622. protected $appliedDefaults = array();
  48623. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  48624. {
  48625. if (is_null($schema) || !is_object($schema)) {
  48626. return;
  48627. }
  48628. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  48629. if ($fromDefault) {
  48630. $path->setFromDefault();
  48631. }
  48632. $this->validateCommonProperties($value, $schema, $path, $i);
  48633. $this->validateOfProperties($value, $schema, $path, '');
  48634. $this->validateTypes($value, $schema, $path, $i);
  48635. }
  48636. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  48637. {
  48638. if ($this->getTypeCheck()->isArray($value)) {
  48639. $this->checkArray($value, $schema, $path, $i);
  48640. }
  48641. if (LooseTypeCheck::isObject($value)) {
  48642. $this->checkObject(
  48643. $value,
  48644. $schema,
  48645. $path,
  48646. isset($schema->properties) ? $schema->properties : null,
  48647. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  48648. isset($schema->patternProperties) ? $schema->patternProperties : null,
  48649. $this->appliedDefaults
  48650. );
  48651. }
  48652. if (is_string($value)) {
  48653. $this->checkString($value, $schema, $path, $i);
  48654. }
  48655. if (is_numeric($value)) {
  48656. $this->checkNumber($value, $schema, $path, $i);
  48657. }
  48658. if (isset($schema->enum)) {
  48659. $this->checkEnum($value, $schema, $path, $i);
  48660. }
  48661. }
  48662. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  48663. {
  48664. if (isset($schema->extends)) {
  48665. if (is_string($schema->extends)) {
  48666. $schema->extends = $this->validateUri($schema, $schema->extends);
  48667. }
  48668. if (is_array($schema->extends)) {
  48669. foreach ($schema->extends as $extends) {
  48670. $this->checkUndefined($value, $extends, $path, $i);
  48671. }
  48672. } else {
  48673. $this->checkUndefined($value, $schema->extends, $path, $i);
  48674. }
  48675. }
  48676. if (!$path->fromDefault()) {
  48677. $this->applyDefaultValues($value, $schema, $path);
  48678. }
  48679. if ($this->getTypeCheck()->isObject($value)) {
  48680. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  48681. foreach ($schema->required as $required) {
  48682. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  48683. $this->addError(
  48684. $this->incrementPath($path ?: new JsonPointer(''), $required),
  48685. 'The property ' . $required . ' is required',
  48686. 'required'
  48687. );
  48688. }
  48689. }
  48690. } elseif (isset($schema->required) && !is_array($schema->required)) {
  48691. if ($schema->required && $value instanceof self) {
  48692. $propertyPaths = $path->getPropertyPaths();
  48693. $propertyName = end($propertyPaths);
  48694. $this->addError(
  48695. $path,
  48696. 'The property ' . $propertyName . ' is required',
  48697. 'required'
  48698. );
  48699. }
  48700. } else {
  48701. if ($value instanceof self) {
  48702. return;
  48703. }
  48704. }
  48705. }
  48706. if (!($value instanceof self)) {
  48707. $this->checkType($value, $schema, $path, $i);
  48708. }
  48709. if (isset($schema->disallow)) {
  48710. $initErrors = $this->getErrors();
  48711. $typeSchema = new \stdClass();
  48712. $typeSchema->type = $schema->disallow;
  48713. $this->checkType($value, $typeSchema, $path);
  48714. if (count($this->getErrors()) == count($initErrors)) {
  48715. $this->addError($path, 'Disallowed value was matched', 'disallow');
  48716. } else {
  48717. $this->errors = $initErrors;
  48718. }
  48719. }
  48720. if (isset($schema->not)) {
  48721. $initErrors = $this->getErrors();
  48722. $this->checkUndefined($value, $schema->not, $path, $i);
  48723. if (count($this->getErrors()) == count($initErrors)) {
  48724. $this->addError($path, 'Matched a schema which it should not', 'not');
  48725. } else {
  48726. $this->errors = $initErrors;
  48727. }
  48728. }
  48729. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  48730. $this->validateDependencies($value, $schema->dependencies, $path);
  48731. }
  48732. }
  48733. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  48734. {
  48735. if (!$requiredOnly) {
  48736. return true;
  48737. }
  48738. if (
  48739. $name !== null
  48740. && isset($parentSchema->required)
  48741. && is_array($parentSchema->required)
  48742. && in_array($name, $parentSchema->required)
  48743. ) {
  48744. return true;
  48745. }
  48746. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  48747. return true;
  48748. }
  48749. return false;
  48750. }
  48751. protected function applyDefaultValues(&$value, $schema, $path)
  48752. {
  48753. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  48754. return;
  48755. }
  48756. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  48757. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  48758. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  48759. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  48760. if (
  48761. !LooseTypeCheck::propertyExists($value, $currentProperty)
  48762. && property_exists($propertyDefinition, 'default')
  48763. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  48764. ) {
  48765. if (is_object($propertyDefinition->default)) {
  48766. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  48767. } else {
  48768. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  48769. }
  48770. $this->appliedDefaults[] = $currentProperty;
  48771. }
  48772. }
  48773. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  48774. $items = array();
  48775. if (LooseTypeCheck::isArray($schema->items)) {
  48776. $items = $schema->items;
  48777. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  48778. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  48779. }
  48780. foreach ($items as $currentItem => $itemDefinition) {
  48781. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  48782. if (
  48783. !array_key_exists($currentItem, $value)
  48784. && property_exists($itemDefinition, 'default')
  48785. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  48786. if (is_object($itemDefinition->default)) {
  48787. $value[$currentItem] = clone $itemDefinition->default;
  48788. } else {
  48789. $value[$currentItem] = $itemDefinition->default;
  48790. }
  48791. }
  48792. $path->setFromDefault();
  48793. }
  48794. } elseif (
  48795. $value instanceof self
  48796. && property_exists($schema, 'default')
  48797. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  48798. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  48799. $path->setFromDefault();
  48800. }
  48801. }
  48802. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  48803. {
  48804. if ($value instanceof self) {
  48805. return;
  48806. }
  48807. if (isset($schema->allOf)) {
  48808. $isValid = true;
  48809. foreach ($schema->allOf as $allOf) {
  48810. $initErrors = $this->getErrors();
  48811. $this->checkUndefined($value, $allOf, $path, $i);
  48812. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  48813. }
  48814. if (!$isValid) {
  48815. $this->addError($path, 'Failed to match all schemas', 'allOf');
  48816. }
  48817. }
  48818. if (isset($schema->anyOf)) {
  48819. $isValid = false;
  48820. $startErrors = $this->getErrors();
  48821. $caughtException = null;
  48822. foreach ($schema->anyOf as $anyOf) {
  48823. $initErrors = $this->getErrors();
  48824. try {
  48825. $this->checkUndefined($value, $anyOf, $path, $i);
  48826. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  48827. break;
  48828. }
  48829. } catch (ValidationException $e) {
  48830. $isValid = false;
  48831. }
  48832. }
  48833. if (!$isValid) {
  48834. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  48835. } else {
  48836. $this->errors = $startErrors;
  48837. }
  48838. }
  48839. if (isset($schema->oneOf)) {
  48840. $allErrors = array();
  48841. $matchedSchemas = 0;
  48842. $startErrors = $this->getErrors();
  48843. foreach ($schema->oneOf as $oneOf) {
  48844. try {
  48845. $this->errors = array();
  48846. $this->checkUndefined($value, $oneOf, $path, $i);
  48847. if (count($this->getErrors()) == 0) {
  48848. $matchedSchemas++;
  48849. }
  48850. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  48851. } catch (ValidationException $e) {
  48852. }
  48853. }
  48854. if ($matchedSchemas !== 1) {
  48855. $this->addErrors(array_merge($allErrors, $startErrors));
  48856. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  48857. } else {
  48858. $this->errors = $startErrors;
  48859. }
  48860. }
  48861. }
  48862. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  48863. {
  48864. foreach ($dependencies as $key => $dependency) {
  48865. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  48866. if (is_string($dependency)) {
  48867. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  48868. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  48869. }
  48870. } elseif (is_array($dependency)) {
  48871. foreach ($dependency as $d) {
  48872. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  48873. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  48874. }
  48875. }
  48876. } elseif (is_object($dependency)) {
  48877. $this->checkUndefined($value, $dependency, $path, $i);
  48878. }
  48879. }
  48880. }
  48881. }
  48882. protected function validateUri($schema, $schemaUri = null)
  48883. {
  48884. $resolver = new UriResolver();
  48885. $retriever = $this->factory->getUriRetriever();
  48886. $jsonSchema = null;
  48887. if ($resolver->isValid($schemaUri)) {
  48888. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  48889. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  48890. }
  48891. return $jsonSchema;
  48892. }
  48893. }
  48894. <?php
  48895. namespace JsonSchema\Entity;
  48896. use JsonSchema\Exception\InvalidArgumentException;
  48897. class JsonPointer
  48898. {
  48899. private $filename;
  48900. private $propertyPaths = array();
  48901. private $fromDefault = false;
  48902. public function __construct($value)
  48903. {
  48904. if (!is_string($value)) {
  48905. throw new InvalidArgumentException('Ref value must be a string');
  48906. }
  48907. $splitRef = explode('#', $value, 2);
  48908. $this->filename = $splitRef[0];
  48909. if (array_key_exists(1, $splitRef)) {
  48910. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  48911. }
  48912. }
  48913. private function decodePropertyPaths($propertyPathString)
  48914. {
  48915. $paths = array();
  48916. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  48917. $path = $this->decodePath($path);
  48918. if (is_string($path) && '' !== $path) {
  48919. $paths[] = $path;
  48920. }
  48921. }
  48922. return $paths;
  48923. }
  48924. private function encodePropertyPaths()
  48925. {
  48926. return array_map(
  48927. array($this, 'encodePath'),
  48928. $this->getPropertyPaths()
  48929. );
  48930. }
  48931. private function decodePath($path)
  48932. {
  48933. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  48934. }
  48935. private function encodePath($path)
  48936. {
  48937. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  48938. }
  48939. public function getFilename()
  48940. {
  48941. return $this->filename;
  48942. }
  48943. public function getPropertyPaths()
  48944. {
  48945. return $this->propertyPaths;
  48946. }
  48947. public function withPropertyPaths(array $propertyPaths)
  48948. {
  48949. $new = clone $this;
  48950. $new->propertyPaths = $propertyPaths;
  48951. return $new;
  48952. }
  48953. public function getPropertyPathAsString()
  48954. {
  48955. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  48956. }
  48957. public function __toString()
  48958. {
  48959. return $this->getFilename() . $this->getPropertyPathAsString();
  48960. }
  48961. public function setFromDefault()
  48962. {
  48963. $this->fromDefault = true;
  48964. }
  48965. public function fromDefault()
  48966. {
  48967. return $this->fromDefault;
  48968. }
  48969. }
  48970. <?php
  48971. namespace JsonSchema\Exception;
  48972. interface ExceptionInterface
  48973. {
  48974. }
  48975. <?php
  48976. namespace JsonSchema\Exception;
  48977. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  48978. {
  48979. }
  48980. <?php
  48981. namespace JsonSchema\Exception;
  48982. class InvalidConfigException extends RuntimeException
  48983. {
  48984. }
  48985. <?php
  48986. namespace JsonSchema\Exception;
  48987. class InvalidSchemaException extends RuntimeException
  48988. {
  48989. }
  48990. <?php
  48991. namespace JsonSchema\Exception;
  48992. class InvalidSchemaMediaTypeException extends RuntimeException
  48993. {
  48994. }
  48995. <?php
  48996. namespace JsonSchema\Exception;
  48997. class InvalidSourceUriException extends InvalidArgumentException
  48998. {
  48999. }
  49000. <?php
  49001. namespace JsonSchema\Exception;
  49002. class JsonDecodingException extends RuntimeException
  49003. {
  49004. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  49005. {
  49006. switch ($code) {
  49007. case JSON_ERROR_DEPTH:
  49008. $message = 'The maximum stack depth has been exceeded';
  49009. break;
  49010. case JSON_ERROR_STATE_MISMATCH:
  49011. $message = 'Invalid or malformed JSON';
  49012. break;
  49013. case JSON_ERROR_CTRL_CHAR:
  49014. $message = 'Control character error, possibly incorrectly encoded';
  49015. break;
  49016. case JSON_ERROR_UTF8:
  49017. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  49018. break;
  49019. case JSON_ERROR_SYNTAX:
  49020. $message = 'JSON syntax is malformed';
  49021. break;
  49022. default:
  49023. $message = 'Syntax error';
  49024. }
  49025. parent::__construct($message, $code, $previous);
  49026. }
  49027. }
  49028. <?php
  49029. namespace JsonSchema\Exception;
  49030. class ResourceNotFoundException extends RuntimeException
  49031. {
  49032. }
  49033. <?php
  49034. namespace JsonSchema\Exception;
  49035. class RuntimeException extends \RuntimeException implements ExceptionInterface
  49036. {
  49037. }
  49038. <?php
  49039. namespace JsonSchema\Exception;
  49040. class UnresolvableJsonPointerException extends InvalidArgumentException
  49041. {
  49042. }
  49043. <?php
  49044. namespace JsonSchema\Exception;
  49045. class UriResolverException extends RuntimeException
  49046. {
  49047. }
  49048. <?php
  49049. namespace JsonSchema\Exception;
  49050. class ValidationException extends RuntimeException
  49051. {
  49052. }
  49053. <?php
  49054. namespace JsonSchema\Iterator;
  49055. class ObjectIterator implements \Iterator, \Countable
  49056. {
  49057. private $object;
  49058. private $position = 0;
  49059. private $data = array();
  49060. private $initialized = false;
  49061. public function __construct($object)
  49062. {
  49063. $this->object = $object;
  49064. }
  49065. public function current()
  49066. {
  49067. $this->initialize();
  49068. return $this->data[$this->position];
  49069. }
  49070. public function next()
  49071. {
  49072. $this->initialize();
  49073. $this->position++;
  49074. }
  49075. public function key()
  49076. {
  49077. $this->initialize();
  49078. return $this->position;
  49079. }
  49080. public function valid()
  49081. {
  49082. $this->initialize();
  49083. return isset($this->data[$this->position]);
  49084. }
  49085. public function rewind()
  49086. {
  49087. $this->initialize();
  49088. $this->position = 0;
  49089. }
  49090. public function count()
  49091. {
  49092. $this->initialize();
  49093. return count($this->data);
  49094. }
  49095. private function initialize()
  49096. {
  49097. if (!$this->initialized) {
  49098. $this->data = $this->buildDataFromObject($this->object);
  49099. $this->initialized = true;
  49100. }
  49101. }
  49102. private function buildDataFromObject($object)
  49103. {
  49104. $result = array();
  49105. $stack = new \SplStack();
  49106. $stack->push($object);
  49107. while (!$stack->isEmpty()) {
  49108. $current = $stack->pop();
  49109. if (is_object($current)) {
  49110. array_push($result, $current);
  49111. }
  49112. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  49113. if (is_object($propertyValue) || is_array($propertyValue)) {
  49114. $stack->push($propertyValue);
  49115. }
  49116. }
  49117. }
  49118. return $result;
  49119. }
  49120. private function getDataFromItem($item)
  49121. {
  49122. if (!is_object($item) && !is_array($item)) {
  49123. return array();
  49124. }
  49125. return is_object($item) ? get_object_vars($item) : $item;
  49126. }
  49127. }
  49128. <?php
  49129. namespace JsonSchema;
  49130. class Rfc3339
  49131. {
  49132. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  49133. public static function createFromString($string)
  49134. {
  49135. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  49136. return null;
  49137. }
  49138. $dateAndTime = $matches[1];
  49139. $microseconds = $matches[2] ?: '.000000';
  49140. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  49141. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  49142. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  49143. return $dateTime ?: null;
  49144. }
  49145. }
  49146. <?php
  49147. namespace JsonSchema;
  49148. use JsonSchema\Constraints\BaseConstraint;
  49149. use JsonSchema\Entity\JsonPointer;
  49150. use JsonSchema\Exception\UnresolvableJsonPointerException;
  49151. use JsonSchema\Uri\UriResolver;
  49152. use JsonSchema\Uri\UriRetriever;
  49153. class SchemaStorage implements SchemaStorageInterface
  49154. {
  49155. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  49156. protected $uriRetriever;
  49157. protected $uriResolver;
  49158. protected $schemas = array();
  49159. public function __construct(
  49160. UriRetrieverInterface $uriRetriever = null,
  49161. UriResolverInterface $uriResolver = null
  49162. ) {
  49163. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  49164. $this->uriResolver = $uriResolver ?: new UriResolver();
  49165. }
  49166. public function getUriRetriever()
  49167. {
  49168. return $this->uriRetriever;
  49169. }
  49170. public function getUriResolver()
  49171. {
  49172. return $this->uriResolver;
  49173. }
  49174. public function addSchema($id, $schema = null)
  49175. {
  49176. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  49177. $schema = $this->uriRetriever->retrieve($id);
  49178. }
  49179. if (is_array($schema)) {
  49180. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  49181. }
  49182. if (is_object($schema) && property_exists($schema, 'id')) {
  49183. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  49184. $schema->properties->id->format = 'uri-reference';
  49185. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  49186. $schema->properties->id->format = 'uri-reference';
  49187. $schema->properties->{'$ref'}->format = 'uri-reference';
  49188. }
  49189. }
  49190. $this->expandRefs($schema, $id);
  49191. $this->schemas[$id] = $schema;
  49192. }
  49193. private function expandRefs(&$schema, $base = null)
  49194. {
  49195. if (!is_object($schema)) {
  49196. if (is_array($schema)) {
  49197. foreach ($schema as &$member) {
  49198. $this->expandRefs($member, $base);
  49199. }
  49200. }
  49201. return;
  49202. }
  49203. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  49204. $base = $this->uriResolver->resolve($schema->id, $base);
  49205. }
  49206. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  49207. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  49208. $schema->{'$ref'} = (string) $refPointer;
  49209. }
  49210. foreach ($schema as &$member) {
  49211. $this->expandRefs($member, $base);
  49212. }
  49213. }
  49214. public function getSchema($id)
  49215. {
  49216. if (!array_key_exists($id, $this->schemas)) {
  49217. $this->addSchema($id);
  49218. }
  49219. return $this->schemas[$id];
  49220. }
  49221. public function resolveRef($ref)
  49222. {
  49223. $jsonPointer = new JsonPointer($ref);
  49224. $fileName = $jsonPointer->getFilename();
  49225. if (!strlen($fileName)) {
  49226. throw new UnresolvableJsonPointerException(sprintf(
  49227. "Could not resolve fragment '%s': no file is defined",
  49228. $jsonPointer->getPropertyPathAsString()
  49229. ));
  49230. }
  49231. $refSchema = $this->getSchema($fileName);
  49232. foreach ($jsonPointer->getPropertyPaths() as $path) {
  49233. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  49234. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  49235. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  49236. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  49237. } else {
  49238. throw new UnresolvableJsonPointerException(sprintf(
  49239. 'File: %s is found, but could not resolve fragment: %s',
  49240. $jsonPointer->getFilename(),
  49241. $jsonPointer->getPropertyPathAsString()
  49242. ));
  49243. }
  49244. }
  49245. return $refSchema;
  49246. }
  49247. public function resolveRefSchema($refSchema)
  49248. {
  49249. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  49250. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  49251. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  49252. unset($refSchema->{'$ref'});
  49253. }
  49254. return $refSchema;
  49255. }
  49256. }
  49257. <?php
  49258. namespace JsonSchema;
  49259. interface SchemaStorageInterface
  49260. {
  49261. public function addSchema($id, $schema = null);
  49262. public function getSchema($id);
  49263. public function resolveRef($ref);
  49264. public function resolveRefSchema($refSchema);
  49265. }
  49266. <?php
  49267. namespace JsonSchema\Uri\Retrievers;
  49268. abstract class AbstractRetriever implements UriRetrieverInterface
  49269. {
  49270. protected $contentType;
  49271. public function getContentType()
  49272. {
  49273. return $this->contentType;
  49274. }
  49275. }
  49276. <?php
  49277. namespace JsonSchema\Uri\Retrievers;
  49278. use JsonSchema\Exception\RuntimeException;
  49279. use JsonSchema\Validator;
  49280. class Curl extends AbstractRetriever
  49281. {
  49282. protected $messageBody;
  49283. public function __construct()
  49284. {
  49285. if (!function_exists('curl_init')) {
  49286. throw new RuntimeException('cURL not installed');
  49287. }
  49288. }
  49289. public function retrieve($uri)
  49290. {
  49291. $ch = curl_init();
  49292. curl_setopt($ch, CURLOPT_URL, $uri);
  49293. curl_setopt($ch, CURLOPT_HEADER, true);
  49294. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  49295. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  49296. $response = curl_exec($ch);
  49297. if (false === $response) {
  49298. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  49299. }
  49300. $this->fetchMessageBody($response);
  49301. $this->fetchContentType($response);
  49302. curl_close($ch);
  49303. return $this->messageBody;
  49304. }
  49305. private function fetchMessageBody($response)
  49306. {
  49307. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  49308. $this->messageBody = $match[1];
  49309. }
  49310. protected function fetchContentType($response)
  49311. {
  49312. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  49313. $this->contentType = trim($match[1]);
  49314. return true;
  49315. }
  49316. return false;
  49317. }
  49318. }
  49319. <?php
  49320. namespace JsonSchema\Uri\Retrievers;
  49321. use JsonSchema\Exception\ResourceNotFoundException;
  49322. class FileGetContents extends AbstractRetriever
  49323. {
  49324. protected $messageBody;
  49325. public function retrieve($uri)
  49326. {
  49327. $errorMessage = null;
  49328. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  49329. $errorMessage = $errstr;
  49330. });
  49331. $response = file_get_contents($uri);
  49332. restore_error_handler();
  49333. if ($errorMessage) {
  49334. throw new ResourceNotFoundException($errorMessage);
  49335. }
  49336. if (false === $response) {
  49337. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  49338. }
  49339. if ($response == ''
  49340. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  49341. ) {
  49342. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  49343. }
  49344. $this->messageBody = $response;
  49345. if (!empty($http_response_header)) {
  49346. $this->fetchContentType($http_response_header);
  49347. } else {
  49348. $this->contentType = null;
  49349. }
  49350. return $this->messageBody;
  49351. }
  49352. private function fetchContentType(array $headers)
  49353. {
  49354. foreach ($headers as $header) {
  49355. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  49356. return true;
  49357. }
  49358. }
  49359. return false;
  49360. }
  49361. protected static function getContentTypeMatchInHeader($header)
  49362. {
  49363. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  49364. return trim($match[1]);
  49365. }
  49366. return null;
  49367. }
  49368. }
  49369. <?php
  49370. namespace JsonSchema\Uri\Retrievers;
  49371. use JsonSchema\Validator;
  49372. class PredefinedArray extends AbstractRetriever
  49373. {
  49374. private $schemas;
  49375. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  49376. {
  49377. $this->schemas = $schemas;
  49378. $this->contentType = $contentType;
  49379. }
  49380. public function retrieve($uri)
  49381. {
  49382. if (!array_key_exists($uri, $this->schemas)) {
  49383. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  49384. 'The JSON schema "%s" was not found.',
  49385. $uri
  49386. ));
  49387. }
  49388. return $this->schemas[$uri];
  49389. }
  49390. }
  49391. <?php
  49392. namespace JsonSchema\Uri\Retrievers;
  49393. interface UriRetrieverInterface
  49394. {
  49395. public function retrieve($uri);
  49396. public function getContentType();
  49397. }
  49398. <?php
  49399. namespace JsonSchema\Uri;
  49400. use JsonSchema\Exception\UriResolverException;
  49401. use JsonSchema\UriResolverInterface;
  49402. class UriResolver implements UriResolverInterface
  49403. {
  49404. public function parse($uri)
  49405. {
  49406. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  49407. $components = array();
  49408. if (5 < count($match)) {
  49409. $components = array(
  49410. 'scheme' => $match[2],
  49411. 'authority' => $match[4],
  49412. 'path' => $match[5]
  49413. );
  49414. }
  49415. if (7 < count($match)) {
  49416. $components['query'] = $match[7];
  49417. }
  49418. if (9 < count($match)) {
  49419. $components['fragment'] = $match[9];
  49420. }
  49421. return $components;
  49422. }
  49423. public function generate(array $components)
  49424. {
  49425. $uri = $components['scheme'] . '://'
  49426. . $components['authority']
  49427. . $components['path'];
  49428. if (array_key_exists('query', $components) && strlen($components['query'])) {
  49429. $uri .= '?' . $components['query'];
  49430. }
  49431. if (array_key_exists('fragment', $components)) {
  49432. $uri .= '#' . $components['fragment'];
  49433. }
  49434. return $uri;
  49435. }
  49436. public function resolve($uri, $baseUri = null)
  49437. {
  49438. if (
  49439. !is_null($baseUri) &&
  49440. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  49441. !preg_match('|^[^/]+://|u', $baseUri)
  49442. ) {
  49443. if (is_file($baseUri)) {
  49444. $baseUri = 'file://' . realpath($baseUri);
  49445. } elseif (is_dir($baseUri)) {
  49446. $baseUri = 'file://' . realpath($baseUri) . '/';
  49447. } else {
  49448. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  49449. }
  49450. }
  49451. if ($uri == '') {
  49452. return $baseUri;
  49453. }
  49454. $components = $this->parse($uri);
  49455. $path = $components['path'];
  49456. if (!empty($components['scheme'])) {
  49457. return $uri;
  49458. }
  49459. $baseComponents = $this->parse($baseUri);
  49460. $basePath = $baseComponents['path'];
  49461. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  49462. if (isset($components['fragment'])) {
  49463. $baseComponents['fragment'] = $components['fragment'];
  49464. }
  49465. return $this->generate($baseComponents);
  49466. }
  49467. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  49468. {
  49469. $relativePath = self::normalizePath($relativePath);
  49470. if ($relativePath == '') {
  49471. return $basePath;
  49472. }
  49473. if ($relativePath[0] == '/') {
  49474. return $relativePath;
  49475. }
  49476. $basePathSegments = explode('/', $basePath);
  49477. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  49478. $numLevelUp = strlen($match[0]) /3 + 1;
  49479. if ($numLevelUp >= count($basePathSegments)) {
  49480. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  49481. }
  49482. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  49483. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  49484. return implode('/', $basePathSegments) . '/' . $path;
  49485. }
  49486. private static function normalizePath($path)
  49487. {
  49488. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  49489. $path = preg_replace('|//|', '/', $path);
  49490. return $path;
  49491. }
  49492. public function isValid($uri)
  49493. {
  49494. $components = $this->parse($uri);
  49495. return !empty($components);
  49496. }
  49497. }
  49498. <?php
  49499. namespace JsonSchema\Uri;
  49500. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  49501. use JsonSchema\Exception\JsonDecodingException;
  49502. use JsonSchema\Exception\ResourceNotFoundException;
  49503. use JsonSchema\Uri\Retrievers\FileGetContents;
  49504. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  49505. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  49506. use JsonSchema\Validator;
  49507. class UriRetriever implements BaseUriRetrieverInterface
  49508. {
  49509. protected $translationMap = array(
  49510. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  49511. );
  49512. protected $allowedInvalidContentTypeEndpoints = array(
  49513. 'http://json-schema.org/',
  49514. 'https://json-schema.org/'
  49515. );
  49516. protected $uriRetriever = null;
  49517. private $schemaCache = array();
  49518. public function addInvalidContentTypeEndpoint($endpoint)
  49519. {
  49520. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  49521. }
  49522. public function confirmMediaType($uriRetriever, $uri)
  49523. {
  49524. $contentType = $uriRetriever->getContentType();
  49525. if (is_null($contentType)) {
  49526. return;
  49527. }
  49528. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  49529. return;
  49530. }
  49531. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  49532. if (strpos($uri, $endpoint) === 0) {
  49533. return true;
  49534. }
  49535. }
  49536. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  49537. }
  49538. public function getUriRetriever()
  49539. {
  49540. if (is_null($this->uriRetriever)) {
  49541. $this->setUriRetriever(new FileGetContents());
  49542. }
  49543. return $this->uriRetriever;
  49544. }
  49545. public function resolvePointer($jsonSchema, $uri)
  49546. {
  49547. $resolver = new UriResolver();
  49548. $parsed = $resolver->parse($uri);
  49549. if (empty($parsed['fragment'])) {
  49550. return $jsonSchema;
  49551. }
  49552. $path = explode('/', $parsed['fragment']);
  49553. while ($path) {
  49554. $pathElement = array_shift($path);
  49555. if (!empty($pathElement)) {
  49556. $pathElement = str_replace('~1', '/', $pathElement);
  49557. $pathElement = str_replace('~0', '~', $pathElement);
  49558. if (!empty($jsonSchema->$pathElement)) {
  49559. $jsonSchema = $jsonSchema->$pathElement;
  49560. } else {
  49561. throw new ResourceNotFoundException(
  49562. 'Fragment "' . $parsed['fragment'] . '" not found'
  49563. . ' in ' . $uri
  49564. );
  49565. }
  49566. if (!is_object($jsonSchema)) {
  49567. throw new ResourceNotFoundException(
  49568. 'Fragment part "' . $pathElement . '" is no object '
  49569. . ' in ' . $uri
  49570. );
  49571. }
  49572. }
  49573. }
  49574. return $jsonSchema;
  49575. }
  49576. public function retrieve($uri, $baseUri = null, $translate = true)
  49577. {
  49578. $resolver = new UriResolver();
  49579. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  49580. $arParts = $resolver->parse($resolvedUri);
  49581. if (isset($arParts['fragment'])) {
  49582. unset($arParts['fragment']);
  49583. $fetchUri = $resolver->generate($arParts);
  49584. }
  49585. if ($translate) {
  49586. $fetchUri = $this->translate($fetchUri);
  49587. }
  49588. $jsonSchema = $this->loadSchema($fetchUri);
  49589. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  49590. if ($jsonSchema instanceof \stdClass) {
  49591. $jsonSchema->id = $resolvedUri;
  49592. }
  49593. return $jsonSchema;
  49594. }
  49595. protected function loadSchema($fetchUri)
  49596. {
  49597. if (isset($this->schemaCache[$fetchUri])) {
  49598. return $this->schemaCache[$fetchUri];
  49599. }
  49600. $uriRetriever = $this->getUriRetriever();
  49601. $contents = $this->uriRetriever->retrieve($fetchUri);
  49602. $this->confirmMediaType($uriRetriever, $fetchUri);
  49603. $jsonSchema = json_decode($contents);
  49604. if (JSON_ERROR_NONE < $error = json_last_error()) {
  49605. throw new JsonDecodingException($error);
  49606. }
  49607. $this->schemaCache[$fetchUri] = $jsonSchema;
  49608. return $jsonSchema;
  49609. }
  49610. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  49611. {
  49612. $this->uriRetriever = $uriRetriever;
  49613. return $this;
  49614. }
  49615. public function parse($uri)
  49616. {
  49617. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  49618. $components = array();
  49619. if (5 < count($match)) {
  49620. $components = array(
  49621. 'scheme' => $match[2],
  49622. 'authority' => $match[4],
  49623. 'path' => $match[5]
  49624. );
  49625. }
  49626. if (7 < count($match)) {
  49627. $components['query'] = $match[7];
  49628. }
  49629. if (9 < count($match)) {
  49630. $components['fragment'] = $match[9];
  49631. }
  49632. return $components;
  49633. }
  49634. public function generate(array $components)
  49635. {
  49636. $uri = $components['scheme'] . '://'
  49637. . $components['authority']
  49638. . $components['path'];
  49639. if (array_key_exists('query', $components)) {
  49640. $uri .= $components['query'];
  49641. }
  49642. if (array_key_exists('fragment', $components)) {
  49643. $uri .= $components['fragment'];
  49644. }
  49645. return $uri;
  49646. }
  49647. public function resolve($uri, $baseUri = null)
  49648. {
  49649. $components = $this->parse($uri);
  49650. $path = $components['path'];
  49651. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  49652. return $uri;
  49653. }
  49654. $baseComponents = $this->parse($baseUri);
  49655. $basePath = $baseComponents['path'];
  49656. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  49657. return $this->generate($baseComponents);
  49658. }
  49659. public function isValid($uri)
  49660. {
  49661. $components = $this->parse($uri);
  49662. return !empty($components);
  49663. }
  49664. public function setTranslation($from, $to)
  49665. {
  49666. $this->translationMap[$from] = $to;
  49667. }
  49668. public function translate($uri)
  49669. {
  49670. foreach ($this->translationMap as $from => $to) {
  49671. $uri = preg_replace($from, $to, $uri);
  49672. }
  49673. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  49674. return $uri;
  49675. }
  49676. }
  49677. <?php
  49678. namespace JsonSchema;
  49679. interface UriResolverInterface
  49680. {
  49681. public function resolve($uri, $baseUri = null);
  49682. }
  49683. <?php
  49684. namespace JsonSchema;
  49685. interface UriRetrieverInterface
  49686. {
  49687. public function retrieve($uri, $baseUri = null);
  49688. }
  49689. <?php
  49690. namespace JsonSchema;
  49691. use JsonSchema\Constraints\BaseConstraint;
  49692. use JsonSchema\Constraints\Constraint;
  49693. class Validator extends BaseConstraint
  49694. {
  49695. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  49696. const ERROR_NONE = 0x00000000;
  49697. const ERROR_ALL = 0xFFFFFFFF;
  49698. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  49699. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  49700. public function validate(&$value, $schema = null, $checkMode = null)
  49701. {
  49702. if (is_array($schema)) {
  49703. $schema = self::arrayToObjectRecursive($schema);
  49704. }
  49705. $initialCheckMode = $this->factory->getConfig();
  49706. if ($checkMode !== null) {
  49707. $this->factory->setConfig($checkMode);
  49708. }
  49709. if (is_object($schema) && property_exists($schema, 'id')) {
  49710. $schemaURI = $schema->id;
  49711. } else {
  49712. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  49713. }
  49714. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  49715. $validator = $this->factory->createInstanceFor('schema');
  49716. $validator->check(
  49717. $value,
  49718. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  49719. );
  49720. $this->factory->setConfig($initialCheckMode);
  49721. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  49722. return $validator->getErrorMask();
  49723. }
  49724. public function check($value, $schema)
  49725. {
  49726. return $this->validate($value, $schema);
  49727. }
  49728. public function coerce(&$value, $schema)
  49729. {
  49730. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  49731. }
  49732. }
  49733. Copyright (c) 2012 PHP Framework Interoperability Group
  49734. Permission is hereby granted, free of charge, to any person obtaining a copy
  49735. of this software and associated documentation files (the "Software"), to deal
  49736. in the Software without restriction, including without limitation the rights
  49737. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  49738. copies of the Software, and to permit persons to whom the Software is
  49739. furnished to do so, subject to the following conditions:
  49740. The above copyright notice and this permission notice shall be included in
  49741. all copies or substantial portions of the Software.
  49742. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  49743. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  49744. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  49745. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  49746. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  49747. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  49748. THE SOFTWARE.
  49749. <?php
  49750. namespace Psr\Log;
  49751. abstract class AbstractLogger implements LoggerInterface
  49752. {
  49753. public function emergency($message, array $context = array())
  49754. {
  49755. $this->log(LogLevel::EMERGENCY, $message, $context);
  49756. }
  49757. public function alert($message, array $context = array())
  49758. {
  49759. $this->log(LogLevel::ALERT, $message, $context);
  49760. }
  49761. public function critical($message, array $context = array())
  49762. {
  49763. $this->log(LogLevel::CRITICAL, $message, $context);
  49764. }
  49765. public function error($message, array $context = array())
  49766. {
  49767. $this->log(LogLevel::ERROR, $message, $context);
  49768. }
  49769. public function warning($message, array $context = array())
  49770. {
  49771. $this->log(LogLevel::WARNING, $message, $context);
  49772. }
  49773. public function notice($message, array $context = array())
  49774. {
  49775. $this->log(LogLevel::NOTICE, $message, $context);
  49776. }
  49777. public function info($message, array $context = array())
  49778. {
  49779. $this->log(LogLevel::INFO, $message, $context);
  49780. }
  49781. public function debug($message, array $context = array())
  49782. {
  49783. $this->log(LogLevel::DEBUG, $message, $context);
  49784. }
  49785. }
  49786. <?php
  49787. namespace Psr\Log;
  49788. class InvalidArgumentException extends \InvalidArgumentException
  49789. {
  49790. }
  49791. <?php
  49792. namespace Psr\Log;
  49793. class LogLevel
  49794. {
  49795. const EMERGENCY = 'emergency';
  49796. const ALERT = 'alert';
  49797. const CRITICAL = 'critical';
  49798. const ERROR = 'error';
  49799. const WARNING = 'warning';
  49800. const NOTICE = 'notice';
  49801. const INFO = 'info';
  49802. const DEBUG = 'debug';
  49803. }
  49804. <?php
  49805. namespace Psr\Log;
  49806. interface LoggerAwareInterface
  49807. {
  49808. public function setLogger(LoggerInterface $logger);
  49809. }
  49810. <?php
  49811. namespace Psr\Log;
  49812. trait LoggerAwareTrait
  49813. {
  49814. protected $logger;
  49815. public function setLogger(LoggerInterface $logger)
  49816. {
  49817. $this->logger = $logger;
  49818. }
  49819. }
  49820. <?php
  49821. namespace Psr\Log;
  49822. interface LoggerInterface
  49823. {
  49824. public function emergency($message, array $context = array());
  49825. public function alert($message, array $context = array());
  49826. public function critical($message, array $context = array());
  49827. public function error($message, array $context = array());
  49828. public function warning($message, array $context = array());
  49829. public function notice($message, array $context = array());
  49830. public function info($message, array $context = array());
  49831. public function debug($message, array $context = array());
  49832. public function log($level, $message, array $context = array());
  49833. }
  49834. <?php
  49835. namespace Psr\Log;
  49836. trait LoggerTrait
  49837. {
  49838. public function emergency($message, array $context = array())
  49839. {
  49840. $this->log(LogLevel::EMERGENCY, $message, $context);
  49841. }
  49842. public function alert($message, array $context = array())
  49843. {
  49844. $this->log(LogLevel::ALERT, $message, $context);
  49845. }
  49846. public function critical($message, array $context = array())
  49847. {
  49848. $this->log(LogLevel::CRITICAL, $message, $context);
  49849. }
  49850. public function error($message, array $context = array())
  49851. {
  49852. $this->log(LogLevel::ERROR, $message, $context);
  49853. }
  49854. public function warning($message, array $context = array())
  49855. {
  49856. $this->log(LogLevel::WARNING, $message, $context);
  49857. }
  49858. public function notice($message, array $context = array())
  49859. {
  49860. $this->log(LogLevel::NOTICE, $message, $context);
  49861. }
  49862. public function info($message, array $context = array())
  49863. {
  49864. $this->log(LogLevel::INFO, $message, $context);
  49865. }
  49866. public function debug($message, array $context = array())
  49867. {
  49868. $this->log(LogLevel::DEBUG, $message, $context);
  49869. }
  49870. abstract public function log($level, $message, array $context = array());
  49871. }
  49872. <?php
  49873. namespace Psr\Log;
  49874. class NullLogger extends AbstractLogger
  49875. {
  49876. public function log($level, $message, array $context = array())
  49877. {
  49878. }
  49879. }
  49880. <?php
  49881. namespace Psr\Log\Test;
  49882. class DummyTest
  49883. {
  49884. public function __toString()
  49885. {
  49886. return 'DummyTest';
  49887. }
  49888. }
  49889. <?php
  49890. namespace Psr\Log\Test;
  49891. use Psr\Log\LoggerInterface;
  49892. use Psr\Log\LogLevel;
  49893. use PHPUnit\Framework\TestCase;
  49894. abstract class LoggerInterfaceTest extends TestCase
  49895. {
  49896. abstract public function getLogger();
  49897. abstract public function getLogs();
  49898. public function testImplements()
  49899. {
  49900. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  49901. }
  49902. public function testLogsAtAllLevels($level, $message)
  49903. {
  49904. $logger = $this->getLogger();
  49905. $logger->{$level}($message, array('user' => 'Bob'));
  49906. $logger->log($level, $message, array('user' => 'Bob'));
  49907. $expected = array(
  49908. $level.' message of level '.$level.' with context: Bob',
  49909. $level.' message of level '.$level.' with context: Bob',
  49910. );
  49911. $this->assertEquals($expected, $this->getLogs());
  49912. }
  49913. public function provideLevelsAndMessages()
  49914. {
  49915. return array(
  49916. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  49917. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  49918. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  49919. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  49920. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  49921. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  49922. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  49923. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  49924. );
  49925. }
  49926. public function testThrowsOnInvalidLevel()
  49927. {
  49928. $logger = $this->getLogger();
  49929. $logger->log('invalid level', 'Foo');
  49930. }
  49931. public function testContextReplacement()
  49932. {
  49933. $logger = $this->getLogger();
  49934. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  49935. $expected = array('info {Message {nothing} Bob Bar a}');
  49936. $this->assertEquals($expected, $this->getLogs());
  49937. }
  49938. public function testObjectCastToString()
  49939. {
  49940. if (method_exists($this, 'createPartialMock')) {
  49941. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  49942. } else {
  49943. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  49944. }
  49945. $dummy->expects($this->once())
  49946. ->method('__toString')
  49947. ->will($this->returnValue('DUMMY'));
  49948. $this->getLogger()->warning($dummy);
  49949. $expected = array('warning DUMMY');
  49950. $this->assertEquals($expected, $this->getLogs());
  49951. }
  49952. public function testContextCanContainAnything()
  49953. {
  49954. $closed = fopen('php://memory', 'r');
  49955. fclose($closed);
  49956. $context = array(
  49957. 'bool' => true,
  49958. 'null' => null,
  49959. 'string' => 'Foo',
  49960. 'int' => 0,
  49961. 'float' => 0.5,
  49962. 'nested' => array('with object' => new DummyTest),
  49963. 'object' => new \DateTime,
  49964. 'resource' => fopen('php://memory', 'r'),
  49965. 'closed' => $closed,
  49966. );
  49967. $this->getLogger()->warning('Crazy context data', $context);
  49968. $expected = array('warning Crazy context data');
  49969. $this->assertEquals($expected, $this->getLogs());
  49970. }
  49971. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  49972. {
  49973. $logger = $this->getLogger();
  49974. $logger->warning('Random message', array('exception' => 'oops'));
  49975. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  49976. $expected = array(
  49977. 'warning Random message',
  49978. 'critical Uncaught Exception!'
  49979. );
  49980. $this->assertEquals($expected, $this->getLogs());
  49981. }
  49982. }
  49983. <?php
  49984. namespace Psr\Log\Test;
  49985. use Psr\Log\AbstractLogger;
  49986. class TestLogger extends AbstractLogger
  49987. {
  49988. public $records = [];
  49989. public $recordsByLevel = [];
  49990. public function log($level, $message, array $context = [])
  49991. {
  49992. $record = [
  49993. 'level' => $level,
  49994. 'message' => $message,
  49995. 'context' => $context,
  49996. ];
  49997. $this->recordsByLevel[$record['level']][] = $record;
  49998. $this->records[] = $record;
  49999. }
  50000. public function hasRecords($level)
  50001. {
  50002. return isset($this->recordsByLevel[$level]);
  50003. }
  50004. public function hasRecord($record, $level)
  50005. {
  50006. if (is_string($record)) {
  50007. $record = ['message' => $record];
  50008. }
  50009. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  50010. if ($rec['message'] !== $record['message']) {
  50011. return false;
  50012. }
  50013. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  50014. return false;
  50015. }
  50016. return true;
  50017. }, $level);
  50018. }
  50019. public function hasRecordThatContains($message, $level)
  50020. {
  50021. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  50022. return strpos($rec['message'], $message) !== false;
  50023. }, $level);
  50024. }
  50025. public function hasRecordThatMatches($regex, $level)
  50026. {
  50027. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  50028. return preg_match($regex, $rec['message']) > 0;
  50029. }, $level);
  50030. }
  50031. public function hasRecordThatPasses(callable $predicate, $level)
  50032. {
  50033. if (!isset($this->recordsByLevel[$level])) {
  50034. return false;
  50035. }
  50036. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  50037. if (call_user_func($predicate, $rec, $i)) {
  50038. return true;
  50039. }
  50040. }
  50041. return false;
  50042. }
  50043. public function __call($method, $args)
  50044. {
  50045. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  50046. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  50047. $level = strtolower($matches[2]);
  50048. if (method_exists($this, $genericMethod)) {
  50049. $args[] = $level;
  50050. return call_user_func_array([$this, $genericMethod], $args);
  50051. }
  50052. }
  50053. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  50054. }
  50055. public function reset()
  50056. {
  50057. $this->records = [];
  50058. $this->recordsByLevel = [];
  50059. }
  50060. }
  50061. Copyright (c) 2012-2016 Jan Sorgalla
  50062. Permission is hereby granted, free of charge, to any person
  50063. obtaining a copy of this software and associated documentation
  50064. files (the "Software"), to deal in the Software without
  50065. restriction, including without limitation the rights to use,
  50066. copy, modify, merge, publish, distribute, sublicense, and/or sell
  50067. copies of the Software, and to permit persons to whom the
  50068. Software is furnished to do so, subject to the following
  50069. conditions:
  50070. The above copyright notice and this permission notice shall be
  50071. included in all copies or substantial portions of the Software.
  50072. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  50073. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  50074. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  50075. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  50076. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  50077. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  50078. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  50079. OTHER DEALINGS IN THE SOFTWARE.
  50080. <?php
  50081. namespace React\Promise;
  50082. interface CancellablePromiseInterface extends PromiseInterface
  50083. {
  50084. public function cancel();
  50085. }
  50086. <?php
  50087. namespace React\Promise;
  50088. class Deferred implements PromiseInterface, ResolverInterface, PromisorInterface, CancellablePromiseInterface
  50089. {
  50090. private $completed;
  50091. private $promise;
  50092. private $resolver;
  50093. private $handlers = array();
  50094. private $progressHandlers = array();
  50095. private $canceller;
  50096. private $requiredCancelRequests = 0;
  50097. private $cancelRequests = 0;
  50098. public function __construct($canceller = null)
  50099. {
  50100. if ($canceller !== null && !is_callable($canceller)) {
  50101. throw new \InvalidArgumentException(
  50102. sprintf(
  50103. 'The canceller argument must be null or of type callable, %s given.',
  50104. gettype($canceller)
  50105. )
  50106. );
  50107. }
  50108. $this->canceller = $canceller;
  50109. }
  50110. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50111. {
  50112. if (null !== $this->completed) {
  50113. return $this->completed->then($fulfilledHandler, $errorHandler, $progressHandler);
  50114. }
  50115. $canceller = null;
  50116. if ($this->canceller !== null) {
  50117. $this->requiredCancelRequests++;
  50118. $that = $this;
  50119. $current =& $this->cancelRequests;
  50120. $required =& $this->requiredCancelRequests;
  50121. $canceller = function () use ($that, &$current, &$required) {
  50122. if (++$current < $required) {
  50123. return;
  50124. }
  50125. $that->cancel();
  50126. };
  50127. }
  50128. $deferred = new static($canceller);
  50129. if (is_callable($progressHandler)) {
  50130. $progHandler = function ($update) use ($deferred, $progressHandler) {
  50131. try {
  50132. $deferred->progress(call_user_func($progressHandler, $update));
  50133. } catch (\Exception $e) {
  50134. $deferred->progress($e);
  50135. }
  50136. };
  50137. } else {
  50138. if (null !== $progressHandler) {
  50139. trigger_error('Invalid $progressHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  50140. }
  50141. $progHandler = array($deferred, 'progress');
  50142. }
  50143. $this->handlers[] = function ($promise) use ($fulfilledHandler, $errorHandler, $deferred, $progHandler) {
  50144. $promise
  50145. ->then($fulfilledHandler, $errorHandler)
  50146. ->then(
  50147. array($deferred, 'resolve'),
  50148. array($deferred, 'reject'),
  50149. $progHandler
  50150. );
  50151. };
  50152. $this->progressHandlers[] = $progHandler;
  50153. return $deferred->promise();
  50154. }
  50155. public function resolve($result = null)
  50156. {
  50157. if (null !== $this->completed) {
  50158. return resolve($result);
  50159. }
  50160. $this->completed = resolve($result);
  50161. $this->processQueue($this->handlers, $this->completed);
  50162. $this->progressHandlers = $this->handlers = array();
  50163. return $this->completed;
  50164. }
  50165. public function reject($reason = null)
  50166. {
  50167. return $this->resolve(reject($reason));
  50168. }
  50169. public function progress($update = null)
  50170. {
  50171. if (null !== $this->completed) {
  50172. return;
  50173. }
  50174. $this->processQueue($this->progressHandlers, $update);
  50175. }
  50176. public function promise()
  50177. {
  50178. if (null === $this->promise) {
  50179. $this->promise = new DeferredPromise($this);
  50180. }
  50181. return $this->promise;
  50182. }
  50183. public function resolver()
  50184. {
  50185. if (null === $this->resolver) {
  50186. $this->resolver = new DeferredResolver($this);
  50187. }
  50188. return $this->resolver;
  50189. }
  50190. public function cancel()
  50191. {
  50192. if (null === $this->canceller || null !== $this->completed) {
  50193. return;
  50194. }
  50195. $canceller = $this->canceller;
  50196. $this->canceller = null;
  50197. try {
  50198. $that = $this;
  50199. call_user_func(
  50200. $canceller,
  50201. function ($value = null) use ($that) {
  50202. $that->resolve($value);
  50203. },
  50204. function ($reason = null) use ($that) {
  50205. $that->reject($reason);
  50206. },
  50207. function ($update = null) use ($that) {
  50208. $that->progress($update);
  50209. }
  50210. );
  50211. } catch (\Exception $e) {
  50212. $this->reject($e);
  50213. }
  50214. }
  50215. protected function processQueue($queue, $value)
  50216. {
  50217. foreach ($queue as $handler) {
  50218. call_user_func($handler, $value);
  50219. }
  50220. }
  50221. }
  50222. <?php
  50223. namespace React\Promise;
  50224. class DeferredPromise implements PromiseInterface, CancellablePromiseInterface
  50225. {
  50226. private $deferred;
  50227. public function __construct(Deferred $deferred)
  50228. {
  50229. $this->deferred = $deferred;
  50230. }
  50231. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50232. {
  50233. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  50234. }
  50235. public function cancel()
  50236. {
  50237. $this->deferred->cancel();
  50238. }
  50239. }
  50240. <?php
  50241. namespace React\Promise;
  50242. class DeferredResolver implements ResolverInterface
  50243. {
  50244. private $deferred;
  50245. public function __construct(Deferred $deferred)
  50246. {
  50247. $this->deferred = $deferred;
  50248. }
  50249. public function resolve($result = null)
  50250. {
  50251. return $this->deferred->resolve($result);
  50252. }
  50253. public function reject($reason = null)
  50254. {
  50255. return $this->deferred->reject($reason);
  50256. }
  50257. public function progress($update = null)
  50258. {
  50259. return $this->deferred->progress($update);
  50260. }
  50261. }
  50262. <?php
  50263. namespace React\Promise;
  50264. class FulfilledPromise implements PromiseInterface, CancellablePromiseInterface
  50265. {
  50266. private $result;
  50267. public function __construct($result = null)
  50268. {
  50269. $this->result = $result;
  50270. }
  50271. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50272. {
  50273. try {
  50274. $result = $this->result;
  50275. if (is_callable($fulfilledHandler)) {
  50276. $result = call_user_func($fulfilledHandler, $result);
  50277. } elseif (null !== $fulfilledHandler) {
  50278. trigger_error('Invalid $fulfilledHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  50279. }
  50280. return resolve($result);
  50281. } catch (\Exception $exception) {
  50282. return new RejectedPromise($exception);
  50283. }
  50284. }
  50285. public function cancel()
  50286. {
  50287. }
  50288. }
  50289. <?php
  50290. namespace React\Promise;
  50291. class LazyPromise implements PromiseInterface, CancellablePromiseInterface
  50292. {
  50293. private $factory;
  50294. private $promise;
  50295. public function __construct($factory)
  50296. {
  50297. $this->factory = $factory;
  50298. }
  50299. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50300. {
  50301. return $this->promise()->then($fulfilledHandler, $errorHandler, $progressHandler);
  50302. }
  50303. public function cancel()
  50304. {
  50305. $promise = $this->promise();
  50306. if ($promise instanceof CancellablePromiseInterface) {
  50307. $promise->cancel();
  50308. }
  50309. }
  50310. private function promise()
  50311. {
  50312. if (null === $this->promise) {
  50313. try {
  50314. $this->promise = resolve(call_user_func($this->factory));
  50315. } catch (\Exception $exception) {
  50316. $this->promise = new RejectedPromise($exception);
  50317. }
  50318. }
  50319. return $this->promise;
  50320. }
  50321. }
  50322. <?php
  50323. namespace React\Promise;
  50324. class Promise implements PromiseInterface, CancellablePromiseInterface
  50325. {
  50326. private $deferred;
  50327. public function __construct($resolver, $canceller = null)
  50328. {
  50329. if (!is_callable($resolver)) {
  50330. throw new \InvalidArgumentException(
  50331. sprintf(
  50332. 'The resolver argument must be of type callable, %s given.',
  50333. gettype($resolver)
  50334. )
  50335. );
  50336. }
  50337. $this->deferred = new Deferred($canceller);
  50338. $this->call($resolver);
  50339. }
  50340. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50341. {
  50342. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  50343. }
  50344. public function cancel()
  50345. {
  50346. $this->deferred->cancel();
  50347. }
  50348. private function call($callback)
  50349. {
  50350. $deferred = $this->deferred;
  50351. try {
  50352. call_user_func(
  50353. $callback,
  50354. function ($result = null) use ($deferred) {
  50355. $deferred->resolve($result);
  50356. },
  50357. function ($reason = null) use ($deferred) {
  50358. $deferred->reject($reason);
  50359. },
  50360. function ($update = null) use ($deferred) {
  50361. $deferred->progress($update);
  50362. }
  50363. );
  50364. } catch (\Exception $e) {
  50365. $this->deferred->reject($e);
  50366. }
  50367. }
  50368. }
  50369. <?php
  50370. namespace React\Promise;
  50371. interface PromiseInterface
  50372. {
  50373. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
  50374. }
  50375. <?php
  50376. namespace React\Promise;
  50377. interface PromisorInterface
  50378. {
  50379. public function promise();
  50380. }
  50381. <?php
  50382. namespace React\Promise;
  50383. class RejectedPromise implements PromiseInterface, CancellablePromiseInterface
  50384. {
  50385. private $reason;
  50386. public function __construct($reason = null)
  50387. {
  50388. $this->reason = $reason;
  50389. }
  50390. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50391. {
  50392. try {
  50393. if (!is_callable($errorHandler)) {
  50394. if (null !== $errorHandler) {
  50395. trigger_error('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  50396. }
  50397. return new RejectedPromise($this->reason);
  50398. }
  50399. return resolve(call_user_func($errorHandler, $this->reason));
  50400. } catch (\Exception $exception) {
  50401. return new RejectedPromise($exception);
  50402. }
  50403. }
  50404. public function cancel()
  50405. {
  50406. }
  50407. }
  50408. <?php
  50409. namespace React\Promise;
  50410. interface ResolverInterface
  50411. {
  50412. public function resolve($result = null);
  50413. public function reject($reason = null);
  50414. public function progress($update = null);
  50415. }
  50416. <?php
  50417. namespace React\Promise;
  50418. class Util
  50419. {
  50420. public static function promiseFor($promiseOrValue)
  50421. {
  50422. return resolve($promiseOrValue);
  50423. }
  50424. public static function rejectedPromiseFor($promiseOrValue)
  50425. {
  50426. return reject($promiseOrValue);
  50427. }
  50428. }
  50429. <?php
  50430. namespace React\Promise;
  50431. class When
  50432. {
  50433. public static function resolve($promiseOrValue = null)
  50434. {
  50435. return resolve($promiseOrValue);
  50436. }
  50437. public static function reject($promiseOrValue = null)
  50438. {
  50439. return reject($promiseOrValue);
  50440. }
  50441. public static function lazy($factory)
  50442. {
  50443. return new LazyPromise($factory);
  50444. }
  50445. public static function all($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50446. {
  50447. return all($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  50448. }
  50449. public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50450. {
  50451. return any($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  50452. }
  50453. public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  50454. {
  50455. return some($promisesOrValues, $howMany)->then($fulfilledHandler, $errorHandler, $progressHandler);
  50456. }
  50457. public static function map($promisesOrValues, $mapFunc)
  50458. {
  50459. return map($promisesOrValues, $mapFunc);
  50460. }
  50461. public static function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  50462. {
  50463. return reduce($promisesOrValues, $reduceFunc, $initialValue);
  50464. }
  50465. }
  50466. <?php
  50467. namespace React\Promise;
  50468. function resolve($promiseOrValue = null)
  50469. {
  50470. if ($promiseOrValue instanceof PromiseInterface) {
  50471. return $promiseOrValue;
  50472. }
  50473. return new FulfilledPromise($promiseOrValue);
  50474. }
  50475. function reject($promiseOrValue = null)
  50476. {
  50477. if ($promiseOrValue instanceof PromiseInterface) {
  50478. return $promiseOrValue->then(function ($value) {
  50479. return new RejectedPromise($value);
  50480. });
  50481. }
  50482. return new RejectedPromise($promiseOrValue);
  50483. }
  50484. function all($promisesOrValues)
  50485. {
  50486. return map($promisesOrValues, function ($val) {
  50487. return $val;
  50488. });
  50489. }
  50490. function any($promisesOrValues)
  50491. {
  50492. return some($promisesOrValues, 1)->then(function($val) {
  50493. return array_shift($val);
  50494. });
  50495. }
  50496. function some($promisesOrValues, $howMany)
  50497. {
  50498. return resolve($promisesOrValues)->then(function ($array) use ($howMany) {
  50499. if (!is_array($array)) {
  50500. $array = array();
  50501. }
  50502. $len = count($array);
  50503. $toResolve = max(0, min($howMany, $len));
  50504. $values = array();
  50505. $deferred = new Deferred();
  50506. if (!$toResolve) {
  50507. $deferred->resolve($values);
  50508. } else {
  50509. $toReject = ($len - $toResolve) + 1;
  50510. $reasons = array();
  50511. $progress = array($deferred, 'progress');
  50512. $fulfillOne = function ($val, $i) use (&$values, &$toResolve, $deferred) {
  50513. $values[$i] = $val;
  50514. if (0 === --$toResolve) {
  50515. $deferred->resolve($values);
  50516. return true;
  50517. }
  50518. };
  50519. $rejectOne = function ($reason, $i) use (&$reasons, &$toReject, $deferred) {
  50520. $reasons[$i] = $reason;
  50521. if (0 === --$toReject) {
  50522. $deferred->reject($reasons);
  50523. return true;
  50524. }
  50525. };
  50526. foreach ($array as $i => $promiseOrValue) {
  50527. $fulfiller = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  50528. $reset = $fulfillOne($val, $i);
  50529. if (true === $reset) {
  50530. $fulfillOne = $rejectOne = function () {};
  50531. }
  50532. };
  50533. $rejecter = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  50534. $reset = $rejectOne($val, $i);
  50535. if (true === $reset) {
  50536. $fulfillOne = $rejectOne = function () {};
  50537. }
  50538. };
  50539. resolve($promiseOrValue)->then($fulfiller, $rejecter, $progress);
  50540. }
  50541. }
  50542. return $deferred->promise();
  50543. });
  50544. }
  50545. function map($promisesOrValues, $mapFunc)
  50546. {
  50547. return resolve($promisesOrValues)->then(function ($array) use ($mapFunc) {
  50548. if (!is_array($array)) {
  50549. $array = array();
  50550. }
  50551. $toResolve = count($array);
  50552. $results = array();
  50553. $deferred = new Deferred();
  50554. if (!$toResolve) {
  50555. $deferred->resolve($results);
  50556. } else {
  50557. $resolve = function ($item, $i) use ($mapFunc, &$results, &$toResolve, $deferred) {
  50558. resolve($item)
  50559. ->then($mapFunc)
  50560. ->then(
  50561. function ($mapped) use (&$results, $i, &$toResolve, $deferred) {
  50562. $results[$i] = $mapped;
  50563. if (0 === --$toResolve) {
  50564. $deferred->resolve($results);
  50565. }
  50566. },
  50567. array($deferred, 'reject')
  50568. );
  50569. };
  50570. foreach ($array as $i => $item) {
  50571. $resolve($item, $i);
  50572. }
  50573. }
  50574. return $deferred->promise();
  50575. });
  50576. }
  50577. function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  50578. {
  50579. return resolve($promisesOrValues)->then(function ($array) use ($reduceFunc, $initialValue) {
  50580. if (!is_array($array)) {
  50581. $array = array();
  50582. }
  50583. $total = count($array);
  50584. $i = 0;
  50585. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $total, &$i) {
  50586. return resolve($current)->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  50587. return resolve($val)->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  50588. return call_user_func($reduceFunc, $c, $value, $i++, $total);
  50589. });
  50590. });
  50591. };
  50592. return array_reduce($array, $wrappedReduceFunc, $initialValue);
  50593. });
  50594. }
  50595. <?php
  50596. if (!function_exists('React\Promise\resolve')) {
  50597. require __DIR__.'/functions.php';
  50598. }
  50599. Copyright (c) 2011 Jordi Boggiano
  50600. Permission is hereby granted, free of charge, to any person obtaining a copy
  50601. of this software and associated documentation files (the "Software"), to deal
  50602. in the Software without restriction, including without limitation the rights
  50603. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  50604. copies of the Software, and to permit persons to whom the Software is furnished
  50605. to do so, subject to the following conditions:
  50606. The above copyright notice and this permission notice shall be included in all
  50607. copies or substantial portions of the Software.
  50608. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50609. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  50610. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  50611. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  50612. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50613. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  50614. THE SOFTWARE.
  50615. <?php
  50616. namespace Seld\JsonLint;
  50617. class DuplicateKeyException extends ParsingException
  50618. {
  50619. public function __construct($message, $key, array $details = array())
  50620. {
  50621. $details['key'] = $key;
  50622. parent::__construct($message, $details);
  50623. }
  50624. public function getKey()
  50625. {
  50626. return $this->details['key'];
  50627. }
  50628. public function getDetails()
  50629. {
  50630. return $this->details;
  50631. }
  50632. }
  50633. <?php
  50634. namespace Seld\JsonLint;
  50635. use stdClass;
  50636. class JsonParser
  50637. {
  50638. const DETECT_KEY_CONFLICTS = 1;
  50639. const ALLOW_DUPLICATE_KEYS = 2;
  50640. const PARSE_TO_ASSOC = 4;
  50641. private $lexer;
  50642. private $flags;
  50643. private $stack;
  50644. private $vstack;
  50645. private $lstack;
  50646. private $symbols = array(
  50647. 'error' => 2,
  50648. 'JSONString' => 3,
  50649. 'STRING' => 4,
  50650. 'JSONNumber' => 5,
  50651. 'NUMBER' => 6,
  50652. 'JSONNullLiteral' => 7,
  50653. 'NULL' => 8,
  50654. 'JSONBooleanLiteral' => 9,
  50655. 'TRUE' => 10,
  50656. 'FALSE' => 11,
  50657. 'JSONText' => 12,
  50658. 'JSONValue' => 13,
  50659. 'EOF' => 14,
  50660. 'JSONObject' => 15,
  50661. 'JSONArray' => 16,
  50662. '{' => 17,
  50663. '}' => 18,
  50664. 'JSONMemberList' => 19,
  50665. 'JSONMember' => 20,
  50666. ':' => 21,
  50667. ',' => 22,
  50668. '[' => 23,
  50669. ']' => 24,
  50670. 'JSONElementList' => 25,
  50671. '$accept' => 0,
  50672. '$end' => 1,
  50673. );
  50674. private $terminals_ = array(
  50675. 2 => "error",
  50676. 4 => "STRING",
  50677. 6 => "NUMBER",
  50678. 8 => "NULL",
  50679. 10 => "TRUE",
  50680. 11 => "FALSE",
  50681. 14 => "EOF",
  50682. 17 => "{",
  50683. 18 => "}",
  50684. 21 => ":",
  50685. 22 => ",",
  50686. 23 => "[",
  50687. 24 => "]",
  50688. );
  50689. private $productions_ = array(
  50690. 0,
  50691. array(3, 1),
  50692. array(5, 1),
  50693. array(7, 1),
  50694. array(9, 1),
  50695. array(9, 1),
  50696. array(12, 2),
  50697. array(13, 1),
  50698. array(13, 1),
  50699. array(13, 1),
  50700. array(13, 1),
  50701. array(13, 1),
  50702. array(13, 1),
  50703. array(15, 2),
  50704. array(15, 3),
  50705. array(20, 3),
  50706. array(19, 1),
  50707. array(19, 3),
  50708. array(16, 2),
  50709. array(16, 3),
  50710. array(25, 1),
  50711. array(25, 3)
  50712. );
  50713. 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)),
  50714. );
  50715. private $defaultActions = array(
  50716. 16 => array(2, 6)
  50717. );
  50718. public function lint($input, $flags = 0)
  50719. {
  50720. try {
  50721. $this->parse($input, $flags);
  50722. } catch (ParsingException $e) {
  50723. return $e;
  50724. }
  50725. return null;
  50726. }
  50727. public function parse($input, $flags = 0)
  50728. {
  50729. $this->failOnBOM($input);
  50730. $this->flags = $flags;
  50731. $this->stack = array(0);
  50732. $this->vstack = array(null);
  50733. $this->lstack = array();
  50734. $yytext = '';
  50735. $yylineno = 0;
  50736. $yyleng = 0;
  50737. $recovering = 0;
  50738. $TERROR = 2;
  50739. $EOF = 1;
  50740. $this->lexer = new Lexer();
  50741. $this->lexer->setInput($input);
  50742. $yyloc = $this->lexer->yylloc;
  50743. $this->lstack[] = $yyloc;
  50744. $symbol = null;
  50745. $preErrorSymbol = null;
  50746. $state = null;
  50747. $action = null;
  50748. $a = null;
  50749. $r = null;
  50750. $yyval = new stdClass;
  50751. $p = null;
  50752. $len = null;
  50753. $newState = null;
  50754. $expected = null;
  50755. $errStr = null;
  50756. while (true) {
  50757. $state = $this->stack[\count($this->stack)-1];
  50758. if (isset($this->defaultActions[$state])) {
  50759. $action = $this->defaultActions[$state];
  50760. } else {
  50761. if ($symbol == null) {
  50762. $symbol = $this->lex();
  50763. }
  50764. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  50765. }
  50766. if (!$action || !$action[0]) {
  50767. if (!$recovering) {
  50768. $expected = array();
  50769. foreach ($this->table[$state] as $p => $ignore) {
  50770. if (isset($this->terminals_[$p]) && $p > 2) {
  50771. $expected[] = "'" . $this->terminals_[$p] . "'";
  50772. }
  50773. }
  50774. $message = null;
  50775. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  50776. $message = "Invalid string";
  50777. if ("'" === substr($this->lexer->match, 0, 1)) {
  50778. $message .= ", it appears you used single quotes instead of double quotes";
  50779. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  50780. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  50781. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  50782. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  50783. }
  50784. }
  50785. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  50786. $errStr .= $this->lexer->showPosition() . "\n";
  50787. if ($message) {
  50788. $errStr .= $message;
  50789. } else {
  50790. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  50791. $errStr .= implode(', ', $expected);
  50792. }
  50793. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  50794. $errStr .= " - It appears you have an extra trailing comma";
  50795. }
  50796. $this->parseError($errStr, array(
  50797. 'text' => $this->lexer->match,
  50798. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  50799. 'line' => $this->lexer->yylineno,
  50800. 'loc' => $yyloc,
  50801. 'expected' => $expected,
  50802. ));
  50803. }
  50804. if ($recovering == 3) {
  50805. if ($symbol == $EOF) {
  50806. throw new ParsingException($errStr ?: 'Parsing halted.');
  50807. }
  50808. $yyleng = $this->lexer->yyleng;
  50809. $yytext = $this->lexer->yytext;
  50810. $yylineno = $this->lexer->yylineno;
  50811. $yyloc = $this->lexer->yylloc;
  50812. $symbol = $this->lex();
  50813. }
  50814. while (true) {
  50815. if (\array_key_exists($TERROR, $this->table[$state])) {
  50816. break;
  50817. }
  50818. if ($state == 0) {
  50819. throw new ParsingException($errStr ?: 'Parsing halted.');
  50820. }
  50821. $this->popStack(1);
  50822. $state = $this->stack[\count($this->stack)-1];
  50823. }
  50824. $preErrorSymbol = $symbol;
  50825. $symbol = $TERROR;
  50826. $state = $this->stack[\count($this->stack)-1];
  50827. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  50828. $recovering = 3;
  50829. }
  50830. if (\is_array($action[0]) && \count($action) > 1) {
  50831. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  50832. }
  50833. switch ($action[0]) {
  50834. case 1:
  50835. $this->stack[] = $symbol;
  50836. $this->vstack[] = $this->lexer->yytext;
  50837. $this->lstack[] = $this->lexer->yylloc;
  50838. $this->stack[] = $action[1];
  50839. $symbol = null;
  50840. if (!$preErrorSymbol) {
  50841. $yyleng = $this->lexer->yyleng;
  50842. $yytext = $this->lexer->yytext;
  50843. $yylineno = $this->lexer->yylineno;
  50844. $yyloc = $this->lexer->yylloc;
  50845. if ($recovering > 0) {
  50846. $recovering--;
  50847. }
  50848. } else {
  50849. $symbol = $preErrorSymbol;
  50850. $preErrorSymbol = null;
  50851. }
  50852. break;
  50853. case 2:
  50854. $len = $this->productions_[$action[1]][1];
  50855. $yyval->token = $this->vstack[\count($this->vstack) - $len];
  50856. $yyval->store = array(
  50857. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  50858. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  50859. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  50860. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  50861. );
  50862. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
  50863. if (!$r instanceof Undefined) {
  50864. return $r;
  50865. }
  50866. if ($len) {
  50867. $this->popStack($len);
  50868. }
  50869. $this->stack[] = $this->productions_[$action[1]][0];
  50870. $this->vstack[] = $yyval->token;
  50871. $this->lstack[] = $yyval->store;
  50872. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  50873. $this->stack[] = $newState;
  50874. break;
  50875. case 3:
  50876. return true;
  50877. }
  50878. }
  50879. }
  50880. protected function parseError($str, $hash)
  50881. {
  50882. throw new ParsingException($str, $hash);
  50883. }
  50884. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  50885. {
  50886. $len = \count($tokens) - 1;
  50887. switch ($yystate) {
  50888. case 1:
  50889. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  50890. $yyval->token = $yytext;
  50891. break;
  50892. case 2:
  50893. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  50894. $yyval->token = \floatval($yytext);
  50895. } else {
  50896. $yyval->token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  50897. }
  50898. break;
  50899. case 3:
  50900. $yyval->token = null;
  50901. break;
  50902. case 4:
  50903. $yyval->token = true;
  50904. break;
  50905. case 5:
  50906. $yyval->token = false;
  50907. break;
  50908. case 6:
  50909. return $yyval->token = $tokens[$len-1];
  50910. case 13:
  50911. if ($this->flags & self::PARSE_TO_ASSOC) {
  50912. $yyval->token = array();
  50913. } else {
  50914. $yyval->token = new stdClass;
  50915. }
  50916. break;
  50917. case 14:
  50918. $yyval->token = $tokens[$len-1];
  50919. break;
  50920. case 15:
  50921. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  50922. break;
  50923. case 16:
  50924. if (PHP_VERSION_ID < 70100) {
  50925. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  50926. } else {
  50927. $property = $tokens[$len][0];
  50928. }
  50929. if ($this->flags & self::PARSE_TO_ASSOC) {
  50930. $yyval->token = array();
  50931. $yyval->token[$property] = $tokens[$len][1];
  50932. } else {
  50933. $yyval->token = new stdClass;
  50934. $yyval->token->$property = $tokens[$len][1];
  50935. }
  50936. break;
  50937. case 17:
  50938. if ($this->flags & self::PARSE_TO_ASSOC) {
  50939. $yyval->token =& $tokens[$len-2];
  50940. $key = $tokens[$len][0];
  50941. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  50942. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  50943. $errStr .= $this->lexer->showPosition() . "\n";
  50944. $errStr .= "Duplicate key: ".$tokens[$len][0];
  50945. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  50946. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  50947. $duplicateCount = 1;
  50948. do {
  50949. $duplicateKey = $key . '.' . $duplicateCount++;
  50950. } while (isset($tokens[$len-2][$duplicateKey]));
  50951. $key = $duplicateKey;
  50952. }
  50953. $tokens[$len-2][$key] = $tokens[$len][1];
  50954. } else {
  50955. $yyval->token = $tokens[$len-2];
  50956. if (PHP_VERSION_ID < 70100) {
  50957. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  50958. } else {
  50959. $key = $tokens[$len][0];
  50960. }
  50961. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  50962. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  50963. $errStr .= $this->lexer->showPosition() . "\n";
  50964. $errStr .= "Duplicate key: ".$tokens[$len][0];
  50965. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  50966. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  50967. $duplicateCount = 1;
  50968. do {
  50969. $duplicateKey = $key . '.' . $duplicateCount++;
  50970. } while (isset($tokens[$len-2]->$duplicateKey));
  50971. $key = $duplicateKey;
  50972. }
  50973. $tokens[$len-2]->$key = $tokens[$len][1];
  50974. }
  50975. break;
  50976. case 18:
  50977. $yyval->token = array();
  50978. break;
  50979. case 19:
  50980. $yyval->token = $tokens[$len-1];
  50981. break;
  50982. case 20:
  50983. $yyval->token = array($tokens[$len]);
  50984. break;
  50985. case 21:
  50986. $tokens[$len-2][] = $tokens[$len];
  50987. $yyval->token = $tokens[$len-2];
  50988. break;
  50989. }
  50990. return new Undefined();
  50991. }
  50992. private function stringInterpolation($match)
  50993. {
  50994. switch ($match[0]) {
  50995. case '\\\\':
  50996. return '\\';
  50997. case '\"':
  50998. return '"';
  50999. case '\b':
  51000. return \chr(8);
  51001. case '\f':
  51002. return \chr(12);
  51003. case '\n':
  51004. return "\n";
  51005. case '\r':
  51006. return "\r";
  51007. case '\t':
  51008. return "\t";
  51009. case '\/':
  51010. return "/";
  51011. default:
  51012. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  51013. }
  51014. }
  51015. private function popStack($n)
  51016. {
  51017. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  51018. $this->vstack = \array_slice($this->vstack, 0, - $n);
  51019. $this->lstack = \array_slice($this->lstack, 0, - $n);
  51020. }
  51021. private function lex()
  51022. {
  51023. $token = $this->lexer->lex() ?: 1;
  51024. if (!is_numeric($token)) {
  51025. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  51026. }
  51027. return $token;
  51028. }
  51029. private function failOnBOM($input)
  51030. {
  51031. $bom = "\xEF\xBB\xBF";
  51032. if (substr($input, 0, 3) === $bom) {
  51033. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  51034. }
  51035. }
  51036. }
  51037. <?php
  51038. namespace Seld\JsonLint;
  51039. class Lexer
  51040. {
  51041. private $EOF = 1;
  51042. private $rules = array(
  51043. 0 => '/\G\s+/',
  51044. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  51045. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  51046. 3 => '/\G\{/',
  51047. 4 => '/\G\}/',
  51048. 5 => '/\G\[/',
  51049. 6 => '/\G\]/',
  51050. 7 => '/\G,/',
  51051. 8 => '/\G:/',
  51052. 9 => '/\Gtrue\b/',
  51053. 10 => '/\Gfalse\b/',
  51054. 11 => '/\Gnull\b/',
  51055. 12 => '/\G$/',
  51056. 13 => '/\G./',
  51057. );
  51058. private $conditions = array(
  51059. "INITIAL" => array(
  51060. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  51061. "inclusive" => true,
  51062. ),
  51063. );
  51064. private $conditionStack;
  51065. private $input;
  51066. private $more;
  51067. private $done;
  51068. private $offset;
  51069. public $match;
  51070. public $yylineno;
  51071. public $yyleng;
  51072. public $yytext;
  51073. public $yylloc;
  51074. public function lex()
  51075. {
  51076. $r = $this->next();
  51077. if (!$r instanceof Undefined) {
  51078. return $r;
  51079. }
  51080. return $this->lex();
  51081. }
  51082. public function setInput($input)
  51083. {
  51084. $this->input = $input;
  51085. $this->more = false;
  51086. $this->done = false;
  51087. $this->offset = 0;
  51088. $this->yylineno = $this->yyleng = 0;
  51089. $this->yytext = $this->match = '';
  51090. $this->conditionStack = array('INITIAL');
  51091. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  51092. return $this;
  51093. }
  51094. public function showPosition()
  51095. {
  51096. $pre = str_replace("\n", '', $this->getPastInput());
  51097. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  51098. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  51099. }
  51100. public function getPastInput()
  51101. {
  51102. $pastLength = $this->offset - \strlen($this->match);
  51103. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  51104. }
  51105. public function getUpcomingInput()
  51106. {
  51107. $next = $this->match;
  51108. if (\strlen($next) < 20) {
  51109. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  51110. }
  51111. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  51112. }
  51113. public function getFullUpcomingInput()
  51114. {
  51115. $next = $this->match;
  51116. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  51117. $len = \strlen($this->input);
  51118. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  51119. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  51120. } elseif (\strlen($next) < 20) {
  51121. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  51122. }
  51123. return $next;
  51124. }
  51125. protected function parseError($str, $hash)
  51126. {
  51127. throw new \Exception($str);
  51128. }
  51129. private function next()
  51130. {
  51131. if ($this->done) {
  51132. return $this->EOF;
  51133. }
  51134. if ($this->offset === \strlen($this->input)) {
  51135. $this->done = true;
  51136. }
  51137. $token = null;
  51138. $match = null;
  51139. $col = null;
  51140. $lines = null;
  51141. if (!$this->more) {
  51142. $this->yytext = '';
  51143. $this->match = '';
  51144. }
  51145. $rules = $this->getCurrentRules();
  51146. $rulesLen = \count($rules);
  51147. for ($i=0; $i < $rulesLen; $i++) {
  51148. if (preg_match($this->rules[$rules[$i]], $this->input, $match, 0, $this->offset)) {
  51149. preg_match_all('/\n.*/', $match[0], $lines);
  51150. $lines = $lines[0];
  51151. if ($lines) {
  51152. $this->yylineno += \count($lines);
  51153. }
  51154. $this->yylloc = array(
  51155. 'first_line' => $this->yylloc['last_line'],
  51156. 'last_line' => $this->yylineno+1,
  51157. 'first_column' => $this->yylloc['last_column'],
  51158. 'last_column' => $lines ? \strlen($lines[\count($lines) - 1]) - 1 : $this->yylloc['last_column'] + \strlen($match[0]),
  51159. );
  51160. $this->yytext .= $match[0];
  51161. $this->match .= $match[0];
  51162. $this->yyleng = \strlen($this->yytext);
  51163. $this->more = false;
  51164. $this->offset += \strlen($match[0]);
  51165. $token = $this->performAction($rules[$i], $this->conditionStack[\count($this->conditionStack)-1]);
  51166. if ($token) {
  51167. return $token;
  51168. }
  51169. return new Undefined();
  51170. }
  51171. }
  51172. if ($this->offset === \strlen($this->input)) {
  51173. return $this->EOF;
  51174. }
  51175. $this->parseError(
  51176. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  51177. array(
  51178. 'text' => "",
  51179. 'token' => null,
  51180. 'line' => $this->yylineno,
  51181. )
  51182. );
  51183. }
  51184. private function getCurrentRules()
  51185. {
  51186. return $this->conditions[$this->conditionStack[\count($this->conditionStack)-1]]['rules'];
  51187. }
  51188. private function performAction($avoiding_name_collisions, $YY_START)
  51189. {
  51190. switch ($avoiding_name_collisions) {
  51191. case 0:
  51192. break;
  51193. case 1:
  51194. return 6;
  51195. case 2:
  51196. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  51197. return 4;
  51198. case 3:
  51199. return 17;
  51200. case 4:
  51201. return 18;
  51202. case 5:
  51203. return 23;
  51204. case 6:
  51205. return 24;
  51206. case 7:
  51207. return 22;
  51208. case 8:
  51209. return 21;
  51210. case 9:
  51211. return 10;
  51212. case 10:
  51213. return 11;
  51214. case 11:
  51215. return 8;
  51216. case 12:
  51217. return 14;
  51218. case 13:
  51219. return 'INVALID';
  51220. }
  51221. }
  51222. }
  51223. <?php
  51224. namespace Seld\JsonLint;
  51225. class ParsingException extends \Exception
  51226. {
  51227. protected $details;
  51228. public function __construct($message, $details = array())
  51229. {
  51230. $this->details = $details;
  51231. parent::__construct($message);
  51232. }
  51233. public function getDetails()
  51234. {
  51235. return $this->details;
  51236. }
  51237. }
  51238. <?php
  51239. namespace Seld\JsonLint;
  51240. class Undefined
  51241. {
  51242. }
  51243. Copyright (c) 2015 Jordi Boggiano
  51244. Permission is hereby granted, free of charge, to any person obtaining a copy
  51245. of this software and associated documentation files (the "Software"), to deal
  51246. in the Software without restriction, including without limitation the rights
  51247. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51248. copies of the Software, and to permit persons to whom the Software is furnished
  51249. to do so, subject to the following conditions:
  51250. The above copyright notice and this permission notice shall be included in all
  51251. copies or substantial portions of the Software.
  51252. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51253. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51254. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51255. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51256. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51257. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  51258. THE SOFTWARE.
  51259. <?php
  51260. namespace Seld\PharUtils;
  51261. class Linter
  51262. {
  51263. public static function lint($path, array $excludedPaths = array())
  51264. {
  51265. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  51266. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  51267. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  51268. if (!$tmpFile || !is_writable($tmpFile)) {
  51269. throw new \RuntimeException('Unable to create temp file');
  51270. }
  51271. $php = self::escapeWindowsPath($php);
  51272. $tmpFile = self::escapeWindowsPath($tmpFile);
  51273. if (PHP_VERSION_ID >= 80000) {
  51274. $format = '%s -l %s';
  51275. } else {
  51276. $format = '"%s -l %s"';
  51277. }
  51278. $command = sprintf($format, $php, $tmpFile);
  51279. } else {
  51280. $command = "'".$php."' -l";
  51281. }
  51282. $descriptorspec = array(
  51283. 0 => array('pipe', 'r'),
  51284. 1 => array('pipe', 'w'),
  51285. 2 => array('pipe', 'w')
  51286. );
  51287. $baseLen = strlen(realpath($path)) + 7 + 1;
  51288. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  51289. if ($file->isDir()) {
  51290. continue;
  51291. }
  51292. if (substr($file, -4) === '.php') {
  51293. $filename = (string) $file;
  51294. if (in_array(substr($filename, $baseLen), $excludedPaths, true)) {
  51295. continue;
  51296. }
  51297. if ($isWindows) {
  51298. file_put_contents($tmpFile, file_get_contents($filename));
  51299. }
  51300. $process = proc_open($command, $descriptorspec, $pipes);
  51301. if (is_resource($process)) {
  51302. if (!$isWindows) {
  51303. fwrite($pipes[0], file_get_contents($filename));
  51304. }
  51305. fclose($pipes[0]);
  51306. $stdout = stream_get_contents($pipes[1]);
  51307. fclose($pipes[1]);
  51308. $stderr = stream_get_contents($pipes[2]);
  51309. fclose($pipes[2]);
  51310. $exitCode = proc_close($process);
  51311. if ($exitCode !== 0) {
  51312. if ($isWindows) {
  51313. $stderr = str_replace($tmpFile, $filename, $stderr);
  51314. }
  51315. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  51316. }
  51317. } else {
  51318. throw new \RuntimeException('Could not start linter process');
  51319. }
  51320. }
  51321. }
  51322. if ($isWindows) {
  51323. @unlink($tmpFile);
  51324. }
  51325. }
  51326. private static function escapeWindowsPath($path)
  51327. {
  51328. if (strpbrk($path, " ()") !== false) {
  51329. $path = '"'.$path.'"';
  51330. }
  51331. return $path;
  51332. }
  51333. }
  51334. <?php
  51335. namespace Seld\PharUtils;
  51336. class Timestamps
  51337. {
  51338. private $contents;
  51339. public function __construct($file)
  51340. {
  51341. $this->contents = file_get_contents($file);
  51342. }
  51343. public function updateTimestamps($timestamp = null)
  51344. {
  51345. if ($timestamp instanceof \DateTime || $timestamp instanceof \DateTimeInterface) {
  51346. $timestamp = $timestamp->getTimestamp();
  51347. } elseif (is_string($timestamp)) {
  51348. $timestamp = strtotime($timestamp);
  51349. } elseif (!is_int($timestamp)) {
  51350. $timestamp = strtotime('1984-12-24T00:00:00Z');
  51351. }
  51352. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  51353. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  51354. }
  51355. $pos = $match[0][1] + strlen($match[0][0]);
  51356. $stubEnd = $pos + $this->readUint($pos, 4);
  51357. $pos += 4;
  51358. $numFiles = $this->readUint($pos, 4);
  51359. $pos += 4;
  51360. $pos += 2;
  51361. $pos += 4;
  51362. $aliasLength = $this->readUint($pos, 4);
  51363. $pos += 4 + $aliasLength;
  51364. $metadataLength = $this->readUint($pos, 4);
  51365. $pos += 4 + $metadataLength;
  51366. while ($pos < $stubEnd) {
  51367. $filenameLength = $this->readUint($pos, 4);
  51368. $pos += 4 + $filenameLength;
  51369. $pos += 4;
  51370. $this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
  51371. $pos += 4*4;
  51372. $metadataLength = $this->readUint($pos, 4);
  51373. $pos += 4 + $metadataLength;
  51374. $numFiles--;
  51375. }
  51376. if ($numFiles !== 0) {
  51377. throw new \LogicException('All files were not processed, something must have gone wrong');
  51378. }
  51379. }
  51380. public function save($path, $signatureAlgo)
  51381. {
  51382. $pos = $this->determineSignatureBegin();
  51383. $algos = array(
  51384. \Phar::MD5 => 'md5',
  51385. \Phar::SHA1 => 'sha1',
  51386. \Phar::SHA256 => 'sha256',
  51387. \Phar::SHA512 => 'sha512',
  51388. );
  51389. if (!isset($algos[$signatureAlgo])) {
  51390. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  51391. }
  51392. $algo = $algos[$signatureAlgo];
  51393. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  51394. . pack('L', $signatureAlgo)
  51395. . 'GBMB';
  51396. $this->contents = substr($this->contents, 0, $pos) . $signature;
  51397. return file_put_contents($path, $this->contents);
  51398. }
  51399. private function readUint($pos, $bytes)
  51400. {
  51401. $res = unpack('V', substr($this->contents, $pos, $bytes));
  51402. return $res[1];
  51403. }
  51404. private function determineSignatureBegin()
  51405. {
  51406. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  51407. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  51408. }
  51409. $pos = $match[0][1] + strlen($match[0][0]);
  51410. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  51411. $pos += 4;
  51412. $numFiles = $this->readUint($pos, 4);
  51413. $pos += 4;
  51414. $pos += 2;
  51415. $pos += 4;
  51416. $aliasLength = $this->readUint($pos, 4);
  51417. $pos += 4 + $aliasLength;
  51418. $metadataLength = $this->readUint($pos, 4);
  51419. $pos += 4 + $metadataLength;
  51420. $compressedSizes = 0;
  51421. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  51422. $filenameLength = $this->readUint($pos, 4);
  51423. $pos += 4 + $filenameLength;
  51424. $pos += 2*4;
  51425. $compressedSizes += $this->readUint($pos, 4);
  51426. $pos += 3*4;
  51427. $metadataLength = $this->readUint($pos, 4);
  51428. $pos += 4 + $metadataLength;
  51429. $numFiles--;
  51430. }
  51431. if ($numFiles !== 0) {
  51432. throw new \LogicException('All files were not processed, something must have gone wrong');
  51433. }
  51434. return $manifestEnd + $compressedSizes;
  51435. }
  51436. }
  51437. <?php
  51438. namespace Symfony\Component\Console;
  51439. use Symfony\Component\Console\Command\Command;
  51440. use Symfony\Component\Console\Command\HelpCommand;
  51441. use Symfony\Component\Console\Command\ListCommand;
  51442. use Symfony\Component\Console\Descriptor\TextDescriptor;
  51443. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  51444. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  51445. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  51446. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  51447. use Symfony\Component\Console\Exception\CommandNotFoundException;
  51448. use Symfony\Component\Console\Exception\ExceptionInterface;
  51449. use Symfony\Component\Console\Exception\LogicException;
  51450. use Symfony\Component\Console\Formatter\OutputFormatter;
  51451. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  51452. use Symfony\Component\Console\Helper\DialogHelper;
  51453. use Symfony\Component\Console\Helper\FormatterHelper;
  51454. use Symfony\Component\Console\Helper\Helper;
  51455. use Symfony\Component\Console\Helper\HelperSet;
  51456. use Symfony\Component\Console\Helper\ProcessHelper;
  51457. use Symfony\Component\Console\Helper\ProgressHelper;
  51458. use Symfony\Component\Console\Helper\QuestionHelper;
  51459. use Symfony\Component\Console\Helper\TableHelper;
  51460. use Symfony\Component\Console\Input\ArgvInput;
  51461. use Symfony\Component\Console\Input\ArrayInput;
  51462. use Symfony\Component\Console\Input\InputArgument;
  51463. use Symfony\Component\Console\Input\InputAwareInterface;
  51464. use Symfony\Component\Console\Input\InputDefinition;
  51465. use Symfony\Component\Console\Input\InputInterface;
  51466. use Symfony\Component\Console\Input\InputOption;
  51467. use Symfony\Component\Console\Output\BufferedOutput;
  51468. use Symfony\Component\Console\Output\ConsoleOutput;
  51469. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  51470. use Symfony\Component\Console\Output\OutputInterface;
  51471. use Symfony\Component\Debug\Exception\FatalThrowableError;
  51472. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  51473. class Application
  51474. {
  51475. private $commands = array();
  51476. private $wantHelps = false;
  51477. private $runningCommand;
  51478. private $name;
  51479. private $version;
  51480. private $catchExceptions = true;
  51481. private $autoExit = true;
  51482. private $definition;
  51483. private $helperSet;
  51484. private $dispatcher;
  51485. private $terminalDimensions;
  51486. private $defaultCommand;
  51487. private $initialized;
  51488. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  51489. {
  51490. $this->name = $name;
  51491. $this->version = $version;
  51492. $this->defaultCommand = 'list';
  51493. }
  51494. public function setDispatcher(EventDispatcherInterface $dispatcher)
  51495. {
  51496. $this->dispatcher = $dispatcher;
  51497. }
  51498. public function run(InputInterface $input = null, OutputInterface $output = null)
  51499. {
  51500. if (null === $input) {
  51501. $input = new ArgvInput();
  51502. }
  51503. if (null === $output) {
  51504. $output = new ConsoleOutput();
  51505. }
  51506. $this->configureIO($input, $output);
  51507. try {
  51508. $e = null;
  51509. $exitCode = $this->doRun($input, $output);
  51510. } catch (\Exception $e) {
  51511. }
  51512. if (null !== $e) {
  51513. if (!$this->catchExceptions) {
  51514. throw $e;
  51515. }
  51516. if ($output instanceof ConsoleOutputInterface) {
  51517. $this->renderException($e, $output->getErrorOutput());
  51518. } else {
  51519. $this->renderException($e, $output);
  51520. }
  51521. $exitCode = $this->getExitCodeForThrowable($e);
  51522. }
  51523. if ($this->autoExit) {
  51524. if ($exitCode > 255) {
  51525. $exitCode = 255;
  51526. }
  51527. exit($exitCode);
  51528. }
  51529. return $exitCode;
  51530. }
  51531. public function doRun(InputInterface $input, OutputInterface $output)
  51532. {
  51533. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  51534. $output->writeln($this->getLongVersion());
  51535. return 0;
  51536. }
  51537. $name = $this->getCommandName($input);
  51538. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  51539. if (!$name) {
  51540. $name = 'help';
  51541. $input = new ArrayInput(array('command' => 'help'));
  51542. } else {
  51543. $this->wantHelps = true;
  51544. }
  51545. }
  51546. if (!$name) {
  51547. $name = $this->defaultCommand;
  51548. $definition = $this->getDefinition();
  51549. $definition->setArguments(array_merge(
  51550. $definition->getArguments(),
  51551. array(
  51552. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  51553. )
  51554. ));
  51555. }
  51556. $this->runningCommand = null;
  51557. $command = $this->find($name);
  51558. $this->runningCommand = $command;
  51559. $exitCode = $this->doRunCommand($command, $input, $output);
  51560. $this->runningCommand = null;
  51561. return $exitCode;
  51562. }
  51563. public function setHelperSet(HelperSet $helperSet)
  51564. {
  51565. $this->helperSet = $helperSet;
  51566. }
  51567. public function getHelperSet()
  51568. {
  51569. if (!$this->helperSet) {
  51570. $this->helperSet = $this->getDefaultHelperSet();
  51571. }
  51572. return $this->helperSet;
  51573. }
  51574. public function setDefinition(InputDefinition $definition)
  51575. {
  51576. $this->definition = $definition;
  51577. }
  51578. public function getDefinition()
  51579. {
  51580. if (!$this->definition) {
  51581. $this->definition = $this->getDefaultInputDefinition();
  51582. }
  51583. return $this->definition;
  51584. }
  51585. public function getHelp()
  51586. {
  51587. return $this->getLongVersion();
  51588. }
  51589. public function setCatchExceptions($boolean)
  51590. {
  51591. $this->catchExceptions = (bool) $boolean;
  51592. }
  51593. public function setAutoExit($boolean)
  51594. {
  51595. $this->autoExit = (bool) $boolean;
  51596. }
  51597. public function getName()
  51598. {
  51599. return $this->name;
  51600. }
  51601. public function setName($name)
  51602. {
  51603. $this->name = $name;
  51604. }
  51605. public function getVersion()
  51606. {
  51607. return $this->version;
  51608. }
  51609. public function setVersion($version)
  51610. {
  51611. $this->version = $version;
  51612. }
  51613. public function getLongVersion()
  51614. {
  51615. if ('UNKNOWN' !== $this->getName()) {
  51616. if ('UNKNOWN' !== $this->getVersion()) {
  51617. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  51618. }
  51619. return sprintf('<info>%s</info>', $this->getName());
  51620. }
  51621. return '<info>Console Tool</info>';
  51622. }
  51623. public function register($name)
  51624. {
  51625. return $this->add(new Command($name));
  51626. }
  51627. public function addCommands(array $commands)
  51628. {
  51629. foreach ($commands as $command) {
  51630. $this->add($command);
  51631. }
  51632. }
  51633. public function add(Command $command)
  51634. {
  51635. $this->init();
  51636. $command->setApplication($this);
  51637. if (!$command->isEnabled()) {
  51638. $command->setApplication(null);
  51639. return;
  51640. }
  51641. if (null === $command->getDefinition()) {
  51642. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  51643. }
  51644. $this->commands[$command->getName()] = $command;
  51645. foreach ($command->getAliases() as $alias) {
  51646. $this->commands[$alias] = $command;
  51647. }
  51648. return $command;
  51649. }
  51650. public function get($name)
  51651. {
  51652. $this->init();
  51653. if (!isset($this->commands[$name])) {
  51654. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  51655. }
  51656. $command = $this->commands[$name];
  51657. if ($this->wantHelps) {
  51658. $this->wantHelps = false;
  51659. $helpCommand = $this->get('help');
  51660. $helpCommand->setCommand($command);
  51661. return $helpCommand;
  51662. }
  51663. return $command;
  51664. }
  51665. public function has($name)
  51666. {
  51667. $this->init();
  51668. return isset($this->commands[$name]);
  51669. }
  51670. public function getNamespaces()
  51671. {
  51672. $namespaces = array();
  51673. foreach ($this->all() as $command) {
  51674. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  51675. foreach ($command->getAliases() as $alias) {
  51676. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  51677. }
  51678. }
  51679. return array_values(array_unique(array_filter($namespaces)));
  51680. }
  51681. public function findNamespace($namespace)
  51682. {
  51683. $allNamespaces = $this->getNamespaces();
  51684. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  51685. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  51686. if (empty($namespaces)) {
  51687. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  51688. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  51689. if (1 == \count($alternatives)) {
  51690. $message .= "\n\nDid you mean this?\n ";
  51691. } else {
  51692. $message .= "\n\nDid you mean one of these?\n ";
  51693. }
  51694. $message .= implode("\n ", $alternatives);
  51695. }
  51696. throw new CommandNotFoundException($message, $alternatives);
  51697. }
  51698. $exact = \in_array($namespace, $namespaces, true);
  51699. if (\count($namespaces) > 1 && !$exact) {
  51700. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  51701. }
  51702. return $exact ? $namespace : reset($namespaces);
  51703. }
  51704. public function find($name)
  51705. {
  51706. $this->init();
  51707. $aliases = array();
  51708. $allCommands = array_keys($this->commands);
  51709. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  51710. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  51711. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  51712. if (false !== $pos = strrpos($name, ':')) {
  51713. $this->findNamespace(substr($name, 0, $pos));
  51714. }
  51715. $message = sprintf('Command "%s" is not defined.', $name);
  51716. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  51717. if (1 == \count($alternatives)) {
  51718. $message .= "\n\nDid you mean this?\n ";
  51719. } else {
  51720. $message .= "\n\nDid you mean one of these?\n ";
  51721. }
  51722. $message .= implode("\n ", $alternatives);
  51723. }
  51724. throw new CommandNotFoundException($message, $alternatives);
  51725. }
  51726. if (\count($commands) > 1) {
  51727. $commandList = $this->commands;
  51728. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  51729. $commandName = $commandList[$nameOrAlias]->getName();
  51730. $aliases[$nameOrAlias] = $commandName;
  51731. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  51732. });
  51733. }
  51734. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  51735. if (!$exact && \count($commands) > 1) {
  51736. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  51737. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  51738. }
  51739. return $this->get($exact ? $name : reset($commands));
  51740. }
  51741. public function all($namespace = null)
  51742. {
  51743. $this->init();
  51744. if (null === $namespace) {
  51745. return $this->commands;
  51746. }
  51747. $commands = array();
  51748. foreach ($this->commands as $name => $command) {
  51749. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  51750. $commands[$name] = $command;
  51751. }
  51752. }
  51753. return $commands;
  51754. }
  51755. public static function getAbbreviations($names)
  51756. {
  51757. $abbrevs = array();
  51758. foreach ($names as $name) {
  51759. for ($len = \strlen($name); $len > 0; --$len) {
  51760. $abbrev = substr($name, 0, $len);
  51761. $abbrevs[$abbrev][] = $name;
  51762. }
  51763. }
  51764. return $abbrevs;
  51765. }
  51766. public function asText($namespace = null, $raw = false)
  51767. {
  51768. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  51769. $descriptor = new TextDescriptor();
  51770. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  51771. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  51772. return $output->fetch();
  51773. }
  51774. public function asXml($namespace = null, $asDom = false)
  51775. {
  51776. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  51777. $descriptor = new XmlDescriptor();
  51778. if ($asDom) {
  51779. return $descriptor->getApplicationDocument($this, $namespace);
  51780. }
  51781. $output = new BufferedOutput();
  51782. $descriptor->describe($output, $this, array('namespace' => $namespace));
  51783. return $output->fetch();
  51784. }
  51785. public function renderException($e, $output)
  51786. {
  51787. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  51788. do {
  51789. $title = sprintf(' [%s] ', \get_class($e));
  51790. $len = Helper::strlen($title);
  51791. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  51792. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  51793. $width = 1 << 31;
  51794. }
  51795. $lines = array();
  51796. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  51797. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  51798. $lineLength = Helper::strlen($line) + 4;
  51799. $lines[] = array($line, $lineLength);
  51800. $len = max($lineLength, $len);
  51801. }
  51802. }
  51803. $messages = array();
  51804. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  51805. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  51806. foreach ($lines as $line) {
  51807. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  51808. }
  51809. $messages[] = $emptyLine;
  51810. $messages[] = '';
  51811. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  51812. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  51813. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  51814. $trace = $e->getTrace();
  51815. array_unshift($trace, array(
  51816. 'function' => '',
  51817. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  51818. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  51819. 'args' => array(),
  51820. ));
  51821. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  51822. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  51823. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  51824. $function = $trace[$i]['function'];
  51825. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  51826. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  51827. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  51828. }
  51829. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  51830. }
  51831. } while ($e = $e->getPrevious());
  51832. if (null !== $this->runningCommand) {
  51833. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  51834. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  51835. }
  51836. }
  51837. protected function getTerminalWidth()
  51838. {
  51839. $dimensions = $this->getTerminalDimensions();
  51840. return $dimensions[0];
  51841. }
  51842. protected function getTerminalHeight()
  51843. {
  51844. $dimensions = $this->getTerminalDimensions();
  51845. return $dimensions[1];
  51846. }
  51847. public function getTerminalDimensions()
  51848. {
  51849. if ($this->terminalDimensions) {
  51850. return $this->terminalDimensions;
  51851. }
  51852. if ('\\' === \DIRECTORY_SEPARATOR) {
  51853. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  51854. return array((int) $matches[1], (int) $matches[2]);
  51855. }
  51856. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  51857. return array((int) $matches[1], (int) $matches[2]);
  51858. }
  51859. }
  51860. if ($sttyString = $this->getSttyColumns()) {
  51861. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  51862. return array((int) $matches[2], (int) $matches[1]);
  51863. }
  51864. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  51865. return array((int) $matches[2], (int) $matches[1]);
  51866. }
  51867. }
  51868. return array(null, null);
  51869. }
  51870. public function setTerminalDimensions($width, $height)
  51871. {
  51872. $this->terminalDimensions = array($width, $height);
  51873. return $this;
  51874. }
  51875. protected function configureIO(InputInterface $input, OutputInterface $output)
  51876. {
  51877. if (true === $input->hasParameterOption(array('--ansi'))) {
  51878. $output->setDecorated(true);
  51879. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  51880. $output->setDecorated(false);
  51881. }
  51882. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  51883. $input->setInteractive(false);
  51884. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  51885. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  51886. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  51887. $input->setInteractive(false);
  51888. }
  51889. }
  51890. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  51891. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  51892. $input->setInteractive(false);
  51893. } else {
  51894. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  51895. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  51896. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  51897. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  51898. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  51899. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  51900. }
  51901. }
  51902. }
  51903. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  51904. {
  51905. foreach ($command->getHelperSet() as $helper) {
  51906. if ($helper instanceof InputAwareInterface) {
  51907. $helper->setInput($input);
  51908. }
  51909. }
  51910. if (null === $this->dispatcher) {
  51911. return $command->run($input, $output);
  51912. }
  51913. try {
  51914. $command->mergeApplicationDefinition();
  51915. $input->bind($command->getDefinition());
  51916. } catch (ExceptionInterface $e) {
  51917. }
  51918. $event = new ConsoleCommandEvent($command, $input, $output);
  51919. $e = null;
  51920. try {
  51921. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  51922. if ($event->commandShouldRun()) {
  51923. $exitCode = $command->run($input, $output);
  51924. } else {
  51925. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  51926. }
  51927. } catch (\Exception $e) {
  51928. } catch (\Throwable $e) {
  51929. }
  51930. if (null !== $e) {
  51931. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  51932. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  51933. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  51934. if ($x !== $event->getException()) {
  51935. $e = $event->getException();
  51936. }
  51937. $exitCode = $this->getExitCodeForThrowable($e);
  51938. }
  51939. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  51940. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  51941. if (null !== $e) {
  51942. throw $e;
  51943. }
  51944. return $event->getExitCode();
  51945. }
  51946. protected function getCommandName(InputInterface $input)
  51947. {
  51948. return $input->getFirstArgument();
  51949. }
  51950. protected function getDefaultInputDefinition()
  51951. {
  51952. return new InputDefinition(array(
  51953. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  51954. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  51955. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  51956. 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'),
  51957. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  51958. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  51959. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  51960. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  51961. ));
  51962. }
  51963. protected function getDefaultCommands()
  51964. {
  51965. return array(new HelpCommand(), new ListCommand());
  51966. }
  51967. protected function getDefaultHelperSet()
  51968. {
  51969. return new HelperSet(array(
  51970. new FormatterHelper(),
  51971. new DialogHelper(false),
  51972. new ProgressHelper(false),
  51973. new TableHelper(false),
  51974. new DebugFormatterHelper(),
  51975. new ProcessHelper(),
  51976. new QuestionHelper(),
  51977. ));
  51978. }
  51979. private function getSttyColumns()
  51980. {
  51981. if (!\function_exists('proc_open')) {
  51982. return;
  51983. }
  51984. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  51985. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  51986. if (\is_resource($process)) {
  51987. $info = stream_get_contents($pipes[1]);
  51988. fclose($pipes[1]);
  51989. fclose($pipes[2]);
  51990. proc_close($process);
  51991. return $info;
  51992. }
  51993. }
  51994. private function getConsoleMode()
  51995. {
  51996. if (!\function_exists('proc_open')) {
  51997. return;
  51998. }
  51999. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  52000. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  52001. if (\is_resource($process)) {
  52002. $info = stream_get_contents($pipes[1]);
  52003. fclose($pipes[1]);
  52004. fclose($pipes[2]);
  52005. proc_close($process);
  52006. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  52007. return $matches[2].'x'.$matches[1];
  52008. }
  52009. }
  52010. }
  52011. private function getAbbreviationSuggestions($abbrevs)
  52012. {
  52013. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  52014. }
  52015. public function extractNamespace($name, $limit = null)
  52016. {
  52017. $parts = explode(':', $name);
  52018. array_pop($parts);
  52019. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  52020. }
  52021. private function findAlternatives($name, $collection)
  52022. {
  52023. $threshold = 1e3;
  52024. $alternatives = array();
  52025. $collectionParts = array();
  52026. foreach ($collection as $item) {
  52027. $collectionParts[$item] = explode(':', $item);
  52028. }
  52029. foreach (explode(':', $name) as $i => $subname) {
  52030. foreach ($collectionParts as $collectionName => $parts) {
  52031. $exists = isset($alternatives[$collectionName]);
  52032. if (!isset($parts[$i]) && $exists) {
  52033. $alternatives[$collectionName] += $threshold;
  52034. continue;
  52035. } elseif (!isset($parts[$i])) {
  52036. continue;
  52037. }
  52038. $lev = levenshtein($subname, $parts[$i]);
  52039. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  52040. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  52041. } elseif ($exists) {
  52042. $alternatives[$collectionName] += $threshold;
  52043. }
  52044. }
  52045. }
  52046. foreach ($collection as $item) {
  52047. $lev = levenshtein($name, $item);
  52048. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  52049. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  52050. }
  52051. }
  52052. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  52053. asort($alternatives);
  52054. return array_keys($alternatives);
  52055. }
  52056. public function setDefaultCommand($commandName)
  52057. {
  52058. $this->defaultCommand = $commandName;
  52059. }
  52060. private function splitStringByWidth($string, $width)
  52061. {
  52062. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  52063. return str_split($string, $width);
  52064. }
  52065. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  52066. $lines = array();
  52067. $line = '';
  52068. foreach (preg_split('//u', $utf8String) as $char) {
  52069. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  52070. $line .= $char;
  52071. continue;
  52072. }
  52073. $lines[] = str_pad($line, $width);
  52074. $line = $char;
  52075. }
  52076. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  52077. mb_convert_variables($encoding, 'utf8', $lines);
  52078. return $lines;
  52079. }
  52080. private function extractAllNamespaces($name)
  52081. {
  52082. $parts = explode(':', $name, -1);
  52083. $namespaces = array();
  52084. foreach ($parts as $part) {
  52085. if (\count($namespaces)) {
  52086. $namespaces[] = end($namespaces).':'.$part;
  52087. } else {
  52088. $namespaces[] = $part;
  52089. }
  52090. }
  52091. return $namespaces;
  52092. }
  52093. private function init()
  52094. {
  52095. if ($this->initialized) {
  52096. return;
  52097. }
  52098. $this->initialized = true;
  52099. foreach ($this->getDefaultCommands() as $command) {
  52100. $this->add($command);
  52101. }
  52102. }
  52103. private function getExitCodeForThrowable($throwable)
  52104. {
  52105. $exitCode = $throwable->getCode();
  52106. if (is_numeric($exitCode)) {
  52107. $exitCode = (int) $exitCode;
  52108. if (0 === $exitCode) {
  52109. $exitCode = 1;
  52110. }
  52111. } else {
  52112. $exitCode = 1;
  52113. }
  52114. return $exitCode;
  52115. }
  52116. }
  52117. <?php
  52118. namespace Symfony\Component\Console\Command;
  52119. use Symfony\Component\Console\Application;
  52120. use Symfony\Component\Console\Descriptor\TextDescriptor;
  52121. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  52122. use Symfony\Component\Console\Exception\ExceptionInterface;
  52123. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52124. use Symfony\Component\Console\Exception\LogicException;
  52125. use Symfony\Component\Console\Helper\HelperSet;
  52126. use Symfony\Component\Console\Input\InputArgument;
  52127. use Symfony\Component\Console\Input\InputDefinition;
  52128. use Symfony\Component\Console\Input\InputInterface;
  52129. use Symfony\Component\Console\Input\InputOption;
  52130. use Symfony\Component\Console\Output\BufferedOutput;
  52131. use Symfony\Component\Console\Output\OutputInterface;
  52132. class Command
  52133. {
  52134. private $application;
  52135. private $name;
  52136. private $processTitle;
  52137. private $aliases = array();
  52138. private $definition;
  52139. private $help;
  52140. private $description;
  52141. private $ignoreValidationErrors = false;
  52142. private $applicationDefinitionMerged = false;
  52143. private $applicationDefinitionMergedWithArgs = false;
  52144. private $code;
  52145. private $synopsis = array();
  52146. private $usages = array();
  52147. private $helperSet;
  52148. public function __construct($name = null)
  52149. {
  52150. $this->definition = new InputDefinition();
  52151. if (null !== $name) {
  52152. $this->setName($name);
  52153. }
  52154. $this->configure();
  52155. if (!$this->name) {
  52156. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  52157. }
  52158. }
  52159. public function ignoreValidationErrors()
  52160. {
  52161. $this->ignoreValidationErrors = true;
  52162. }
  52163. public function setApplication(Application $application = null)
  52164. {
  52165. $this->application = $application;
  52166. if ($application) {
  52167. $this->setHelperSet($application->getHelperSet());
  52168. } else {
  52169. $this->helperSet = null;
  52170. }
  52171. }
  52172. public function setHelperSet(HelperSet $helperSet)
  52173. {
  52174. $this->helperSet = $helperSet;
  52175. }
  52176. public function getHelperSet()
  52177. {
  52178. return $this->helperSet;
  52179. }
  52180. public function getApplication()
  52181. {
  52182. return $this->application;
  52183. }
  52184. public function isEnabled()
  52185. {
  52186. return true;
  52187. }
  52188. protected function configure()
  52189. {
  52190. }
  52191. protected function execute(InputInterface $input, OutputInterface $output)
  52192. {
  52193. throw new LogicException('You must override the execute() method in the concrete command class.');
  52194. }
  52195. protected function interact(InputInterface $input, OutputInterface $output)
  52196. {
  52197. }
  52198. protected function initialize(InputInterface $input, OutputInterface $output)
  52199. {
  52200. }
  52201. public function run(InputInterface $input, OutputInterface $output)
  52202. {
  52203. $this->getSynopsis(true);
  52204. $this->getSynopsis(false);
  52205. $this->mergeApplicationDefinition();
  52206. try {
  52207. $input->bind($this->definition);
  52208. } catch (ExceptionInterface $e) {
  52209. if (!$this->ignoreValidationErrors) {
  52210. throw $e;
  52211. }
  52212. }
  52213. $this->initialize($input, $output);
  52214. if (null !== $this->processTitle) {
  52215. if (\function_exists('cli_set_process_title')) {
  52216. if (!@cli_set_process_title($this->processTitle)) {
  52217. if ('Darwin' === PHP_OS) {
  52218. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  52219. } else {
  52220. cli_set_process_title($this->processTitle);
  52221. }
  52222. }
  52223. } elseif (\function_exists('setproctitle')) {
  52224. setproctitle($this->processTitle);
  52225. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  52226. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  52227. }
  52228. }
  52229. if ($input->isInteractive()) {
  52230. $this->interact($input, $output);
  52231. }
  52232. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  52233. $input->setArgument('command', $this->getName());
  52234. }
  52235. $input->validate();
  52236. if ($this->code) {
  52237. $statusCode = \call_user_func($this->code, $input, $output);
  52238. } else {
  52239. $statusCode = $this->execute($input, $output);
  52240. }
  52241. return is_numeric($statusCode) ? (int) $statusCode : 0;
  52242. }
  52243. public function setCode($code)
  52244. {
  52245. if (!\is_callable($code)) {
  52246. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  52247. }
  52248. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  52249. $r = new \ReflectionFunction($code);
  52250. if (null === $r->getClosureThis()) {
  52251. if (\PHP_VERSION_ID < 70000) {
  52252. $code = @\Closure::bind($code, $this);
  52253. } else {
  52254. $code = \Closure::bind($code, $this);
  52255. }
  52256. }
  52257. }
  52258. $this->code = $code;
  52259. return $this;
  52260. }
  52261. public function mergeApplicationDefinition($mergeArgs = true)
  52262. {
  52263. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  52264. return;
  52265. }
  52266. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  52267. $this->applicationDefinitionMerged = true;
  52268. if ($mergeArgs) {
  52269. $currentArguments = $this->definition->getArguments();
  52270. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  52271. $this->definition->addArguments($currentArguments);
  52272. $this->applicationDefinitionMergedWithArgs = true;
  52273. }
  52274. }
  52275. public function setDefinition($definition)
  52276. {
  52277. if ($definition instanceof InputDefinition) {
  52278. $this->definition = $definition;
  52279. } else {
  52280. $this->definition->setDefinition($definition);
  52281. }
  52282. $this->applicationDefinitionMerged = false;
  52283. return $this;
  52284. }
  52285. public function getDefinition()
  52286. {
  52287. return $this->definition;
  52288. }
  52289. public function getNativeDefinition()
  52290. {
  52291. return $this->getDefinition();
  52292. }
  52293. public function addArgument($name, $mode = null, $description = '', $default = null)
  52294. {
  52295. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  52296. return $this;
  52297. }
  52298. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  52299. {
  52300. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  52301. return $this;
  52302. }
  52303. public function setName($name)
  52304. {
  52305. $this->validateName($name);
  52306. $this->name = $name;
  52307. return $this;
  52308. }
  52309. public function setProcessTitle($title)
  52310. {
  52311. $this->processTitle = $title;
  52312. return $this;
  52313. }
  52314. public function getName()
  52315. {
  52316. return $this->name;
  52317. }
  52318. public function setDescription($description)
  52319. {
  52320. $this->description = $description;
  52321. return $this;
  52322. }
  52323. public function getDescription()
  52324. {
  52325. return $this->description;
  52326. }
  52327. public function setHelp($help)
  52328. {
  52329. $this->help = $help;
  52330. return $this;
  52331. }
  52332. public function getHelp()
  52333. {
  52334. return $this->help;
  52335. }
  52336. public function getProcessedHelp()
  52337. {
  52338. $name = $this->name;
  52339. $placeholders = array(
  52340. '%command.name%',
  52341. '%command.full_name%',
  52342. );
  52343. $replacements = array(
  52344. $name,
  52345. $_SERVER['PHP_SELF'].' '.$name,
  52346. );
  52347. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  52348. }
  52349. public function setAliases($aliases)
  52350. {
  52351. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  52352. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  52353. }
  52354. foreach ($aliases as $alias) {
  52355. $this->validateName($alias);
  52356. }
  52357. $this->aliases = $aliases;
  52358. return $this;
  52359. }
  52360. public function getAliases()
  52361. {
  52362. return $this->aliases;
  52363. }
  52364. public function getSynopsis($short = false)
  52365. {
  52366. $key = $short ? 'short' : 'long';
  52367. if (!isset($this->synopsis[$key])) {
  52368. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  52369. }
  52370. return $this->synopsis[$key];
  52371. }
  52372. public function addUsage($usage)
  52373. {
  52374. if (0 !== strpos($usage, $this->name)) {
  52375. $usage = sprintf('%s %s', $this->name, $usage);
  52376. }
  52377. $this->usages[] = $usage;
  52378. return $this;
  52379. }
  52380. public function getUsages()
  52381. {
  52382. return $this->usages;
  52383. }
  52384. public function getHelper($name)
  52385. {
  52386. if (null === $this->helperSet) {
  52387. 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));
  52388. }
  52389. return $this->helperSet->get($name);
  52390. }
  52391. public function asText()
  52392. {
  52393. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  52394. $descriptor = new TextDescriptor();
  52395. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  52396. $descriptor->describe($output, $this, array('raw_output' => true));
  52397. return $output->fetch();
  52398. }
  52399. public function asXml($asDom = false)
  52400. {
  52401. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  52402. $descriptor = new XmlDescriptor();
  52403. if ($asDom) {
  52404. return $descriptor->getCommandDocument($this);
  52405. }
  52406. $output = new BufferedOutput();
  52407. $descriptor->describe($output, $this);
  52408. return $output->fetch();
  52409. }
  52410. private function validateName($name)
  52411. {
  52412. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  52413. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  52414. }
  52415. }
  52416. }
  52417. <?php
  52418. namespace Symfony\Component\Console\Command;
  52419. use Symfony\Component\Console\Helper\DescriptorHelper;
  52420. use Symfony\Component\Console\Input\InputArgument;
  52421. use Symfony\Component\Console\Input\InputInterface;
  52422. use Symfony\Component\Console\Input\InputOption;
  52423. use Symfony\Component\Console\Output\OutputInterface;
  52424. class HelpCommand extends Command
  52425. {
  52426. private $command;
  52427. protected function configure()
  52428. {
  52429. $this->ignoreValidationErrors();
  52430. $this
  52431. ->setName('help')
  52432. ->setDefinition(array(
  52433. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  52434. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  52435. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  52436. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  52437. ))
  52438. ->setDescription('Displays help for a command')
  52439. ->setHelp(<<<'EOF'
  52440. The <info>%command.name%</info> command displays help for a given command:
  52441. <info>php %command.full_name% list</info>
  52442. You can also output the help in other formats by using the <comment>--format</comment> option:
  52443. <info>php %command.full_name% --format=xml list</info>
  52444. To display the list of available commands, please use the <info>list</info> command.
  52445. EOF
  52446. )
  52447. ;
  52448. }
  52449. public function setCommand(Command $command)
  52450. {
  52451. $this->command = $command;
  52452. }
  52453. protected function execute(InputInterface $input, OutputInterface $output)
  52454. {
  52455. if (null === $this->command) {
  52456. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  52457. }
  52458. if ($input->getOption('xml')) {
  52459. @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);
  52460. $input->setOption('format', 'xml');
  52461. }
  52462. $helper = new DescriptorHelper();
  52463. $helper->describe($output, $this->command, array(
  52464. 'format' => $input->getOption('format'),
  52465. 'raw_text' => $input->getOption('raw'),
  52466. ));
  52467. $this->command = null;
  52468. }
  52469. }
  52470. <?php
  52471. namespace Symfony\Component\Console\Command;
  52472. use Symfony\Component\Console\Helper\DescriptorHelper;
  52473. use Symfony\Component\Console\Input\InputArgument;
  52474. use Symfony\Component\Console\Input\InputDefinition;
  52475. use Symfony\Component\Console\Input\InputInterface;
  52476. use Symfony\Component\Console\Input\InputOption;
  52477. use Symfony\Component\Console\Output\OutputInterface;
  52478. class ListCommand extends Command
  52479. {
  52480. protected function configure()
  52481. {
  52482. $this
  52483. ->setName('list')
  52484. ->setDefinition($this->createDefinition())
  52485. ->setDescription('Lists commands')
  52486. ->setHelp(<<<'EOF'
  52487. The <info>%command.name%</info> command lists all commands:
  52488. <info>php %command.full_name%</info>
  52489. You can also display the commands for a specific namespace:
  52490. <info>php %command.full_name% test</info>
  52491. You can also output the information in other formats by using the <comment>--format</comment> option:
  52492. <info>php %command.full_name% --format=xml</info>
  52493. It's also possible to get raw list of commands (useful for embedding command runner):
  52494. <info>php %command.full_name% --raw</info>
  52495. EOF
  52496. )
  52497. ;
  52498. }
  52499. public function getNativeDefinition()
  52500. {
  52501. return $this->createDefinition();
  52502. }
  52503. protected function execute(InputInterface $input, OutputInterface $output)
  52504. {
  52505. if ($input->getOption('xml')) {
  52506. @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);
  52507. $input->setOption('format', 'xml');
  52508. }
  52509. $helper = new DescriptorHelper();
  52510. $helper->describe($output, $this->getApplication(), array(
  52511. 'format' => $input->getOption('format'),
  52512. 'raw_text' => $input->getOption('raw'),
  52513. 'namespace' => $input->getArgument('namespace'),
  52514. ));
  52515. }
  52516. private function createDefinition()
  52517. {
  52518. return new InputDefinition(array(
  52519. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  52520. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  52521. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  52522. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  52523. ));
  52524. }
  52525. }
  52526. <?php
  52527. namespace Symfony\Component\Console;
  52528. final class ConsoleEvents
  52529. {
  52530. const COMMAND = 'console.command';
  52531. const TERMINATE = 'console.terminate';
  52532. const EXCEPTION = 'console.exception';
  52533. }
  52534. <?php
  52535. namespace Symfony\Component\Console\Descriptor;
  52536. use Symfony\Component\Console\Application;
  52537. use Symfony\Component\Console\Command\Command;
  52538. use Symfony\Component\Console\Exception\CommandNotFoundException;
  52539. class ApplicationDescription
  52540. {
  52541. const GLOBAL_NAMESPACE = '_global';
  52542. private $application;
  52543. private $namespace;
  52544. private $namespaces;
  52545. private $commands;
  52546. private $aliases;
  52547. public function __construct(Application $application, $namespace = null)
  52548. {
  52549. $this->application = $application;
  52550. $this->namespace = $namespace;
  52551. }
  52552. public function getNamespaces()
  52553. {
  52554. if (null === $this->namespaces) {
  52555. $this->inspectApplication();
  52556. }
  52557. return $this->namespaces;
  52558. }
  52559. public function getCommands()
  52560. {
  52561. if (null === $this->commands) {
  52562. $this->inspectApplication();
  52563. }
  52564. return $this->commands;
  52565. }
  52566. public function getCommand($name)
  52567. {
  52568. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  52569. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  52570. }
  52571. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  52572. }
  52573. private function inspectApplication()
  52574. {
  52575. $this->commands = array();
  52576. $this->namespaces = array();
  52577. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  52578. foreach ($this->sortCommands($all) as $namespace => $commands) {
  52579. $names = array();
  52580. foreach ($commands as $name => $command) {
  52581. if (!$command->getName()) {
  52582. continue;
  52583. }
  52584. if ($command->getName() === $name) {
  52585. $this->commands[$name] = $command;
  52586. } else {
  52587. $this->aliases[$name] = $command;
  52588. }
  52589. $names[] = $name;
  52590. }
  52591. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  52592. }
  52593. }
  52594. private function sortCommands(array $commands)
  52595. {
  52596. $namespacedCommands = array();
  52597. $globalCommands = array();
  52598. foreach ($commands as $name => $command) {
  52599. $key = $this->application->extractNamespace($name, 1);
  52600. if (!$key) {
  52601. $globalCommands['_global'][$name] = $command;
  52602. } else {
  52603. $namespacedCommands[$key][$name] = $command;
  52604. }
  52605. }
  52606. ksort($namespacedCommands);
  52607. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  52608. foreach ($namespacedCommands as &$commandsSet) {
  52609. ksort($commandsSet);
  52610. }
  52611. unset($commandsSet);
  52612. return $namespacedCommands;
  52613. }
  52614. }
  52615. <?php
  52616. namespace Symfony\Component\Console\Descriptor;
  52617. use Symfony\Component\Console\Application;
  52618. use Symfony\Component\Console\Command\Command;
  52619. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52620. use Symfony\Component\Console\Input\InputArgument;
  52621. use Symfony\Component\Console\Input\InputDefinition;
  52622. use Symfony\Component\Console\Input\InputOption;
  52623. use Symfony\Component\Console\Output\OutputInterface;
  52624. abstract class Descriptor implements DescriptorInterface
  52625. {
  52626. private $output;
  52627. public function describe(OutputInterface $output, $object, array $options = array())
  52628. {
  52629. $this->output = $output;
  52630. switch (true) {
  52631. case $object instanceof InputArgument:
  52632. $this->describeInputArgument($object, $options);
  52633. break;
  52634. case $object instanceof InputOption:
  52635. $this->describeInputOption($object, $options);
  52636. break;
  52637. case $object instanceof InputDefinition:
  52638. $this->describeInputDefinition($object, $options);
  52639. break;
  52640. case $object instanceof Command:
  52641. $this->describeCommand($object, $options);
  52642. break;
  52643. case $object instanceof Application:
  52644. $this->describeApplication($object, $options);
  52645. break;
  52646. default:
  52647. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  52648. }
  52649. }
  52650. protected function write($content, $decorated = false)
  52651. {
  52652. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  52653. }
  52654. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  52655. abstract protected function describeInputOption(InputOption $option, array $options = array());
  52656. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  52657. abstract protected function describeCommand(Command $command, array $options = array());
  52658. abstract protected function describeApplication(Application $application, array $options = array());
  52659. }
  52660. <?php
  52661. namespace Symfony\Component\Console\Descriptor;
  52662. use Symfony\Component\Console\Output\OutputInterface;
  52663. interface DescriptorInterface
  52664. {
  52665. public function describe(OutputInterface $output, $object, array $options = array());
  52666. }
  52667. <?php
  52668. namespace Symfony\Component\Console\Descriptor;
  52669. use Symfony\Component\Console\Application;
  52670. use Symfony\Component\Console\Command\Command;
  52671. use Symfony\Component\Console\Input\InputArgument;
  52672. use Symfony\Component\Console\Input\InputDefinition;
  52673. use Symfony\Component\Console\Input\InputOption;
  52674. class JsonDescriptor extends Descriptor
  52675. {
  52676. protected function describeInputArgument(InputArgument $argument, array $options = array())
  52677. {
  52678. $this->writeData($this->getInputArgumentData($argument), $options);
  52679. }
  52680. protected function describeInputOption(InputOption $option, array $options = array())
  52681. {
  52682. $this->writeData($this->getInputOptionData($option), $options);
  52683. }
  52684. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  52685. {
  52686. $this->writeData($this->getInputDefinitionData($definition), $options);
  52687. }
  52688. protected function describeCommand(Command $command, array $options = array())
  52689. {
  52690. $this->writeData($this->getCommandData($command), $options);
  52691. }
  52692. protected function describeApplication(Application $application, array $options = array())
  52693. {
  52694. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  52695. $description = new ApplicationDescription($application, $describedNamespace);
  52696. $commands = array();
  52697. foreach ($description->getCommands() as $command) {
  52698. $commands[] = $this->getCommandData($command);
  52699. }
  52700. $data = $describedNamespace
  52701. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  52702. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  52703. $this->writeData($data, $options);
  52704. }
  52705. private function writeData(array $data, array $options)
  52706. {
  52707. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  52708. }
  52709. private function getInputArgumentData(InputArgument $argument)
  52710. {
  52711. return array(
  52712. 'name' => $argument->getName(),
  52713. 'is_required' => $argument->isRequired(),
  52714. 'is_array' => $argument->isArray(),
  52715. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  52716. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  52717. );
  52718. }
  52719. private function getInputOptionData(InputOption $option)
  52720. {
  52721. return array(
  52722. 'name' => '--'.$option->getName(),
  52723. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  52724. 'accept_value' => $option->acceptValue(),
  52725. 'is_value_required' => $option->isValueRequired(),
  52726. 'is_multiple' => $option->isArray(),
  52727. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  52728. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  52729. );
  52730. }
  52731. private function getInputDefinitionData(InputDefinition $definition)
  52732. {
  52733. $inputArguments = array();
  52734. foreach ($definition->getArguments() as $name => $argument) {
  52735. $inputArguments[$name] = $this->getInputArgumentData($argument);
  52736. }
  52737. $inputOptions = array();
  52738. foreach ($definition->getOptions() as $name => $option) {
  52739. $inputOptions[$name] = $this->getInputOptionData($option);
  52740. }
  52741. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  52742. }
  52743. private function getCommandData(Command $command)
  52744. {
  52745. $command->getSynopsis();
  52746. $command->mergeApplicationDefinition(false);
  52747. return array(
  52748. 'name' => $command->getName(),
  52749. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  52750. 'description' => $command->getDescription(),
  52751. 'help' => $command->getProcessedHelp(),
  52752. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  52753. );
  52754. }
  52755. }
  52756. <?php
  52757. namespace Symfony\Component\Console\Descriptor;
  52758. use Symfony\Component\Console\Application;
  52759. use Symfony\Component\Console\Command\Command;
  52760. use Symfony\Component\Console\Helper\Helper;
  52761. use Symfony\Component\Console\Input\InputArgument;
  52762. use Symfony\Component\Console\Input\InputDefinition;
  52763. use Symfony\Component\Console\Input\InputOption;
  52764. class MarkdownDescriptor extends Descriptor
  52765. {
  52766. protected function describeInputArgument(InputArgument $argument, array $options = array())
  52767. {
  52768. $this->write(
  52769. '**'.$argument->getName().':**'."\n\n"
  52770. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  52771. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  52772. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  52773. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  52774. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  52775. );
  52776. }
  52777. protected function describeInputOption(InputOption $option, array $options = array())
  52778. {
  52779. $this->write(
  52780. '**'.$option->getName().':**'."\n\n"
  52781. .'* Name: `--'.$option->getName().'`'."\n"
  52782. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  52783. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  52784. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  52785. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  52786. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  52787. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  52788. );
  52789. }
  52790. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  52791. {
  52792. if ($showArguments = \count($definition->getArguments()) > 0) {
  52793. $this->write('### Arguments:');
  52794. foreach ($definition->getArguments() as $argument) {
  52795. $this->write("\n\n");
  52796. $this->write($this->describeInputArgument($argument));
  52797. }
  52798. }
  52799. if (\count($definition->getOptions()) > 0) {
  52800. if ($showArguments) {
  52801. $this->write("\n\n");
  52802. }
  52803. $this->write('### Options:');
  52804. foreach ($definition->getOptions() as $option) {
  52805. $this->write("\n\n");
  52806. $this->write($this->describeInputOption($option));
  52807. }
  52808. }
  52809. }
  52810. protected function describeCommand(Command $command, array $options = array())
  52811. {
  52812. $command->getSynopsis();
  52813. $command->mergeApplicationDefinition(false);
  52814. $this->write(
  52815. $command->getName()."\n"
  52816. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  52817. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  52818. .'* Usage:'."\n\n"
  52819. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  52820. return $carry.' * `'.$usage.'`'."\n";
  52821. })
  52822. );
  52823. if ($help = $command->getProcessedHelp()) {
  52824. $this->write("\n");
  52825. $this->write($help);
  52826. }
  52827. if ($command->getNativeDefinition()) {
  52828. $this->write("\n\n");
  52829. $this->describeInputDefinition($command->getNativeDefinition());
  52830. }
  52831. }
  52832. protected function describeApplication(Application $application, array $options = array())
  52833. {
  52834. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  52835. $description = new ApplicationDescription($application, $describedNamespace);
  52836. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  52837. foreach ($description->getNamespaces() as $namespace) {
  52838. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  52839. $this->write("\n\n");
  52840. $this->write('**'.$namespace['id'].':**');
  52841. }
  52842. $this->write("\n\n");
  52843. $this->write(implode("\n", array_map(function ($commandName) {
  52844. return '* '.$commandName;
  52845. }, $namespace['commands'])));
  52846. }
  52847. foreach ($description->getCommands() as $command) {
  52848. $this->write("\n\n");
  52849. $this->write($this->describeCommand($command));
  52850. }
  52851. }
  52852. }
  52853. <?php
  52854. namespace Symfony\Component\Console\Descriptor;
  52855. use Symfony\Component\Console\Application;
  52856. use Symfony\Component\Console\Command\Command;
  52857. use Symfony\Component\Console\Formatter\OutputFormatter;
  52858. use Symfony\Component\Console\Helper\Helper;
  52859. use Symfony\Component\Console\Input\InputArgument;
  52860. use Symfony\Component\Console\Input\InputDefinition;
  52861. use Symfony\Component\Console\Input\InputOption;
  52862. class TextDescriptor extends Descriptor
  52863. {
  52864. protected function describeInputArgument(InputArgument $argument, array $options = array())
  52865. {
  52866. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  52867. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  52868. } else {
  52869. $default = '';
  52870. }
  52871. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  52872. $spacingWidth = $totalWidth - \strlen($argument->getName());
  52873. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  52874. $argument->getName(),
  52875. str_repeat(' ', $spacingWidth),
  52876. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  52877. $default
  52878. ), $options);
  52879. }
  52880. protected function describeInputOption(InputOption $option, array $options = array())
  52881. {
  52882. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  52883. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  52884. } else {
  52885. $default = '';
  52886. }
  52887. $value = '';
  52888. if ($option->acceptValue()) {
  52889. $value = '='.strtoupper($option->getName());
  52890. if ($option->isValueOptional()) {
  52891. $value = '['.$value.']';
  52892. }
  52893. }
  52894. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  52895. $synopsis = sprintf('%s%s',
  52896. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  52897. sprintf('--%s%s', $option->getName(), $value)
  52898. );
  52899. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  52900. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  52901. $synopsis,
  52902. str_repeat(' ', $spacingWidth),
  52903. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  52904. $default,
  52905. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  52906. ), $options);
  52907. }
  52908. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  52909. {
  52910. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  52911. foreach ($definition->getArguments() as $argument) {
  52912. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  52913. }
  52914. if ($definition->getArguments()) {
  52915. $this->writeText('<comment>Arguments:</comment>', $options);
  52916. $this->writeText("\n");
  52917. foreach ($definition->getArguments() as $argument) {
  52918. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  52919. $this->writeText("\n");
  52920. }
  52921. }
  52922. if ($definition->getArguments() && $definition->getOptions()) {
  52923. $this->writeText("\n");
  52924. }
  52925. if ($definition->getOptions()) {
  52926. $laterOptions = array();
  52927. $this->writeText('<comment>Options:</comment>', $options);
  52928. foreach ($definition->getOptions() as $option) {
  52929. if (\strlen($option->getShortcut()) > 1) {
  52930. $laterOptions[] = $option;
  52931. continue;
  52932. }
  52933. $this->writeText("\n");
  52934. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  52935. }
  52936. foreach ($laterOptions as $option) {
  52937. $this->writeText("\n");
  52938. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  52939. }
  52940. }
  52941. }
  52942. protected function describeCommand(Command $command, array $options = array())
  52943. {
  52944. $command->getSynopsis(true);
  52945. $command->getSynopsis(false);
  52946. $command->mergeApplicationDefinition(false);
  52947. $this->writeText('<comment>Usage:</comment>', $options);
  52948. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  52949. $this->writeText("\n");
  52950. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  52951. }
  52952. $this->writeText("\n");
  52953. $definition = $command->getNativeDefinition();
  52954. if ($definition->getOptions() || $definition->getArguments()) {
  52955. $this->writeText("\n");
  52956. $this->describeInputDefinition($definition, $options);
  52957. $this->writeText("\n");
  52958. }
  52959. if ($help = $command->getProcessedHelp()) {
  52960. $this->writeText("\n");
  52961. $this->writeText('<comment>Help:</comment>', $options);
  52962. $this->writeText("\n");
  52963. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  52964. $this->writeText("\n");
  52965. }
  52966. }
  52967. protected function describeApplication(Application $application, array $options = array())
  52968. {
  52969. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  52970. $description = new ApplicationDescription($application, $describedNamespace);
  52971. if (isset($options['raw_text']) && $options['raw_text']) {
  52972. $width = $this->getColumnWidth($description->getCommands());
  52973. foreach ($description->getCommands() as $command) {
  52974. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  52975. $this->writeText("\n");
  52976. }
  52977. } else {
  52978. if ('' != $help = $application->getHelp()) {
  52979. $this->writeText("$help\n\n", $options);
  52980. }
  52981. $this->writeText("<comment>Usage:</comment>\n", $options);
  52982. $this->writeText(" command [options] [arguments]\n\n", $options);
  52983. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  52984. $this->writeText("\n");
  52985. $this->writeText("\n");
  52986. $width = $this->getColumnWidth($description->getCommands());
  52987. if ($describedNamespace) {
  52988. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  52989. } else {
  52990. $this->writeText('<comment>Available commands:</comment>', $options);
  52991. }
  52992. foreach ($description->getNamespaces() as $namespace) {
  52993. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  52994. $this->writeText("\n");
  52995. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  52996. }
  52997. foreach ($namespace['commands'] as $name) {
  52998. $this->writeText("\n");
  52999. $spacingWidth = $width - Helper::strlen($name);
  53000. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  53001. }
  53002. }
  53003. $this->writeText("\n");
  53004. }
  53005. }
  53006. private function writeText($content, array $options = array())
  53007. {
  53008. $this->write(
  53009. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  53010. isset($options['raw_output']) ? !$options['raw_output'] : true
  53011. );
  53012. }
  53013. private function formatDefaultValue($default)
  53014. {
  53015. if (INF === $default) {
  53016. return 'INF';
  53017. }
  53018. if (\is_string($default)) {
  53019. $default = OutputFormatter::escape($default);
  53020. } elseif (\is_array($default)) {
  53021. foreach ($default as $key => $value) {
  53022. if (\is_string($value)) {
  53023. $default[$key] = OutputFormatter::escape($value);
  53024. }
  53025. }
  53026. }
  53027. if (\PHP_VERSION_ID < 50400) {
  53028. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  53029. }
  53030. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  53031. }
  53032. private function getColumnWidth(array $commands)
  53033. {
  53034. $widths = array();
  53035. foreach ($commands as $command) {
  53036. $widths[] = Helper::strlen($command->getName());
  53037. foreach ($command->getAliases() as $alias) {
  53038. $widths[] = Helper::strlen($alias);
  53039. }
  53040. }
  53041. return max($widths) + 2;
  53042. }
  53043. private function calculateTotalWidthForOptions(array $options)
  53044. {
  53045. $totalWidth = 0;
  53046. foreach ($options as $option) {
  53047. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  53048. if ($option->acceptValue()) {
  53049. $valueLength = 1 + Helper::strlen($option->getName());
  53050. $valueLength += $option->isValueOptional() ? 2 : 0;
  53051. $nameLength += $valueLength;
  53052. }
  53053. $totalWidth = max($totalWidth, $nameLength);
  53054. }
  53055. return $totalWidth;
  53056. }
  53057. }
  53058. <?php
  53059. namespace Symfony\Component\Console\Descriptor;
  53060. use Symfony\Component\Console\Application;
  53061. use Symfony\Component\Console\Command\Command;
  53062. use Symfony\Component\Console\Input\InputArgument;
  53063. use Symfony\Component\Console\Input\InputDefinition;
  53064. use Symfony\Component\Console\Input\InputOption;
  53065. class XmlDescriptor extends Descriptor
  53066. {
  53067. public function getInputDefinitionDocument(InputDefinition $definition)
  53068. {
  53069. $dom = new \DOMDocument('1.0', 'UTF-8');
  53070. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  53071. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  53072. foreach ($definition->getArguments() as $argument) {
  53073. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  53074. }
  53075. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  53076. foreach ($definition->getOptions() as $option) {
  53077. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  53078. }
  53079. return $dom;
  53080. }
  53081. public function getCommandDocument(Command $command)
  53082. {
  53083. $dom = new \DOMDocument('1.0', 'UTF-8');
  53084. $dom->appendChild($commandXML = $dom->createElement('command'));
  53085. $command->getSynopsis();
  53086. $command->mergeApplicationDefinition(false);
  53087. $commandXML->setAttribute('id', $command->getName());
  53088. $commandXML->setAttribute('name', $command->getName());
  53089. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  53090. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  53091. $usagesXML->appendChild($dom->createElement('usage', $usage));
  53092. }
  53093. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  53094. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  53095. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  53096. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  53097. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  53098. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  53099. return $dom;
  53100. }
  53101. public function getApplicationDocument(Application $application, $namespace = null)
  53102. {
  53103. $dom = new \DOMDocument('1.0', 'UTF-8');
  53104. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  53105. if ('UNKNOWN' !== $application->getName()) {
  53106. $rootXml->setAttribute('name', $application->getName());
  53107. if ('UNKNOWN' !== $application->getVersion()) {
  53108. $rootXml->setAttribute('version', $application->getVersion());
  53109. }
  53110. }
  53111. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  53112. $description = new ApplicationDescription($application, $namespace);
  53113. if ($namespace) {
  53114. $commandsXML->setAttribute('namespace', $namespace);
  53115. }
  53116. foreach ($description->getCommands() as $command) {
  53117. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  53118. }
  53119. if (!$namespace) {
  53120. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  53121. foreach ($description->getNamespaces() as $namespaceDescription) {
  53122. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  53123. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  53124. foreach ($namespaceDescription['commands'] as $name) {
  53125. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  53126. $commandXML->appendChild($dom->createTextNode($name));
  53127. }
  53128. }
  53129. }
  53130. return $dom;
  53131. }
  53132. protected function describeInputArgument(InputArgument $argument, array $options = array())
  53133. {
  53134. $this->writeDocument($this->getInputArgumentDocument($argument));
  53135. }
  53136. protected function describeInputOption(InputOption $option, array $options = array())
  53137. {
  53138. $this->writeDocument($this->getInputOptionDocument($option));
  53139. }
  53140. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  53141. {
  53142. $this->writeDocument($this->getInputDefinitionDocument($definition));
  53143. }
  53144. protected function describeCommand(Command $command, array $options = array())
  53145. {
  53146. $this->writeDocument($this->getCommandDocument($command));
  53147. }
  53148. protected function describeApplication(Application $application, array $options = array())
  53149. {
  53150. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  53151. }
  53152. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  53153. {
  53154. foreach ($importedParent->childNodes as $childNode) {
  53155. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  53156. }
  53157. }
  53158. private function writeDocument(\DOMDocument $dom)
  53159. {
  53160. $dom->formatOutput = true;
  53161. $this->write($dom->saveXML());
  53162. }
  53163. private function getInputArgumentDocument(InputArgument $argument)
  53164. {
  53165. $dom = new \DOMDocument('1.0', 'UTF-8');
  53166. $dom->appendChild($objectXML = $dom->createElement('argument'));
  53167. $objectXML->setAttribute('name', $argument->getName());
  53168. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  53169. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  53170. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  53171. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  53172. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  53173. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  53174. foreach ($defaults as $default) {
  53175. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  53176. $defaultXML->appendChild($dom->createTextNode($default));
  53177. }
  53178. return $dom;
  53179. }
  53180. private function getInputOptionDocument(InputOption $option)
  53181. {
  53182. $dom = new \DOMDocument('1.0', 'UTF-8');
  53183. $dom->appendChild($objectXML = $dom->createElement('option'));
  53184. $objectXML->setAttribute('name', '--'.$option->getName());
  53185. $pos = strpos($option->getShortcut(), '|');
  53186. if (false !== $pos) {
  53187. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  53188. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  53189. } else {
  53190. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  53191. }
  53192. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  53193. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  53194. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  53195. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  53196. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  53197. if ($option->acceptValue()) {
  53198. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  53199. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  53200. if (!empty($defaults)) {
  53201. foreach ($defaults as $default) {
  53202. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  53203. $defaultXML->appendChild($dom->createTextNode($default));
  53204. }
  53205. }
  53206. }
  53207. return $dom;
  53208. }
  53209. }
  53210. <?php
  53211. namespace Symfony\Component\Console\Event;
  53212. class ConsoleCommandEvent extends ConsoleEvent
  53213. {
  53214. const RETURN_CODE_DISABLED = 113;
  53215. private $commandShouldRun = true;
  53216. public function disableCommand()
  53217. {
  53218. return $this->commandShouldRun = false;
  53219. }
  53220. public function enableCommand()
  53221. {
  53222. return $this->commandShouldRun = true;
  53223. }
  53224. public function commandShouldRun()
  53225. {
  53226. return $this->commandShouldRun;
  53227. }
  53228. }
  53229. <?php
  53230. namespace Symfony\Component\Console\Event;
  53231. use Symfony\Component\Console\Command\Command;
  53232. use Symfony\Component\Console\Input\InputInterface;
  53233. use Symfony\Component\Console\Output\OutputInterface;
  53234. use Symfony\Component\EventDispatcher\Event;
  53235. class ConsoleEvent extends Event
  53236. {
  53237. protected $command;
  53238. private $input;
  53239. private $output;
  53240. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  53241. {
  53242. $this->command = $command;
  53243. $this->input = $input;
  53244. $this->output = $output;
  53245. }
  53246. public function getCommand()
  53247. {
  53248. return $this->command;
  53249. }
  53250. public function getInput()
  53251. {
  53252. return $this->input;
  53253. }
  53254. public function getOutput()
  53255. {
  53256. return $this->output;
  53257. }
  53258. }
  53259. <?php
  53260. namespace Symfony\Component\Console\Event;
  53261. use Symfony\Component\Console\Command\Command;
  53262. use Symfony\Component\Console\Input\InputInterface;
  53263. use Symfony\Component\Console\Output\OutputInterface;
  53264. class ConsoleExceptionEvent extends ConsoleEvent
  53265. {
  53266. private $exception;
  53267. private $exitCode;
  53268. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  53269. {
  53270. parent::__construct($command, $input, $output);
  53271. $this->setException($exception);
  53272. $this->exitCode = (int) $exitCode;
  53273. }
  53274. public function getException()
  53275. {
  53276. return $this->exception;
  53277. }
  53278. public function setException(\Exception $exception)
  53279. {
  53280. $this->exception = $exception;
  53281. }
  53282. public function getExitCode()
  53283. {
  53284. return $this->exitCode;
  53285. }
  53286. }
  53287. <?php
  53288. namespace Symfony\Component\Console\Event;
  53289. use Symfony\Component\Console\Command\Command;
  53290. use Symfony\Component\Console\Input\InputInterface;
  53291. use Symfony\Component\Console\Output\OutputInterface;
  53292. class ConsoleTerminateEvent extends ConsoleEvent
  53293. {
  53294. private $exitCode;
  53295. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  53296. {
  53297. parent::__construct($command, $input, $output);
  53298. $this->setExitCode($exitCode);
  53299. }
  53300. public function setExitCode($exitCode)
  53301. {
  53302. $this->exitCode = (int) $exitCode;
  53303. }
  53304. public function getExitCode()
  53305. {
  53306. return $this->exitCode;
  53307. }
  53308. }
  53309. <?php
  53310. namespace Symfony\Component\Console\Exception;
  53311. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  53312. {
  53313. private $alternatives;
  53314. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  53315. {
  53316. parent::__construct($message, $code, $previous);
  53317. $this->alternatives = $alternatives;
  53318. }
  53319. public function getAlternatives()
  53320. {
  53321. return $this->alternatives;
  53322. }
  53323. }
  53324. <?php
  53325. namespace Symfony\Component\Console\Exception;
  53326. interface ExceptionInterface
  53327. {
  53328. }
  53329. <?php
  53330. namespace Symfony\Component\Console\Exception;
  53331. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  53332. {
  53333. }
  53334. <?php
  53335. namespace Symfony\Component\Console\Exception;
  53336. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  53337. {
  53338. }
  53339. <?php
  53340. namespace Symfony\Component\Console\Exception;
  53341. class LogicException extends \LogicException implements ExceptionInterface
  53342. {
  53343. }
  53344. <?php
  53345. namespace Symfony\Component\Console\Exception;
  53346. class RuntimeException extends \RuntimeException implements ExceptionInterface
  53347. {
  53348. }
  53349. <?php
  53350. namespace Symfony\Component\Console\Formatter;
  53351. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53352. class OutputFormatter implements OutputFormatterInterface
  53353. {
  53354. private $decorated;
  53355. private $styles = array();
  53356. private $styleStack;
  53357. public static function escape($text)
  53358. {
  53359. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  53360. return self::escapeTrailingBackslash($text);
  53361. }
  53362. public static function escapeTrailingBackslash($text)
  53363. {
  53364. if ('\\' === substr($text, -1)) {
  53365. $len = \strlen($text);
  53366. $text = rtrim($text, '\\');
  53367. $text = str_replace("\0", '', $text);
  53368. $text .= str_repeat("\0", $len - \strlen($text));
  53369. }
  53370. return $text;
  53371. }
  53372. public function __construct($decorated = false, array $styles = array())
  53373. {
  53374. $this->decorated = (bool) $decorated;
  53375. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  53376. $this->setStyle('info', new OutputFormatterStyle('green'));
  53377. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  53378. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  53379. foreach ($styles as $name => $style) {
  53380. $this->setStyle($name, $style);
  53381. }
  53382. $this->styleStack = new OutputFormatterStyleStack();
  53383. }
  53384. public function setDecorated($decorated)
  53385. {
  53386. $this->decorated = (bool) $decorated;
  53387. }
  53388. public function isDecorated()
  53389. {
  53390. return $this->decorated;
  53391. }
  53392. public function setStyle($name, OutputFormatterStyleInterface $style)
  53393. {
  53394. $this->styles[strtolower($name)] = $style;
  53395. }
  53396. public function hasStyle($name)
  53397. {
  53398. return isset($this->styles[strtolower($name)]);
  53399. }
  53400. public function getStyle($name)
  53401. {
  53402. if (!$this->hasStyle($name)) {
  53403. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  53404. }
  53405. return $this->styles[strtolower($name)];
  53406. }
  53407. public function format($message)
  53408. {
  53409. $message = (string) $message;
  53410. $offset = 0;
  53411. $output = '';
  53412. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  53413. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  53414. foreach ($matches[0] as $i => $match) {
  53415. $pos = $match[1];
  53416. $text = $match[0];
  53417. if (0 != $pos && '\\' == $message[$pos - 1]) {
  53418. continue;
  53419. }
  53420. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  53421. $offset = $pos + \strlen($text);
  53422. if ($open = '/' != $text[1]) {
  53423. $tag = $matches[1][$i][0];
  53424. } else {
  53425. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  53426. }
  53427. if (!$open && !$tag) {
  53428. $this->styleStack->pop();
  53429. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  53430. $output .= $this->applyCurrentStyle($text);
  53431. } elseif ($open) {
  53432. $this->styleStack->push($style);
  53433. } else {
  53434. $this->styleStack->pop($style);
  53435. }
  53436. }
  53437. $output .= $this->applyCurrentStyle(substr($message, $offset));
  53438. if (false !== strpos($output, "\0")) {
  53439. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  53440. }
  53441. return str_replace('\\<', '<', $output);
  53442. }
  53443. public function getStyleStack()
  53444. {
  53445. return $this->styleStack;
  53446. }
  53447. private function createStyleFromString($string)
  53448. {
  53449. if (isset($this->styles[$string])) {
  53450. return $this->styles[$string];
  53451. }
  53452. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  53453. return false;
  53454. }
  53455. $style = new OutputFormatterStyle();
  53456. foreach ($matches as $match) {
  53457. array_shift($match);
  53458. if ('fg' == $match[0]) {
  53459. $style->setForeground($match[1]);
  53460. } elseif ('bg' == $match[0]) {
  53461. $style->setBackground($match[1]);
  53462. } else {
  53463. try {
  53464. $style->setOption($match[1]);
  53465. } catch (\InvalidArgumentException $e) {
  53466. return false;
  53467. }
  53468. }
  53469. }
  53470. return $style;
  53471. }
  53472. private function applyCurrentStyle($text)
  53473. {
  53474. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  53475. }
  53476. }
  53477. <?php
  53478. namespace Symfony\Component\Console\Formatter;
  53479. interface OutputFormatterInterface
  53480. {
  53481. public function setDecorated($decorated);
  53482. public function isDecorated();
  53483. public function setStyle($name, OutputFormatterStyleInterface $style);
  53484. public function hasStyle($name);
  53485. public function getStyle($name);
  53486. public function format($message);
  53487. }
  53488. <?php
  53489. namespace Symfony\Component\Console\Formatter;
  53490. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53491. class OutputFormatterStyle implements OutputFormatterStyleInterface
  53492. {
  53493. private static $availableForegroundColors = array(
  53494. 'black' => array('set' => 30, 'unset' => 39),
  53495. 'red' => array('set' => 31, 'unset' => 39),
  53496. 'green' => array('set' => 32, 'unset' => 39),
  53497. 'yellow' => array('set' => 33, 'unset' => 39),
  53498. 'blue' => array('set' => 34, 'unset' => 39),
  53499. 'magenta' => array('set' => 35, 'unset' => 39),
  53500. 'cyan' => array('set' => 36, 'unset' => 39),
  53501. 'white' => array('set' => 37, 'unset' => 39),
  53502. 'default' => array('set' => 39, 'unset' => 39),
  53503. );
  53504. private static $availableBackgroundColors = array(
  53505. 'black' => array('set' => 40, 'unset' => 49),
  53506. 'red' => array('set' => 41, 'unset' => 49),
  53507. 'green' => array('set' => 42, 'unset' => 49),
  53508. 'yellow' => array('set' => 43, 'unset' => 49),
  53509. 'blue' => array('set' => 44, 'unset' => 49),
  53510. 'magenta' => array('set' => 45, 'unset' => 49),
  53511. 'cyan' => array('set' => 46, 'unset' => 49),
  53512. 'white' => array('set' => 47, 'unset' => 49),
  53513. 'default' => array('set' => 49, 'unset' => 49),
  53514. );
  53515. private static $availableOptions = array(
  53516. 'bold' => array('set' => 1, 'unset' => 22),
  53517. 'underscore' => array('set' => 4, 'unset' => 24),
  53518. 'blink' => array('set' => 5, 'unset' => 25),
  53519. 'reverse' => array('set' => 7, 'unset' => 27),
  53520. 'conceal' => array('set' => 8, 'unset' => 28),
  53521. );
  53522. private $foreground;
  53523. private $background;
  53524. private $options = array();
  53525. public function __construct($foreground = null, $background = null, array $options = array())
  53526. {
  53527. if (null !== $foreground) {
  53528. $this->setForeground($foreground);
  53529. }
  53530. if (null !== $background) {
  53531. $this->setBackground($background);
  53532. }
  53533. if (\count($options)) {
  53534. $this->setOptions($options);
  53535. }
  53536. }
  53537. public function setForeground($color = null)
  53538. {
  53539. if (null === $color) {
  53540. $this->foreground = null;
  53541. return;
  53542. }
  53543. if (!isset(static::$availableForegroundColors[$color])) {
  53544. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  53545. }
  53546. $this->foreground = static::$availableForegroundColors[$color];
  53547. }
  53548. public function setBackground($color = null)
  53549. {
  53550. if (null === $color) {
  53551. $this->background = null;
  53552. return;
  53553. }
  53554. if (!isset(static::$availableBackgroundColors[$color])) {
  53555. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  53556. }
  53557. $this->background = static::$availableBackgroundColors[$color];
  53558. }
  53559. public function setOption($option)
  53560. {
  53561. if (!isset(static::$availableOptions[$option])) {
  53562. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  53563. }
  53564. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  53565. $this->options[] = static::$availableOptions[$option];
  53566. }
  53567. }
  53568. public function unsetOption($option)
  53569. {
  53570. if (!isset(static::$availableOptions[$option])) {
  53571. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  53572. }
  53573. $pos = array_search(static::$availableOptions[$option], $this->options);
  53574. if (false !== $pos) {
  53575. unset($this->options[$pos]);
  53576. }
  53577. }
  53578. public function setOptions(array $options)
  53579. {
  53580. $this->options = array();
  53581. foreach ($options as $option) {
  53582. $this->setOption($option);
  53583. }
  53584. }
  53585. public function apply($text)
  53586. {
  53587. $setCodes = array();
  53588. $unsetCodes = array();
  53589. if (null !== $this->foreground) {
  53590. $setCodes[] = $this->foreground['set'];
  53591. $unsetCodes[] = $this->foreground['unset'];
  53592. }
  53593. if (null !== $this->background) {
  53594. $setCodes[] = $this->background['set'];
  53595. $unsetCodes[] = $this->background['unset'];
  53596. }
  53597. if (\count($this->options)) {
  53598. foreach ($this->options as $option) {
  53599. $setCodes[] = $option['set'];
  53600. $unsetCodes[] = $option['unset'];
  53601. }
  53602. }
  53603. if (0 === \count($setCodes)) {
  53604. return $text;
  53605. }
  53606. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  53607. }
  53608. }
  53609. <?php
  53610. namespace Symfony\Component\Console\Formatter;
  53611. interface OutputFormatterStyleInterface
  53612. {
  53613. public function setForeground($color = null);
  53614. public function setBackground($color = null);
  53615. public function setOption($option);
  53616. public function unsetOption($option);
  53617. public function setOptions(array $options);
  53618. public function apply($text);
  53619. }
  53620. <?php
  53621. namespace Symfony\Component\Console\Formatter;
  53622. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53623. class OutputFormatterStyleStack
  53624. {
  53625. private $styles;
  53626. private $emptyStyle;
  53627. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  53628. {
  53629. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  53630. $this->reset();
  53631. }
  53632. public function reset()
  53633. {
  53634. $this->styles = array();
  53635. }
  53636. public function push(OutputFormatterStyleInterface $style)
  53637. {
  53638. $this->styles[] = $style;
  53639. }
  53640. public function pop(OutputFormatterStyleInterface $style = null)
  53641. {
  53642. if (empty($this->styles)) {
  53643. return $this->emptyStyle;
  53644. }
  53645. if (null === $style) {
  53646. return array_pop($this->styles);
  53647. }
  53648. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  53649. if ($style->apply('') === $stackedStyle->apply('')) {
  53650. $this->styles = \array_slice($this->styles, 0, $index);
  53651. return $stackedStyle;
  53652. }
  53653. }
  53654. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  53655. }
  53656. public function getCurrent()
  53657. {
  53658. if (empty($this->styles)) {
  53659. return $this->emptyStyle;
  53660. }
  53661. return $this->styles[\count($this->styles) - 1];
  53662. }
  53663. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  53664. {
  53665. $this->emptyStyle = $emptyStyle;
  53666. return $this;
  53667. }
  53668. public function getEmptyStyle()
  53669. {
  53670. return $this->emptyStyle;
  53671. }
  53672. }
  53673. <?php
  53674. namespace Symfony\Component\Console\Helper;
  53675. class DebugFormatterHelper extends Helper
  53676. {
  53677. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  53678. private $started = array();
  53679. private $count = -1;
  53680. public function start($id, $message, $prefix = 'RUN')
  53681. {
  53682. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  53683. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  53684. }
  53685. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  53686. {
  53687. $message = '';
  53688. if ($error) {
  53689. if (isset($this->started[$id]['out'])) {
  53690. $message .= "\n";
  53691. unset($this->started[$id]['out']);
  53692. }
  53693. if (!isset($this->started[$id]['err'])) {
  53694. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  53695. $this->started[$id]['err'] = true;
  53696. }
  53697. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  53698. } else {
  53699. if (isset($this->started[$id]['err'])) {
  53700. $message .= "\n";
  53701. unset($this->started[$id]['err']);
  53702. }
  53703. if (!isset($this->started[$id]['out'])) {
  53704. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  53705. $this->started[$id]['out'] = true;
  53706. }
  53707. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  53708. }
  53709. return $message;
  53710. }
  53711. public function stop($id, $message, $successful, $prefix = 'RES')
  53712. {
  53713. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  53714. if ($successful) {
  53715. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  53716. }
  53717. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  53718. unset($this->started[$id]['out'], $this->started[$id]['err']);
  53719. return $message;
  53720. }
  53721. private function getBorder($id)
  53722. {
  53723. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  53724. }
  53725. public function getName()
  53726. {
  53727. return 'debug_formatter';
  53728. }
  53729. }
  53730. <?php
  53731. namespace Symfony\Component\Console\Helper;
  53732. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  53733. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  53734. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  53735. use Symfony\Component\Console\Descriptor\TextDescriptor;
  53736. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  53737. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53738. use Symfony\Component\Console\Output\OutputInterface;
  53739. class DescriptorHelper extends Helper
  53740. {
  53741. private $descriptors = array();
  53742. public function __construct()
  53743. {
  53744. $this
  53745. ->register('txt', new TextDescriptor())
  53746. ->register('xml', new XmlDescriptor())
  53747. ->register('json', new JsonDescriptor())
  53748. ->register('md', new MarkdownDescriptor())
  53749. ;
  53750. }
  53751. public function describe(OutputInterface $output, $object, array $options = array())
  53752. {
  53753. $options = array_merge(array(
  53754. 'raw_text' => false,
  53755. 'format' => 'txt',
  53756. ), $options);
  53757. if (!isset($this->descriptors[$options['format']])) {
  53758. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  53759. }
  53760. $descriptor = $this->descriptors[$options['format']];
  53761. $descriptor->describe($output, $object, $options);
  53762. }
  53763. public function register($format, DescriptorInterface $descriptor)
  53764. {
  53765. $this->descriptors[$format] = $descriptor;
  53766. return $this;
  53767. }
  53768. public function getName()
  53769. {
  53770. return 'descriptor';
  53771. }
  53772. }
  53773. <?php
  53774. namespace Symfony\Component\Console\Helper;
  53775. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53776. use Symfony\Component\Console\Exception\RuntimeException;
  53777. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  53778. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  53779. use Symfony\Component\Console\Output\OutputInterface;
  53780. class DialogHelper extends InputAwareHelper
  53781. {
  53782. private $inputStream;
  53783. private static $shell;
  53784. private static $stty;
  53785. public function __construct($triggerDeprecationError = true)
  53786. {
  53787. if ($triggerDeprecationError) {
  53788. @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);
  53789. }
  53790. }
  53791. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  53792. {
  53793. if ($output instanceof ConsoleOutputInterface) {
  53794. $output = $output->getErrorOutput();
  53795. }
  53796. $width = max(array_map('strlen', array_keys($choices)));
  53797. $messages = (array) $question;
  53798. foreach ($choices as $key => $value) {
  53799. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  53800. }
  53801. $output->writeln($messages);
  53802. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  53803. $selectedChoices = str_replace(' ', '', $picked);
  53804. if ($multiselect) {
  53805. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  53806. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  53807. }
  53808. $selectedChoices = explode(',', $selectedChoices);
  53809. } else {
  53810. $selectedChoices = array($picked);
  53811. }
  53812. $multiselectChoices = array();
  53813. foreach ($selectedChoices as $value) {
  53814. if (empty($choices[$value])) {
  53815. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  53816. }
  53817. $multiselectChoices[] = $value;
  53818. }
  53819. if ($multiselect) {
  53820. return $multiselectChoices;
  53821. }
  53822. return $picked;
  53823. }, $attempts, $default);
  53824. return $result;
  53825. }
  53826. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  53827. {
  53828. if ($this->input && !$this->input->isInteractive()) {
  53829. return $default;
  53830. }
  53831. if ($output instanceof ConsoleOutputInterface) {
  53832. $output = $output->getErrorOutput();
  53833. }
  53834. $output->write($question);
  53835. $inputStream = $this->inputStream ?: STDIN;
  53836. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  53837. $ret = fgets($inputStream, 4096);
  53838. if (false === $ret) {
  53839. throw new RuntimeException('Aborted');
  53840. }
  53841. $ret = trim($ret);
  53842. } else {
  53843. $ret = '';
  53844. $i = 0;
  53845. $ofs = -1;
  53846. $matches = $autocomplete;
  53847. $numMatches = \count($matches);
  53848. $sttyMode = shell_exec('stty -g');
  53849. shell_exec('stty -icanon -echo');
  53850. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  53851. while (!feof($inputStream)) {
  53852. $c = fread($inputStream, 1);
  53853. if ("\177" === $c) {
  53854. if (0 === $numMatches && 0 !== $i) {
  53855. --$i;
  53856. $output->write("\033[1D");
  53857. }
  53858. if (0 === $i) {
  53859. $ofs = -1;
  53860. $matches = $autocomplete;
  53861. $numMatches = \count($matches);
  53862. } else {
  53863. $numMatches = 0;
  53864. }
  53865. $ret = substr($ret, 0, $i);
  53866. } elseif ("\033" === $c) {
  53867. $c .= fread($inputStream, 2);
  53868. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  53869. if ('A' === $c[2] && -1 === $ofs) {
  53870. $ofs = 0;
  53871. }
  53872. if (0 === $numMatches) {
  53873. continue;
  53874. }
  53875. $ofs += ('A' === $c[2]) ? -1 : 1;
  53876. $ofs = ($numMatches + $ofs) % $numMatches;
  53877. }
  53878. } elseif (\ord($c) < 32) {
  53879. if ("\t" === $c || "\n" === $c) {
  53880. if ($numMatches > 0 && -1 !== $ofs) {
  53881. $ret = $matches[$ofs];
  53882. $output->write(substr($ret, $i));
  53883. $i = \strlen($ret);
  53884. }
  53885. if ("\n" === $c) {
  53886. $output->write($c);
  53887. break;
  53888. }
  53889. $numMatches = 0;
  53890. }
  53891. continue;
  53892. } else {
  53893. $output->write($c);
  53894. $ret .= $c;
  53895. ++$i;
  53896. $numMatches = 0;
  53897. $ofs = 0;
  53898. foreach ($autocomplete as $value) {
  53899. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  53900. $matches[$numMatches++] = $value;
  53901. }
  53902. }
  53903. }
  53904. $output->write("\033[K");
  53905. if ($numMatches > 0 && -1 !== $ofs) {
  53906. $output->write("\0337");
  53907. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  53908. $output->write("\0338");
  53909. }
  53910. }
  53911. shell_exec(sprintf('stty %s', $sttyMode));
  53912. }
  53913. return \strlen($ret) > 0 ? $ret : $default;
  53914. }
  53915. public function askConfirmation(OutputInterface $output, $question, $default = true)
  53916. {
  53917. $answer = 'z';
  53918. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  53919. $answer = $this->ask($output, $question);
  53920. }
  53921. if (false === $default) {
  53922. return $answer && 'y' == strtolower($answer[0]);
  53923. }
  53924. return !$answer || 'y' == strtolower($answer[0]);
  53925. }
  53926. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  53927. {
  53928. if ($output instanceof ConsoleOutputInterface) {
  53929. $output = $output->getErrorOutput();
  53930. }
  53931. if ('\\' === \DIRECTORY_SEPARATOR) {
  53932. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  53933. if ('phar:' === substr(__FILE__, 0, 5)) {
  53934. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  53935. copy($exe, $tmpExe);
  53936. $exe = $tmpExe;
  53937. }
  53938. $output->write($question);
  53939. $value = rtrim(shell_exec($exe));
  53940. $output->writeln('');
  53941. if (isset($tmpExe)) {
  53942. unlink($tmpExe);
  53943. }
  53944. return $value;
  53945. }
  53946. if ($this->hasSttyAvailable()) {
  53947. $output->write($question);
  53948. $sttyMode = shell_exec('stty -g');
  53949. shell_exec('stty -echo');
  53950. $value = fgets($this->inputStream ?: STDIN, 4096);
  53951. shell_exec(sprintf('stty %s', $sttyMode));
  53952. if (false === $value) {
  53953. throw new RuntimeException('Aborted');
  53954. }
  53955. $value = trim($value);
  53956. $output->writeln('');
  53957. return $value;
  53958. }
  53959. if (false !== $shell = $this->getShell()) {
  53960. $output->write($question);
  53961. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  53962. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  53963. $value = rtrim(shell_exec($command));
  53964. $output->writeln('');
  53965. return $value;
  53966. }
  53967. if ($fallback) {
  53968. return $this->ask($output, $question);
  53969. }
  53970. throw new RuntimeException('Unable to hide the response');
  53971. }
  53972. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  53973. {
  53974. $that = $this;
  53975. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  53976. return $that->ask($output, $question, $default, $autocomplete);
  53977. };
  53978. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  53979. }
  53980. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  53981. {
  53982. $that = $this;
  53983. $interviewer = function () use ($output, $question, $fallback, $that) {
  53984. return $that->askHiddenResponse($output, $question, $fallback);
  53985. };
  53986. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  53987. }
  53988. public function setInputStream($stream)
  53989. {
  53990. $this->inputStream = $stream;
  53991. }
  53992. public function getInputStream()
  53993. {
  53994. return $this->inputStream;
  53995. }
  53996. public function getName()
  53997. {
  53998. return 'dialog';
  53999. }
  54000. private function getShell()
  54001. {
  54002. if (null !== self::$shell) {
  54003. return self::$shell;
  54004. }
  54005. self::$shell = false;
  54006. if (file_exists('/usr/bin/env')) {
  54007. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  54008. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  54009. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  54010. self::$shell = $sh;
  54011. break;
  54012. }
  54013. }
  54014. }
  54015. return self::$shell;
  54016. }
  54017. private function hasSttyAvailable()
  54018. {
  54019. if (null !== self::$stty) {
  54020. return self::$stty;
  54021. }
  54022. exec('stty 2>&1', $output, $exitcode);
  54023. return self::$stty = 0 === $exitcode;
  54024. }
  54025. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  54026. {
  54027. if ($output instanceof ConsoleOutputInterface) {
  54028. $output = $output->getErrorOutput();
  54029. }
  54030. $e = null;
  54031. while (false === $attempts || $attempts--) {
  54032. if (null !== $e) {
  54033. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  54034. }
  54035. try {
  54036. return \call_user_func($validator, $interviewer());
  54037. } catch (\Exception $e) {
  54038. }
  54039. }
  54040. throw $e;
  54041. }
  54042. }
  54043. <?php
  54044. namespace Symfony\Component\Console\Helper;
  54045. use Symfony\Component\Console\Formatter\OutputFormatter;
  54046. class FormatterHelper extends Helper
  54047. {
  54048. public function formatSection($section, $message, $style = 'info')
  54049. {
  54050. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  54051. }
  54052. public function formatBlock($messages, $style, $large = false)
  54053. {
  54054. if (!\is_array($messages)) {
  54055. $messages = array($messages);
  54056. }
  54057. $len = 0;
  54058. $lines = array();
  54059. foreach ($messages as $message) {
  54060. $message = OutputFormatter::escape($message);
  54061. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  54062. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  54063. }
  54064. $messages = $large ? array(str_repeat(' ', $len)) : array();
  54065. for ($i = 0; isset($lines[$i]); ++$i) {
  54066. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  54067. }
  54068. if ($large) {
  54069. $messages[] = str_repeat(' ', $len);
  54070. }
  54071. for ($i = 0; isset($messages[$i]); ++$i) {
  54072. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  54073. }
  54074. return implode("\n", $messages);
  54075. }
  54076. public function getName()
  54077. {
  54078. return 'formatter';
  54079. }
  54080. }
  54081. <?php
  54082. namespace Symfony\Component\Console\Helper;
  54083. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  54084. abstract class Helper implements HelperInterface
  54085. {
  54086. protected $helperSet = null;
  54087. public function setHelperSet(HelperSet $helperSet = null)
  54088. {
  54089. $this->helperSet = $helperSet;
  54090. }
  54091. public function getHelperSet()
  54092. {
  54093. return $this->helperSet;
  54094. }
  54095. public static function strlen($string)
  54096. {
  54097. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  54098. return \strlen($string);
  54099. }
  54100. return mb_strwidth($string, $encoding);
  54101. }
  54102. public static function formatTime($secs)
  54103. {
  54104. static $timeFormats = array(
  54105. array(0, '< 1 sec'),
  54106. array(1, '1 sec'),
  54107. array(2, 'secs', 1),
  54108. array(60, '1 min'),
  54109. array(120, 'mins', 60),
  54110. array(3600, '1 hr'),
  54111. array(7200, 'hrs', 3600),
  54112. array(86400, '1 day'),
  54113. array(172800, 'days', 86400),
  54114. );
  54115. foreach ($timeFormats as $index => $format) {
  54116. if ($secs >= $format[0]) {
  54117. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  54118. || $index == \count($timeFormats) - 1
  54119. ) {
  54120. if (2 == \count($format)) {
  54121. return $format[1];
  54122. }
  54123. return floor($secs / $format[2]).' '.$format[1];
  54124. }
  54125. }
  54126. }
  54127. }
  54128. public static function formatMemory($memory)
  54129. {
  54130. if ($memory >= 1024 * 1024 * 1024) {
  54131. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  54132. }
  54133. if ($memory >= 1024 * 1024) {
  54134. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  54135. }
  54136. if ($memory >= 1024) {
  54137. return sprintf('%d KiB', $memory / 1024);
  54138. }
  54139. return sprintf('%d B', $memory);
  54140. }
  54141. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  54142. {
  54143. return self::strlen(self::removeDecoration($formatter, $string));
  54144. }
  54145. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  54146. {
  54147. $isDecorated = $formatter->isDecorated();
  54148. $formatter->setDecorated(false);
  54149. $string = $formatter->format($string);
  54150. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  54151. $formatter->setDecorated($isDecorated);
  54152. return $string;
  54153. }
  54154. }
  54155. <?php
  54156. namespace Symfony\Component\Console\Helper;
  54157. interface HelperInterface
  54158. {
  54159. public function setHelperSet(HelperSet $helperSet = null);
  54160. public function getHelperSet();
  54161. public function getName();
  54162. }
  54163. <?php
  54164. namespace Symfony\Component\Console\Helper;
  54165. use Symfony\Component\Console\Command\Command;
  54166. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54167. class HelperSet implements \IteratorAggregate
  54168. {
  54169. private $helpers = array();
  54170. private $command;
  54171. public function __construct(array $helpers = array())
  54172. {
  54173. foreach ($helpers as $alias => $helper) {
  54174. $this->set($helper, \is_int($alias) ? null : $alias);
  54175. }
  54176. }
  54177. public function set(HelperInterface $helper, $alias = null)
  54178. {
  54179. $this->helpers[$helper->getName()] = $helper;
  54180. if (null !== $alias) {
  54181. $this->helpers[$alias] = $helper;
  54182. }
  54183. $helper->setHelperSet($this);
  54184. }
  54185. public function has($name)
  54186. {
  54187. return isset($this->helpers[$name]);
  54188. }
  54189. public function get($name)
  54190. {
  54191. if (!$this->has($name)) {
  54192. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  54193. }
  54194. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  54195. @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);
  54196. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  54197. @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);
  54198. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  54199. @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);
  54200. }
  54201. return $this->helpers[$name];
  54202. }
  54203. public function setCommand(Command $command = null)
  54204. {
  54205. $this->command = $command;
  54206. }
  54207. public function getCommand()
  54208. {
  54209. return $this->command;
  54210. }
  54211. public function getIterator()
  54212. {
  54213. return new \ArrayIterator($this->helpers);
  54214. }
  54215. }
  54216. <?php
  54217. namespace Symfony\Component\Console\Helper;
  54218. use Symfony\Component\Console\Input\InputAwareInterface;
  54219. use Symfony\Component\Console\Input\InputInterface;
  54220. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  54221. {
  54222. protected $input;
  54223. public function setInput(InputInterface $input)
  54224. {
  54225. $this->input = $input;
  54226. }
  54227. }
  54228. <?php
  54229. namespace Symfony\Component\Console\Helper;
  54230. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  54231. use Symfony\Component\Console\Output\OutputInterface;
  54232. use Symfony\Component\Process\Exception\ProcessFailedException;
  54233. use Symfony\Component\Process\Process;
  54234. use Symfony\Component\Process\ProcessBuilder;
  54235. class ProcessHelper extends Helper
  54236. {
  54237. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  54238. {
  54239. if ($output instanceof ConsoleOutputInterface) {
  54240. $output = $output->getErrorOutput();
  54241. }
  54242. $formatter = $this->getHelperSet()->get('debug_formatter');
  54243. if (\is_array($cmd)) {
  54244. $process = ProcessBuilder::create($cmd)->getProcess();
  54245. } elseif ($cmd instanceof Process) {
  54246. $process = $cmd;
  54247. } else {
  54248. $process = new Process($cmd);
  54249. }
  54250. if ($verbosity <= $output->getVerbosity()) {
  54251. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  54252. }
  54253. if ($output->isDebug()) {
  54254. $callback = $this->wrapCallback($output, $process, $callback);
  54255. }
  54256. $process->run($callback);
  54257. if ($verbosity <= $output->getVerbosity()) {
  54258. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  54259. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  54260. }
  54261. if (!$process->isSuccessful() && null !== $error) {
  54262. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  54263. }
  54264. return $process;
  54265. }
  54266. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  54267. {
  54268. $process = $this->run($output, $cmd, $error, $callback);
  54269. if (!$process->isSuccessful()) {
  54270. throw new ProcessFailedException($process);
  54271. }
  54272. return $process;
  54273. }
  54274. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  54275. {
  54276. if ($output instanceof ConsoleOutputInterface) {
  54277. $output = $output->getErrorOutput();
  54278. }
  54279. $formatter = $this->getHelperSet()->get('debug_formatter');
  54280. $that = $this;
  54281. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  54282. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  54283. if (null !== $callback) {
  54284. \call_user_func($callback, $type, $buffer);
  54285. }
  54286. };
  54287. }
  54288. public function escapeString($str)
  54289. {
  54290. return str_replace('<', '\\<', $str);
  54291. }
  54292. public function getName()
  54293. {
  54294. return 'process';
  54295. }
  54296. }
  54297. <?php
  54298. namespace Symfony\Component\Console\Helper;
  54299. use Symfony\Component\Console\Exception\LogicException;
  54300. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  54301. use Symfony\Component\Console\Output\OutputInterface;
  54302. class ProgressBar
  54303. {
  54304. private $barWidth = 28;
  54305. private $barChar;
  54306. private $emptyBarChar = '-';
  54307. private $progressChar = '>';
  54308. private $format;
  54309. private $internalFormat;
  54310. private $redrawFreq = 1;
  54311. private $output;
  54312. private $step = 0;
  54313. private $max;
  54314. private $startTime;
  54315. private $stepWidth;
  54316. private $percent = 0.0;
  54317. private $formatLineCount;
  54318. private $messages = array();
  54319. private $overwrite = true;
  54320. private $firstRun = true;
  54321. private static $formatters;
  54322. private static $formats;
  54323. public function __construct(OutputInterface $output, $max = 0)
  54324. {
  54325. if ($output instanceof ConsoleOutputInterface) {
  54326. $output = $output->getErrorOutput();
  54327. }
  54328. $this->output = $output;
  54329. $this->setMaxSteps($max);
  54330. if (!$this->output->isDecorated()) {
  54331. $this->overwrite = false;
  54332. $this->setRedrawFrequency($max / 10);
  54333. }
  54334. $this->startTime = time();
  54335. }
  54336. public static function setPlaceholderFormatterDefinition($name, $callable)
  54337. {
  54338. if (!self::$formatters) {
  54339. self::$formatters = self::initPlaceholderFormatters();
  54340. }
  54341. self::$formatters[$name] = $callable;
  54342. }
  54343. public static function getPlaceholderFormatterDefinition($name)
  54344. {
  54345. if (!self::$formatters) {
  54346. self::$formatters = self::initPlaceholderFormatters();
  54347. }
  54348. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  54349. }
  54350. public static function setFormatDefinition($name, $format)
  54351. {
  54352. if (!self::$formats) {
  54353. self::$formats = self::initFormats();
  54354. }
  54355. self::$formats[$name] = $format;
  54356. }
  54357. public static function getFormatDefinition($name)
  54358. {
  54359. if (!self::$formats) {
  54360. self::$formats = self::initFormats();
  54361. }
  54362. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  54363. }
  54364. public function setMessage($message, $name = 'message')
  54365. {
  54366. $this->messages[$name] = $message;
  54367. }
  54368. public function getMessage($name = 'message')
  54369. {
  54370. return $this->messages[$name];
  54371. }
  54372. public function getStartTime()
  54373. {
  54374. return $this->startTime;
  54375. }
  54376. public function getMaxSteps()
  54377. {
  54378. return $this->max;
  54379. }
  54380. public function getStep()
  54381. {
  54382. @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);
  54383. return $this->getProgress();
  54384. }
  54385. public function getProgress()
  54386. {
  54387. return $this->step;
  54388. }
  54389. public function getStepWidth()
  54390. {
  54391. return $this->stepWidth;
  54392. }
  54393. public function getProgressPercent()
  54394. {
  54395. return $this->percent;
  54396. }
  54397. public function setBarWidth($size)
  54398. {
  54399. $this->barWidth = (int) $size;
  54400. }
  54401. public function getBarWidth()
  54402. {
  54403. return $this->barWidth;
  54404. }
  54405. public function setBarCharacter($char)
  54406. {
  54407. $this->barChar = $char;
  54408. }
  54409. public function getBarCharacter()
  54410. {
  54411. if (null === $this->barChar) {
  54412. return $this->max ? '=' : $this->emptyBarChar;
  54413. }
  54414. return $this->barChar;
  54415. }
  54416. public function setEmptyBarCharacter($char)
  54417. {
  54418. $this->emptyBarChar = $char;
  54419. }
  54420. public function getEmptyBarCharacter()
  54421. {
  54422. return $this->emptyBarChar;
  54423. }
  54424. public function setProgressCharacter($char)
  54425. {
  54426. $this->progressChar = $char;
  54427. }
  54428. public function getProgressCharacter()
  54429. {
  54430. return $this->progressChar;
  54431. }
  54432. public function setFormat($format)
  54433. {
  54434. $this->format = null;
  54435. $this->internalFormat = $format;
  54436. }
  54437. public function setRedrawFrequency($freq)
  54438. {
  54439. $this->redrawFreq = max((int) $freq, 1);
  54440. }
  54441. public function start($max = null)
  54442. {
  54443. $this->startTime = time();
  54444. $this->step = 0;
  54445. $this->percent = 0.0;
  54446. if (null !== $max) {
  54447. $this->setMaxSteps($max);
  54448. }
  54449. $this->display();
  54450. }
  54451. public function advance($step = 1)
  54452. {
  54453. $this->setProgress($this->step + $step);
  54454. }
  54455. public function setCurrent($step)
  54456. {
  54457. @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);
  54458. $this->setProgress($step);
  54459. }
  54460. public function setOverwrite($overwrite)
  54461. {
  54462. $this->overwrite = (bool) $overwrite;
  54463. }
  54464. public function setProgress($step)
  54465. {
  54466. $step = (int) $step;
  54467. if ($step < $this->step) {
  54468. throw new LogicException('You can\'t regress the progress bar.');
  54469. }
  54470. if ($this->max && $step > $this->max) {
  54471. $this->max = $step;
  54472. }
  54473. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  54474. $currPeriod = (int) ($step / $this->redrawFreq);
  54475. $this->step = $step;
  54476. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  54477. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  54478. $this->display();
  54479. }
  54480. }
  54481. public function finish()
  54482. {
  54483. if (!$this->max) {
  54484. $this->max = $this->step;
  54485. }
  54486. if ($this->step === $this->max && !$this->overwrite) {
  54487. return;
  54488. }
  54489. $this->setProgress($this->max);
  54490. }
  54491. public function display()
  54492. {
  54493. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  54494. return;
  54495. }
  54496. if (null === $this->format) {
  54497. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  54498. }
  54499. $self = $this;
  54500. $output = $this->output;
  54501. $messages = $this->messages;
  54502. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  54503. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  54504. $text = \call_user_func($formatter, $self, $output);
  54505. } elseif (isset($messages[$matches[1]])) {
  54506. $text = $messages[$matches[1]];
  54507. } else {
  54508. return $matches[0];
  54509. }
  54510. if (isset($matches[2])) {
  54511. $text = sprintf('%'.$matches[2], $text);
  54512. }
  54513. return $text;
  54514. }, $this->format));
  54515. }
  54516. public function clear()
  54517. {
  54518. if (!$this->overwrite) {
  54519. return;
  54520. }
  54521. if (null === $this->format) {
  54522. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  54523. }
  54524. $this->overwrite('');
  54525. }
  54526. private function setRealFormat($format)
  54527. {
  54528. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  54529. $this->format = self::getFormatDefinition($format.'_nomax');
  54530. } elseif (null !== self::getFormatDefinition($format)) {
  54531. $this->format = self::getFormatDefinition($format);
  54532. } else {
  54533. $this->format = $format;
  54534. }
  54535. $this->formatLineCount = substr_count($this->format, "\n");
  54536. }
  54537. private function setMaxSteps($max)
  54538. {
  54539. $this->max = max(0, (int) $max);
  54540. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  54541. }
  54542. private function overwrite($message)
  54543. {
  54544. if ($this->overwrite) {
  54545. if (!$this->firstRun) {
  54546. $this->output->write("\x0D");
  54547. $this->output->write("\x1B[2K");
  54548. if ($this->formatLineCount > 0) {
  54549. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  54550. }
  54551. }
  54552. } elseif ($this->step > 0) {
  54553. $this->output->writeln('');
  54554. }
  54555. $this->firstRun = false;
  54556. $this->output->write($message);
  54557. }
  54558. private function determineBestFormat()
  54559. {
  54560. switch ($this->output->getVerbosity()) {
  54561. case OutputInterface::VERBOSITY_VERBOSE:
  54562. return $this->max ? 'verbose' : 'verbose_nomax';
  54563. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  54564. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  54565. case OutputInterface::VERBOSITY_DEBUG:
  54566. return $this->max ? 'debug' : 'debug_nomax';
  54567. default:
  54568. return $this->max ? 'normal' : 'normal_nomax';
  54569. }
  54570. }
  54571. private static function initPlaceholderFormatters()
  54572. {
  54573. return array(
  54574. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  54575. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  54576. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  54577. if ($completeBars < $bar->getBarWidth()) {
  54578. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  54579. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  54580. }
  54581. return $display;
  54582. },
  54583. 'elapsed' => function (ProgressBar $bar) {
  54584. return Helper::formatTime(time() - $bar->getStartTime());
  54585. },
  54586. 'remaining' => function (ProgressBar $bar) {
  54587. if (!$bar->getMaxSteps()) {
  54588. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  54589. }
  54590. if (!$bar->getProgress()) {
  54591. $remaining = 0;
  54592. } else {
  54593. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  54594. }
  54595. return Helper::formatTime($remaining);
  54596. },
  54597. 'estimated' => function (ProgressBar $bar) {
  54598. if (!$bar->getMaxSteps()) {
  54599. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  54600. }
  54601. if (!$bar->getProgress()) {
  54602. $estimated = 0;
  54603. } else {
  54604. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  54605. }
  54606. return Helper::formatTime($estimated);
  54607. },
  54608. 'memory' => function (ProgressBar $bar) {
  54609. return Helper::formatMemory(memory_get_usage(true));
  54610. },
  54611. 'current' => function (ProgressBar $bar) {
  54612. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  54613. },
  54614. 'max' => function (ProgressBar $bar) {
  54615. return $bar->getMaxSteps();
  54616. },
  54617. 'percent' => function (ProgressBar $bar) {
  54618. return floor($bar->getProgressPercent() * 100);
  54619. },
  54620. );
  54621. }
  54622. private static function initFormats()
  54623. {
  54624. return array(
  54625. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  54626. 'normal_nomax' => ' %current% [%bar%]',
  54627. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  54628. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  54629. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  54630. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  54631. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  54632. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  54633. );
  54634. }
  54635. }
  54636. <?php
  54637. namespace Symfony\Component\Console\Helper;
  54638. use Symfony\Component\Console\Exception\LogicException;
  54639. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  54640. use Symfony\Component\Console\Output\NullOutput;
  54641. use Symfony\Component\Console\Output\OutputInterface;
  54642. class ProgressHelper extends Helper
  54643. {
  54644. const FORMAT_QUIET = ' %percent%%';
  54645. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  54646. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  54647. const FORMAT_QUIET_NOMAX = ' %current%';
  54648. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  54649. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  54650. private $barWidth = 28;
  54651. private $barChar = '=';
  54652. private $emptyBarChar = '-';
  54653. private $progressChar = '>';
  54654. private $format = null;
  54655. private $redrawFreq = 1;
  54656. private $lastMessagesLength;
  54657. private $barCharOriginal;
  54658. private $output;
  54659. private $current;
  54660. private $max;
  54661. private $startTime;
  54662. private $defaultFormatVars = array(
  54663. 'current',
  54664. 'max',
  54665. 'bar',
  54666. 'percent',
  54667. 'elapsed',
  54668. );
  54669. private $formatVars;
  54670. private $widths = array(
  54671. 'current' => 4,
  54672. 'max' => 4,
  54673. 'percent' => 3,
  54674. 'elapsed' => 6,
  54675. );
  54676. private $timeFormats = array(
  54677. array(0, '???'),
  54678. array(2, '1 sec'),
  54679. array(59, 'secs', 1),
  54680. array(60, '1 min'),
  54681. array(3600, 'mins', 60),
  54682. array(5400, '1 hr'),
  54683. array(86400, 'hrs', 3600),
  54684. array(129600, '1 day'),
  54685. array(604800, 'days', 86400),
  54686. );
  54687. public function __construct($triggerDeprecationError = true)
  54688. {
  54689. if ($triggerDeprecationError) {
  54690. @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);
  54691. }
  54692. }
  54693. public function setBarWidth($size)
  54694. {
  54695. $this->barWidth = (int) $size;
  54696. }
  54697. public function setBarCharacter($char)
  54698. {
  54699. $this->barChar = $char;
  54700. }
  54701. public function setEmptyBarCharacter($char)
  54702. {
  54703. $this->emptyBarChar = $char;
  54704. }
  54705. public function setProgressCharacter($char)
  54706. {
  54707. $this->progressChar = $char;
  54708. }
  54709. public function setFormat($format)
  54710. {
  54711. $this->format = $format;
  54712. }
  54713. public function setRedrawFrequency($freq)
  54714. {
  54715. $this->redrawFreq = (int) $freq;
  54716. }
  54717. public function start(OutputInterface $output, $max = null)
  54718. {
  54719. if ($output instanceof ConsoleOutputInterface) {
  54720. $output = $output->getErrorOutput();
  54721. }
  54722. $this->startTime = time();
  54723. $this->current = 0;
  54724. $this->max = (int) $max;
  54725. $this->output = $output->isDecorated() ? $output : new NullOutput();
  54726. $this->lastMessagesLength = 0;
  54727. $this->barCharOriginal = '';
  54728. if (null === $this->format) {
  54729. switch ($output->getVerbosity()) {
  54730. case OutputInterface::VERBOSITY_QUIET:
  54731. $this->format = self::FORMAT_QUIET_NOMAX;
  54732. if ($this->max > 0) {
  54733. $this->format = self::FORMAT_QUIET;
  54734. }
  54735. break;
  54736. case OutputInterface::VERBOSITY_VERBOSE:
  54737. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  54738. case OutputInterface::VERBOSITY_DEBUG:
  54739. $this->format = self::FORMAT_VERBOSE_NOMAX;
  54740. if ($this->max > 0) {
  54741. $this->format = self::FORMAT_VERBOSE;
  54742. }
  54743. break;
  54744. default:
  54745. $this->format = self::FORMAT_NORMAL_NOMAX;
  54746. if ($this->max > 0) {
  54747. $this->format = self::FORMAT_NORMAL;
  54748. }
  54749. break;
  54750. }
  54751. }
  54752. $this->initialize();
  54753. }
  54754. public function advance($step = 1, $redraw = false)
  54755. {
  54756. $this->setCurrent($this->current + $step, $redraw);
  54757. }
  54758. public function setCurrent($current, $redraw = false)
  54759. {
  54760. if (null === $this->startTime) {
  54761. throw new LogicException('You must start the progress bar before calling setCurrent().');
  54762. }
  54763. $current = (int) $current;
  54764. if ($current < $this->current) {
  54765. throw new LogicException('You can\'t regress the progress bar');
  54766. }
  54767. if (0 === $this->current) {
  54768. $redraw = true;
  54769. }
  54770. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  54771. $this->current = $current;
  54772. $currPeriod = (int) ($this->current / $this->redrawFreq);
  54773. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  54774. $this->display();
  54775. }
  54776. }
  54777. public function display($finish = false)
  54778. {
  54779. if (null === $this->startTime) {
  54780. throw new LogicException('You must start the progress bar before calling display().');
  54781. }
  54782. $message = $this->format;
  54783. foreach ($this->generate($finish) as $name => $value) {
  54784. $message = str_replace("%{$name}%", $value, $message);
  54785. }
  54786. $this->overwrite($this->output, $message);
  54787. }
  54788. public function clear()
  54789. {
  54790. $this->overwrite($this->output, '');
  54791. }
  54792. public function finish()
  54793. {
  54794. if (null === $this->startTime) {
  54795. throw new LogicException('You must start the progress bar before calling finish().');
  54796. }
  54797. if (null !== $this->startTime) {
  54798. if (!$this->max) {
  54799. $this->barChar = $this->barCharOriginal;
  54800. $this->display(true);
  54801. }
  54802. $this->startTime = null;
  54803. $this->output->writeln('');
  54804. $this->output = null;
  54805. }
  54806. }
  54807. private function initialize()
  54808. {
  54809. $this->formatVars = array();
  54810. foreach ($this->defaultFormatVars as $var) {
  54811. if (false !== strpos($this->format, "%{$var}%")) {
  54812. $this->formatVars[$var] = true;
  54813. }
  54814. }
  54815. if ($this->max > 0) {
  54816. $this->widths['max'] = $this->strlen($this->max);
  54817. $this->widths['current'] = $this->widths['max'];
  54818. } else {
  54819. $this->barCharOriginal = $this->barChar;
  54820. $this->barChar = $this->emptyBarChar;
  54821. }
  54822. }
  54823. private function generate($finish = false)
  54824. {
  54825. $vars = array();
  54826. $percent = 0;
  54827. if ($this->max > 0) {
  54828. $percent = (float) $this->current / $this->max;
  54829. }
  54830. if (isset($this->formatVars['bar'])) {
  54831. if ($this->max > 0) {
  54832. $completeBars = floor($percent * $this->barWidth);
  54833. } else {
  54834. if (!$finish) {
  54835. $completeBars = floor($this->current % $this->barWidth);
  54836. } else {
  54837. $completeBars = $this->barWidth;
  54838. }
  54839. }
  54840. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  54841. $bar = str_repeat($this->barChar, $completeBars);
  54842. if ($completeBars < $this->barWidth) {
  54843. $bar .= $this->progressChar;
  54844. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  54845. }
  54846. $vars['bar'] = $bar;
  54847. }
  54848. if (isset($this->formatVars['elapsed'])) {
  54849. $elapsed = time() - $this->startTime;
  54850. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  54851. }
  54852. if (isset($this->formatVars['current'])) {
  54853. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  54854. }
  54855. if (isset($this->formatVars['max'])) {
  54856. $vars['max'] = $this->max;
  54857. }
  54858. if (isset($this->formatVars['percent'])) {
  54859. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  54860. }
  54861. return $vars;
  54862. }
  54863. private function humaneTime($secs)
  54864. {
  54865. $text = '';
  54866. foreach ($this->timeFormats as $format) {
  54867. if ($secs < $format[0]) {
  54868. if (2 == \count($format)) {
  54869. $text = $format[1];
  54870. break;
  54871. } else {
  54872. $text = ceil($secs / $format[2]).' '.$format[1];
  54873. break;
  54874. }
  54875. }
  54876. }
  54877. return $text;
  54878. }
  54879. private function overwrite(OutputInterface $output, $message)
  54880. {
  54881. $length = $this->strlen($message);
  54882. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  54883. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  54884. }
  54885. $output->write("\x0D");
  54886. $output->write($message);
  54887. $this->lastMessagesLength = $this->strlen($message);
  54888. }
  54889. public function getName()
  54890. {
  54891. return 'progress';
  54892. }
  54893. }
  54894. <?php
  54895. namespace Symfony\Component\Console\Helper;
  54896. use Symfony\Component\Console\Exception\InvalidArgumentException;
  54897. use Symfony\Component\Console\Exception\LogicException;
  54898. use Symfony\Component\Console\Output\OutputInterface;
  54899. class ProgressIndicator
  54900. {
  54901. private $output;
  54902. private $startTime;
  54903. private $format;
  54904. private $message;
  54905. private $indicatorValues;
  54906. private $indicatorCurrent;
  54907. private $indicatorChangeInterval;
  54908. private $indicatorUpdateTime;
  54909. private $started = false;
  54910. private static $formatters;
  54911. private static $formats;
  54912. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  54913. {
  54914. $this->output = $output;
  54915. if (null === $format) {
  54916. $format = $this->determineBestFormat();
  54917. }
  54918. if (null === $indicatorValues) {
  54919. $indicatorValues = array('-', '\\', '|', '/');
  54920. }
  54921. $indicatorValues = array_values($indicatorValues);
  54922. if (2 > \count($indicatorValues)) {
  54923. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  54924. }
  54925. $this->format = self::getFormatDefinition($format);
  54926. $this->indicatorChangeInterval = $indicatorChangeInterval;
  54927. $this->indicatorValues = $indicatorValues;
  54928. $this->startTime = time();
  54929. }
  54930. public function setMessage($message)
  54931. {
  54932. $this->message = $message;
  54933. $this->display();
  54934. }
  54935. public function getMessage()
  54936. {
  54937. return $this->message;
  54938. }
  54939. public function getStartTime()
  54940. {
  54941. return $this->startTime;
  54942. }
  54943. public function getCurrentValue()
  54944. {
  54945. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  54946. }
  54947. public function start($message)
  54948. {
  54949. if ($this->started) {
  54950. throw new LogicException('Progress indicator already started.');
  54951. }
  54952. $this->message = $message;
  54953. $this->started = true;
  54954. $this->startTime = time();
  54955. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  54956. $this->indicatorCurrent = 0;
  54957. $this->display();
  54958. }
  54959. public function advance()
  54960. {
  54961. if (!$this->started) {
  54962. throw new LogicException('Progress indicator has not yet been started.');
  54963. }
  54964. if (!$this->output->isDecorated()) {
  54965. return;
  54966. }
  54967. $currentTime = $this->getCurrentTimeInMilliseconds();
  54968. if ($currentTime < $this->indicatorUpdateTime) {
  54969. return;
  54970. }
  54971. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  54972. ++$this->indicatorCurrent;
  54973. $this->display();
  54974. }
  54975. public function finish($message)
  54976. {
  54977. if (!$this->started) {
  54978. throw new LogicException('Progress indicator has not yet been started.');
  54979. }
  54980. $this->message = $message;
  54981. $this->display();
  54982. $this->output->writeln('');
  54983. $this->started = false;
  54984. }
  54985. public static function getFormatDefinition($name)
  54986. {
  54987. if (!self::$formats) {
  54988. self::$formats = self::initFormats();
  54989. }
  54990. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  54991. }
  54992. public static function setPlaceholderFormatterDefinition($name, $callable)
  54993. {
  54994. if (!self::$formatters) {
  54995. self::$formatters = self::initPlaceholderFormatters();
  54996. }
  54997. self::$formatters[$name] = $callable;
  54998. }
  54999. public static function getPlaceholderFormatterDefinition($name)
  55000. {
  55001. if (!self::$formatters) {
  55002. self::$formatters = self::initPlaceholderFormatters();
  55003. }
  55004. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  55005. }
  55006. private function display()
  55007. {
  55008. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  55009. return;
  55010. }
  55011. $self = $this;
  55012. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  55013. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  55014. return \call_user_func($formatter, $self);
  55015. }
  55016. return $matches[0];
  55017. }, $this->format));
  55018. }
  55019. private function determineBestFormat()
  55020. {
  55021. switch ($this->output->getVerbosity()) {
  55022. case OutputInterface::VERBOSITY_VERBOSE:
  55023. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  55024. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  55025. case OutputInterface::VERBOSITY_DEBUG:
  55026. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  55027. default:
  55028. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  55029. }
  55030. }
  55031. private function overwrite($message)
  55032. {
  55033. if ($this->output->isDecorated()) {
  55034. $this->output->write("\x0D\x1B[2K");
  55035. $this->output->write($message);
  55036. } else {
  55037. $this->output->writeln($message);
  55038. }
  55039. }
  55040. private function getCurrentTimeInMilliseconds()
  55041. {
  55042. return round(microtime(true) * 1000);
  55043. }
  55044. private static function initPlaceholderFormatters()
  55045. {
  55046. return array(
  55047. 'indicator' => function (ProgressIndicator $indicator) {
  55048. return $indicator->getCurrentValue();
  55049. },
  55050. 'message' => function (ProgressIndicator $indicator) {
  55051. return $indicator->getMessage();
  55052. },
  55053. 'elapsed' => function (ProgressIndicator $indicator) {
  55054. return Helper::formatTime(time() - $indicator->getStartTime());
  55055. },
  55056. 'memory' => function () {
  55057. return Helper::formatMemory(memory_get_usage(true));
  55058. },
  55059. );
  55060. }
  55061. private static function initFormats()
  55062. {
  55063. return array(
  55064. 'normal' => ' %indicator% %message%',
  55065. 'normal_no_ansi' => ' %message%',
  55066. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  55067. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  55068. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  55069. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  55070. );
  55071. }
  55072. }
  55073. <?php
  55074. namespace Symfony\Component\Console\Helper;
  55075. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55076. use Symfony\Component\Console\Exception\RuntimeException;
  55077. use Symfony\Component\Console\Formatter\OutputFormatter;
  55078. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  55079. use Symfony\Component\Console\Input\InputInterface;
  55080. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  55081. use Symfony\Component\Console\Output\OutputInterface;
  55082. use Symfony\Component\Console\Question\ChoiceQuestion;
  55083. use Symfony\Component\Console\Question\Question;
  55084. class QuestionHelper extends Helper
  55085. {
  55086. private $inputStream;
  55087. private static $shell;
  55088. private static $stty;
  55089. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  55090. {
  55091. if ($output instanceof ConsoleOutputInterface) {
  55092. $output = $output->getErrorOutput();
  55093. }
  55094. if (!$input->isInteractive()) {
  55095. $default = $question->getDefault();
  55096. if (null !== $default && $question instanceof ChoiceQuestion) {
  55097. $choices = $question->getChoices();
  55098. if (!$question->isMultiselect()) {
  55099. return isset($choices[$default]) ? $choices[$default] : $default;
  55100. }
  55101. $default = explode(',', $default);
  55102. foreach ($default as $k => $v) {
  55103. $v = trim($v);
  55104. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  55105. }
  55106. }
  55107. return $default;
  55108. }
  55109. if (!$question->getValidator()) {
  55110. return $this->doAsk($output, $question);
  55111. }
  55112. $that = $this;
  55113. $interviewer = function () use ($output, $question, $that) {
  55114. return $that->doAsk($output, $question);
  55115. };
  55116. return $this->validateAttempts($interviewer, $output, $question);
  55117. }
  55118. public function setInputStream($stream)
  55119. {
  55120. if (!\is_resource($stream)) {
  55121. throw new InvalidArgumentException('Input stream must be a valid resource.');
  55122. }
  55123. $this->inputStream = $stream;
  55124. }
  55125. public function getInputStream()
  55126. {
  55127. return $this->inputStream;
  55128. }
  55129. public function getName()
  55130. {
  55131. return 'question';
  55132. }
  55133. public function doAsk(OutputInterface $output, Question $question)
  55134. {
  55135. $this->writePrompt($output, $question);
  55136. $inputStream = $this->inputStream ?: STDIN;
  55137. $autocomplete = $question->getAutocompleterValues();
  55138. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  55139. $ret = false;
  55140. if ($question->isHidden()) {
  55141. try {
  55142. $ret = trim($this->getHiddenResponse($output, $inputStream));
  55143. } catch (RuntimeException $e) {
  55144. if (!$question->isHiddenFallback()) {
  55145. throw $e;
  55146. }
  55147. }
  55148. }
  55149. if (false === $ret) {
  55150. $ret = fgets($inputStream, 4096);
  55151. if (false === $ret) {
  55152. throw new RuntimeException('Aborted');
  55153. }
  55154. $ret = trim($ret);
  55155. }
  55156. } else {
  55157. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  55158. }
  55159. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  55160. if ($normalizer = $question->getNormalizer()) {
  55161. return $normalizer($ret);
  55162. }
  55163. return $ret;
  55164. }
  55165. protected function writePrompt(OutputInterface $output, Question $question)
  55166. {
  55167. $message = $question->getQuestion();
  55168. if ($question instanceof ChoiceQuestion) {
  55169. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  55170. $messages = (array) $question->getQuestion();
  55171. foreach ($question->getChoices() as $key => $value) {
  55172. $width = $maxWidth - $this->strlen($key);
  55173. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  55174. }
  55175. $output->writeln($messages);
  55176. $message = $question->getPrompt();
  55177. }
  55178. $output->write($message);
  55179. }
  55180. protected function writeError(OutputInterface $output, \Exception $error)
  55181. {
  55182. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  55183. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  55184. } else {
  55185. $message = '<error>'.$error->getMessage().'</error>';
  55186. }
  55187. $output->writeln($message);
  55188. }
  55189. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  55190. {
  55191. $ret = '';
  55192. $i = 0;
  55193. $ofs = -1;
  55194. $matches = $autocomplete;
  55195. $numMatches = \count($matches);
  55196. $sttyMode = shell_exec('stty -g');
  55197. shell_exec('stty -icanon -echo');
  55198. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  55199. while (!feof($inputStream)) {
  55200. $c = fread($inputStream, 1);
  55201. if ("\177" === $c) {
  55202. if (0 === $numMatches && 0 !== $i) {
  55203. --$i;
  55204. $output->write("\033[1D");
  55205. }
  55206. if (0 === $i) {
  55207. $ofs = -1;
  55208. $matches = $autocomplete;
  55209. $numMatches = \count($matches);
  55210. } else {
  55211. $numMatches = 0;
  55212. }
  55213. $ret = substr($ret, 0, $i);
  55214. } elseif ("\033" === $c) {
  55215. $c .= fread($inputStream, 2);
  55216. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  55217. if ('A' === $c[2] && -1 === $ofs) {
  55218. $ofs = 0;
  55219. }
  55220. if (0 === $numMatches) {
  55221. continue;
  55222. }
  55223. $ofs += ('A' === $c[2]) ? -1 : 1;
  55224. $ofs = ($numMatches + $ofs) % $numMatches;
  55225. }
  55226. } elseif (\ord($c) < 32) {
  55227. if ("\t" === $c || "\n" === $c) {
  55228. if ($numMatches > 0 && -1 !== $ofs) {
  55229. $ret = $matches[$ofs];
  55230. $output->write(substr($ret, $i));
  55231. $i = \strlen($ret);
  55232. }
  55233. if ("\n" === $c) {
  55234. $output->write($c);
  55235. break;
  55236. }
  55237. $numMatches = 0;
  55238. }
  55239. continue;
  55240. } else {
  55241. $output->write($c);
  55242. $ret .= $c;
  55243. ++$i;
  55244. $numMatches = 0;
  55245. $ofs = 0;
  55246. foreach ($autocomplete as $value) {
  55247. if (0 === strpos($value, $ret)) {
  55248. $matches[$numMatches++] = $value;
  55249. }
  55250. }
  55251. }
  55252. $output->write("\033[K");
  55253. if ($numMatches > 0 && -1 !== $ofs) {
  55254. $output->write("\0337");
  55255. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  55256. $output->write("\0338");
  55257. }
  55258. }
  55259. shell_exec(sprintf('stty %s', $sttyMode));
  55260. return $ret;
  55261. }
  55262. private function getHiddenResponse(OutputInterface $output, $inputStream)
  55263. {
  55264. if ('\\' === \DIRECTORY_SEPARATOR) {
  55265. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  55266. if ('phar:' === substr(__FILE__, 0, 5)) {
  55267. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  55268. copy($exe, $tmpExe);
  55269. $exe = $tmpExe;
  55270. }
  55271. $value = rtrim(shell_exec($exe));
  55272. $output->writeln('');
  55273. if (isset($tmpExe)) {
  55274. unlink($tmpExe);
  55275. }
  55276. return $value;
  55277. }
  55278. if ($this->hasSttyAvailable()) {
  55279. $sttyMode = shell_exec('stty -g');
  55280. shell_exec('stty -echo');
  55281. $value = fgets($inputStream, 4096);
  55282. shell_exec(sprintf('stty %s', $sttyMode));
  55283. if (false === $value) {
  55284. throw new RuntimeException('Aborted');
  55285. }
  55286. $value = trim($value);
  55287. $output->writeln('');
  55288. return $value;
  55289. }
  55290. if (false !== $shell = $this->getShell()) {
  55291. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  55292. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  55293. $value = rtrim(shell_exec($command));
  55294. $output->writeln('');
  55295. return $value;
  55296. }
  55297. throw new RuntimeException('Unable to hide the response.');
  55298. }
  55299. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  55300. {
  55301. $error = null;
  55302. $attempts = $question->getMaxAttempts();
  55303. while (null === $attempts || $attempts--) {
  55304. if (null !== $error) {
  55305. $this->writeError($output, $error);
  55306. }
  55307. try {
  55308. return \call_user_func($question->getValidator(), $interviewer());
  55309. } catch (RuntimeException $e) {
  55310. throw $e;
  55311. } catch (\Exception $error) {
  55312. }
  55313. }
  55314. throw $error;
  55315. }
  55316. private function getShell()
  55317. {
  55318. if (null !== self::$shell) {
  55319. return self::$shell;
  55320. }
  55321. self::$shell = false;
  55322. if (file_exists('/usr/bin/env')) {
  55323. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  55324. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  55325. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  55326. self::$shell = $sh;
  55327. break;
  55328. }
  55329. }
  55330. }
  55331. return self::$shell;
  55332. }
  55333. private function hasSttyAvailable()
  55334. {
  55335. if (null !== self::$stty) {
  55336. return self::$stty;
  55337. }
  55338. exec('stty 2>&1', $output, $exitcode);
  55339. return self::$stty = 0 === $exitcode;
  55340. }
  55341. }
  55342. <?php
  55343. namespace Symfony\Component\Console\Helper;
  55344. use Symfony\Component\Console\Exception\LogicException;
  55345. use Symfony\Component\Console\Formatter\OutputFormatter;
  55346. use Symfony\Component\Console\Input\InputInterface;
  55347. use Symfony\Component\Console\Output\OutputInterface;
  55348. use Symfony\Component\Console\Question\ChoiceQuestion;
  55349. use Symfony\Component\Console\Question\ConfirmationQuestion;
  55350. use Symfony\Component\Console\Question\Question;
  55351. use Symfony\Component\Console\Style\SymfonyStyle;
  55352. class SymfonyQuestionHelper extends QuestionHelper
  55353. {
  55354. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  55355. {
  55356. $validator = $question->getValidator();
  55357. $question->setValidator(function ($value) use ($validator) {
  55358. if (null !== $validator) {
  55359. $value = $validator($value);
  55360. } else {
  55361. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  55362. throw new LogicException('A value is required.');
  55363. }
  55364. }
  55365. return $value;
  55366. });
  55367. return parent::ask($input, $output, $question);
  55368. }
  55369. protected function writePrompt(OutputInterface $output, Question $question)
  55370. {
  55371. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  55372. $default = $question->getDefault();
  55373. switch (true) {
  55374. case null === $default:
  55375. $text = sprintf(' <info>%s</info>:', $text);
  55376. break;
  55377. case $question instanceof ConfirmationQuestion:
  55378. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  55379. break;
  55380. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  55381. $choices = $question->getChoices();
  55382. $default = explode(',', $default);
  55383. foreach ($default as $key => $value) {
  55384. $default[$key] = $choices[trim($value)];
  55385. }
  55386. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  55387. break;
  55388. case $question instanceof ChoiceQuestion:
  55389. $choices = $question->getChoices();
  55390. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  55391. break;
  55392. default:
  55393. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  55394. }
  55395. $output->writeln($text);
  55396. if ($question instanceof ChoiceQuestion) {
  55397. $width = max(array_map('strlen', array_keys($question->getChoices())));
  55398. foreach ($question->getChoices() as $key => $value) {
  55399. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  55400. }
  55401. }
  55402. $output->write(' > ');
  55403. }
  55404. protected function writeError(OutputInterface $output, \Exception $error)
  55405. {
  55406. if ($output instanceof SymfonyStyle) {
  55407. $output->newLine();
  55408. $output->error($error->getMessage());
  55409. return;
  55410. }
  55411. parent::writeError($output, $error);
  55412. }
  55413. }
  55414. <?php
  55415. namespace Symfony\Component\Console\Helper;
  55416. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55417. use Symfony\Component\Console\Output\OutputInterface;
  55418. class Table
  55419. {
  55420. private $headers = array();
  55421. private $rows = array();
  55422. private $columnWidths = array();
  55423. private $numberOfColumns;
  55424. private $output;
  55425. private $style;
  55426. private $columnStyles = array();
  55427. private static $styles;
  55428. public function __construct(OutputInterface $output)
  55429. {
  55430. $this->output = $output;
  55431. if (!self::$styles) {
  55432. self::$styles = self::initStyles();
  55433. }
  55434. $this->setStyle('default');
  55435. }
  55436. public static function setStyleDefinition($name, TableStyle $style)
  55437. {
  55438. if (!self::$styles) {
  55439. self::$styles = self::initStyles();
  55440. }
  55441. self::$styles[$name] = $style;
  55442. }
  55443. public static function getStyleDefinition($name)
  55444. {
  55445. if (!self::$styles) {
  55446. self::$styles = self::initStyles();
  55447. }
  55448. if (isset(self::$styles[$name])) {
  55449. return self::$styles[$name];
  55450. }
  55451. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  55452. }
  55453. public function setStyle($name)
  55454. {
  55455. $this->style = $this->resolveStyle($name);
  55456. return $this;
  55457. }
  55458. public function getStyle()
  55459. {
  55460. return $this->style;
  55461. }
  55462. public function setColumnStyle($columnIndex, $name)
  55463. {
  55464. $columnIndex = (int) $columnIndex;
  55465. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  55466. return $this;
  55467. }
  55468. public function getColumnStyle($columnIndex)
  55469. {
  55470. if (isset($this->columnStyles[$columnIndex])) {
  55471. return $this->columnStyles[$columnIndex];
  55472. }
  55473. return $this->getStyle();
  55474. }
  55475. public function setHeaders(array $headers)
  55476. {
  55477. $headers = array_values($headers);
  55478. if (!empty($headers) && !\is_array($headers[0])) {
  55479. $headers = array($headers);
  55480. }
  55481. $this->headers = $headers;
  55482. return $this;
  55483. }
  55484. public function setRows(array $rows)
  55485. {
  55486. $this->rows = array();
  55487. return $this->addRows($rows);
  55488. }
  55489. public function addRows(array $rows)
  55490. {
  55491. foreach ($rows as $row) {
  55492. $this->addRow($row);
  55493. }
  55494. return $this;
  55495. }
  55496. public function addRow($row)
  55497. {
  55498. if ($row instanceof TableSeparator) {
  55499. $this->rows[] = $row;
  55500. return $this;
  55501. }
  55502. if (!\is_array($row)) {
  55503. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  55504. }
  55505. $this->rows[] = array_values($row);
  55506. return $this;
  55507. }
  55508. public function setRow($column, array $row)
  55509. {
  55510. $this->rows[$column] = $row;
  55511. return $this;
  55512. }
  55513. public function render()
  55514. {
  55515. $this->calculateNumberOfColumns();
  55516. $rows = $this->buildTableRows($this->rows);
  55517. $headers = $this->buildTableRows($this->headers);
  55518. $this->calculateColumnsWidth(array_merge($headers, $rows));
  55519. $this->renderRowSeparator();
  55520. if (!empty($headers)) {
  55521. foreach ($headers as $header) {
  55522. $this->renderRow($header, $this->style->getCellHeaderFormat());
  55523. $this->renderRowSeparator();
  55524. }
  55525. }
  55526. foreach ($rows as $row) {
  55527. if ($row instanceof TableSeparator) {
  55528. $this->renderRowSeparator();
  55529. } else {
  55530. $this->renderRow($row, $this->style->getCellRowFormat());
  55531. }
  55532. }
  55533. if (!empty($rows)) {
  55534. $this->renderRowSeparator();
  55535. }
  55536. $this->cleanup();
  55537. }
  55538. private function renderRowSeparator()
  55539. {
  55540. if (0 === $count = $this->numberOfColumns) {
  55541. return;
  55542. }
  55543. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  55544. return;
  55545. }
  55546. $markup = $this->style->getCrossingChar();
  55547. for ($column = 0; $column < $count; ++$column) {
  55548. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  55549. }
  55550. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  55551. }
  55552. private function renderColumnSeparator()
  55553. {
  55554. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  55555. }
  55556. private function renderRow(array $row, $cellFormat)
  55557. {
  55558. if (empty($row)) {
  55559. return;
  55560. }
  55561. $rowContent = $this->renderColumnSeparator();
  55562. foreach ($this->getRowColumns($row) as $column) {
  55563. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  55564. $rowContent .= $this->renderColumnSeparator();
  55565. }
  55566. $this->output->writeln($rowContent);
  55567. }
  55568. private function renderCell(array $row, $column, $cellFormat)
  55569. {
  55570. $cell = isset($row[$column]) ? $row[$column] : '';
  55571. $width = $this->columnWidths[$column];
  55572. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  55573. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  55574. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  55575. }
  55576. }
  55577. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  55578. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  55579. }
  55580. $style = $this->getColumnStyle($column);
  55581. if ($cell instanceof TableSeparator) {
  55582. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  55583. }
  55584. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  55585. $content = sprintf($style->getCellRowContentFormat(), $cell);
  55586. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  55587. }
  55588. private function calculateNumberOfColumns()
  55589. {
  55590. if (null !== $this->numberOfColumns) {
  55591. return;
  55592. }
  55593. $columns = array(0);
  55594. foreach (array_merge($this->headers, $this->rows) as $row) {
  55595. if ($row instanceof TableSeparator) {
  55596. continue;
  55597. }
  55598. $columns[] = $this->getNumberOfColumns($row);
  55599. }
  55600. $this->numberOfColumns = max($columns);
  55601. }
  55602. private function buildTableRows($rows)
  55603. {
  55604. $unmergedRows = array();
  55605. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  55606. $rows = $this->fillNextRows($rows, $rowKey);
  55607. foreach ($rows[$rowKey] as $column => $cell) {
  55608. if (!strstr($cell, "\n")) {
  55609. continue;
  55610. }
  55611. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  55612. foreach ($lines as $lineKey => $line) {
  55613. if ($cell instanceof TableCell) {
  55614. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  55615. }
  55616. if (0 === $lineKey) {
  55617. $rows[$rowKey][$column] = $line;
  55618. } else {
  55619. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  55620. }
  55621. }
  55622. }
  55623. }
  55624. $tableRows = array();
  55625. foreach ($rows as $rowKey => $row) {
  55626. $tableRows[] = $this->fillCells($row);
  55627. if (isset($unmergedRows[$rowKey])) {
  55628. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  55629. }
  55630. }
  55631. return $tableRows;
  55632. }
  55633. private function fillNextRows(array $rows, $line)
  55634. {
  55635. $unmergedRows = array();
  55636. foreach ($rows[$line] as $column => $cell) {
  55637. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  55638. $nbLines = $cell->getRowspan() - 1;
  55639. $lines = array($cell);
  55640. if (strstr($cell, "\n")) {
  55641. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  55642. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  55643. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  55644. unset($lines[0]);
  55645. }
  55646. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  55647. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  55648. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  55649. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  55650. if ($nbLines === $unmergedRowKey - $line) {
  55651. break;
  55652. }
  55653. }
  55654. }
  55655. }
  55656. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  55657. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  55658. foreach ($unmergedRow as $cellKey => $cell) {
  55659. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  55660. }
  55661. } else {
  55662. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  55663. foreach ($unmergedRow as $column => $cell) {
  55664. if (!empty($cell)) {
  55665. $row[$column] = $unmergedRow[$column];
  55666. }
  55667. }
  55668. array_splice($rows, $unmergedRowKey, 0, array($row));
  55669. }
  55670. }
  55671. return $rows;
  55672. }
  55673. private function fillCells($row)
  55674. {
  55675. $newRow = array();
  55676. foreach ($row as $column => $cell) {
  55677. $newRow[] = $cell;
  55678. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  55679. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  55680. $newRow[] = '';
  55681. }
  55682. }
  55683. }
  55684. return $newRow ?: $row;
  55685. }
  55686. private function copyRow(array $rows, $line)
  55687. {
  55688. $row = $rows[$line];
  55689. foreach ($row as $cellKey => $cellValue) {
  55690. $row[$cellKey] = '';
  55691. if ($cellValue instanceof TableCell) {
  55692. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  55693. }
  55694. }
  55695. return $row;
  55696. }
  55697. private function getNumberOfColumns(array $row)
  55698. {
  55699. $columns = \count($row);
  55700. foreach ($row as $column) {
  55701. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  55702. }
  55703. return $columns;
  55704. }
  55705. private function getRowColumns(array $row)
  55706. {
  55707. $columns = range(0, $this->numberOfColumns - 1);
  55708. foreach ($row as $cellKey => $cell) {
  55709. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  55710. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  55711. }
  55712. }
  55713. return $columns;
  55714. }
  55715. private function calculateColumnsWidth($rows)
  55716. {
  55717. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  55718. $lengths = array();
  55719. foreach ($rows as $row) {
  55720. if ($row instanceof TableSeparator) {
  55721. continue;
  55722. }
  55723. foreach ($row as $i => $cell) {
  55724. if ($cell instanceof TableCell) {
  55725. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  55726. $textLength = Helper::strlen($textContent);
  55727. if ($textLength > 0) {
  55728. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  55729. foreach ($contentColumns as $position => $content) {
  55730. $row[$i + $position] = $content;
  55731. }
  55732. }
  55733. }
  55734. }
  55735. $lengths[] = $this->getCellWidth($row, $column);
  55736. }
  55737. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  55738. }
  55739. }
  55740. private function getColumnSeparatorWidth()
  55741. {
  55742. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  55743. }
  55744. private function getCellWidth(array $row, $column)
  55745. {
  55746. if (isset($row[$column])) {
  55747. $cell = $row[$column];
  55748. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  55749. return $cellWidth;
  55750. }
  55751. return 0;
  55752. }
  55753. private function cleanup()
  55754. {
  55755. $this->columnWidths = array();
  55756. $this->numberOfColumns = null;
  55757. }
  55758. private static function initStyles()
  55759. {
  55760. $borderless = new TableStyle();
  55761. $borderless
  55762. ->setHorizontalBorderChar('=')
  55763. ->setVerticalBorderChar(' ')
  55764. ->setCrossingChar(' ')
  55765. ;
  55766. $compact = new TableStyle();
  55767. $compact
  55768. ->setHorizontalBorderChar('')
  55769. ->setVerticalBorderChar(' ')
  55770. ->setCrossingChar('')
  55771. ->setCellRowContentFormat('%s')
  55772. ;
  55773. $styleGuide = new TableStyle();
  55774. $styleGuide
  55775. ->setHorizontalBorderChar('-')
  55776. ->setVerticalBorderChar(' ')
  55777. ->setCrossingChar(' ')
  55778. ->setCellHeaderFormat('%s')
  55779. ;
  55780. return array(
  55781. 'default' => new TableStyle(),
  55782. 'borderless' => $borderless,
  55783. 'compact' => $compact,
  55784. 'symfony-style-guide' => $styleGuide,
  55785. );
  55786. }
  55787. private function resolveStyle($name)
  55788. {
  55789. if ($name instanceof TableStyle) {
  55790. return $name;
  55791. }
  55792. if (isset(self::$styles[$name])) {
  55793. return self::$styles[$name];
  55794. }
  55795. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  55796. }
  55797. }
  55798. <?php
  55799. namespace Symfony\Component\Console\Helper;
  55800. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55801. class TableCell
  55802. {
  55803. private $value;
  55804. private $options = array(
  55805. 'rowspan' => 1,
  55806. 'colspan' => 1,
  55807. );
  55808. public function __construct($value = '', array $options = array())
  55809. {
  55810. if (is_numeric($value) && !\is_string($value)) {
  55811. $value = (string) $value;
  55812. }
  55813. $this->value = $value;
  55814. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  55815. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  55816. }
  55817. $this->options = array_merge($this->options, $options);
  55818. }
  55819. public function __toString()
  55820. {
  55821. return $this->value;
  55822. }
  55823. public function getColspan()
  55824. {
  55825. return (int) $this->options['colspan'];
  55826. }
  55827. public function getRowspan()
  55828. {
  55829. return (int) $this->options['rowspan'];
  55830. }
  55831. }
  55832. <?php
  55833. namespace Symfony\Component\Console\Helper;
  55834. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55835. use Symfony\Component\Console\Output\NullOutput;
  55836. use Symfony\Component\Console\Output\OutputInterface;
  55837. class TableHelper extends Helper
  55838. {
  55839. const LAYOUT_DEFAULT = 0;
  55840. const LAYOUT_BORDERLESS = 1;
  55841. const LAYOUT_COMPACT = 2;
  55842. private $table;
  55843. public function __construct($triggerDeprecationError = true)
  55844. {
  55845. if ($triggerDeprecationError) {
  55846. @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);
  55847. }
  55848. $this->table = new Table(new NullOutput());
  55849. }
  55850. public function setLayout($layout)
  55851. {
  55852. switch ($layout) {
  55853. case self::LAYOUT_BORDERLESS:
  55854. $this->table->setStyle('borderless');
  55855. break;
  55856. case self::LAYOUT_COMPACT:
  55857. $this->table->setStyle('compact');
  55858. break;
  55859. case self::LAYOUT_DEFAULT:
  55860. $this->table->setStyle('default');
  55861. break;
  55862. default:
  55863. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  55864. }
  55865. return $this;
  55866. }
  55867. public function setHeaders(array $headers)
  55868. {
  55869. $this->table->setHeaders($headers);
  55870. return $this;
  55871. }
  55872. public function setRows(array $rows)
  55873. {
  55874. $this->table->setRows($rows);
  55875. return $this;
  55876. }
  55877. public function addRows(array $rows)
  55878. {
  55879. $this->table->addRows($rows);
  55880. return $this;
  55881. }
  55882. public function addRow(array $row)
  55883. {
  55884. $this->table->addRow($row);
  55885. return $this;
  55886. }
  55887. public function setRow($column, array $row)
  55888. {
  55889. $this->table->setRow($column, $row);
  55890. return $this;
  55891. }
  55892. public function setPaddingChar($paddingChar)
  55893. {
  55894. $this->table->getStyle()->setPaddingChar($paddingChar);
  55895. return $this;
  55896. }
  55897. public function setHorizontalBorderChar($horizontalBorderChar)
  55898. {
  55899. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  55900. return $this;
  55901. }
  55902. public function setVerticalBorderChar($verticalBorderChar)
  55903. {
  55904. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  55905. return $this;
  55906. }
  55907. public function setCrossingChar($crossingChar)
  55908. {
  55909. $this->table->getStyle()->setCrossingChar($crossingChar);
  55910. return $this;
  55911. }
  55912. public function setCellHeaderFormat($cellHeaderFormat)
  55913. {
  55914. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  55915. return $this;
  55916. }
  55917. public function setCellRowFormat($cellRowFormat)
  55918. {
  55919. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  55920. return $this;
  55921. }
  55922. public function setCellRowContentFormat($cellRowContentFormat)
  55923. {
  55924. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  55925. return $this;
  55926. }
  55927. public function setBorderFormat($borderFormat)
  55928. {
  55929. $this->table->getStyle()->setBorderFormat($borderFormat);
  55930. return $this;
  55931. }
  55932. public function setPadType($padType)
  55933. {
  55934. $this->table->getStyle()->setPadType($padType);
  55935. return $this;
  55936. }
  55937. public function render(OutputInterface $output)
  55938. {
  55939. $p = new \ReflectionProperty($this->table, 'output');
  55940. $p->setAccessible(true);
  55941. $p->setValue($this->table, $output);
  55942. $this->table->render();
  55943. }
  55944. public function getName()
  55945. {
  55946. return 'table';
  55947. }
  55948. }
  55949. <?php
  55950. namespace Symfony\Component\Console\Helper;
  55951. class TableSeparator extends TableCell
  55952. {
  55953. public function __construct(array $options = array())
  55954. {
  55955. parent::__construct('', $options);
  55956. }
  55957. }
  55958. <?php
  55959. namespace Symfony\Component\Console\Helper;
  55960. use Symfony\Component\Console\Exception\InvalidArgumentException;
  55961. use Symfony\Component\Console\Exception\LogicException;
  55962. class TableStyle
  55963. {
  55964. private $paddingChar = ' ';
  55965. private $horizontalBorderChar = '-';
  55966. private $verticalBorderChar = '|';
  55967. private $crossingChar = '+';
  55968. private $cellHeaderFormat = '<info>%s</info>';
  55969. private $cellRowFormat = '%s';
  55970. private $cellRowContentFormat = ' %s ';
  55971. private $borderFormat = '%s';
  55972. private $padType = STR_PAD_RIGHT;
  55973. public function setPaddingChar($paddingChar)
  55974. {
  55975. if (!$paddingChar) {
  55976. throw new LogicException('The padding char must not be empty');
  55977. }
  55978. $this->paddingChar = $paddingChar;
  55979. return $this;
  55980. }
  55981. public function getPaddingChar()
  55982. {
  55983. return $this->paddingChar;
  55984. }
  55985. public function setHorizontalBorderChar($horizontalBorderChar)
  55986. {
  55987. $this->horizontalBorderChar = $horizontalBorderChar;
  55988. return $this;
  55989. }
  55990. public function getHorizontalBorderChar()
  55991. {
  55992. return $this->horizontalBorderChar;
  55993. }
  55994. public function setVerticalBorderChar($verticalBorderChar)
  55995. {
  55996. $this->verticalBorderChar = $verticalBorderChar;
  55997. return $this;
  55998. }
  55999. public function getVerticalBorderChar()
  56000. {
  56001. return $this->verticalBorderChar;
  56002. }
  56003. public function setCrossingChar($crossingChar)
  56004. {
  56005. $this->crossingChar = $crossingChar;
  56006. return $this;
  56007. }
  56008. public function getCrossingChar()
  56009. {
  56010. return $this->crossingChar;
  56011. }
  56012. public function setCellHeaderFormat($cellHeaderFormat)
  56013. {
  56014. $this->cellHeaderFormat = $cellHeaderFormat;
  56015. return $this;
  56016. }
  56017. public function getCellHeaderFormat()
  56018. {
  56019. return $this->cellHeaderFormat;
  56020. }
  56021. public function setCellRowFormat($cellRowFormat)
  56022. {
  56023. $this->cellRowFormat = $cellRowFormat;
  56024. return $this;
  56025. }
  56026. public function getCellRowFormat()
  56027. {
  56028. return $this->cellRowFormat;
  56029. }
  56030. public function setCellRowContentFormat($cellRowContentFormat)
  56031. {
  56032. $this->cellRowContentFormat = $cellRowContentFormat;
  56033. return $this;
  56034. }
  56035. public function getCellRowContentFormat()
  56036. {
  56037. return $this->cellRowContentFormat;
  56038. }
  56039. public function setBorderFormat($borderFormat)
  56040. {
  56041. $this->borderFormat = $borderFormat;
  56042. return $this;
  56043. }
  56044. public function getBorderFormat()
  56045. {
  56046. return $this->borderFormat;
  56047. }
  56048. public function setPadType($padType)
  56049. {
  56050. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  56051. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  56052. }
  56053. $this->padType = $padType;
  56054. return $this;
  56055. }
  56056. public function getPadType()
  56057. {
  56058. return $this->padType;
  56059. }
  56060. }
  56061. <?php
  56062. namespace Symfony\Component\Console\Input;
  56063. use Symfony\Component\Console\Exception\RuntimeException;
  56064. class ArgvInput extends Input
  56065. {
  56066. private $tokens;
  56067. private $parsed;
  56068. public function __construct(array $argv = null, InputDefinition $definition = null)
  56069. {
  56070. if (null === $argv) {
  56071. $argv = $_SERVER['argv'];
  56072. }
  56073. array_shift($argv);
  56074. $this->tokens = $argv;
  56075. parent::__construct($definition);
  56076. }
  56077. protected function setTokens(array $tokens)
  56078. {
  56079. $this->tokens = $tokens;
  56080. }
  56081. protected function parse()
  56082. {
  56083. $parseOptions = true;
  56084. $this->parsed = $this->tokens;
  56085. while (null !== $token = array_shift($this->parsed)) {
  56086. if ($parseOptions && '' == $token) {
  56087. $this->parseArgument($token);
  56088. } elseif ($parseOptions && '--' == $token) {
  56089. $parseOptions = false;
  56090. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  56091. $this->parseLongOption($token);
  56092. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  56093. $this->parseShortOption($token);
  56094. } else {
  56095. $this->parseArgument($token);
  56096. }
  56097. }
  56098. }
  56099. private function parseShortOption($token)
  56100. {
  56101. $name = substr($token, 1);
  56102. if (\strlen($name) > 1) {
  56103. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  56104. $this->addShortOption($name[0], substr($name, 1));
  56105. } else {
  56106. $this->parseShortOptionSet($name);
  56107. }
  56108. } else {
  56109. $this->addShortOption($name, null);
  56110. }
  56111. }
  56112. private function parseShortOptionSet($name)
  56113. {
  56114. $len = \strlen($name);
  56115. for ($i = 0; $i < $len; ++$i) {
  56116. if (!$this->definition->hasShortcut($name[$i])) {
  56117. $encoding = mb_detect_encoding($name, null, true);
  56118. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  56119. }
  56120. $option = $this->definition->getOptionForShortcut($name[$i]);
  56121. if ($option->acceptValue()) {
  56122. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  56123. break;
  56124. } else {
  56125. $this->addLongOption($option->getName(), null);
  56126. }
  56127. }
  56128. }
  56129. private function parseLongOption($token)
  56130. {
  56131. $name = substr($token, 2);
  56132. if (false !== $pos = strpos($name, '=')) {
  56133. if (0 === \strlen($value = substr($name, $pos + 1))) {
  56134. array_unshift($this->parsed, null);
  56135. }
  56136. $this->addLongOption(substr($name, 0, $pos), $value);
  56137. } else {
  56138. $this->addLongOption($name, null);
  56139. }
  56140. }
  56141. private function parseArgument($token)
  56142. {
  56143. $c = \count($this->arguments);
  56144. if ($this->definition->hasArgument($c)) {
  56145. $arg = $this->definition->getArgument($c);
  56146. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  56147. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  56148. $arg = $this->definition->getArgument($c - 1);
  56149. $this->arguments[$arg->getName()][] = $token;
  56150. } else {
  56151. $all = $this->definition->getArguments();
  56152. if (\count($all)) {
  56153. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  56154. }
  56155. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  56156. }
  56157. }
  56158. private function addShortOption($shortcut, $value)
  56159. {
  56160. if (!$this->definition->hasShortcut($shortcut)) {
  56161. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  56162. }
  56163. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  56164. }
  56165. private function addLongOption($name, $value)
  56166. {
  56167. if (!$this->definition->hasOption($name)) {
  56168. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  56169. }
  56170. $option = $this->definition->getOption($name);
  56171. if (!isset($value[0])) {
  56172. $value = null;
  56173. }
  56174. if (null !== $value && !$option->acceptValue()) {
  56175. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  56176. }
  56177. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  56178. $next = array_shift($this->parsed);
  56179. if (isset($next[0]) && '-' !== $next[0]) {
  56180. $value = $next;
  56181. } elseif (empty($next)) {
  56182. $value = null;
  56183. } else {
  56184. array_unshift($this->parsed, $next);
  56185. }
  56186. }
  56187. if (null === $value) {
  56188. if ($option->isValueRequired()) {
  56189. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  56190. }
  56191. if (!$option->isArray()) {
  56192. $value = $option->isValueOptional() ? $option->getDefault() : true;
  56193. }
  56194. }
  56195. if ($option->isArray()) {
  56196. $this->options[$name][] = $value;
  56197. } else {
  56198. $this->options[$name] = $value;
  56199. }
  56200. }
  56201. public function getFirstArgument()
  56202. {
  56203. foreach ($this->tokens as $token) {
  56204. if ($token && '-' === $token[0]) {
  56205. continue;
  56206. }
  56207. return $token;
  56208. }
  56209. }
  56210. public function hasParameterOption($values)
  56211. {
  56212. $values = (array) $values;
  56213. foreach ($this->tokens as $token) {
  56214. foreach ($values as $value) {
  56215. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  56216. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  56217. return true;
  56218. }
  56219. }
  56220. }
  56221. return false;
  56222. }
  56223. public function getParameterOption($values, $default = false)
  56224. {
  56225. $values = (array) $values;
  56226. $tokens = $this->tokens;
  56227. while (0 < \count($tokens)) {
  56228. $token = array_shift($tokens);
  56229. foreach ($values as $value) {
  56230. if ($token === $value) {
  56231. return array_shift($tokens);
  56232. }
  56233. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  56234. if ('' !== $leading && 0 === strpos($token, $leading)) {
  56235. return substr($token, \strlen($leading));
  56236. }
  56237. }
  56238. }
  56239. return $default;
  56240. }
  56241. public function __toString()
  56242. {
  56243. $self = $this;
  56244. $tokens = array_map(function ($token) use ($self) {
  56245. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  56246. return $match[1].$self->escapeToken($match[2]);
  56247. }
  56248. if ($token && '-' !== $token[0]) {
  56249. return $self->escapeToken($token);
  56250. }
  56251. return $token;
  56252. }, $this->tokens);
  56253. return implode(' ', $tokens);
  56254. }
  56255. }
  56256. <?php
  56257. namespace Symfony\Component\Console\Input;
  56258. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56259. use Symfony\Component\Console\Exception\InvalidOptionException;
  56260. class ArrayInput extends Input
  56261. {
  56262. private $parameters;
  56263. public function __construct(array $parameters, InputDefinition $definition = null)
  56264. {
  56265. $this->parameters = $parameters;
  56266. parent::__construct($definition);
  56267. }
  56268. public function getFirstArgument()
  56269. {
  56270. foreach ($this->parameters as $key => $value) {
  56271. if ($key && '-' === $key[0]) {
  56272. continue;
  56273. }
  56274. return $value;
  56275. }
  56276. }
  56277. public function hasParameterOption($values)
  56278. {
  56279. $values = (array) $values;
  56280. foreach ($this->parameters as $k => $v) {
  56281. if (!\is_int($k)) {
  56282. $v = $k;
  56283. }
  56284. if (\in_array($v, $values)) {
  56285. return true;
  56286. }
  56287. }
  56288. return false;
  56289. }
  56290. public function getParameterOption($values, $default = false)
  56291. {
  56292. $values = (array) $values;
  56293. foreach ($this->parameters as $k => $v) {
  56294. if (\is_int($k)) {
  56295. if (\in_array($v, $values)) {
  56296. return true;
  56297. }
  56298. } elseif (\in_array($k, $values)) {
  56299. return $v;
  56300. }
  56301. }
  56302. return $default;
  56303. }
  56304. public function __toString()
  56305. {
  56306. $params = array();
  56307. foreach ($this->parameters as $param => $val) {
  56308. if ($param && '-' === $param[0]) {
  56309. if (\is_array($val)) {
  56310. foreach ($val as $v) {
  56311. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  56312. }
  56313. } else {
  56314. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  56315. }
  56316. } else {
  56317. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  56318. }
  56319. }
  56320. return implode(' ', $params);
  56321. }
  56322. protected function parse()
  56323. {
  56324. foreach ($this->parameters as $key => $value) {
  56325. if (0 === strpos($key, '--')) {
  56326. $this->addLongOption(substr($key, 2), $value);
  56327. } elseif ('-' === $key[0]) {
  56328. $this->addShortOption(substr($key, 1), $value);
  56329. } else {
  56330. $this->addArgument($key, $value);
  56331. }
  56332. }
  56333. }
  56334. private function addShortOption($shortcut, $value)
  56335. {
  56336. if (!$this->definition->hasShortcut($shortcut)) {
  56337. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  56338. }
  56339. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  56340. }
  56341. private function addLongOption($name, $value)
  56342. {
  56343. if (!$this->definition->hasOption($name)) {
  56344. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  56345. }
  56346. $option = $this->definition->getOption($name);
  56347. if (null === $value) {
  56348. if ($option->isValueRequired()) {
  56349. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  56350. }
  56351. $value = $option->isValueOptional() ? $option->getDefault() : true;
  56352. }
  56353. $this->options[$name] = $value;
  56354. }
  56355. private function addArgument($name, $value)
  56356. {
  56357. if (!$this->definition->hasArgument($name)) {
  56358. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  56359. }
  56360. $this->arguments[$name] = $value;
  56361. }
  56362. }
  56363. <?php
  56364. namespace Symfony\Component\Console\Input;
  56365. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56366. use Symfony\Component\Console\Exception\RuntimeException;
  56367. abstract class Input implements InputInterface
  56368. {
  56369. protected $definition;
  56370. protected $options = array();
  56371. protected $arguments = array();
  56372. protected $interactive = true;
  56373. public function __construct(InputDefinition $definition = null)
  56374. {
  56375. if (null === $definition) {
  56376. $this->definition = new InputDefinition();
  56377. } else {
  56378. $this->bind($definition);
  56379. $this->validate();
  56380. }
  56381. }
  56382. public function bind(InputDefinition $definition)
  56383. {
  56384. $this->arguments = array();
  56385. $this->options = array();
  56386. $this->definition = $definition;
  56387. $this->parse();
  56388. }
  56389. abstract protected function parse();
  56390. public function validate()
  56391. {
  56392. $definition = $this->definition;
  56393. $givenArguments = $this->arguments;
  56394. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  56395. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  56396. });
  56397. if (\count($missingArguments) > 0) {
  56398. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  56399. }
  56400. }
  56401. public function isInteractive()
  56402. {
  56403. return $this->interactive;
  56404. }
  56405. public function setInteractive($interactive)
  56406. {
  56407. $this->interactive = (bool) $interactive;
  56408. }
  56409. public function getArguments()
  56410. {
  56411. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  56412. }
  56413. public function getArgument($name)
  56414. {
  56415. if (!$this->definition->hasArgument($name)) {
  56416. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  56417. }
  56418. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  56419. }
  56420. public function setArgument($name, $value)
  56421. {
  56422. if (!$this->definition->hasArgument($name)) {
  56423. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  56424. }
  56425. $this->arguments[$name] = $value;
  56426. }
  56427. public function hasArgument($name)
  56428. {
  56429. return $this->definition->hasArgument($name);
  56430. }
  56431. public function getOptions()
  56432. {
  56433. return array_merge($this->definition->getOptionDefaults(), $this->options);
  56434. }
  56435. public function getOption($name)
  56436. {
  56437. if (!$this->definition->hasOption($name)) {
  56438. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  56439. }
  56440. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  56441. }
  56442. public function setOption($name, $value)
  56443. {
  56444. if (!$this->definition->hasOption($name)) {
  56445. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  56446. }
  56447. $this->options[$name] = $value;
  56448. }
  56449. public function hasOption($name)
  56450. {
  56451. return $this->definition->hasOption($name);
  56452. }
  56453. public function escapeToken($token)
  56454. {
  56455. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  56456. }
  56457. }
  56458. <?php
  56459. namespace Symfony\Component\Console\Input;
  56460. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56461. use Symfony\Component\Console\Exception\LogicException;
  56462. class InputArgument
  56463. {
  56464. const REQUIRED = 1;
  56465. const OPTIONAL = 2;
  56466. const IS_ARRAY = 4;
  56467. private $name;
  56468. private $mode;
  56469. private $default;
  56470. private $description;
  56471. public function __construct($name, $mode = null, $description = '', $default = null)
  56472. {
  56473. if (null === $mode) {
  56474. $mode = self::OPTIONAL;
  56475. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  56476. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  56477. }
  56478. $this->name = $name;
  56479. $this->mode = $mode;
  56480. $this->description = $description;
  56481. $this->setDefault($default);
  56482. }
  56483. public function getName()
  56484. {
  56485. return $this->name;
  56486. }
  56487. public function isRequired()
  56488. {
  56489. return self::REQUIRED === (self::REQUIRED & $this->mode);
  56490. }
  56491. public function isArray()
  56492. {
  56493. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  56494. }
  56495. public function setDefault($default = null)
  56496. {
  56497. if (self::REQUIRED === $this->mode && null !== $default) {
  56498. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  56499. }
  56500. if ($this->isArray()) {
  56501. if (null === $default) {
  56502. $default = array();
  56503. } elseif (!\is_array($default)) {
  56504. throw new LogicException('A default value for an array argument must be an array.');
  56505. }
  56506. }
  56507. $this->default = $default;
  56508. }
  56509. public function getDefault()
  56510. {
  56511. return $this->default;
  56512. }
  56513. public function getDescription()
  56514. {
  56515. return $this->description;
  56516. }
  56517. }
  56518. <?php
  56519. namespace Symfony\Component\Console\Input;
  56520. interface InputAwareInterface
  56521. {
  56522. public function setInput(InputInterface $input);
  56523. }
  56524. <?php
  56525. namespace Symfony\Component\Console\Input;
  56526. use Symfony\Component\Console\Descriptor\TextDescriptor;
  56527. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  56528. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56529. use Symfony\Component\Console\Exception\LogicException;
  56530. use Symfony\Component\Console\Output\BufferedOutput;
  56531. class InputDefinition
  56532. {
  56533. private $arguments;
  56534. private $requiredCount;
  56535. private $hasAnArrayArgument = false;
  56536. private $hasOptional;
  56537. private $options;
  56538. private $shortcuts;
  56539. public function __construct(array $definition = array())
  56540. {
  56541. $this->setDefinition($definition);
  56542. }
  56543. public function setDefinition(array $definition)
  56544. {
  56545. $arguments = array();
  56546. $options = array();
  56547. foreach ($definition as $item) {
  56548. if ($item instanceof InputOption) {
  56549. $options[] = $item;
  56550. } else {
  56551. $arguments[] = $item;
  56552. }
  56553. }
  56554. $this->setArguments($arguments);
  56555. $this->setOptions($options);
  56556. }
  56557. public function setArguments($arguments = array())
  56558. {
  56559. $this->arguments = array();
  56560. $this->requiredCount = 0;
  56561. $this->hasOptional = false;
  56562. $this->hasAnArrayArgument = false;
  56563. $this->addArguments($arguments);
  56564. }
  56565. public function addArguments($arguments = array())
  56566. {
  56567. if (null !== $arguments) {
  56568. foreach ($arguments as $argument) {
  56569. $this->addArgument($argument);
  56570. }
  56571. }
  56572. }
  56573. public function addArgument(InputArgument $argument)
  56574. {
  56575. if (isset($this->arguments[$argument->getName()])) {
  56576. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  56577. }
  56578. if ($this->hasAnArrayArgument) {
  56579. throw new LogicException('Cannot add an argument after an array argument.');
  56580. }
  56581. if ($argument->isRequired() && $this->hasOptional) {
  56582. throw new LogicException('Cannot add a required argument after an optional one.');
  56583. }
  56584. if ($argument->isArray()) {
  56585. $this->hasAnArrayArgument = true;
  56586. }
  56587. if ($argument->isRequired()) {
  56588. ++$this->requiredCount;
  56589. } else {
  56590. $this->hasOptional = true;
  56591. }
  56592. $this->arguments[$argument->getName()] = $argument;
  56593. }
  56594. public function getArgument($name)
  56595. {
  56596. if (!$this->hasArgument($name)) {
  56597. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  56598. }
  56599. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  56600. return $arguments[$name];
  56601. }
  56602. public function hasArgument($name)
  56603. {
  56604. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  56605. return isset($arguments[$name]);
  56606. }
  56607. public function getArguments()
  56608. {
  56609. return $this->arguments;
  56610. }
  56611. public function getArgumentCount()
  56612. {
  56613. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  56614. }
  56615. public function getArgumentRequiredCount()
  56616. {
  56617. return $this->requiredCount;
  56618. }
  56619. public function getArgumentDefaults()
  56620. {
  56621. $values = array();
  56622. foreach ($this->arguments as $argument) {
  56623. $values[$argument->getName()] = $argument->getDefault();
  56624. }
  56625. return $values;
  56626. }
  56627. public function setOptions($options = array())
  56628. {
  56629. $this->options = array();
  56630. $this->shortcuts = array();
  56631. $this->addOptions($options);
  56632. }
  56633. public function addOptions($options = array())
  56634. {
  56635. foreach ($options as $option) {
  56636. $this->addOption($option);
  56637. }
  56638. }
  56639. public function addOption(InputOption $option)
  56640. {
  56641. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  56642. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  56643. }
  56644. if ($option->getShortcut()) {
  56645. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  56646. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  56647. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  56648. }
  56649. }
  56650. }
  56651. $this->options[$option->getName()] = $option;
  56652. if ($option->getShortcut()) {
  56653. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  56654. $this->shortcuts[$shortcut] = $option->getName();
  56655. }
  56656. }
  56657. }
  56658. public function getOption($name)
  56659. {
  56660. if (!$this->hasOption($name)) {
  56661. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  56662. }
  56663. return $this->options[$name];
  56664. }
  56665. public function hasOption($name)
  56666. {
  56667. return isset($this->options[$name]);
  56668. }
  56669. public function getOptions()
  56670. {
  56671. return $this->options;
  56672. }
  56673. public function hasShortcut($name)
  56674. {
  56675. return isset($this->shortcuts[$name]);
  56676. }
  56677. public function getOptionForShortcut($shortcut)
  56678. {
  56679. return $this->getOption($this->shortcutToName($shortcut));
  56680. }
  56681. public function getOptionDefaults()
  56682. {
  56683. $values = array();
  56684. foreach ($this->options as $option) {
  56685. $values[$option->getName()] = $option->getDefault();
  56686. }
  56687. return $values;
  56688. }
  56689. private function shortcutToName($shortcut)
  56690. {
  56691. if (!isset($this->shortcuts[$shortcut])) {
  56692. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  56693. }
  56694. return $this->shortcuts[$shortcut];
  56695. }
  56696. public function getSynopsis($short = false)
  56697. {
  56698. $elements = array();
  56699. if ($short && $this->getOptions()) {
  56700. $elements[] = '[options]';
  56701. } elseif (!$short) {
  56702. foreach ($this->getOptions() as $option) {
  56703. $value = '';
  56704. if ($option->acceptValue()) {
  56705. $value = sprintf(
  56706. ' %s%s%s',
  56707. $option->isValueOptional() ? '[' : '',
  56708. strtoupper($option->getName()),
  56709. $option->isValueOptional() ? ']' : ''
  56710. );
  56711. }
  56712. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  56713. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  56714. }
  56715. }
  56716. if (\count($elements) && $this->getArguments()) {
  56717. $elements[] = '[--]';
  56718. }
  56719. foreach ($this->getArguments() as $argument) {
  56720. $element = '<'.$argument->getName().'>';
  56721. if (!$argument->isRequired()) {
  56722. $element = '['.$element.']';
  56723. } elseif ($argument->isArray()) {
  56724. $element .= ' ('.$element.')';
  56725. }
  56726. if ($argument->isArray()) {
  56727. $element .= '...';
  56728. }
  56729. $elements[] = $element;
  56730. }
  56731. return implode(' ', $elements);
  56732. }
  56733. public function asText()
  56734. {
  56735. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  56736. $descriptor = new TextDescriptor();
  56737. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  56738. $descriptor->describe($output, $this, array('raw_output' => true));
  56739. return $output->fetch();
  56740. }
  56741. public function asXml($asDom = false)
  56742. {
  56743. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  56744. $descriptor = new XmlDescriptor();
  56745. if ($asDom) {
  56746. return $descriptor->getInputDefinitionDocument($this);
  56747. }
  56748. $output = new BufferedOutput();
  56749. $descriptor->describe($output, $this);
  56750. return $output->fetch();
  56751. }
  56752. }
  56753. <?php
  56754. namespace Symfony\Component\Console\Input;
  56755. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56756. use Symfony\Component\Console\Exception\RuntimeException;
  56757. interface InputInterface
  56758. {
  56759. public function getFirstArgument();
  56760. public function hasParameterOption($values);
  56761. public function getParameterOption($values, $default = false);
  56762. public function bind(InputDefinition $definition);
  56763. public function validate();
  56764. public function getArguments();
  56765. public function getArgument($name);
  56766. public function setArgument($name, $value);
  56767. public function hasArgument($name);
  56768. public function getOptions();
  56769. public function getOption($name);
  56770. public function setOption($name, $value);
  56771. public function hasOption($name);
  56772. public function isInteractive();
  56773. public function setInteractive($interactive);
  56774. }
  56775. <?php
  56776. namespace Symfony\Component\Console\Input;
  56777. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56778. use Symfony\Component\Console\Exception\LogicException;
  56779. class InputOption
  56780. {
  56781. const VALUE_NONE = 1;
  56782. const VALUE_REQUIRED = 2;
  56783. const VALUE_OPTIONAL = 4;
  56784. const VALUE_IS_ARRAY = 8;
  56785. private $name;
  56786. private $shortcut;
  56787. private $mode;
  56788. private $default;
  56789. private $description;
  56790. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  56791. {
  56792. if (0 === strpos($name, '--')) {
  56793. $name = substr($name, 2);
  56794. }
  56795. if (empty($name)) {
  56796. throw new InvalidArgumentException('An option name cannot be empty.');
  56797. }
  56798. if (empty($shortcut)) {
  56799. $shortcut = null;
  56800. }
  56801. if (null !== $shortcut) {
  56802. if (\is_array($shortcut)) {
  56803. $shortcut = implode('|', $shortcut);
  56804. }
  56805. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  56806. $shortcuts = array_filter($shortcuts);
  56807. $shortcut = implode('|', $shortcuts);
  56808. if (empty($shortcut)) {
  56809. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  56810. }
  56811. }
  56812. if (null === $mode) {
  56813. $mode = self::VALUE_NONE;
  56814. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  56815. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  56816. }
  56817. $this->name = $name;
  56818. $this->shortcut = $shortcut;
  56819. $this->mode = $mode;
  56820. $this->description = $description;
  56821. if ($this->isArray() && !$this->acceptValue()) {
  56822. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  56823. }
  56824. $this->setDefault($default);
  56825. }
  56826. public function getShortcut()
  56827. {
  56828. return $this->shortcut;
  56829. }
  56830. public function getName()
  56831. {
  56832. return $this->name;
  56833. }
  56834. public function acceptValue()
  56835. {
  56836. return $this->isValueRequired() || $this->isValueOptional();
  56837. }
  56838. public function isValueRequired()
  56839. {
  56840. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  56841. }
  56842. public function isValueOptional()
  56843. {
  56844. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  56845. }
  56846. public function isArray()
  56847. {
  56848. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  56849. }
  56850. public function setDefault($default = null)
  56851. {
  56852. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  56853. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  56854. }
  56855. if ($this->isArray()) {
  56856. if (null === $default) {
  56857. $default = array();
  56858. } elseif (!\is_array($default)) {
  56859. throw new LogicException('A default value for an array option must be an array.');
  56860. }
  56861. }
  56862. $this->default = $this->acceptValue() ? $default : false;
  56863. }
  56864. public function getDefault()
  56865. {
  56866. return $this->default;
  56867. }
  56868. public function getDescription()
  56869. {
  56870. return $this->description;
  56871. }
  56872. public function equals(self $option)
  56873. {
  56874. return $option->getName() === $this->getName()
  56875. && $option->getShortcut() === $this->getShortcut()
  56876. && $option->getDefault() === $this->getDefault()
  56877. && $option->isArray() === $this->isArray()
  56878. && $option->isValueRequired() === $this->isValueRequired()
  56879. && $option->isValueOptional() === $this->isValueOptional()
  56880. ;
  56881. }
  56882. }
  56883. <?php
  56884. namespace Symfony\Component\Console\Input;
  56885. use Symfony\Component\Console\Exception\InvalidArgumentException;
  56886. class StringInput extends ArgvInput
  56887. {
  56888. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  56889. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  56890. public function __construct($input, InputDefinition $definition = null)
  56891. {
  56892. if ($definition) {
  56893. @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);
  56894. }
  56895. parent::__construct(array(), null);
  56896. $this->setTokens($this->tokenize($input));
  56897. if (null !== $definition) {
  56898. $this->bind($definition);
  56899. }
  56900. }
  56901. private function tokenize($input)
  56902. {
  56903. $tokens = array();
  56904. $length = \strlen($input);
  56905. $cursor = 0;
  56906. while ($cursor < $length) {
  56907. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  56908. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  56909. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  56910. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  56911. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  56912. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  56913. $tokens[] = stripcslashes($match[1]);
  56914. } else {
  56915. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  56916. }
  56917. $cursor += \strlen($match[0]);
  56918. }
  56919. return $tokens;
  56920. }
  56921. }
  56922. Copyright (c) 2004-2018 Fabien Potencier
  56923. Permission is hereby granted, free of charge, to any person obtaining a copy
  56924. of this software and associated documentation files (the "Software"), to deal
  56925. in the Software without restriction, including without limitation the rights
  56926. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56927. copies of the Software, and to permit persons to whom the Software is furnished
  56928. to do so, subject to the following conditions:
  56929. The above copyright notice and this permission notice shall be included in all
  56930. copies or substantial portions of the Software.
  56931. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56932. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56933. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56934. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56935. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56936. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56937. THE SOFTWARE.
  56938. <?php
  56939. namespace Symfony\Component\Console\Logger;
  56940. use Psr\Log\AbstractLogger;
  56941. use Psr\Log\InvalidArgumentException;
  56942. use Psr\Log\LogLevel;
  56943. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  56944. use Symfony\Component\Console\Output\OutputInterface;
  56945. class ConsoleLogger extends AbstractLogger
  56946. {
  56947. const INFO = 'info';
  56948. const ERROR = 'error';
  56949. private $output;
  56950. private $verbosityLevelMap = array(
  56951. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  56952. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  56953. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  56954. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  56955. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  56956. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  56957. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  56958. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  56959. );
  56960. private $formatLevelMap = array(
  56961. LogLevel::EMERGENCY => self::ERROR,
  56962. LogLevel::ALERT => self::ERROR,
  56963. LogLevel::CRITICAL => self::ERROR,
  56964. LogLevel::ERROR => self::ERROR,
  56965. LogLevel::WARNING => self::INFO,
  56966. LogLevel::NOTICE => self::INFO,
  56967. LogLevel::INFO => self::INFO,
  56968. LogLevel::DEBUG => self::INFO,
  56969. );
  56970. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  56971. {
  56972. $this->output = $output;
  56973. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  56974. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  56975. }
  56976. public function log($level, $message, array $context = array())
  56977. {
  56978. if (!isset($this->verbosityLevelMap[$level])) {
  56979. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  56980. }
  56981. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  56982. $output = $this->output->getErrorOutput();
  56983. } else {
  56984. $output = $this->output;
  56985. }
  56986. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  56987. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  56988. }
  56989. }
  56990. private function interpolate($message, array $context)
  56991. {
  56992. $replace = array();
  56993. foreach ($context as $key => $val) {
  56994. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  56995. $replace[sprintf('{%s}', $key)] = $val;
  56996. }
  56997. }
  56998. return strtr($message, $replace);
  56999. }
  57000. }
  57001. <?php
  57002. namespace Symfony\Component\Console\Output;
  57003. class BufferedOutput extends Output
  57004. {
  57005. private $buffer = '';
  57006. public function fetch()
  57007. {
  57008. $content = $this->buffer;
  57009. $this->buffer = '';
  57010. return $content;
  57011. }
  57012. protected function doWrite($message, $newline)
  57013. {
  57014. $this->buffer .= $message;
  57015. if ($newline) {
  57016. $this->buffer .= PHP_EOL;
  57017. }
  57018. }
  57019. }
  57020. <?php
  57021. namespace Symfony\Component\Console\Output;
  57022. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  57023. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  57024. {
  57025. private $stderr;
  57026. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  57027. {
  57028. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  57029. $actualDecorated = $this->isDecorated();
  57030. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  57031. if (null === $decorated) {
  57032. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  57033. }
  57034. }
  57035. public function setDecorated($decorated)
  57036. {
  57037. parent::setDecorated($decorated);
  57038. $this->stderr->setDecorated($decorated);
  57039. }
  57040. public function setFormatter(OutputFormatterInterface $formatter)
  57041. {
  57042. parent::setFormatter($formatter);
  57043. $this->stderr->setFormatter($formatter);
  57044. }
  57045. public function setVerbosity($level)
  57046. {
  57047. parent::setVerbosity($level);
  57048. $this->stderr->setVerbosity($level);
  57049. }
  57050. public function getErrorOutput()
  57051. {
  57052. return $this->stderr;
  57053. }
  57054. public function setErrorOutput(OutputInterface $error)
  57055. {
  57056. $this->stderr = $error;
  57057. }
  57058. protected function hasStdoutSupport()
  57059. {
  57060. return false === $this->isRunningOS400();
  57061. }
  57062. protected function hasStderrSupport()
  57063. {
  57064. return false === $this->isRunningOS400();
  57065. }
  57066. private function isRunningOS400()
  57067. {
  57068. $checks = array(
  57069. \function_exists('php_uname') ? php_uname('s') : '',
  57070. getenv('OSTYPE'),
  57071. PHP_OS,
  57072. );
  57073. return false !== stripos(implode(';', $checks), 'OS400');
  57074. }
  57075. private function openOutputStream()
  57076. {
  57077. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  57078. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  57079. }
  57080. private function openErrorStream()
  57081. {
  57082. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  57083. return fopen($errorStream, 'w');
  57084. }
  57085. }
  57086. <?php
  57087. namespace Symfony\Component\Console\Output;
  57088. interface ConsoleOutputInterface extends OutputInterface
  57089. {
  57090. public function getErrorOutput();
  57091. public function setErrorOutput(OutputInterface $error);
  57092. }
  57093. <?php
  57094. namespace Symfony\Component\Console\Output;
  57095. use Symfony\Component\Console\Formatter\OutputFormatter;
  57096. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  57097. class NullOutput implements OutputInterface
  57098. {
  57099. public function setFormatter(OutputFormatterInterface $formatter)
  57100. {
  57101. }
  57102. public function getFormatter()
  57103. {
  57104. return new OutputFormatter();
  57105. }
  57106. public function setDecorated($decorated)
  57107. {
  57108. }
  57109. public function isDecorated()
  57110. {
  57111. return false;
  57112. }
  57113. public function setVerbosity($level)
  57114. {
  57115. }
  57116. public function getVerbosity()
  57117. {
  57118. return self::VERBOSITY_QUIET;
  57119. }
  57120. public function isQuiet()
  57121. {
  57122. return true;
  57123. }
  57124. public function isVerbose()
  57125. {
  57126. return false;
  57127. }
  57128. public function isVeryVerbose()
  57129. {
  57130. return false;
  57131. }
  57132. public function isDebug()
  57133. {
  57134. return false;
  57135. }
  57136. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  57137. {
  57138. }
  57139. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  57140. {
  57141. }
  57142. }
  57143. <?php
  57144. namespace Symfony\Component\Console\Output;
  57145. use Symfony\Component\Console\Formatter\OutputFormatter;
  57146. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  57147. abstract class Output implements OutputInterface
  57148. {
  57149. private $verbosity;
  57150. private $formatter;
  57151. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  57152. {
  57153. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  57154. $this->formatter = $formatter ?: new OutputFormatter();
  57155. $this->formatter->setDecorated($decorated);
  57156. }
  57157. public function setFormatter(OutputFormatterInterface $formatter)
  57158. {
  57159. $this->formatter = $formatter;
  57160. }
  57161. public function getFormatter()
  57162. {
  57163. return $this->formatter;
  57164. }
  57165. public function setDecorated($decorated)
  57166. {
  57167. $this->formatter->setDecorated($decorated);
  57168. }
  57169. public function isDecorated()
  57170. {
  57171. return $this->formatter->isDecorated();
  57172. }
  57173. public function setVerbosity($level)
  57174. {
  57175. $this->verbosity = (int) $level;
  57176. }
  57177. public function getVerbosity()
  57178. {
  57179. return $this->verbosity;
  57180. }
  57181. public function isQuiet()
  57182. {
  57183. return self::VERBOSITY_QUIET === $this->verbosity;
  57184. }
  57185. public function isVerbose()
  57186. {
  57187. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  57188. }
  57189. public function isVeryVerbose()
  57190. {
  57191. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  57192. }
  57193. public function isDebug()
  57194. {
  57195. return self::VERBOSITY_DEBUG <= $this->verbosity;
  57196. }
  57197. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  57198. {
  57199. $this->write($messages, true, $options);
  57200. }
  57201. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  57202. {
  57203. $messages = (array) $messages;
  57204. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  57205. $type = $types & $options ?: self::OUTPUT_NORMAL;
  57206. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  57207. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  57208. if ($verbosity > $this->getVerbosity()) {
  57209. return;
  57210. }
  57211. foreach ($messages as $message) {
  57212. switch ($type) {
  57213. case OutputInterface::OUTPUT_NORMAL:
  57214. $message = $this->formatter->format($message);
  57215. break;
  57216. case OutputInterface::OUTPUT_RAW:
  57217. break;
  57218. case OutputInterface::OUTPUT_PLAIN:
  57219. $message = strip_tags($this->formatter->format($message));
  57220. break;
  57221. }
  57222. $this->doWrite($message, $newline);
  57223. }
  57224. }
  57225. abstract protected function doWrite($message, $newline);
  57226. }
  57227. <?php
  57228. namespace Symfony\Component\Console\Output;
  57229. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  57230. interface OutputInterface
  57231. {
  57232. const VERBOSITY_QUIET = 16;
  57233. const VERBOSITY_NORMAL = 32;
  57234. const VERBOSITY_VERBOSE = 64;
  57235. const VERBOSITY_VERY_VERBOSE = 128;
  57236. const VERBOSITY_DEBUG = 256;
  57237. const OUTPUT_NORMAL = 1;
  57238. const OUTPUT_RAW = 2;
  57239. const OUTPUT_PLAIN = 4;
  57240. public function write($messages, $newline = false, $options = 0);
  57241. public function writeln($messages, $options = 0);
  57242. public function setVerbosity($level);
  57243. public function getVerbosity();
  57244. public function setDecorated($decorated);
  57245. public function isDecorated();
  57246. public function setFormatter(OutputFormatterInterface $formatter);
  57247. public function getFormatter();
  57248. }
  57249. <?php
  57250. namespace Symfony\Component\Console\Output;
  57251. use Symfony\Component\Console\Exception\InvalidArgumentException;
  57252. use Symfony\Component\Console\Exception\RuntimeException;
  57253. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  57254. class StreamOutput extends Output
  57255. {
  57256. private $stream;
  57257. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  57258. {
  57259. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  57260. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  57261. }
  57262. $this->stream = $stream;
  57263. if (null === $decorated) {
  57264. $decorated = $this->hasColorSupport();
  57265. }
  57266. parent::__construct($verbosity, $decorated, $formatter);
  57267. }
  57268. public function getStream()
  57269. {
  57270. return $this->stream;
  57271. }
  57272. protected function doWrite($message, $newline)
  57273. {
  57274. if ($newline) {
  57275. $message .= PHP_EOL;
  57276. }
  57277. if (false === @fwrite($this->stream, $message)) {
  57278. throw new RuntimeException('Unable to write output.');
  57279. }
  57280. fflush($this->stream);
  57281. }
  57282. protected function hasColorSupport()
  57283. {
  57284. if ('Hyper' === getenv('TERM_PROGRAM')) {
  57285. return true;
  57286. }
  57287. if (\DIRECTORY_SEPARATOR === '\\') {
  57288. return (\function_exists('sapi_windows_vt100_support')
  57289. && @sapi_windows_vt100_support($this->stream))
  57290. || false !== getenv('ANSICON')
  57291. || 'ON' === getenv('ConEmuANSI')
  57292. || 'xterm' === getenv('TERM');
  57293. }
  57294. if (\function_exists('stream_isatty')) {
  57295. return @stream_isatty($this->stream);
  57296. }
  57297. if (\function_exists('posix_isatty')) {
  57298. return @posix_isatty($this->stream);
  57299. }
  57300. $stat = @fstat($this->stream);
  57301. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  57302. }
  57303. }
  57304. <?php
  57305. namespace Symfony\Component\Console\Question;
  57306. use Symfony\Component\Console\Exception\InvalidArgumentException;
  57307. class ChoiceQuestion extends Question
  57308. {
  57309. private $choices;
  57310. private $multiselect = false;
  57311. private $prompt = ' > ';
  57312. private $errorMessage = 'Value "%s" is invalid';
  57313. public function __construct($question, array $choices, $default = null)
  57314. {
  57315. if (!$choices) {
  57316. throw new \LogicException('Choice question must have at least 1 choice available.');
  57317. }
  57318. parent::__construct($question, $default);
  57319. $this->choices = $choices;
  57320. $this->setValidator($this->getDefaultValidator());
  57321. $this->setAutocompleterValues($choices);
  57322. }
  57323. public function getChoices()
  57324. {
  57325. return $this->choices;
  57326. }
  57327. public function setMultiselect($multiselect)
  57328. {
  57329. $this->multiselect = $multiselect;
  57330. $this->setValidator($this->getDefaultValidator());
  57331. return $this;
  57332. }
  57333. public function isMultiselect()
  57334. {
  57335. return $this->multiselect;
  57336. }
  57337. public function getPrompt()
  57338. {
  57339. return $this->prompt;
  57340. }
  57341. public function setPrompt($prompt)
  57342. {
  57343. $this->prompt = $prompt;
  57344. return $this;
  57345. }
  57346. public function setErrorMessage($errorMessage)
  57347. {
  57348. $this->errorMessage = $errorMessage;
  57349. $this->setValidator($this->getDefaultValidator());
  57350. return $this;
  57351. }
  57352. private function getDefaultValidator()
  57353. {
  57354. $choices = $this->choices;
  57355. $errorMessage = $this->errorMessage;
  57356. $multiselect = $this->multiselect;
  57357. $isAssoc = $this->isAssoc($choices);
  57358. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  57359. $selectedChoices = str_replace(' ', '', $selected);
  57360. if ($multiselect) {
  57361. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  57362. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  57363. }
  57364. $selectedChoices = explode(',', $selectedChoices);
  57365. } else {
  57366. $selectedChoices = array($selected);
  57367. }
  57368. $multiselectChoices = array();
  57369. foreach ($selectedChoices as $value) {
  57370. $results = array();
  57371. foreach ($choices as $key => $choice) {
  57372. if ($choice === $value) {
  57373. $results[] = $key;
  57374. }
  57375. }
  57376. if (\count($results) > 1) {
  57377. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  57378. }
  57379. $result = array_search($value, $choices);
  57380. if (!$isAssoc) {
  57381. if (false !== $result) {
  57382. $result = $choices[$result];
  57383. } elseif (isset($choices[$value])) {
  57384. $result = $choices[$value];
  57385. }
  57386. } elseif (false === $result && isset($choices[$value])) {
  57387. $result = $value;
  57388. }
  57389. if (false === $result) {
  57390. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  57391. }
  57392. $multiselectChoices[] = (string) $result;
  57393. }
  57394. if ($multiselect) {
  57395. return $multiselectChoices;
  57396. }
  57397. return current($multiselectChoices);
  57398. };
  57399. }
  57400. }
  57401. <?php
  57402. namespace Symfony\Component\Console\Question;
  57403. class ConfirmationQuestion extends Question
  57404. {
  57405. private $trueAnswerRegex;
  57406. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  57407. {
  57408. parent::__construct($question, (bool) $default);
  57409. $this->trueAnswerRegex = $trueAnswerRegex;
  57410. $this->setNormalizer($this->getDefaultNormalizer());
  57411. }
  57412. private function getDefaultNormalizer()
  57413. {
  57414. $default = $this->getDefault();
  57415. $regex = $this->trueAnswerRegex;
  57416. return function ($answer) use ($default, $regex) {
  57417. if (\is_bool($answer)) {
  57418. return $answer;
  57419. }
  57420. $answerIsTrue = (bool) preg_match($regex, $answer);
  57421. if (false === $default) {
  57422. return $answer && $answerIsTrue;
  57423. }
  57424. return !$answer || $answerIsTrue;
  57425. };
  57426. }
  57427. }
  57428. <?php
  57429. namespace Symfony\Component\Console\Question;
  57430. use Symfony\Component\Console\Exception\InvalidArgumentException;
  57431. use Symfony\Component\Console\Exception\LogicException;
  57432. class Question
  57433. {
  57434. private $question;
  57435. private $attempts;
  57436. private $hidden = false;
  57437. private $hiddenFallback = true;
  57438. private $autocompleterValues;
  57439. private $validator;
  57440. private $default;
  57441. private $normalizer;
  57442. public function __construct($question, $default = null)
  57443. {
  57444. $this->question = $question;
  57445. $this->default = $default;
  57446. }
  57447. public function getQuestion()
  57448. {
  57449. return $this->question;
  57450. }
  57451. public function getDefault()
  57452. {
  57453. return $this->default;
  57454. }
  57455. public function isHidden()
  57456. {
  57457. return $this->hidden;
  57458. }
  57459. public function setHidden($hidden)
  57460. {
  57461. if ($this->autocompleterValues) {
  57462. throw new LogicException('A hidden question cannot use the autocompleter.');
  57463. }
  57464. $this->hidden = (bool) $hidden;
  57465. return $this;
  57466. }
  57467. public function isHiddenFallback()
  57468. {
  57469. return $this->hiddenFallback;
  57470. }
  57471. public function setHiddenFallback($fallback)
  57472. {
  57473. $this->hiddenFallback = (bool) $fallback;
  57474. return $this;
  57475. }
  57476. public function getAutocompleterValues()
  57477. {
  57478. return $this->autocompleterValues;
  57479. }
  57480. public function setAutocompleterValues($values)
  57481. {
  57482. if (\is_array($values)) {
  57483. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  57484. }
  57485. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  57486. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  57487. }
  57488. if ($this->hidden) {
  57489. throw new LogicException('A hidden question cannot use the autocompleter.');
  57490. }
  57491. $this->autocompleterValues = $values;
  57492. return $this;
  57493. }
  57494. public function setValidator($validator)
  57495. {
  57496. $this->validator = $validator;
  57497. return $this;
  57498. }
  57499. public function getValidator()
  57500. {
  57501. return $this->validator;
  57502. }
  57503. public function setMaxAttempts($attempts)
  57504. {
  57505. if (null !== $attempts && $attempts < 1) {
  57506. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  57507. }
  57508. $this->attempts = $attempts;
  57509. return $this;
  57510. }
  57511. public function getMaxAttempts()
  57512. {
  57513. return $this->attempts;
  57514. }
  57515. public function setNormalizer($normalizer)
  57516. {
  57517. $this->normalizer = $normalizer;
  57518. return $this;
  57519. }
  57520. public function getNormalizer()
  57521. {
  57522. return $this->normalizer;
  57523. }
  57524. protected function isAssoc($array)
  57525. {
  57526. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  57527. }
  57528. }
  57529. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  57530. $�������Æ,Í;§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��������à�  ��
  57531. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  57532. ����������������� ��`.rdata����� ���
  57533. �����������������@��@.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
  57534. 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
  57535. 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
  57536. 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">
  57537. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  57538. <security>
  57539. <requestedPrivileges>
  57540. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  57541. </requestedPrivileges>
  57542. </security>
  57543. </trustInfo>
  57544. <dependency>
  57545. <dependentAssembly>
  57546. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  57547. </dependentAssembly>
  57548. </dependency>
  57549. </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
  57550. namespace Symfony\Component\Console;
  57551. use Symfony\Component\Console\Exception\RuntimeException;
  57552. use Symfony\Component\Console\Input\StringInput;
  57553. use Symfony\Component\Console\Output\ConsoleOutput;
  57554. use Symfony\Component\Process\PhpExecutableFinder;
  57555. use Symfony\Component\Process\ProcessBuilder;
  57556. class Shell
  57557. {
  57558. private $application;
  57559. private $history;
  57560. private $output;
  57561. private $hasReadline;
  57562. private $processIsolation = false;
  57563. public function __construct(Application $application)
  57564. {
  57565. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57566. $this->hasReadline = \function_exists('readline');
  57567. $this->application = $application;
  57568. $this->history = getenv('HOME').'/.history_'.$application->getName();
  57569. $this->output = new ConsoleOutput();
  57570. }
  57571. public function run()
  57572. {
  57573. $this->application->setAutoExit(false);
  57574. $this->application->setCatchExceptions(true);
  57575. if ($this->hasReadline) {
  57576. readline_read_history($this->history);
  57577. readline_completion_function(array($this, 'autocompleter'));
  57578. }
  57579. $this->output->writeln($this->getHeader());
  57580. $php = null;
  57581. if ($this->processIsolation) {
  57582. $finder = new PhpExecutableFinder();
  57583. $php = $finder->find();
  57584. $this->output->writeln(<<<'EOF'
  57585. <info>Running with process isolation, you should consider this:</info>
  57586. * each command is executed as separate process,
  57587. * commands don't support interactivity, all params must be passed explicitly,
  57588. * commands output is not colorized.
  57589. EOF
  57590. );
  57591. }
  57592. while (true) {
  57593. $command = $this->readline();
  57594. if (false === $command) {
  57595. $this->output->writeln("\n");
  57596. break;
  57597. }
  57598. if ($this->hasReadline) {
  57599. readline_add_history($command);
  57600. readline_write_history($this->history);
  57601. }
  57602. if ($this->processIsolation) {
  57603. $pb = new ProcessBuilder();
  57604. $process = $pb
  57605. ->add($php)
  57606. ->add($_SERVER['argv'][0])
  57607. ->add($command)
  57608. ->inheritEnvironmentVariables(true)
  57609. ->getProcess()
  57610. ;
  57611. $output = $this->output;
  57612. $process->run(function ($type, $data) use ($output) {
  57613. $output->writeln($data);
  57614. });
  57615. $ret = $process->getExitCode();
  57616. } else {
  57617. $ret = $this->application->run(new StringInput($command), $this->output);
  57618. }
  57619. if (0 !== $ret) {
  57620. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  57621. }
  57622. }
  57623. }
  57624. protected function getHeader()
  57625. {
  57626. return <<<EOF
  57627. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  57628. At the prompt, type <comment>help</comment> for some help,
  57629. or <comment>list</comment> to get a list of available commands.
  57630. To exit the shell, type <comment>^D</comment>.
  57631. EOF;
  57632. }
  57633. protected function getPrompt()
  57634. {
  57635. return $this->output->getFormatter()->format($this->application->getName().' > ');
  57636. }
  57637. protected function getOutput()
  57638. {
  57639. return $this->output;
  57640. }
  57641. protected function getApplication()
  57642. {
  57643. return $this->application;
  57644. }
  57645. private function autocompleter($text)
  57646. {
  57647. $info = readline_info();
  57648. $text = substr($info['line_buffer'], 0, $info['end']);
  57649. if ($info['point'] !== $info['end']) {
  57650. return true;
  57651. }
  57652. if (false === strpos($text, ' ') || !$text) {
  57653. return array_keys($this->application->all());
  57654. }
  57655. try {
  57656. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  57657. } catch (\Exception $e) {
  57658. return true;
  57659. }
  57660. $list = array('--help');
  57661. foreach ($command->getDefinition()->getOptions() as $option) {
  57662. $list[] = '--'.$option->getName();
  57663. }
  57664. return $list;
  57665. }
  57666. private function readline()
  57667. {
  57668. if ($this->hasReadline) {
  57669. $line = readline($this->getPrompt());
  57670. } else {
  57671. $this->output->write($this->getPrompt());
  57672. $line = fgets(STDIN, 1024);
  57673. $line = (false === $line || '' === $line) ? false : rtrim($line);
  57674. }
  57675. return $line;
  57676. }
  57677. public function getProcessIsolation()
  57678. {
  57679. return $this->processIsolation;
  57680. }
  57681. public function setProcessIsolation($processIsolation)
  57682. {
  57683. $this->processIsolation = (bool) $processIsolation;
  57684. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  57685. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  57686. }
  57687. }
  57688. }
  57689. <?php
  57690. namespace Symfony\Component\Console\Style;
  57691. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  57692. use Symfony\Component\Console\Helper\ProgressBar;
  57693. use Symfony\Component\Console\Output\OutputInterface;
  57694. abstract class OutputStyle implements OutputInterface, StyleInterface
  57695. {
  57696. private $output;
  57697. public function __construct(OutputInterface $output)
  57698. {
  57699. $this->output = $output;
  57700. }
  57701. public function newLine($count = 1)
  57702. {
  57703. $this->output->write(str_repeat(PHP_EOL, $count));
  57704. }
  57705. public function createProgressBar($max = 0)
  57706. {
  57707. return new ProgressBar($this->output, $max);
  57708. }
  57709. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  57710. {
  57711. $this->output->write($messages, $newline, $type);
  57712. }
  57713. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  57714. {
  57715. $this->output->writeln($messages, $type);
  57716. }
  57717. public function setVerbosity($level)
  57718. {
  57719. $this->output->setVerbosity($level);
  57720. }
  57721. public function getVerbosity()
  57722. {
  57723. return $this->output->getVerbosity();
  57724. }
  57725. public function setDecorated($decorated)
  57726. {
  57727. $this->output->setDecorated($decorated);
  57728. }
  57729. public function isDecorated()
  57730. {
  57731. return $this->output->isDecorated();
  57732. }
  57733. public function setFormatter(OutputFormatterInterface $formatter)
  57734. {
  57735. $this->output->setFormatter($formatter);
  57736. }
  57737. public function getFormatter()
  57738. {
  57739. return $this->output->getFormatter();
  57740. }
  57741. }
  57742. <?php
  57743. namespace Symfony\Component\Console\Style;
  57744. interface StyleInterface
  57745. {
  57746. public function title($message);
  57747. public function section($message);
  57748. public function listing(array $elements);
  57749. public function text($message);
  57750. public function success($message);
  57751. public function error($message);
  57752. public function warning($message);
  57753. public function note($message);
  57754. public function caution($message);
  57755. public function table(array $headers, array $rows);
  57756. public function ask($question, $default = null, $validator = null);
  57757. public function askHidden($question, $validator = null);
  57758. public function confirm($question, $default = true);
  57759. public function choice($question, array $choices, $default = null);
  57760. public function newLine($count = 1);
  57761. public function progressStart($max = 0);
  57762. public function progressAdvance($step = 1);
  57763. public function progressFinish();
  57764. }
  57765. <?php
  57766. namespace Symfony\Component\Console\Style;
  57767. use Symfony\Component\Console\Application;
  57768. use Symfony\Component\Console\Exception\RuntimeException;
  57769. use Symfony\Component\Console\Formatter\OutputFormatter;
  57770. use Symfony\Component\Console\Helper\Helper;
  57771. use Symfony\Component\Console\Helper\ProgressBar;
  57772. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  57773. use Symfony\Component\Console\Helper\Table;
  57774. use Symfony\Component\Console\Input\InputInterface;
  57775. use Symfony\Component\Console\Output\BufferedOutput;
  57776. use Symfony\Component\Console\Output\OutputInterface;
  57777. use Symfony\Component\Console\Question\ChoiceQuestion;
  57778. use Symfony\Component\Console\Question\ConfirmationQuestion;
  57779. use Symfony\Component\Console\Question\Question;
  57780. class SymfonyStyle extends OutputStyle
  57781. {
  57782. const MAX_LINE_LENGTH = 120;
  57783. private $input;
  57784. private $questionHelper;
  57785. private $progressBar;
  57786. private $lineLength;
  57787. private $bufferedOutput;
  57788. public function __construct(InputInterface $input, OutputInterface $output)
  57789. {
  57790. $this->input = $input;
  57791. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  57792. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  57793. parent::__construct($output);
  57794. }
  57795. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  57796. {
  57797. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  57798. $this->autoPrependBlock();
  57799. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  57800. $this->newLine();
  57801. }
  57802. public function title($message)
  57803. {
  57804. $this->autoPrependBlock();
  57805. $this->writeln(array(
  57806. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  57807. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  57808. ));
  57809. $this->newLine();
  57810. }
  57811. public function section($message)
  57812. {
  57813. $this->autoPrependBlock();
  57814. $this->writeln(array(
  57815. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  57816. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  57817. ));
  57818. $this->newLine();
  57819. }
  57820. public function listing(array $elements)
  57821. {
  57822. $this->autoPrependText();
  57823. $elements = array_map(function ($element) {
  57824. return sprintf(' * %s', $element);
  57825. }, $elements);
  57826. $this->writeln($elements);
  57827. $this->newLine();
  57828. }
  57829. public function text($message)
  57830. {
  57831. $this->autoPrependText();
  57832. $messages = \is_array($message) ? array_values($message) : array($message);
  57833. foreach ($messages as $message) {
  57834. $this->writeln(sprintf(' %s', $message));
  57835. }
  57836. }
  57837. public function comment($message)
  57838. {
  57839. $messages = \is_array($message) ? array_values($message) : array($message);
  57840. $this->autoPrependBlock();
  57841. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  57842. $this->newLine();
  57843. }
  57844. public function success($message)
  57845. {
  57846. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  57847. }
  57848. public function error($message)
  57849. {
  57850. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  57851. }
  57852. public function warning($message)
  57853. {
  57854. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  57855. }
  57856. public function note($message)
  57857. {
  57858. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  57859. }
  57860. public function caution($message)
  57861. {
  57862. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  57863. }
  57864. public function table(array $headers, array $rows)
  57865. {
  57866. $style = clone Table::getStyleDefinition('symfony-style-guide');
  57867. $style->setCellHeaderFormat('<info>%s</info>');
  57868. $table = new Table($this);
  57869. $table->setHeaders($headers);
  57870. $table->setRows($rows);
  57871. $table->setStyle($style);
  57872. $table->render();
  57873. $this->newLine();
  57874. }
  57875. public function ask($question, $default = null, $validator = null)
  57876. {
  57877. $question = new Question($question, $default);
  57878. $question->setValidator($validator);
  57879. return $this->askQuestion($question);
  57880. }
  57881. public function askHidden($question, $validator = null)
  57882. {
  57883. $question = new Question($question);
  57884. $question->setHidden(true);
  57885. $question->setValidator($validator);
  57886. return $this->askQuestion($question);
  57887. }
  57888. public function confirm($question, $default = true)
  57889. {
  57890. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  57891. }
  57892. public function choice($question, array $choices, $default = null)
  57893. {
  57894. if (null !== $default) {
  57895. $values = array_flip($choices);
  57896. $default = $values[$default];
  57897. }
  57898. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  57899. }
  57900. public function progressStart($max = 0)
  57901. {
  57902. $this->progressBar = $this->createProgressBar($max);
  57903. $this->progressBar->start();
  57904. }
  57905. public function progressAdvance($step = 1)
  57906. {
  57907. $this->getProgressBar()->advance($step);
  57908. }
  57909. public function progressFinish()
  57910. {
  57911. $this->getProgressBar()->finish();
  57912. $this->newLine(2);
  57913. $this->progressBar = null;
  57914. }
  57915. public function createProgressBar($max = 0)
  57916. {
  57917. $progressBar = parent::createProgressBar($max);
  57918. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  57919. $progressBar->setEmptyBarCharacter('â–‘');
  57920. $progressBar->setProgressCharacter('');
  57921. $progressBar->setBarCharacter('â–“');
  57922. }
  57923. return $progressBar;
  57924. }
  57925. public function askQuestion(Question $question)
  57926. {
  57927. if ($this->input->isInteractive()) {
  57928. $this->autoPrependBlock();
  57929. }
  57930. if (!$this->questionHelper) {
  57931. $this->questionHelper = new SymfonyQuestionHelper();
  57932. }
  57933. $answer = $this->questionHelper->ask($this->input, $this, $question);
  57934. if ($this->input->isInteractive()) {
  57935. $this->newLine();
  57936. $this->bufferedOutput->write("\n");
  57937. }
  57938. return $answer;
  57939. }
  57940. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  57941. {
  57942. parent::writeln($messages, $type);
  57943. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  57944. }
  57945. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  57946. {
  57947. parent::write($messages, $newline, $type);
  57948. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  57949. }
  57950. public function newLine($count = 1)
  57951. {
  57952. parent::newLine($count);
  57953. $this->bufferedOutput->write(str_repeat("\n", $count));
  57954. }
  57955. private function getProgressBar()
  57956. {
  57957. if (!$this->progressBar) {
  57958. throw new RuntimeException('The ProgressBar is not started.');
  57959. }
  57960. return $this->progressBar;
  57961. }
  57962. private function getTerminalWidth()
  57963. {
  57964. $application = new Application();
  57965. $dimensions = $application->getTerminalDimensions();
  57966. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  57967. }
  57968. private function autoPrependBlock()
  57969. {
  57970. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  57971. if (!isset($chars[0])) {
  57972. return $this->newLine();
  57973. }
  57974. $this->newLine(2 - substr_count($chars, "\n"));
  57975. }
  57976. private function autoPrependText()
  57977. {
  57978. $fetched = $this->bufferedOutput->fetch();
  57979. if ("\n" !== substr($fetched, -1)) {
  57980. $this->newLine();
  57981. }
  57982. }
  57983. private function reduceBuffer($messages)
  57984. {
  57985. return array_map(function ($value) {
  57986. return substr($value, -4);
  57987. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  57988. }
  57989. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  57990. {
  57991. $indentLength = 0;
  57992. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  57993. $lines = array();
  57994. if (null !== $type) {
  57995. $type = sprintf('[%s] ', $type);
  57996. $indentLength = \strlen($type);
  57997. $lineIndentation = str_repeat(' ', $indentLength);
  57998. }
  57999. foreach ($messages as $key => $message) {
  58000. if ($escape) {
  58001. $message = OutputFormatter::escape($message);
  58002. }
  58003. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  58004. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  58005. $lines[] = '';
  58006. }
  58007. }
  58008. $firstLineIndex = 0;
  58009. if ($padding && $this->isDecorated()) {
  58010. $firstLineIndex = 1;
  58011. array_unshift($lines, '');
  58012. $lines[] = '';
  58013. }
  58014. foreach ($lines as $i => &$line) {
  58015. if (null !== $type) {
  58016. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  58017. }
  58018. $line = $prefix.$line;
  58019. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  58020. if ($style) {
  58021. $line = sprintf('<%s>%s</>', $style, $line);
  58022. }
  58023. }
  58024. return $lines;
  58025. }
  58026. }
  58027. <?php
  58028. namespace Symfony\Component\Console\Tester;
  58029. use Symfony\Component\Console\Application;
  58030. use Symfony\Component\Console\Input\ArrayInput;
  58031. use Symfony\Component\Console\Input\InputInterface;
  58032. use Symfony\Component\Console\Output\OutputInterface;
  58033. use Symfony\Component\Console\Output\StreamOutput;
  58034. class ApplicationTester
  58035. {
  58036. private $application;
  58037. private $input;
  58038. private $output;
  58039. private $statusCode;
  58040. public function __construct(Application $application)
  58041. {
  58042. $this->application = $application;
  58043. }
  58044. public function run(array $input, $options = array())
  58045. {
  58046. $this->input = new ArrayInput($input);
  58047. if (isset($options['interactive'])) {
  58048. $this->input->setInteractive($options['interactive']);
  58049. }
  58050. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  58051. if (isset($options['decorated'])) {
  58052. $this->output->setDecorated($options['decorated']);
  58053. }
  58054. if (isset($options['verbosity'])) {
  58055. $this->output->setVerbosity($options['verbosity']);
  58056. }
  58057. return $this->statusCode = $this->application->run($this->input, $this->output);
  58058. }
  58059. public function getDisplay($normalize = false)
  58060. {
  58061. rewind($this->output->getStream());
  58062. $display = stream_get_contents($this->output->getStream());
  58063. if ($normalize) {
  58064. $display = str_replace(PHP_EOL, "\n", $display);
  58065. }
  58066. return $display;
  58067. }
  58068. public function getInput()
  58069. {
  58070. return $this->input;
  58071. }
  58072. public function getOutput()
  58073. {
  58074. return $this->output;
  58075. }
  58076. public function getStatusCode()
  58077. {
  58078. return $this->statusCode;
  58079. }
  58080. }
  58081. <?php
  58082. namespace Symfony\Component\Console\Tester;
  58083. use Symfony\Component\Console\Command\Command;
  58084. use Symfony\Component\Console\Input\ArrayInput;
  58085. use Symfony\Component\Console\Input\InputInterface;
  58086. use Symfony\Component\Console\Output\OutputInterface;
  58087. use Symfony\Component\Console\Output\StreamOutput;
  58088. class CommandTester
  58089. {
  58090. private $command;
  58091. private $input;
  58092. private $output;
  58093. private $statusCode;
  58094. public function __construct(Command $command)
  58095. {
  58096. $this->command = $command;
  58097. }
  58098. public function execute(array $input, array $options = array())
  58099. {
  58100. if (!isset($input['command'])
  58101. && (null !== $application = $this->command->getApplication())
  58102. && $application->getDefinition()->hasArgument('command')
  58103. ) {
  58104. $input = array_merge(array('command' => $this->command->getName()), $input);
  58105. }
  58106. $this->input = new ArrayInput($input);
  58107. if (isset($options['interactive'])) {
  58108. $this->input->setInteractive($options['interactive']);
  58109. }
  58110. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  58111. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  58112. if (isset($options['verbosity'])) {
  58113. $this->output->setVerbosity($options['verbosity']);
  58114. }
  58115. return $this->statusCode = $this->command->run($this->input, $this->output);
  58116. }
  58117. public function getDisplay($normalize = false)
  58118. {
  58119. rewind($this->output->getStream());
  58120. $display = stream_get_contents($this->output->getStream());
  58121. if ($normalize) {
  58122. $display = str_replace(PHP_EOL, "\n", $display);
  58123. }
  58124. return $display;
  58125. }
  58126. public function getInput()
  58127. {
  58128. return $this->input;
  58129. }
  58130. public function getOutput()
  58131. {
  58132. return $this->output;
  58133. }
  58134. public function getStatusCode()
  58135. {
  58136. return $this->statusCode;
  58137. }
  58138. }
  58139. <?php
  58140. namespace Symfony\Component\Debug;
  58141. use Psr\Log\AbstractLogger;
  58142. class BufferingLogger extends AbstractLogger
  58143. {
  58144. private $logs = array();
  58145. public function log($level, $message, array $context = array())
  58146. {
  58147. $this->logs[] = array($level, $message, $context);
  58148. }
  58149. public function cleanLogs()
  58150. {
  58151. $logs = $this->logs;
  58152. $this->logs = array();
  58153. return $logs;
  58154. }
  58155. }
  58156. <?php
  58157. namespace Symfony\Component\Debug;
  58158. class Debug
  58159. {
  58160. private static $enabled = false;
  58161. public static function enable($errorReportingLevel = null, $displayErrors = true)
  58162. {
  58163. if (static::$enabled) {
  58164. return;
  58165. }
  58166. static::$enabled = true;
  58167. if (null !== $errorReportingLevel) {
  58168. error_reporting($errorReportingLevel);
  58169. } else {
  58170. error_reporting(-1);
  58171. }
  58172. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  58173. ini_set('display_errors', 0);
  58174. ExceptionHandler::register();
  58175. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  58176. ini_set('display_errors', 1);
  58177. }
  58178. if ($displayErrors) {
  58179. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  58180. } else {
  58181. ErrorHandler::register()->throwAt(0, true);
  58182. }
  58183. DebugClassLoader::enable();
  58184. }
  58185. }
  58186. <?php
  58187. namespace Symfony\Component\Debug;
  58188. class DebugClassLoader
  58189. {
  58190. private $classLoader;
  58191. private $isFinder;
  58192. private $loaded = array();
  58193. private $wasFinder;
  58194. private static $caseCheck;
  58195. private static $deprecated = array();
  58196. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  58197. private static $darwinCache = array('/' => array('/', array()));
  58198. public function __construct($classLoader)
  58199. {
  58200. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  58201. if ($this->wasFinder) {
  58202. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  58203. $this->classLoader = array($classLoader, 'loadClass');
  58204. $this->isFinder = true;
  58205. } else {
  58206. $this->classLoader = $classLoader;
  58207. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  58208. }
  58209. if (!isset(self::$caseCheck)) {
  58210. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  58211. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  58212. $dir = substr($file, 0, 1 + $i);
  58213. $file = substr($file, 1 + $i);
  58214. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  58215. $test = realpath($dir.$test);
  58216. if (false === $test || false === $i) {
  58217. self::$caseCheck = 0;
  58218. } elseif (substr($test, -\strlen($file)) === $file) {
  58219. self::$caseCheck = 1;
  58220. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  58221. self::$caseCheck = 2;
  58222. } else {
  58223. self::$caseCheck = 0;
  58224. }
  58225. }
  58226. }
  58227. public function getClassLoader()
  58228. {
  58229. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  58230. }
  58231. public static function enable()
  58232. {
  58233. class_exists('Symfony\Component\Debug\ErrorHandler');
  58234. class_exists('Psr\Log\LogLevel');
  58235. if (!\is_array($functions = spl_autoload_functions())) {
  58236. return;
  58237. }
  58238. foreach ($functions as $function) {
  58239. spl_autoload_unregister($function);
  58240. }
  58241. foreach ($functions as $function) {
  58242. if (!\is_array($function) || !$function[0] instanceof self) {
  58243. $function = array(new static($function), 'loadClass');
  58244. }
  58245. spl_autoload_register($function);
  58246. }
  58247. }
  58248. public static function disable()
  58249. {
  58250. if (!\is_array($functions = spl_autoload_functions())) {
  58251. return;
  58252. }
  58253. foreach ($functions as $function) {
  58254. spl_autoload_unregister($function);
  58255. }
  58256. foreach ($functions as $function) {
  58257. if (\is_array($function) && $function[0] instanceof self) {
  58258. $function = $function[0]->getClassLoader();
  58259. }
  58260. spl_autoload_register($function);
  58261. }
  58262. }
  58263. public function findFile($class)
  58264. {
  58265. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  58266. if ($this->wasFinder) {
  58267. return $this->classLoader[0]->findFile($class);
  58268. }
  58269. }
  58270. public function loadClass($class)
  58271. {
  58272. ErrorHandler::stackErrors();
  58273. try {
  58274. if ($this->isFinder && !isset($this->loaded[$class])) {
  58275. $this->loaded[$class] = true;
  58276. if ($file = $this->classLoader[0]->findFile($class)) {
  58277. require $file;
  58278. }
  58279. } else {
  58280. \call_user_func($this->classLoader, $class);
  58281. $file = false;
  58282. }
  58283. } catch (\Exception $e) {
  58284. ErrorHandler::unstackErrors();
  58285. throw $e;
  58286. } catch (\Throwable $e) {
  58287. ErrorHandler::unstackErrors();
  58288. throw $e;
  58289. }
  58290. ErrorHandler::unstackErrors();
  58291. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  58292. if ($class && '\\' === $class[0]) {
  58293. $class = substr($class, 1);
  58294. }
  58295. if ($exists) {
  58296. $refl = new \ReflectionClass($class);
  58297. $name = $refl->getName();
  58298. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  58299. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  58300. }
  58301. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  58302. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  58303. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  58304. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  58305. } else {
  58306. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  58307. $len = 0;
  58308. $ns = '';
  58309. } else {
  58310. $ns = substr($name, 0, $len);
  58311. }
  58312. $parent = get_parent_class($class);
  58313. if (!$parent || strncmp($ns, $parent, $len)) {
  58314. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  58315. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  58316. }
  58317. $parentInterfaces = array();
  58318. $deprecatedInterfaces = array();
  58319. if ($parent) {
  58320. foreach (class_implements($parent) as $interface) {
  58321. $parentInterfaces[$interface] = 1;
  58322. }
  58323. }
  58324. foreach ($refl->getInterfaceNames() as $interface) {
  58325. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  58326. $deprecatedInterfaces[] = $interface;
  58327. }
  58328. foreach (class_implements($interface) as $interface) {
  58329. $parentInterfaces[$interface] = 1;
  58330. }
  58331. }
  58332. foreach ($deprecatedInterfaces as $interface) {
  58333. if (!isset($parentInterfaces[$interface])) {
  58334. @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);
  58335. }
  58336. }
  58337. }
  58338. }
  58339. }
  58340. if ($file) {
  58341. if (!$exists) {
  58342. if (false !== strpos($class, '/')) {
  58343. 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));
  58344. }
  58345. 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));
  58346. }
  58347. if (self::$caseCheck) {
  58348. $real = explode('\\', $class.strrchr($file, '.'));
  58349. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  58350. $i = \count($tail) - 1;
  58351. $j = \count($real) - 1;
  58352. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  58353. --$i;
  58354. --$j;
  58355. }
  58356. array_splice($tail, 0, $i + 1);
  58357. }
  58358. if (self::$caseCheck && $tail) {
  58359. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  58360. $tailLen = \strlen($tail);
  58361. $real = $refl->getFileName();
  58362. if (2 === self::$caseCheck) {
  58363. $i = 1 + strrpos($real, '/');
  58364. $file = substr($real, $i);
  58365. $real = substr($real, 0, $i);
  58366. if (isset(self::$darwinCache[$real])) {
  58367. $kDir = $real;
  58368. } else {
  58369. $kDir = strtolower($real);
  58370. if (isset(self::$darwinCache[$kDir])) {
  58371. $real = self::$darwinCache[$kDir][0];
  58372. } else {
  58373. $dir = getcwd();
  58374. chdir($real);
  58375. $real = getcwd().'/';
  58376. chdir($dir);
  58377. $dir = $real;
  58378. $k = $kDir;
  58379. $i = \strlen($dir) - 1;
  58380. while (!isset(self::$darwinCache[$k])) {
  58381. self::$darwinCache[$k] = array($dir, array());
  58382. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  58383. while ('/' !== $dir[--$i]) {
  58384. }
  58385. $k = substr($k, 0, ++$i);
  58386. $dir = substr($dir, 0, $i--);
  58387. }
  58388. }
  58389. }
  58390. $dirFiles = self::$darwinCache[$kDir][1];
  58391. if (isset($dirFiles[$file])) {
  58392. $kFile = $file;
  58393. } else {
  58394. $kFile = strtolower($file);
  58395. if (!isset($dirFiles[$kFile])) {
  58396. foreach (scandir($real, 2) as $f) {
  58397. if ('.' !== $f[0]) {
  58398. $dirFiles[$f] = $f;
  58399. if ($f === $file) {
  58400. $kFile = $k = $file;
  58401. } elseif ($f !== $k = strtolower($f)) {
  58402. $dirFiles[$k] = $f;
  58403. }
  58404. }
  58405. }
  58406. self::$darwinCache[$kDir][1] = $dirFiles;
  58407. }
  58408. }
  58409. $real .= $dirFiles[$kFile];
  58410. }
  58411. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  58412. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  58413. ) {
  58414. 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)));
  58415. }
  58416. }
  58417. return true;
  58418. }
  58419. }
  58420. }
  58421. <?php
  58422. namespace Symfony\Component\Debug;
  58423. use Psr\Log\LoggerInterface;
  58424. use Psr\Log\LogLevel;
  58425. use Symfony\Component\Debug\Exception\ContextErrorException;
  58426. use Symfony\Component\Debug\Exception\FatalErrorException;
  58427. use Symfony\Component\Debug\Exception\FatalThrowableError;
  58428. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  58429. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  58430. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  58431. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  58432. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  58433. class ErrorHandler
  58434. {
  58435. const TYPE_DEPRECATION = -100;
  58436. private $levels = array(
  58437. E_DEPRECATED => 'Deprecated',
  58438. E_USER_DEPRECATED => 'User Deprecated',
  58439. E_NOTICE => 'Notice',
  58440. E_USER_NOTICE => 'User Notice',
  58441. E_STRICT => 'Runtime Notice',
  58442. E_WARNING => 'Warning',
  58443. E_USER_WARNING => 'User Warning',
  58444. E_COMPILE_WARNING => 'Compile Warning',
  58445. E_CORE_WARNING => 'Core Warning',
  58446. E_USER_ERROR => 'User Error',
  58447. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  58448. E_COMPILE_ERROR => 'Compile Error',
  58449. E_PARSE => 'Parse Error',
  58450. E_ERROR => 'Error',
  58451. E_CORE_ERROR => 'Core Error',
  58452. );
  58453. private $loggers = array(
  58454. E_DEPRECATED => array(null, LogLevel::INFO),
  58455. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  58456. E_NOTICE => array(null, LogLevel::WARNING),
  58457. E_USER_NOTICE => array(null, LogLevel::WARNING),
  58458. E_STRICT => array(null, LogLevel::WARNING),
  58459. E_WARNING => array(null, LogLevel::WARNING),
  58460. E_USER_WARNING => array(null, LogLevel::WARNING),
  58461. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  58462. E_CORE_WARNING => array(null, LogLevel::WARNING),
  58463. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  58464. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  58465. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  58466. E_PARSE => array(null, LogLevel::CRITICAL),
  58467. E_ERROR => array(null, LogLevel::CRITICAL),
  58468. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  58469. );
  58470. private $thrownErrors = 0x1FFF;
  58471. private $scopedErrors = 0x1FFF;
  58472. private $tracedErrors = 0x77FB;
  58473. private $screamedErrors = 0x55;
  58474. private $loggedErrors = 0;
  58475. private $loggedTraces = array();
  58476. private $isRecursive = 0;
  58477. private $isRoot = false;
  58478. private $exceptionHandler;
  58479. private $bootstrappingLogger;
  58480. private static $reservedMemory;
  58481. private static $stackedErrors = array();
  58482. private static $stackedErrorLevels = array();
  58483. private static $toStringException = null;
  58484. private static $exitCode = 0;
  58485. private $displayErrors = 0x1FFF;
  58486. public static function register($handler = null, $replace = true)
  58487. {
  58488. if (null === self::$reservedMemory) {
  58489. self::$reservedMemory = str_repeat('x', 10240);
  58490. register_shutdown_function(__CLASS__.'::handleFatalError');
  58491. }
  58492. $levels = -1;
  58493. if ($handlerIsNew = !$handler instanceof self) {
  58494. if (null !== $handler) {
  58495. $levels = $replace ? $handler : 0;
  58496. $replace = true;
  58497. }
  58498. $handler = new static();
  58499. }
  58500. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  58501. restore_error_handler();
  58502. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  58503. $handler->isRoot = true;
  58504. }
  58505. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  58506. $handler = $prev[0];
  58507. $replace = false;
  58508. }
  58509. if (!$replace && $prev) {
  58510. restore_error_handler();
  58511. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  58512. } else {
  58513. $handlerIsRegistered = true;
  58514. }
  58515. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  58516. restore_exception_handler();
  58517. if (!$handlerIsRegistered) {
  58518. $handler = $prev[0];
  58519. } elseif ($handler !== $prev[0] && $replace) {
  58520. set_exception_handler(array($handler, 'handleException'));
  58521. $p = $prev[0]->setExceptionHandler(null);
  58522. $handler->setExceptionHandler($p);
  58523. $prev[0]->setExceptionHandler($p);
  58524. }
  58525. } else {
  58526. $handler->setExceptionHandler($prev);
  58527. }
  58528. $handler->throwAt($levels & $handler->thrownErrors, true);
  58529. return $handler;
  58530. }
  58531. public function __construct(BufferingLogger $bootstrappingLogger = null)
  58532. {
  58533. if ($bootstrappingLogger) {
  58534. $this->bootstrappingLogger = $bootstrappingLogger;
  58535. $this->setDefaultLogger($bootstrappingLogger);
  58536. }
  58537. }
  58538. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  58539. {
  58540. $loggers = array();
  58541. if (\is_array($levels)) {
  58542. foreach ($levels as $type => $logLevel) {
  58543. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  58544. $loggers[$type] = array($logger, $logLevel);
  58545. }
  58546. }
  58547. } else {
  58548. if (null === $levels) {
  58549. $levels = E_ALL | E_STRICT;
  58550. }
  58551. foreach ($this->loggers as $type => $log) {
  58552. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  58553. $log[0] = $logger;
  58554. $loggers[$type] = $log;
  58555. }
  58556. }
  58557. }
  58558. $this->setLoggers($loggers);
  58559. }
  58560. public function setLoggers(array $loggers)
  58561. {
  58562. $prevLogged = $this->loggedErrors;
  58563. $prev = $this->loggers;
  58564. $flush = array();
  58565. foreach ($loggers as $type => $log) {
  58566. if (!isset($prev[$type])) {
  58567. throw new \InvalidArgumentException('Unknown error type: '.$type);
  58568. }
  58569. if (!\is_array($log)) {
  58570. $log = array($log);
  58571. } elseif (!array_key_exists(0, $log)) {
  58572. throw new \InvalidArgumentException('No logger provided');
  58573. }
  58574. if (null === $log[0]) {
  58575. $this->loggedErrors &= ~$type;
  58576. } elseif ($log[0] instanceof LoggerInterface) {
  58577. $this->loggedErrors |= $type;
  58578. } else {
  58579. throw new \InvalidArgumentException('Invalid logger provided');
  58580. }
  58581. $this->loggers[$type] = $log + $prev[$type];
  58582. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  58583. $flush[$type] = $type;
  58584. }
  58585. }
  58586. $this->reRegister($prevLogged | $this->thrownErrors);
  58587. if ($flush) {
  58588. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  58589. $type = $log[2]['type'];
  58590. if (!isset($flush[$type])) {
  58591. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  58592. } elseif ($this->loggers[$type][0]) {
  58593. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  58594. }
  58595. }
  58596. }
  58597. return $prev;
  58598. }
  58599. public function setExceptionHandler($handler)
  58600. {
  58601. if (null !== $handler && !\is_callable($handler)) {
  58602. throw new \LogicException('The exception handler must be a valid PHP callable.');
  58603. }
  58604. $prev = $this->exceptionHandler;
  58605. $this->exceptionHandler = $handler;
  58606. return $prev;
  58607. }
  58608. public function throwAt($levels, $replace = false)
  58609. {
  58610. $prev = $this->thrownErrors;
  58611. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  58612. if (!$replace) {
  58613. $this->thrownErrors |= $prev;
  58614. }
  58615. $this->reRegister($prev | $this->loggedErrors);
  58616. $this->displayErrors = $this->thrownErrors;
  58617. return $prev;
  58618. }
  58619. public function scopeAt($levels, $replace = false)
  58620. {
  58621. $prev = $this->scopedErrors;
  58622. $this->scopedErrors = (int) $levels;
  58623. if (!$replace) {
  58624. $this->scopedErrors |= $prev;
  58625. }
  58626. return $prev;
  58627. }
  58628. public function traceAt($levels, $replace = false)
  58629. {
  58630. $prev = $this->tracedErrors;
  58631. $this->tracedErrors = (int) $levels;
  58632. if (!$replace) {
  58633. $this->tracedErrors |= $prev;
  58634. }
  58635. return $prev;
  58636. }
  58637. public function screamAt($levels, $replace = false)
  58638. {
  58639. $prev = $this->screamedErrors;
  58640. $this->screamedErrors = (int) $levels;
  58641. if (!$replace) {
  58642. $this->screamedErrors |= $prev;
  58643. }
  58644. return $prev;
  58645. }
  58646. private function reRegister($prev)
  58647. {
  58648. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  58649. $handler = set_error_handler('var_dump');
  58650. $handler = \is_array($handler) ? $handler[0] : null;
  58651. restore_error_handler();
  58652. if ($handler === $this) {
  58653. restore_error_handler();
  58654. if ($this->isRoot) {
  58655. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  58656. } else {
  58657. set_error_handler(array($this, 'handleError'));
  58658. }
  58659. }
  58660. }
  58661. }
  58662. public function handleError($type, $message, $file, $line)
  58663. {
  58664. $level = error_reporting();
  58665. $silenced = 0 === ($level & $type);
  58666. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  58667. $log = $this->loggedErrors & $type;
  58668. $throw = $this->thrownErrors & $type & $level;
  58669. $type &= $level | $this->screamedErrors;
  58670. if (!$type || (!$log && !$throw)) {
  58671. return !$silenced && $type && $log;
  58672. }
  58673. $scope = $this->scopedErrors & $type;
  58674. if (4 < $numArgs = \func_num_args()) {
  58675. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  58676. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  58677. } else {
  58678. $context = array();
  58679. $backtrace = null;
  58680. }
  58681. if (isset($context['GLOBALS']) && $scope) {
  58682. $e = $context;
  58683. unset($e['GLOBALS'], $context);
  58684. $context = $e;
  58685. }
  58686. if (null !== $backtrace && $type & E_ERROR) {
  58687. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  58688. return true;
  58689. }
  58690. if ($throw) {
  58691. if (null !== self::$toStringException) {
  58692. $throw = self::$toStringException;
  58693. self::$toStringException = null;
  58694. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  58695. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  58696. } else {
  58697. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  58698. }
  58699. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  58700. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  58701. }
  58702. if (E_USER_ERROR & $type) {
  58703. $backtrace = $backtrace ?: $throw->getTrace();
  58704. for ($i = 1; isset($backtrace[$i]); ++$i) {
  58705. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  58706. && '__toString' === $backtrace[$i]['function']
  58707. && '->' === $backtrace[$i]['type']
  58708. && !isset($backtrace[$i - 1]['class'])
  58709. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  58710. ) {
  58711. foreach ($context as $e) {
  58712. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  58713. if (1 === $i) {
  58714. $throw = $e;
  58715. break;
  58716. }
  58717. self::$toStringException = $e;
  58718. return true;
  58719. }
  58720. }
  58721. if (1 < $i) {
  58722. $this->handleException($throw);
  58723. return false;
  58724. }
  58725. }
  58726. }
  58727. }
  58728. throw $throw;
  58729. }
  58730. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  58731. $trace = true;
  58732. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  58733. $trace = false;
  58734. } else {
  58735. $this->loggedTraces[$e] = 1;
  58736. }
  58737. $e = compact('type', 'file', 'line', 'level');
  58738. if ($type & $level) {
  58739. if ($scope) {
  58740. $e['scope_vars'] = $context;
  58741. if ($trace) {
  58742. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  58743. }
  58744. } elseif ($trace) {
  58745. if (null === $backtrace) {
  58746. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  58747. } else {
  58748. foreach ($backtrace as &$frame) {
  58749. unset($frame['args'], $frame);
  58750. }
  58751. $e['stack'] = $backtrace;
  58752. }
  58753. }
  58754. }
  58755. if ($this->isRecursive) {
  58756. $log = 0;
  58757. } elseif (self::$stackedErrorLevels) {
  58758. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  58759. } else {
  58760. try {
  58761. $this->isRecursive = true;
  58762. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  58763. $this->isRecursive = false;
  58764. } catch (\Exception $e) {
  58765. $this->isRecursive = false;
  58766. throw $e;
  58767. } catch (\Throwable $e) {
  58768. $this->isRecursive = false;
  58769. throw $e;
  58770. }
  58771. }
  58772. return !$silenced && $type && $log;
  58773. }
  58774. public function handleException($exception, array $error = null)
  58775. {
  58776. if (null === $error) {
  58777. self::$exitCode = 255;
  58778. }
  58779. if (!$exception instanceof \Exception) {
  58780. $exception = new FatalThrowableError($exception);
  58781. }
  58782. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  58783. $handlerException = null;
  58784. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  58785. $e = array(
  58786. 'type' => $type,
  58787. 'file' => $exception->getFile(),
  58788. 'line' => $exception->getLine(),
  58789. 'level' => error_reporting(),
  58790. 'stack' => $exception->getTrace(),
  58791. );
  58792. if ($exception instanceof FatalErrorException) {
  58793. if ($exception instanceof FatalThrowableError) {
  58794. $error = array(
  58795. 'type' => $type,
  58796. 'message' => $message = $exception->getMessage(),
  58797. 'file' => $e['file'],
  58798. 'line' => $e['line'],
  58799. );
  58800. } else {
  58801. $message = 'Fatal '.$exception->getMessage();
  58802. }
  58803. } elseif ($exception instanceof \ErrorException) {
  58804. $message = 'Uncaught '.$exception->getMessage();
  58805. if ($exception instanceof ContextErrorException) {
  58806. $e['context'] = $exception->getContext();
  58807. }
  58808. } else {
  58809. $message = 'Uncaught Exception: '.$exception->getMessage();
  58810. }
  58811. }
  58812. if ($this->loggedErrors & $type) {
  58813. try {
  58814. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  58815. } catch (\Exception $handlerException) {
  58816. } catch (\Throwable $handlerException) {
  58817. }
  58818. }
  58819. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  58820. foreach ($this->getFatalErrorHandlers() as $handler) {
  58821. if ($e = $handler->handleError($error, $exception)) {
  58822. $exception = $e;
  58823. break;
  58824. }
  58825. }
  58826. }
  58827. $exceptionHandler = $this->exceptionHandler;
  58828. $this->exceptionHandler = null;
  58829. try {
  58830. if (null !== $exceptionHandler) {
  58831. return \call_user_func($exceptionHandler, $exception);
  58832. }
  58833. $handlerException = $handlerException ?: $exception;
  58834. } catch (\Exception $handlerException) {
  58835. } catch (\Throwable $handlerException) {
  58836. }
  58837. if ($exception === $handlerException) {
  58838. self::$reservedMemory = null;
  58839. throw $exception;
  58840. }
  58841. $this->handleException($handlerException);
  58842. }
  58843. public static function handleFatalError(array $error = null)
  58844. {
  58845. if (null === self::$reservedMemory) {
  58846. return;
  58847. }
  58848. $handler = self::$reservedMemory = null;
  58849. $handlers = array();
  58850. $previousHandler = null;
  58851. $sameHandlerLimit = 10;
  58852. while (!\is_array($handler) || !$handler[0] instanceof self) {
  58853. $handler = set_exception_handler('var_dump');
  58854. restore_exception_handler();
  58855. if (!$handler) {
  58856. break;
  58857. }
  58858. restore_exception_handler();
  58859. if ($handler !== $previousHandler) {
  58860. array_unshift($handlers, $handler);
  58861. $previousHandler = $handler;
  58862. } elseif (0 === --$sameHandlerLimit) {
  58863. $handler = null;
  58864. break;
  58865. }
  58866. }
  58867. foreach ($handlers as $h) {
  58868. set_exception_handler($h);
  58869. }
  58870. if (!$handler) {
  58871. return;
  58872. }
  58873. if ($handler !== $h) {
  58874. $handler[0]->setExceptionHandler($h);
  58875. }
  58876. $handler = $handler[0];
  58877. $handlers = array();
  58878. if ($exit = null === $error) {
  58879. $error = error_get_last();
  58880. }
  58881. try {
  58882. while (self::$stackedErrorLevels) {
  58883. static::unstackErrors();
  58884. }
  58885. } catch (\Exception $exception) {
  58886. } catch (\Throwable $exception) {
  58887. }
  58888. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  58889. $handler->throwAt(0, true);
  58890. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  58891. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  58892. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  58893. } else {
  58894. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  58895. }
  58896. }
  58897. try {
  58898. if (isset($exception)) {
  58899. self::$exitCode = 255;
  58900. $handler->handleException($exception, $error);
  58901. }
  58902. } catch (FatalErrorException $e) {
  58903. }
  58904. if ($exit && self::$exitCode) {
  58905. $exitCode = self::$exitCode;
  58906. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  58907. }
  58908. }
  58909. public static function stackErrors()
  58910. {
  58911. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  58912. }
  58913. public static function unstackErrors()
  58914. {
  58915. $level = array_pop(self::$stackedErrorLevels);
  58916. if (null !== $level) {
  58917. $e = error_reporting($level);
  58918. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  58919. error_reporting($e);
  58920. }
  58921. }
  58922. if (empty(self::$stackedErrorLevels)) {
  58923. $errors = self::$stackedErrors;
  58924. self::$stackedErrors = array();
  58925. foreach ($errors as $e) {
  58926. $e[0]->log($e[1], $e[2], $e[3]);
  58927. }
  58928. }
  58929. }
  58930. protected function getFatalErrorHandlers()
  58931. {
  58932. return array(
  58933. new UndefinedFunctionFatalErrorHandler(),
  58934. new UndefinedMethodFatalErrorHandler(),
  58935. new ClassNotFoundFatalErrorHandler(),
  58936. );
  58937. }
  58938. public function setLevel($level)
  58939. {
  58940. @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);
  58941. $level = null === $level ? error_reporting() : $level;
  58942. $this->throwAt($level, true);
  58943. }
  58944. public function setDisplayErrors($displayErrors)
  58945. {
  58946. @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);
  58947. if ($displayErrors) {
  58948. $this->throwAt($this->displayErrors, true);
  58949. } else {
  58950. $displayErrors = $this->displayErrors;
  58951. $this->throwAt(0, true);
  58952. $this->displayErrors = $displayErrors;
  58953. }
  58954. }
  58955. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  58956. {
  58957. @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);
  58958. $handler = set_error_handler('var_dump');
  58959. $handler = \is_array($handler) ? $handler[0] : null;
  58960. restore_error_handler();
  58961. if (!$handler instanceof self) {
  58962. return;
  58963. }
  58964. if ('deprecation' === $channel) {
  58965. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  58966. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  58967. } elseif ('scream' === $channel) {
  58968. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  58969. $handler->screamAt(E_ALL | E_STRICT);
  58970. } elseif ('emergency' === $channel) {
  58971. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  58972. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  58973. }
  58974. }
  58975. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  58976. {
  58977. $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());
  58978. return $this->handleError($level, $message, $file, $line, (array) $context);
  58979. }
  58980. public function handleFatal()
  58981. {
  58982. @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);
  58983. static::handleFatalError();
  58984. }
  58985. }
  58986. class ErrorHandlerCanary
  58987. {
  58988. private static $displayErrors = null;
  58989. public function __construct()
  58990. {
  58991. if (null === self::$displayErrors) {
  58992. self::$displayErrors = ini_set('display_errors', 1);
  58993. }
  58994. }
  58995. public function __destruct()
  58996. {
  58997. if (null !== self::$displayErrors) {
  58998. ini_set('display_errors', self::$displayErrors);
  58999. self::$displayErrors = null;
  59000. }
  59001. }
  59002. }
  59003. <?php
  59004. namespace Symfony\Component\Debug\Exception;
  59005. class ClassNotFoundException extends FatalErrorException
  59006. {
  59007. public function __construct($message, \ErrorException $previous)
  59008. {
  59009. parent::__construct(
  59010. $message,
  59011. $previous->getCode(),
  59012. $previous->getSeverity(),
  59013. $previous->getFile(),
  59014. $previous->getLine(),
  59015. null,
  59016. true,
  59017. null,
  59018. $previous->getPrevious()
  59019. );
  59020. $this->setTrace($previous->getTrace());
  59021. }
  59022. }
  59023. <?php
  59024. namespace Symfony\Component\Debug\Exception;
  59025. class ContextErrorException extends \ErrorException
  59026. {
  59027. private $context = array();
  59028. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  59029. {
  59030. parent::__construct($message, $code, $severity, $filename, $lineno);
  59031. $this->context = $context;
  59032. }
  59033. public function getContext()
  59034. {
  59035. return $this->context;
  59036. }
  59037. }
  59038. <?php
  59039. namespace Symfony\Component\Debug\Exception;
  59040. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  59041. class DummyException extends \ErrorException
  59042. {
  59043. }
  59044. <?php
  59045. namespace Symfony\Component\HttpKernel\Exception;
  59046. class FatalErrorException extends \ErrorException
  59047. {
  59048. }
  59049. namespace Symfony\Component\Debug\Exception;
  59050. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  59051. class FatalErrorException extends LegacyFatalErrorException
  59052. {
  59053. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  59054. {
  59055. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  59056. if (null !== $trace) {
  59057. if (!$traceArgs) {
  59058. foreach ($trace as &$frame) {
  59059. unset($frame['args'], $frame['this'], $frame);
  59060. }
  59061. }
  59062. $this->setTrace($trace);
  59063. } elseif (null !== $traceOffset) {
  59064. if (\function_exists('xdebug_get_function_stack')) {
  59065. $trace = xdebug_get_function_stack();
  59066. if (0 < $traceOffset) {
  59067. array_splice($trace, -$traceOffset);
  59068. }
  59069. foreach ($trace as &$frame) {
  59070. if (!isset($frame['type'])) {
  59071. if (isset($frame['class'])) {
  59072. $frame['type'] = '::';
  59073. }
  59074. } elseif ('dynamic' === $frame['type']) {
  59075. $frame['type'] = '->';
  59076. } elseif ('static' === $frame['type']) {
  59077. $frame['type'] = '::';
  59078. }
  59079. if (!$traceArgs) {
  59080. unset($frame['params'], $frame['args']);
  59081. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  59082. $frame['args'] = $frame['params'];
  59083. unset($frame['params']);
  59084. }
  59085. }
  59086. unset($frame);
  59087. $trace = array_reverse($trace);
  59088. } elseif (\function_exists('symfony_debug_backtrace')) {
  59089. $trace = symfony_debug_backtrace();
  59090. if (0 < $traceOffset) {
  59091. array_splice($trace, 0, $traceOffset);
  59092. }
  59093. } else {
  59094. $trace = array();
  59095. }
  59096. $this->setTrace($trace);
  59097. }
  59098. }
  59099. protected function setTrace($trace)
  59100. {
  59101. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  59102. $traceReflector->setAccessible(true);
  59103. $traceReflector->setValue($this, $trace);
  59104. }
  59105. }
  59106. <?php
  59107. namespace Symfony\Component\Debug\Exception;
  59108. class FatalThrowableError extends FatalErrorException
  59109. {
  59110. public function __construct(\Throwable $e)
  59111. {
  59112. if ($e instanceof \ParseError) {
  59113. $message = 'Parse error: '.$e->getMessage();
  59114. $severity = E_PARSE;
  59115. } elseif ($e instanceof \TypeError) {
  59116. $message = 'Type error: '.$e->getMessage();
  59117. $severity = E_RECOVERABLE_ERROR;
  59118. } else {
  59119. $message = $e->getMessage();
  59120. $severity = E_ERROR;
  59121. }
  59122. \ErrorException::__construct(
  59123. $message,
  59124. $e->getCode(),
  59125. $severity,
  59126. $e->getFile(),
  59127. $e->getLine(),
  59128. $e->getPrevious()
  59129. );
  59130. $this->setTrace($e->getTrace());
  59131. }
  59132. }
  59133. <?php
  59134. namespace Symfony\Component\HttpKernel\Exception;
  59135. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  59136. class FlattenException
  59137. {
  59138. private $handler;
  59139. public static function __callStatic($method, $args)
  59140. {
  59141. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  59142. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  59143. }
  59144. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  59145. }
  59146. public function __call($method, $args)
  59147. {
  59148. if (!isset($this->handler)) {
  59149. $this->handler = new DebugFlattenException();
  59150. }
  59151. if (!method_exists($this->handler, $method)) {
  59152. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  59153. }
  59154. return \call_user_func_array(array($this->handler, $method), $args);
  59155. }
  59156. }
  59157. namespace Symfony\Component\Debug\Exception;
  59158. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  59159. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  59160. class FlattenException extends LegacyFlattenException
  59161. {
  59162. private $message;
  59163. private $code;
  59164. private $previous;
  59165. private $trace;
  59166. private $class;
  59167. private $statusCode;
  59168. private $headers;
  59169. private $file;
  59170. private $line;
  59171. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  59172. {
  59173. $e = new static();
  59174. $e->setMessage($exception->getMessage());
  59175. $e->setCode($exception->getCode());
  59176. if ($exception instanceof HttpExceptionInterface) {
  59177. $statusCode = $exception->getStatusCode();
  59178. $headers = array_merge($headers, $exception->getHeaders());
  59179. }
  59180. if (null === $statusCode) {
  59181. $statusCode = 500;
  59182. }
  59183. $e->setStatusCode($statusCode);
  59184. $e->setHeaders($headers);
  59185. $e->setTraceFromException($exception);
  59186. $e->setClass(\get_class($exception));
  59187. $e->setFile($exception->getFile());
  59188. $e->setLine($exception->getLine());
  59189. $previous = $exception->getPrevious();
  59190. if ($previous instanceof \Exception) {
  59191. $e->setPrevious(static::create($previous));
  59192. } elseif ($previous instanceof \Throwable) {
  59193. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  59194. }
  59195. return $e;
  59196. }
  59197. public function toArray()
  59198. {
  59199. $exceptions = array();
  59200. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  59201. $exceptions[] = array(
  59202. 'message' => $exception->getMessage(),
  59203. 'class' => $exception->getClass(),
  59204. 'trace' => $exception->getTrace(),
  59205. );
  59206. }
  59207. return $exceptions;
  59208. }
  59209. public function getStatusCode()
  59210. {
  59211. return $this->statusCode;
  59212. }
  59213. public function setStatusCode($code)
  59214. {
  59215. $this->statusCode = $code;
  59216. }
  59217. public function getHeaders()
  59218. {
  59219. return $this->headers;
  59220. }
  59221. public function setHeaders(array $headers)
  59222. {
  59223. $this->headers = $headers;
  59224. }
  59225. public function getClass()
  59226. {
  59227. return $this->class;
  59228. }
  59229. public function setClass($class)
  59230. {
  59231. $this->class = $class;
  59232. }
  59233. public function getFile()
  59234. {
  59235. return $this->file;
  59236. }
  59237. public function setFile($file)
  59238. {
  59239. $this->file = $file;
  59240. }
  59241. public function getLine()
  59242. {
  59243. return $this->line;
  59244. }
  59245. public function setLine($line)
  59246. {
  59247. $this->line = $line;
  59248. }
  59249. public function getMessage()
  59250. {
  59251. return $this->message;
  59252. }
  59253. public function setMessage($message)
  59254. {
  59255. $this->message = $message;
  59256. }
  59257. public function getCode()
  59258. {
  59259. return $this->code;
  59260. }
  59261. public function setCode($code)
  59262. {
  59263. $this->code = $code;
  59264. }
  59265. public function getPrevious()
  59266. {
  59267. return $this->previous;
  59268. }
  59269. public function setPrevious(FlattenException $previous)
  59270. {
  59271. $this->previous = $previous;
  59272. }
  59273. public function getAllPrevious()
  59274. {
  59275. $exceptions = array();
  59276. $e = $this;
  59277. while ($e = $e->getPrevious()) {
  59278. $exceptions[] = $e;
  59279. }
  59280. return $exceptions;
  59281. }
  59282. public function getTrace()
  59283. {
  59284. return $this->trace;
  59285. }
  59286. public function setTraceFromException(\Exception $exception)
  59287. {
  59288. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  59289. }
  59290. public function setTrace($trace, $file, $line)
  59291. {
  59292. $this->trace = array();
  59293. $this->trace[] = array(
  59294. 'namespace' => '',
  59295. 'short_class' => '',
  59296. 'class' => '',
  59297. 'type' => '',
  59298. 'function' => '',
  59299. 'file' => $file,
  59300. 'line' => $line,
  59301. 'args' => array(),
  59302. );
  59303. foreach ($trace as $entry) {
  59304. $class = '';
  59305. $namespace = '';
  59306. if (isset($entry['class'])) {
  59307. $parts = explode('\\', $entry['class']);
  59308. $class = array_pop($parts);
  59309. $namespace = implode('\\', $parts);
  59310. }
  59311. $this->trace[] = array(
  59312. 'namespace' => $namespace,
  59313. 'short_class' => $class,
  59314. 'class' => isset($entry['class']) ? $entry['class'] : '',
  59315. 'type' => isset($entry['type']) ? $entry['type'] : '',
  59316. 'function' => isset($entry['function']) ? $entry['function'] : null,
  59317. 'file' => isset($entry['file']) ? $entry['file'] : null,
  59318. 'line' => isset($entry['line']) ? $entry['line'] : null,
  59319. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  59320. );
  59321. }
  59322. }
  59323. private function flattenArgs($args, $level = 0, &$count = 0)
  59324. {
  59325. $result = array();
  59326. foreach ($args as $key => $value) {
  59327. if (++$count > 1e4) {
  59328. return array('array', '*SKIPPED over 10000 entries*');
  59329. }
  59330. if ($value instanceof \__PHP_Incomplete_Class) {
  59331. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  59332. } elseif (\is_object($value)) {
  59333. $result[$key] = array('object', \get_class($value));
  59334. } elseif (\is_array($value)) {
  59335. if ($level > 10) {
  59336. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  59337. } else {
  59338. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  59339. }
  59340. } elseif (null === $value) {
  59341. $result[$key] = array('null', null);
  59342. } elseif (\is_bool($value)) {
  59343. $result[$key] = array('boolean', $value);
  59344. } elseif (\is_resource($value)) {
  59345. $result[$key] = array('resource', get_resource_type($value));
  59346. } else {
  59347. $result[$key] = array('string', (string) $value);
  59348. }
  59349. }
  59350. return $result;
  59351. }
  59352. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  59353. {
  59354. $array = new \ArrayObject($value);
  59355. return $array['__PHP_Incomplete_Class_Name'];
  59356. }
  59357. }
  59358. <?php
  59359. namespace Symfony\Component\Debug\Exception;
  59360. class OutOfMemoryException extends FatalErrorException
  59361. {
  59362. }
  59363. <?php
  59364. namespace Symfony\Component\Debug\Exception;
  59365. class UndefinedFunctionException extends FatalErrorException
  59366. {
  59367. public function __construct($message, \ErrorException $previous)
  59368. {
  59369. parent::__construct(
  59370. $message,
  59371. $previous->getCode(),
  59372. $previous->getSeverity(),
  59373. $previous->getFile(),
  59374. $previous->getLine(),
  59375. null,
  59376. true,
  59377. null,
  59378. $previous->getPrevious()
  59379. );
  59380. $this->setTrace($previous->getTrace());
  59381. }
  59382. }
  59383. <?php
  59384. namespace Symfony\Component\Debug\Exception;
  59385. class UndefinedMethodException extends FatalErrorException
  59386. {
  59387. public function __construct($message, \ErrorException $previous)
  59388. {
  59389. parent::__construct(
  59390. $message,
  59391. $previous->getCode(),
  59392. $previous->getSeverity(),
  59393. $previous->getFile(),
  59394. $previous->getLine(),
  59395. null,
  59396. true,
  59397. null,
  59398. $previous->getPrevious()
  59399. );
  59400. $this->setTrace($previous->getTrace());
  59401. }
  59402. }
  59403. <?php
  59404. namespace Symfony\Component\Debug;
  59405. use Symfony\Component\Debug\Exception\FlattenException;
  59406. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  59407. use Symfony\Component\HttpFoundation\Response;
  59408. class ExceptionHandler
  59409. {
  59410. private $debug;
  59411. private $charset;
  59412. private $handler;
  59413. private $caughtBuffer;
  59414. private $caughtLength;
  59415. private $fileLinkFormat;
  59416. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  59417. {
  59418. if (false !== strpos($charset, '%')) {
  59419. @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);
  59420. $pivot = $fileLinkFormat;
  59421. $fileLinkFormat = $charset;
  59422. $charset = $pivot;
  59423. }
  59424. $this->debug = $debug;
  59425. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  59426. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  59427. }
  59428. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  59429. {
  59430. $handler = new static($debug, $charset, $fileLinkFormat);
  59431. $prev = set_exception_handler(array($handler, 'handle'));
  59432. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  59433. restore_exception_handler();
  59434. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  59435. }
  59436. return $handler;
  59437. }
  59438. public function setHandler($handler)
  59439. {
  59440. if (null !== $handler && !\is_callable($handler)) {
  59441. throw new \LogicException('The exception handler must be a valid PHP callable.');
  59442. }
  59443. $old = $this->handler;
  59444. $this->handler = $handler;
  59445. return $old;
  59446. }
  59447. public function setFileLinkFormat($format)
  59448. {
  59449. $old = $this->fileLinkFormat;
  59450. $this->fileLinkFormat = $format;
  59451. return $old;
  59452. }
  59453. public function handle(\Exception $exception)
  59454. {
  59455. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  59456. $this->failSafeHandle($exception);
  59457. return;
  59458. }
  59459. $caughtLength = $this->caughtLength = 0;
  59460. ob_start(array($this, 'catchOutput'));
  59461. $this->failSafeHandle($exception);
  59462. while (null === $this->caughtBuffer && ob_end_flush()) {
  59463. }
  59464. if (isset($this->caughtBuffer[0])) {
  59465. ob_start(array($this, 'cleanOutput'));
  59466. echo $this->caughtBuffer;
  59467. $caughtLength = ob_get_length();
  59468. }
  59469. $this->caughtBuffer = null;
  59470. try {
  59471. \call_user_func($this->handler, $exception);
  59472. $this->caughtLength = $caughtLength;
  59473. } catch (\Exception $e) {
  59474. if (!$caughtLength) {
  59475. throw $exception;
  59476. }
  59477. }
  59478. }
  59479. private function failSafeHandle(\Exception $exception)
  59480. {
  59481. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  59482. && __CLASS__ !== \get_class($this)
  59483. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  59484. && __CLASS__ !== $reflector->class
  59485. ) {
  59486. $response = $this->createResponse($exception);
  59487. $response->sendHeaders();
  59488. $response->sendContent();
  59489. @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);
  59490. return;
  59491. }
  59492. $this->sendPhpResponse($exception);
  59493. }
  59494. public function sendPhpResponse($exception)
  59495. {
  59496. if (!$exception instanceof FlattenException) {
  59497. $exception = FlattenException::create($exception);
  59498. }
  59499. if (!headers_sent()) {
  59500. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  59501. foreach ($exception->getHeaders() as $name => $value) {
  59502. header($name.': '.$value, false);
  59503. }
  59504. header('Content-Type: text/html; charset='.$this->charset);
  59505. }
  59506. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  59507. }
  59508. public function createResponse($exception)
  59509. {
  59510. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59511. if (!$exception instanceof FlattenException) {
  59512. $exception = FlattenException::create($exception);
  59513. }
  59514. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  59515. }
  59516. public function getHtml($exception)
  59517. {
  59518. if (!$exception instanceof FlattenException) {
  59519. $exception = FlattenException::create($exception);
  59520. }
  59521. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  59522. }
  59523. public function getContent(FlattenException $exception)
  59524. {
  59525. switch ($exception->getStatusCode()) {
  59526. case 404:
  59527. $title = 'Sorry, the page you are looking for could not be found.';
  59528. break;
  59529. default:
  59530. $title = 'Whoops, looks like something went wrong.';
  59531. }
  59532. $content = '';
  59533. if ($this->debug) {
  59534. try {
  59535. $count = \count($exception->getAllPrevious());
  59536. $total = $count + 1;
  59537. foreach ($exception->toArray() as $position => $e) {
  59538. $ind = $count - $position + 1;
  59539. $class = $this->formatClass($e['class']);
  59540. $message = nl2br($this->escapeHtml($e['message']));
  59541. $content .= sprintf(<<<'EOF'
  59542. <h2 class="block_exception clear_fix">
  59543. <span class="exception_counter">%d/%d</span>
  59544. <span class="exception_title">%s%s:</span>
  59545. <span class="exception_message">%s</span>
  59546. </h2>
  59547. <div class="block">
  59548. <ol class="traces list_exception">
  59549. EOF
  59550. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  59551. foreach ($e['trace'] as $trace) {
  59552. $content .= ' <li>';
  59553. if ($trace['function']) {
  59554. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  59555. }
  59556. if (isset($trace['file']) && isset($trace['line'])) {
  59557. $content .= $this->formatPath($trace['file'], $trace['line']);
  59558. }
  59559. $content .= "</li>\n";
  59560. }
  59561. $content .= " </ol>\n</div>\n";
  59562. }
  59563. } catch (\Exception $e) {
  59564. if ($this->debug) {
  59565. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  59566. } else {
  59567. $title = 'Whoops, looks like something went wrong.';
  59568. }
  59569. }
  59570. }
  59571. return <<<EOF
  59572. <div id="sf-resetcontent" class="sf-reset">
  59573. <h1>$title</h1>
  59574. $content
  59575. </div>
  59576. EOF;
  59577. }
  59578. public function getStylesheet(FlattenException $exception)
  59579. {
  59580. return <<<'EOF'
  59581. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  59582. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  59583. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  59584. .sf-reset .clear_fix { display:inline-block; }
  59585. .sf-reset * html .clear_fix { height:1%; }
  59586. .sf-reset .clear_fix { display:block; }
  59587. .sf-reset, .sf-reset .block { margin: auto }
  59588. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  59589. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  59590. .sf-reset strong { font-weight:bold; }
  59591. .sf-reset a { color:#6c6159; cursor: default; }
  59592. .sf-reset a img { border:none; }
  59593. .sf-reset a:hover { text-decoration:underline; }
  59594. .sf-reset em { font-style:italic; }
  59595. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  59596. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  59597. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  59598. .sf-reset .exception_message { margin-left: 3em; display: block; }
  59599. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  59600. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  59601. -webkit-border-bottom-right-radius: 16px;
  59602. -webkit-border-bottom-left-radius: 16px;
  59603. -moz-border-radius-bottomright: 16px;
  59604. -moz-border-radius-bottomleft: 16px;
  59605. border-bottom-right-radius: 16px;
  59606. border-bottom-left-radius: 16px;
  59607. border-bottom:1px solid #ccc;
  59608. border-right:1px solid #ccc;
  59609. border-left:1px solid #ccc;
  59610. word-wrap: break-word;
  59611. }
  59612. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  59613. -webkit-border-top-left-radius: 16px;
  59614. -webkit-border-top-right-radius: 16px;
  59615. -moz-border-radius-topleft: 16px;
  59616. -moz-border-radius-topright: 16px;
  59617. border-top-left-radius: 16px;
  59618. border-top-right-radius: 16px;
  59619. border-top:1px solid #ccc;
  59620. border-right:1px solid #ccc;
  59621. border-left:1px solid #ccc;
  59622. overflow: hidden;
  59623. word-wrap: break-word;
  59624. }
  59625. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  59626. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  59627. .sf-reset ol { padding: 10px 0; }
  59628. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  59629. -webkit-border-radius: 10px;
  59630. -moz-border-radius: 10px;
  59631. border-radius: 10px;
  59632. border: 1px solid #ccc;
  59633. }
  59634. EOF;
  59635. }
  59636. private function decorate($content, $css)
  59637. {
  59638. return <<<EOF
  59639. <!DOCTYPE html>
  59640. <html>
  59641. <head>
  59642. <meta charset="{$this->charset}" />
  59643. <meta name="robots" content="noindex,nofollow" />
  59644. <style>
  59645. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  59646. 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;}
  59647. html { background: #eee; padding: 10px }
  59648. img { border: 0; }
  59649. #sf-resetcontent { width:970px; margin:0 auto; }
  59650. $css
  59651. </style>
  59652. </head>
  59653. <body>
  59654. $content
  59655. </body>
  59656. </html>
  59657. EOF;
  59658. }
  59659. private function formatClass($class)
  59660. {
  59661. $parts = explode('\\', $class);
  59662. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  59663. }
  59664. private function formatPath($path, $line)
  59665. {
  59666. $path = $this->escapeHtml($path);
  59667. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  59668. if ($linkFormat = $this->fileLinkFormat) {
  59669. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  59670. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  59671. }
  59672. 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);
  59673. }
  59674. private function formatArgs(array $args)
  59675. {
  59676. $result = array();
  59677. foreach ($args as $key => $item) {
  59678. if ('object' === $item[0]) {
  59679. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  59680. } elseif ('array' === $item[0]) {
  59681. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  59682. } elseif ('string' === $item[0]) {
  59683. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  59684. } elseif ('null' === $item[0]) {
  59685. $formattedValue = '<em>null</em>';
  59686. } elseif ('boolean' === $item[0]) {
  59687. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  59688. } elseif ('resource' === $item[0]) {
  59689. $formattedValue = '<em>resource</em>';
  59690. } else {
  59691. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  59692. }
  59693. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  59694. }
  59695. return implode(', ', $result);
  59696. }
  59697. protected static function utf8Htmlize($str)
  59698. {
  59699. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  59700. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  59701. }
  59702. private function escapeHtml($str)
  59703. {
  59704. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  59705. }
  59706. public function catchOutput($buffer)
  59707. {
  59708. $this->caughtBuffer = $buffer;
  59709. return '';
  59710. }
  59711. public function cleanOutput($buffer)
  59712. {
  59713. if ($this->caughtLength) {
  59714. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  59715. if (isset($cleanBuffer[0])) {
  59716. $buffer = $cleanBuffer;
  59717. }
  59718. }
  59719. return $buffer;
  59720. }
  59721. }
  59722. <?php
  59723. namespace Symfony\Component\Debug\FatalErrorHandler;
  59724. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  59725. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  59726. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  59727. use Symfony\Component\Debug\DebugClassLoader;
  59728. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  59729. use Symfony\Component\Debug\Exception\FatalErrorException;
  59730. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  59731. {
  59732. public function handleError(array $error, FatalErrorException $exception)
  59733. {
  59734. $messageLen = \strlen($error['message']);
  59735. $notFoundSuffix = '\' not found';
  59736. $notFoundSuffixLen = \strlen($notFoundSuffix);
  59737. if ($notFoundSuffixLen > $messageLen) {
  59738. return;
  59739. }
  59740. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  59741. return;
  59742. }
  59743. foreach (array('class', 'interface', 'trait') as $typeName) {
  59744. $prefix = ucfirst($typeName).' \'';
  59745. $prefixLen = \strlen($prefix);
  59746. if (0 !== strpos($error['message'], $prefix)) {
  59747. continue;
  59748. }
  59749. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  59750. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  59751. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  59752. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  59753. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  59754. $tail = ' for another namespace?';
  59755. } else {
  59756. $className = $fullyQualifiedClassName;
  59757. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  59758. $tail = '?';
  59759. }
  59760. if ($candidates = $this->getClassCandidates($className)) {
  59761. $tail = array_pop($candidates).'"?';
  59762. if ($candidates) {
  59763. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  59764. } else {
  59765. $tail = ' for "'.$tail;
  59766. }
  59767. }
  59768. $message .= "\nDid you forget a \"use\" statement".$tail;
  59769. return new ClassNotFoundException($message, $exception);
  59770. }
  59771. }
  59772. private function getClassCandidates($class)
  59773. {
  59774. if (!\is_array($functions = spl_autoload_functions())) {
  59775. return array();
  59776. }
  59777. $classes = array();
  59778. foreach ($functions as $function) {
  59779. if (!\is_array($function)) {
  59780. continue;
  59781. }
  59782. if ($function[0] instanceof DebugClassLoader) {
  59783. $function = $function[0]->getClassLoader();
  59784. if (\is_object($function)) {
  59785. $function = array($function);
  59786. }
  59787. if (!\is_array($function)) {
  59788. continue;
  59789. }
  59790. }
  59791. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  59792. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  59793. foreach ($paths as $path) {
  59794. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  59795. }
  59796. }
  59797. }
  59798. if ($function[0] instanceof ComposerClassLoader) {
  59799. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  59800. foreach ($paths as $path) {
  59801. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  59802. }
  59803. }
  59804. }
  59805. }
  59806. return array_unique($classes);
  59807. }
  59808. private function findClassInPath($path, $class, $prefix)
  59809. {
  59810. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  59811. return array();
  59812. }
  59813. $classes = array();
  59814. $filename = $class.'.php';
  59815. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  59816. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  59817. $classes[] = $class;
  59818. }
  59819. }
  59820. return $classes;
  59821. }
  59822. private function convertFileToClass($path, $file, $prefix)
  59823. {
  59824. $candidates = array(
  59825. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  59826. $prefix.$namespacedClass,
  59827. $prefix.'\\'.$namespacedClass,
  59828. str_replace('\\', '_', $namespacedClass),
  59829. str_replace('\\', '_', $prefix.$namespacedClass),
  59830. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  59831. );
  59832. if ($prefix) {
  59833. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  59834. }
  59835. foreach ($candidates as $candidate) {
  59836. if ($this->classExists($candidate)) {
  59837. return $candidate;
  59838. }
  59839. }
  59840. require_once $file;
  59841. foreach ($candidates as $candidate) {
  59842. if ($this->classExists($candidate)) {
  59843. return $candidate;
  59844. }
  59845. }
  59846. }
  59847. private function classExists($class)
  59848. {
  59849. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  59850. }
  59851. }
  59852. <?php
  59853. namespace Symfony\Component\Debug\FatalErrorHandler;
  59854. use Symfony\Component\Debug\Exception\FatalErrorException;
  59855. interface FatalErrorHandlerInterface
  59856. {
  59857. public function handleError(array $error, FatalErrorException $exception);
  59858. }
  59859. <?php
  59860. namespace Symfony\Component\Debug\FatalErrorHandler;
  59861. use Symfony\Component\Debug\Exception\FatalErrorException;
  59862. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  59863. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  59864. {
  59865. public function handleError(array $error, FatalErrorException $exception)
  59866. {
  59867. $messageLen = \strlen($error['message']);
  59868. $notFoundSuffix = '()';
  59869. $notFoundSuffixLen = \strlen($notFoundSuffix);
  59870. if ($notFoundSuffixLen > $messageLen) {
  59871. return;
  59872. }
  59873. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  59874. return;
  59875. }
  59876. $prefix = 'Call to undefined function ';
  59877. $prefixLen = \strlen($prefix);
  59878. if (0 !== strpos($error['message'], $prefix)) {
  59879. return;
  59880. }
  59881. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  59882. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  59883. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  59884. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  59885. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  59886. } else {
  59887. $functionName = $fullyQualifiedFunctionName;
  59888. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  59889. }
  59890. $candidates = array();
  59891. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  59892. foreach ($definedFunctionNames as $definedFunctionName) {
  59893. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  59894. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  59895. } else {
  59896. $definedFunctionNameBasename = $definedFunctionName;
  59897. }
  59898. if ($definedFunctionNameBasename === $functionName) {
  59899. $candidates[] = '\\'.$definedFunctionName;
  59900. }
  59901. }
  59902. }
  59903. if ($candidates) {
  59904. sort($candidates);
  59905. $last = array_pop($candidates).'"?';
  59906. if ($candidates) {
  59907. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  59908. } else {
  59909. $candidates = '"'.$last;
  59910. }
  59911. $message .= "\nDid you mean to call ".$candidates;
  59912. }
  59913. return new UndefinedFunctionException($message, $exception);
  59914. }
  59915. }
  59916. <?php
  59917. namespace Symfony\Component\Debug\FatalErrorHandler;
  59918. use Symfony\Component\Debug\Exception\FatalErrorException;
  59919. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  59920. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  59921. {
  59922. public function handleError(array $error, FatalErrorException $exception)
  59923. {
  59924. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  59925. if (!$matches) {
  59926. return;
  59927. }
  59928. $className = $matches[1];
  59929. $methodName = $matches[2];
  59930. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  59931. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  59932. return new UndefinedMethodException($message, $exception);
  59933. }
  59934. $candidates = array();
  59935. foreach ($methods as $definedMethodName) {
  59936. $lev = levenshtein($methodName, $definedMethodName);
  59937. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  59938. $candidates[] = $definedMethodName;
  59939. }
  59940. }
  59941. if ($candidates) {
  59942. sort($candidates);
  59943. $last = array_pop($candidates).'"?';
  59944. if ($candidates) {
  59945. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  59946. } else {
  59947. $candidates = '"'.$last;
  59948. }
  59949. $message .= "\nDid you mean to call ".$candidates;
  59950. }
  59951. return new UndefinedMethodException($message, $exception);
  59952. }
  59953. }
  59954. Copyright (c) 2004-2018 Fabien Potencier
  59955. Permission is hereby granted, free of charge, to any person obtaining a copy
  59956. of this software and associated documentation files (the "Software"), to deal
  59957. in the Software without restriction, including without limitation the rights
  59958. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59959. copies of the Software, and to permit persons to whom the Software is furnished
  59960. to do so, subject to the following conditions:
  59961. The above copyright notice and this permission notice shall be included in all
  59962. copies or substantial portions of the Software.
  59963. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  59964. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59965. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59966. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59967. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  59968. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  59969. THE SOFTWARE.
  59970. <?php
  59971. namespace Symfony\Component\Filesystem\Exception;
  59972. interface ExceptionInterface
  59973. {
  59974. }
  59975. <?php
  59976. namespace Symfony\Component\Filesystem\Exception;
  59977. class FileNotFoundException extends IOException
  59978. {
  59979. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  59980. {
  59981. if (null === $message) {
  59982. if (null === $path) {
  59983. $message = 'File could not be found.';
  59984. } else {
  59985. $message = sprintf('File "%s" could not be found.', $path);
  59986. }
  59987. }
  59988. parent::__construct($message, $code, $previous, $path);
  59989. }
  59990. }
  59991. <?php
  59992. namespace Symfony\Component\Filesystem\Exception;
  59993. class IOException extends \RuntimeException implements IOExceptionInterface
  59994. {
  59995. private $path;
  59996. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  59997. {
  59998. $this->path = $path;
  59999. parent::__construct($message, $code, $previous);
  60000. }
  60001. public function getPath()
  60002. {
  60003. return $this->path;
  60004. }
  60005. }
  60006. <?php
  60007. namespace Symfony\Component\Filesystem\Exception;
  60008. interface IOExceptionInterface extends ExceptionInterface
  60009. {
  60010. public function getPath();
  60011. }
  60012. <?php
  60013. namespace Symfony\Component\Filesystem;
  60014. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  60015. use Symfony\Component\Filesystem\Exception\IOException;
  60016. class Filesystem
  60017. {
  60018. private static $lastError;
  60019. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  60020. {
  60021. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  60022. if ($originIsLocal && !is_file($originFile)) {
  60023. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  60024. }
  60025. $this->mkdir(\dirname($targetFile));
  60026. $doCopy = true;
  60027. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  60028. $doCopy = filemtime($originFile) > filemtime($targetFile);
  60029. }
  60030. if ($doCopy) {
  60031. if (false === $source = @fopen($originFile, 'r')) {
  60032. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  60033. }
  60034. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  60035. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  60036. }
  60037. $bytesCopied = stream_copy_to_stream($source, $target);
  60038. fclose($source);
  60039. fclose($target);
  60040. unset($source, $target);
  60041. if (!is_file($targetFile)) {
  60042. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  60043. }
  60044. if ($originIsLocal) {
  60045. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  60046. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  60047. 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);
  60048. }
  60049. }
  60050. }
  60051. }
  60052. public function mkdir($dirs, $mode = 0777)
  60053. {
  60054. foreach ($this->toIterator($dirs) as $dir) {
  60055. if (is_dir($dir)) {
  60056. continue;
  60057. }
  60058. if (!self::box('mkdir', $dir, $mode, true)) {
  60059. if (!is_dir($dir)) {
  60060. if (self::$lastError) {
  60061. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  60062. }
  60063. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  60064. }
  60065. }
  60066. }
  60067. }
  60068. public function exists($files)
  60069. {
  60070. $maxPathLength = PHP_MAXPATHLEN - 2;
  60071. foreach ($this->toIterator($files) as $file) {
  60072. if (\strlen($file) > $maxPathLength) {
  60073. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  60074. }
  60075. if (!file_exists($file)) {
  60076. return false;
  60077. }
  60078. }
  60079. return true;
  60080. }
  60081. public function touch($files, $time = null, $atime = null)
  60082. {
  60083. foreach ($this->toIterator($files) as $file) {
  60084. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  60085. if (true !== $touch) {
  60086. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  60087. }
  60088. }
  60089. }
  60090. public function remove($files)
  60091. {
  60092. if ($files instanceof \Traversable) {
  60093. $files = iterator_to_array($files, false);
  60094. } elseif (!\is_array($files)) {
  60095. $files = array($files);
  60096. }
  60097. $files = array_reverse($files);
  60098. foreach ($files as $file) {
  60099. if (is_link($file)) {
  60100. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  60101. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  60102. }
  60103. } elseif (is_dir($file)) {
  60104. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  60105. if (!self::box('rmdir', $file) && file_exists($file)) {
  60106. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  60107. }
  60108. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  60109. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  60110. }
  60111. }
  60112. }
  60113. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  60114. {
  60115. foreach ($this->toIterator($files) as $file) {
  60116. if (true !== @chmod($file, $mode & ~$umask)) {
  60117. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  60118. }
  60119. if ($recursive && is_dir($file) && !is_link($file)) {
  60120. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  60121. }
  60122. }
  60123. }
  60124. public function chown($files, $user, $recursive = false)
  60125. {
  60126. foreach ($this->toIterator($files) as $file) {
  60127. if ($recursive && is_dir($file) && !is_link($file)) {
  60128. $this->chown(new \FilesystemIterator($file), $user, true);
  60129. }
  60130. if (is_link($file) && \function_exists('lchown')) {
  60131. if (true !== @lchown($file, $user)) {
  60132. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  60133. }
  60134. } else {
  60135. if (true !== @chown($file, $user)) {
  60136. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  60137. }
  60138. }
  60139. }
  60140. }
  60141. public function chgrp($files, $group, $recursive = false)
  60142. {
  60143. foreach ($this->toIterator($files) as $file) {
  60144. if ($recursive && is_dir($file) && !is_link($file)) {
  60145. $this->chgrp(new \FilesystemIterator($file), $group, true);
  60146. }
  60147. if (is_link($file) && \function_exists('lchgrp')) {
  60148. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  60149. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  60150. }
  60151. } else {
  60152. if (true !== @chgrp($file, $group)) {
  60153. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  60154. }
  60155. }
  60156. }
  60157. }
  60158. public function rename($origin, $target, $overwrite = false)
  60159. {
  60160. if (!$overwrite && $this->isReadable($target)) {
  60161. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  60162. }
  60163. if (true !== @rename($origin, $target)) {
  60164. if (is_dir($origin)) {
  60165. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  60166. $this->remove($origin);
  60167. return;
  60168. }
  60169. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  60170. }
  60171. }
  60172. private function isReadable($filename)
  60173. {
  60174. $maxPathLength = PHP_MAXPATHLEN - 2;
  60175. if (\strlen($filename) > $maxPathLength) {
  60176. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  60177. }
  60178. return is_readable($filename);
  60179. }
  60180. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  60181. {
  60182. if ('\\' === \DIRECTORY_SEPARATOR) {
  60183. $originDir = strtr($originDir, '/', '\\');
  60184. $targetDir = strtr($targetDir, '/', '\\');
  60185. if ($copyOnWindows) {
  60186. $this->mirror($originDir, $targetDir);
  60187. return;
  60188. }
  60189. }
  60190. $this->mkdir(\dirname($targetDir));
  60191. if (is_link($targetDir)) {
  60192. if (readlink($targetDir) === $originDir) {
  60193. return;
  60194. }
  60195. $this->remove($targetDir);
  60196. }
  60197. if (!self::box('symlink', $originDir, $targetDir)) {
  60198. if (null !== self::$lastError) {
  60199. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  60200. 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);
  60201. }
  60202. }
  60203. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  60204. }
  60205. }
  60206. public function makePathRelative($endPath, $startPath)
  60207. {
  60208. if ('\\' === \DIRECTORY_SEPARATOR) {
  60209. $endPath = str_replace('\\', '/', $endPath);
  60210. $startPath = str_replace('\\', '/', $startPath);
  60211. }
  60212. $stripDriveLetter = function ($path) {
  60213. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  60214. return substr($path, 2);
  60215. }
  60216. return $path;
  60217. };
  60218. $endPath = $stripDriveLetter($endPath);
  60219. $startPath = $stripDriveLetter($startPath);
  60220. $startPathArr = explode('/', trim($startPath, '/'));
  60221. $endPathArr = explode('/', trim($endPath, '/'));
  60222. $normalizePathArray = function ($pathSegments, $absolute) {
  60223. $result = array();
  60224. foreach ($pathSegments as $segment) {
  60225. if ('..' === $segment && ($absolute || \count($result))) {
  60226. array_pop($result);
  60227. } elseif ('.' !== $segment) {
  60228. $result[] = $segment;
  60229. }
  60230. }
  60231. return $result;
  60232. };
  60233. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  60234. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  60235. $index = 0;
  60236. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  60237. ++$index;
  60238. }
  60239. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  60240. $depth = 0;
  60241. } else {
  60242. $depth = \count($startPathArr) - $index;
  60243. }
  60244. $traverser = str_repeat('../', $depth);
  60245. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  60246. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  60247. return '' === $relativePath ? './' : $relativePath;
  60248. }
  60249. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  60250. {
  60251. $targetDir = rtrim($targetDir, '/\\');
  60252. $originDir = rtrim($originDir, '/\\');
  60253. $originDirLen = \strlen($originDir);
  60254. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  60255. $deleteIterator = $iterator;
  60256. if (null === $deleteIterator) {
  60257. $flags = \FilesystemIterator::SKIP_DOTS;
  60258. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  60259. }
  60260. $targetDirLen = \strlen($targetDir);
  60261. foreach ($deleteIterator as $file) {
  60262. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  60263. if (!$this->exists($origin)) {
  60264. $this->remove($file);
  60265. }
  60266. }
  60267. }
  60268. $copyOnWindows = false;
  60269. if (isset($options['copy_on_windows'])) {
  60270. $copyOnWindows = $options['copy_on_windows'];
  60271. }
  60272. if (null === $iterator) {
  60273. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  60274. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  60275. }
  60276. if ($this->exists($originDir)) {
  60277. $this->mkdir($targetDir);
  60278. }
  60279. foreach ($iterator as $file) {
  60280. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  60281. if ($copyOnWindows) {
  60282. if (is_file($file)) {
  60283. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  60284. } elseif (is_dir($file)) {
  60285. $this->mkdir($target);
  60286. } else {
  60287. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  60288. }
  60289. } else {
  60290. if (is_link($file)) {
  60291. $this->symlink($file->getLinkTarget(), $target);
  60292. } elseif (is_dir($file)) {
  60293. $this->mkdir($target);
  60294. } elseif (is_file($file)) {
  60295. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  60296. } else {
  60297. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  60298. }
  60299. }
  60300. }
  60301. }
  60302. public function isAbsolutePath($file)
  60303. {
  60304. return strspn($file, '/\\', 0, 1)
  60305. || (\strlen($file) > 3 && ctype_alpha($file[0])
  60306. && ':' === substr($file, 1, 1)
  60307. && strspn($file, '/\\', 2, 1)
  60308. )
  60309. || null !== parse_url($file, PHP_URL_SCHEME)
  60310. ;
  60311. }
  60312. public function tempnam($dir, $prefix)
  60313. {
  60314. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  60315. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  60316. $tmpFile = @tempnam($hierarchy, $prefix);
  60317. if (false !== $tmpFile) {
  60318. if (null !== $scheme && 'gs' !== $scheme) {
  60319. return $scheme.'://'.$tmpFile;
  60320. }
  60321. return $tmpFile;
  60322. }
  60323. throw new IOException('A temporary file could not be created.');
  60324. }
  60325. for ($i = 0; $i < 10; ++$i) {
  60326. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  60327. $handle = @fopen($tmpFile, 'x+');
  60328. if (false === $handle) {
  60329. continue;
  60330. }
  60331. @fclose($handle);
  60332. return $tmpFile;
  60333. }
  60334. throw new IOException('A temporary file could not be created.');
  60335. }
  60336. public function dumpFile($filename, $content, $mode = 0666)
  60337. {
  60338. $dir = \dirname($filename);
  60339. if (!is_dir($dir)) {
  60340. $this->mkdir($dir);
  60341. }
  60342. if (!is_writable($dir)) {
  60343. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  60344. }
  60345. $tmpFile = $this->tempnam($dir, basename($filename));
  60346. if (false === @file_put_contents($tmpFile, $content)) {
  60347. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  60348. }
  60349. if (null !== $mode) {
  60350. if (\func_num_args() > 2) {
  60351. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  60352. }
  60353. $this->chmod($tmpFile, $mode);
  60354. } elseif (file_exists($filename)) {
  60355. @chmod($tmpFile, fileperms($filename));
  60356. }
  60357. $this->rename($tmpFile, $filename, true);
  60358. }
  60359. private function toIterator($files)
  60360. {
  60361. if (!$files instanceof \Traversable) {
  60362. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  60363. }
  60364. return $files;
  60365. }
  60366. private function getSchemeAndHierarchy($filename)
  60367. {
  60368. $components = explode('://', $filename, 2);
  60369. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  60370. }
  60371. private static function box($func)
  60372. {
  60373. self::$lastError = null;
  60374. \set_error_handler(__CLASS__.'::handleError');
  60375. try {
  60376. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  60377. \restore_error_handler();
  60378. return $result;
  60379. } catch (\Throwable $e) {
  60380. } catch (\Exception $e) {
  60381. }
  60382. \restore_error_handler();
  60383. throw $e;
  60384. }
  60385. public static function handleError($type, $msg)
  60386. {
  60387. self::$lastError = $msg;
  60388. }
  60389. }
  60390. Copyright (c) 2004-2018 Fabien Potencier
  60391. Permission is hereby granted, free of charge, to any person obtaining a copy
  60392. of this software and associated documentation files (the "Software"), to deal
  60393. in the Software without restriction, including without limitation the rights
  60394. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  60395. copies of the Software, and to permit persons to whom the Software is furnished
  60396. to do so, subject to the following conditions:
  60397. The above copyright notice and this permission notice shall be included in all
  60398. copies or substantial portions of the Software.
  60399. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  60400. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  60401. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  60402. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  60403. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  60404. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  60405. THE SOFTWARE.
  60406. <?php
  60407. namespace Symfony\Component\Filesystem;
  60408. use Symfony\Component\Filesystem\Exception\IOException;
  60409. class LockHandler
  60410. {
  60411. private $file;
  60412. private $handle;
  60413. public function __construct($name, $lockPath = null)
  60414. {
  60415. $lockPath = $lockPath ?: sys_get_temp_dir();
  60416. if (!is_dir($lockPath)) {
  60417. $fs = new Filesystem();
  60418. $fs->mkdir($lockPath);
  60419. }
  60420. if (!is_writable($lockPath)) {
  60421. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  60422. }
  60423. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  60424. }
  60425. public function lock($blocking = false)
  60426. {
  60427. if ($this->handle) {
  60428. return true;
  60429. }
  60430. $error = null;
  60431. set_error_handler(function ($errno, $msg) use (&$error) {
  60432. $error = $msg;
  60433. });
  60434. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  60435. if ($this->handle = fopen($this->file, 'x')) {
  60436. chmod($this->file, 0666);
  60437. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  60438. usleep(100);
  60439. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  60440. }
  60441. }
  60442. restore_error_handler();
  60443. if (!$this->handle) {
  60444. throw new IOException($error, 0, null, $this->file);
  60445. }
  60446. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  60447. fclose($this->handle);
  60448. $this->handle = null;
  60449. return false;
  60450. }
  60451. return true;
  60452. }
  60453. public function release()
  60454. {
  60455. if ($this->handle) {
  60456. flock($this->handle, LOCK_UN | LOCK_NB);
  60457. fclose($this->handle);
  60458. $this->handle = null;
  60459. }
  60460. }
  60461. }
  60462. <?php
  60463. namespace Symfony\Component\Finder\Adapter;
  60464. @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);
  60465. abstract class AbstractAdapter implements AdapterInterface
  60466. {
  60467. protected $followLinks = false;
  60468. protected $mode = 0;
  60469. protected $minDepth = 0;
  60470. protected $maxDepth = PHP_INT_MAX;
  60471. protected $exclude = array();
  60472. protected $names = array();
  60473. protected $notNames = array();
  60474. protected $contains = array();
  60475. protected $notContains = array();
  60476. protected $sizes = array();
  60477. protected $dates = array();
  60478. protected $filters = array();
  60479. protected $sort = false;
  60480. protected $paths = array();
  60481. protected $notPaths = array();
  60482. protected $ignoreUnreadableDirs = false;
  60483. private static $areSupported = array();
  60484. public function isSupported()
  60485. {
  60486. $name = $this->getName();
  60487. if (!array_key_exists($name, self::$areSupported)) {
  60488. self::$areSupported[$name] = $this->canBeUsed();
  60489. }
  60490. return self::$areSupported[$name];
  60491. }
  60492. public function setFollowLinks($followLinks)
  60493. {
  60494. $this->followLinks = $followLinks;
  60495. return $this;
  60496. }
  60497. public function setMode($mode)
  60498. {
  60499. $this->mode = $mode;
  60500. return $this;
  60501. }
  60502. public function setDepths(array $depths)
  60503. {
  60504. $this->minDepth = 0;
  60505. $this->maxDepth = PHP_INT_MAX;
  60506. foreach ($depths as $comparator) {
  60507. switch ($comparator->getOperator()) {
  60508. case '>':
  60509. $this->minDepth = $comparator->getTarget() + 1;
  60510. break;
  60511. case '>=':
  60512. $this->minDepth = $comparator->getTarget();
  60513. break;
  60514. case '<':
  60515. $this->maxDepth = $comparator->getTarget() - 1;
  60516. break;
  60517. case '<=':
  60518. $this->maxDepth = $comparator->getTarget();
  60519. break;
  60520. default:
  60521. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  60522. }
  60523. }
  60524. return $this;
  60525. }
  60526. public function setExclude(array $exclude)
  60527. {
  60528. $this->exclude = $exclude;
  60529. return $this;
  60530. }
  60531. public function setNames(array $names)
  60532. {
  60533. $this->names = $names;
  60534. return $this;
  60535. }
  60536. public function setNotNames(array $notNames)
  60537. {
  60538. $this->notNames = $notNames;
  60539. return $this;
  60540. }
  60541. public function setContains(array $contains)
  60542. {
  60543. $this->contains = $contains;
  60544. return $this;
  60545. }
  60546. public function setNotContains(array $notContains)
  60547. {
  60548. $this->notContains = $notContains;
  60549. return $this;
  60550. }
  60551. public function setSizes(array $sizes)
  60552. {
  60553. $this->sizes = $sizes;
  60554. return $this;
  60555. }
  60556. public function setDates(array $dates)
  60557. {
  60558. $this->dates = $dates;
  60559. return $this;
  60560. }
  60561. public function setFilters(array $filters)
  60562. {
  60563. $this->filters = $filters;
  60564. return $this;
  60565. }
  60566. public function setSort($sort)
  60567. {
  60568. $this->sort = $sort;
  60569. return $this;
  60570. }
  60571. public function setPath(array $paths)
  60572. {
  60573. $this->paths = $paths;
  60574. return $this;
  60575. }
  60576. public function setNotPath(array $notPaths)
  60577. {
  60578. $this->notPaths = $notPaths;
  60579. return $this;
  60580. }
  60581. public function ignoreUnreadableDirs($ignore = true)
  60582. {
  60583. $this->ignoreUnreadableDirs = (bool) $ignore;
  60584. return $this;
  60585. }
  60586. abstract protected function canBeUsed();
  60587. }
  60588. <?php
  60589. namespace Symfony\Component\Finder\Adapter;
  60590. @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);
  60591. use Symfony\Component\Finder\Comparator\DateComparator;
  60592. use Symfony\Component\Finder\Comparator\NumberComparator;
  60593. use Symfony\Component\Finder\Exception\AccessDeniedException;
  60594. use Symfony\Component\Finder\Expression\Expression;
  60595. use Symfony\Component\Finder\Iterator;
  60596. use Symfony\Component\Finder\Shell\Command;
  60597. use Symfony\Component\Finder\Shell\Shell;
  60598. abstract class AbstractFindAdapter extends AbstractAdapter
  60599. {
  60600. protected $shell;
  60601. public function __construct()
  60602. {
  60603. $this->shell = new Shell();
  60604. }
  60605. public function searchInDirectory($dir)
  60606. {
  60607. $dir = realpath($dir);
  60608. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  60609. return new Iterator\FilePathsIterator(array(), $dir);
  60610. }
  60611. $command = Command::create();
  60612. $find = $this->buildFindCommand($command, $dir);
  60613. if ($this->followLinks) {
  60614. $find->add('-follow');
  60615. }
  60616. $find->add('-mindepth')->add($this->minDepth + 1);
  60617. if (PHP_INT_MAX !== $this->maxDepth) {
  60618. $find->add('-maxdepth')->add($this->maxDepth + 1);
  60619. }
  60620. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  60621. $find->add('-type d');
  60622. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  60623. $find->add('-type f');
  60624. }
  60625. $this->buildNamesFiltering($find, $this->names);
  60626. $this->buildNamesFiltering($find, $this->notNames, true);
  60627. $this->buildPathsFiltering($find, $dir, $this->paths);
  60628. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  60629. $this->buildSizesFiltering($find, $this->sizes);
  60630. $this->buildDatesFiltering($find, $this->dates);
  60631. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  60632. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  60633. if ($useGrep && ($this->contains || $this->notContains)) {
  60634. $grep = $command->ins('grep');
  60635. $this->buildContentFiltering($grep, $this->contains);
  60636. $this->buildContentFiltering($grep, $this->notContains, true);
  60637. }
  60638. if ($useSort) {
  60639. $this->buildSorting($command, $this->sort);
  60640. }
  60641. $command->setErrorHandler(
  60642. $this->ignoreUnreadableDirs
  60643. ? function ($stderr) { }
  60644. : function ($stderr) { throw new AccessDeniedException($stderr); }
  60645. );
  60646. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  60647. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  60648. if ($this->exclude) {
  60649. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  60650. }
  60651. if (!$useGrep && ($this->contains || $this->notContains)) {
  60652. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  60653. }
  60654. if ($this->filters) {
  60655. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  60656. }
  60657. if (!$useSort && $this->sort) {
  60658. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  60659. $iterator = $iteratorAggregate->getIterator();
  60660. }
  60661. return $iterator;
  60662. }
  60663. protected function canBeUsed()
  60664. {
  60665. return $this->shell->testCommand('find');
  60666. }
  60667. protected function buildFindCommand(Command $command, $dir)
  60668. {
  60669. return $command
  60670. ->ins('find')
  60671. ->add('find ')
  60672. ->arg($dir)
  60673. ->add('-noleaf');
  60674. }
  60675. private function buildNamesFiltering(Command $command, array $names, $not = false)
  60676. {
  60677. if (0 === \count($names)) {
  60678. return;
  60679. }
  60680. $command->add($not ? '-not' : null)->cmd('(');
  60681. foreach ($names as $i => $name) {
  60682. $expr = Expression::create($name);
  60683. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  60684. $expr = Expression::create($expr->getGlob()->toRegex(false));
  60685. }
  60686. if ($expr->isRegex()) {
  60687. $regex = $expr->getRegex();
  60688. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  60689. ->setStartFlag(false)
  60690. ->setStartJoker(true)
  60691. ->replaceJokers('[^/]');
  60692. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  60693. $regex->setEndJoker(false)->append('[^/]*');
  60694. }
  60695. }
  60696. $command
  60697. ->add($i > 0 ? '-or' : null)
  60698. ->add($expr->isRegex()
  60699. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  60700. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  60701. )
  60702. ->arg($expr->renderPattern());
  60703. }
  60704. $command->cmd(')');
  60705. }
  60706. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  60707. {
  60708. if (0 === \count($paths)) {
  60709. return;
  60710. }
  60711. $command->add($not ? '-not' : null)->cmd('(');
  60712. foreach ($paths as $i => $path) {
  60713. $expr = Expression::create($path);
  60714. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  60715. $expr = Expression::create($expr->getGlob()->toRegex(false));
  60716. }
  60717. if ($expr->isRegex()) {
  60718. $regex = $expr->getRegex();
  60719. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  60720. } else {
  60721. $expr->prepend('*')->append('*');
  60722. }
  60723. $command
  60724. ->add($i > 0 ? '-or' : null)
  60725. ->add($expr->isRegex()
  60726. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  60727. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  60728. )
  60729. ->arg($expr->renderPattern());
  60730. }
  60731. $command->cmd(')');
  60732. }
  60733. private function buildSizesFiltering(Command $command, array $sizes)
  60734. {
  60735. foreach ($sizes as $i => $size) {
  60736. $command->add($i > 0 ? '-and' : null);
  60737. switch ($size->getOperator()) {
  60738. case '<=':
  60739. $command->add('-size -'.($size->getTarget() + 1).'c');
  60740. break;
  60741. case '>=':
  60742. $command->add('-size +'.($size->getTarget() - 1).'c');
  60743. break;
  60744. case '>':
  60745. $command->add('-size +'.$size->getTarget().'c');
  60746. break;
  60747. case '!=':
  60748. $command->add('-size -'.$size->getTarget().'c');
  60749. $command->add('-size +'.$size->getTarget().'c');
  60750. break;
  60751. case '<':
  60752. default:
  60753. $command->add('-size -'.$size->getTarget().'c');
  60754. }
  60755. }
  60756. }
  60757. private function buildDatesFiltering(Command $command, array $dates)
  60758. {
  60759. foreach ($dates as $i => $date) {
  60760. $command->add($i > 0 ? '-and' : null);
  60761. $mins = (int) round((time() - $date->getTarget()) / 60);
  60762. if (0 > $mins) {
  60763. $command->add(' -mmin -0');
  60764. return;
  60765. }
  60766. switch ($date->getOperator()) {
  60767. case '<=':
  60768. $command->add('-mmin +'.($mins - 1));
  60769. break;
  60770. case '>=':
  60771. $command->add('-mmin -'.($mins + 1));
  60772. break;
  60773. case '>':
  60774. $command->add('-mmin -'.$mins);
  60775. break;
  60776. case '!=':
  60777. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  60778. break;
  60779. case '<':
  60780. default:
  60781. $command->add('-mmin +'.$mins);
  60782. }
  60783. }
  60784. }
  60785. private function buildSorting(Command $command, $sort)
  60786. {
  60787. $this->buildFormatSorting($command, $sort);
  60788. }
  60789. abstract protected function buildFormatSorting(Command $command, $sort);
  60790. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  60791. }
  60792. <?php
  60793. namespace Symfony\Component\Finder\Adapter;
  60794. interface AdapterInterface
  60795. {
  60796. public function setFollowLinks($followLinks);
  60797. public function setMode($mode);
  60798. public function setExclude(array $exclude);
  60799. public function setDepths(array $depths);
  60800. public function setNames(array $names);
  60801. public function setNotNames(array $notNames);
  60802. public function setContains(array $contains);
  60803. public function setNotContains(array $notContains);
  60804. public function setSizes(array $sizes);
  60805. public function setDates(array $dates);
  60806. public function setFilters(array $filters);
  60807. public function setSort($sort);
  60808. public function setPath(array $paths);
  60809. public function setNotPath(array $notPaths);
  60810. public function ignoreUnreadableDirs($ignore = true);
  60811. public function searchInDirectory($dir);
  60812. public function isSupported();
  60813. public function getName();
  60814. }
  60815. <?php
  60816. namespace Symfony\Component\Finder\Adapter;
  60817. @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);
  60818. use Symfony\Component\Finder\Expression\Expression;
  60819. use Symfony\Component\Finder\Iterator\SortableIterator;
  60820. use Symfony\Component\Finder\Shell\Command;
  60821. use Symfony\Component\Finder\Shell\Shell;
  60822. class BsdFindAdapter extends AbstractFindAdapter
  60823. {
  60824. public function getName()
  60825. {
  60826. return 'bsd_find';
  60827. }
  60828. protected function canBeUsed()
  60829. {
  60830. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  60831. }
  60832. protected function buildFormatSorting(Command $command, $sort)
  60833. {
  60834. switch ($sort) {
  60835. case SortableIterator::SORT_BY_NAME:
  60836. $command->ins('sort')->add('| sort');
  60837. return;
  60838. case SortableIterator::SORT_BY_TYPE:
  60839. $format = '%HT';
  60840. break;
  60841. case SortableIterator::SORT_BY_ACCESSED_TIME:
  60842. $format = '%a';
  60843. break;
  60844. case SortableIterator::SORT_BY_CHANGED_TIME:
  60845. $format = '%c';
  60846. break;
  60847. case SortableIterator::SORT_BY_MODIFIED_TIME:
  60848. $format = '%m';
  60849. break;
  60850. default:
  60851. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  60852. }
  60853. $command
  60854. ->add('-print0 | xargs -0 stat -f')
  60855. ->arg($format.'%t%N')
  60856. ->add('| sort | cut -f 2');
  60857. }
  60858. protected function buildFindCommand(Command $command, $dir)
  60859. {
  60860. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  60861. return $command;
  60862. }
  60863. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  60864. {
  60865. foreach ($contains as $contain) {
  60866. $expr = Expression::create($contain);
  60867. $command
  60868. ->add('| grep -v \'^$\'')
  60869. ->add('| xargs -I{} grep -I')
  60870. ->add($expr->isCaseSensitive() ? null : '-i')
  60871. ->add($not ? '-L' : '-l')
  60872. ->add('-Ee')->arg($expr->renderPattern())
  60873. ->add('{}')
  60874. ;
  60875. }
  60876. }
  60877. }
  60878. <?php
  60879. namespace Symfony\Component\Finder\Adapter;
  60880. @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);
  60881. use Symfony\Component\Finder\Expression\Expression;
  60882. use Symfony\Component\Finder\Iterator\SortableIterator;
  60883. use Symfony\Component\Finder\Shell\Command;
  60884. use Symfony\Component\Finder\Shell\Shell;
  60885. class GnuFindAdapter extends AbstractFindAdapter
  60886. {
  60887. public function getName()
  60888. {
  60889. return 'gnu_find';
  60890. }
  60891. protected function buildFormatSorting(Command $command, $sort)
  60892. {
  60893. switch ($sort) {
  60894. case SortableIterator::SORT_BY_NAME:
  60895. $command->ins('sort')->add('| sort');
  60896. return;
  60897. case SortableIterator::SORT_BY_TYPE:
  60898. $format = '%y';
  60899. break;
  60900. case SortableIterator::SORT_BY_ACCESSED_TIME:
  60901. $format = '%A@';
  60902. break;
  60903. case SortableIterator::SORT_BY_CHANGED_TIME:
  60904. $format = '%C@';
  60905. break;
  60906. case SortableIterator::SORT_BY_MODIFIED_TIME:
  60907. $format = '%T@';
  60908. break;
  60909. default:
  60910. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  60911. }
  60912. $command
  60913. ->get('find')
  60914. ->add('-printf')
  60915. ->arg($format.' %h/%f\\n')
  60916. ->add('| sort | cut')
  60917. ->arg('-d ')
  60918. ->arg('-f2-')
  60919. ;
  60920. }
  60921. protected function canBeUsed()
  60922. {
  60923. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  60924. }
  60925. protected function buildFindCommand(Command $command, $dir)
  60926. {
  60927. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  60928. }
  60929. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  60930. {
  60931. foreach ($contains as $contain) {
  60932. $expr = Expression::create($contain);
  60933. $command
  60934. ->add('| xargs -I{} -r grep -I')
  60935. ->add($expr->isCaseSensitive() ? null : '-i')
  60936. ->add($not ? '-L' : '-l')
  60937. ->add('-Ee')->arg($expr->renderPattern())
  60938. ->add('{}')
  60939. ;
  60940. }
  60941. }
  60942. }
  60943. <?php
  60944. namespace Symfony\Component\Finder\Adapter;
  60945. @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);
  60946. use Symfony\Component\Finder\Iterator;
  60947. class PhpAdapter extends AbstractAdapter
  60948. {
  60949. public function searchInDirectory($dir)
  60950. {
  60951. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  60952. if ($this->followLinks) {
  60953. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  60954. }
  60955. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  60956. if ($this->exclude) {
  60957. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  60958. }
  60959. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  60960. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  60961. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  60962. }
  60963. if ($this->mode) {
  60964. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  60965. }
  60966. if ($this->names || $this->notNames) {
  60967. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  60968. }
  60969. if ($this->contains || $this->notContains) {
  60970. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  60971. }
  60972. if ($this->sizes) {
  60973. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  60974. }
  60975. if ($this->dates) {
  60976. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  60977. }
  60978. if ($this->filters) {
  60979. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  60980. }
  60981. if ($this->paths || $this->notPaths) {
  60982. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  60983. }
  60984. if ($this->sort) {
  60985. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  60986. $iterator = $iteratorAggregate->getIterator();
  60987. }
  60988. return $iterator;
  60989. }
  60990. public function getName()
  60991. {
  60992. return 'php';
  60993. }
  60994. protected function canBeUsed()
  60995. {
  60996. return true;
  60997. }
  60998. }
  60999. <?php
  61000. namespace Symfony\Component\Finder\Comparator;
  61001. class Comparator
  61002. {
  61003. private $target;
  61004. private $operator = '==';
  61005. public function getTarget()
  61006. {
  61007. return $this->target;
  61008. }
  61009. public function setTarget($target)
  61010. {
  61011. $this->target = $target;
  61012. }
  61013. public function getOperator()
  61014. {
  61015. return $this->operator;
  61016. }
  61017. public function setOperator($operator)
  61018. {
  61019. if (!$operator) {
  61020. $operator = '==';
  61021. }
  61022. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  61023. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  61024. }
  61025. $this->operator = $operator;
  61026. }
  61027. public function test($test)
  61028. {
  61029. switch ($this->operator) {
  61030. case '>':
  61031. return $test > $this->target;
  61032. case '>=':
  61033. return $test >= $this->target;
  61034. case '<':
  61035. return $test < $this->target;
  61036. case '<=':
  61037. return $test <= $this->target;
  61038. case '!=':
  61039. return $test != $this->target;
  61040. }
  61041. return $test == $this->target;
  61042. }
  61043. }
  61044. <?php
  61045. namespace Symfony\Component\Finder\Comparator;
  61046. class DateComparator extends Comparator
  61047. {
  61048. public function __construct($test)
  61049. {
  61050. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  61051. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  61052. }
  61053. try {
  61054. $date = new \DateTime($matches[2]);
  61055. $target = $date->format('U');
  61056. } catch (\Exception $e) {
  61057. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  61058. }
  61059. $operator = isset($matches[1]) ? $matches[1] : '==';
  61060. if ('since' === $operator || 'after' === $operator) {
  61061. $operator = '>';
  61062. }
  61063. if ('until' === $operator || 'before' === $operator) {
  61064. $operator = '<';
  61065. }
  61066. $this->setOperator($operator);
  61067. $this->setTarget($target);
  61068. }
  61069. }
  61070. <?php
  61071. namespace Symfony\Component\Finder\Comparator;
  61072. class NumberComparator extends Comparator
  61073. {
  61074. public function __construct($test)
  61075. {
  61076. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  61077. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  61078. }
  61079. $target = $matches[2];
  61080. if (!is_numeric($target)) {
  61081. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  61082. }
  61083. if (isset($matches[3])) {
  61084. switch (strtolower($matches[3])) {
  61085. case 'k':
  61086. $target *= 1000;
  61087. break;
  61088. case 'ki':
  61089. $target *= 1024;
  61090. break;
  61091. case 'm':
  61092. $target *= 1000000;
  61093. break;
  61094. case 'mi':
  61095. $target *= 1024 * 1024;
  61096. break;
  61097. case 'g':
  61098. $target *= 1000000000;
  61099. break;
  61100. case 'gi':
  61101. $target *= 1024 * 1024 * 1024;
  61102. break;
  61103. }
  61104. }
  61105. $this->setTarget($target);
  61106. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  61107. }
  61108. }
  61109. <?php
  61110. namespace Symfony\Component\Finder\Exception;
  61111. class AccessDeniedException extends \UnexpectedValueException
  61112. {
  61113. }
  61114. <?php
  61115. namespace Symfony\Component\Finder\Exception;
  61116. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61117. use Symfony\Component\Finder\Adapter\AdapterInterface;
  61118. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  61119. {
  61120. private $adapter;
  61121. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  61122. {
  61123. $this->adapter = $adapter;
  61124. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  61125. }
  61126. public function getAdapter()
  61127. {
  61128. return $this->adapter;
  61129. }
  61130. }
  61131. <?php
  61132. namespace Symfony\Component\Finder\Exception;
  61133. interface ExceptionInterface
  61134. {
  61135. public function getAdapter();
  61136. }
  61137. <?php
  61138. namespace Symfony\Component\Finder\Exception;
  61139. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61140. class OperationNotPermitedException extends AdapterFailureException
  61141. {
  61142. }
  61143. <?php
  61144. namespace Symfony\Component\Finder\Exception;
  61145. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61146. use Symfony\Component\Finder\Adapter\AdapterInterface;
  61147. use Symfony\Component\Finder\Shell\Command;
  61148. class ShellCommandFailureException extends AdapterFailureException
  61149. {
  61150. private $command;
  61151. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  61152. {
  61153. $this->command = $command;
  61154. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  61155. }
  61156. public function getCommand()
  61157. {
  61158. return $this->command;
  61159. }
  61160. }
  61161. <?php
  61162. namespace Symfony\Component\Finder\Expression;
  61163. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61164. class Expression implements ValueInterface
  61165. {
  61166. const TYPE_REGEX = 1;
  61167. const TYPE_GLOB = 2;
  61168. private $value;
  61169. public static function create($expr)
  61170. {
  61171. return new self($expr);
  61172. }
  61173. public function __construct($expr)
  61174. {
  61175. try {
  61176. $this->value = Regex::create($expr);
  61177. } catch (\InvalidArgumentException $e) {
  61178. $this->value = new Glob($expr);
  61179. }
  61180. }
  61181. public function __toString()
  61182. {
  61183. return $this->render();
  61184. }
  61185. public function render()
  61186. {
  61187. return $this->value->render();
  61188. }
  61189. public function renderPattern()
  61190. {
  61191. return $this->value->renderPattern();
  61192. }
  61193. public function isCaseSensitive()
  61194. {
  61195. return $this->value->isCaseSensitive();
  61196. }
  61197. public function getType()
  61198. {
  61199. return $this->value->getType();
  61200. }
  61201. public function prepend($expr)
  61202. {
  61203. $this->value->prepend($expr);
  61204. return $this;
  61205. }
  61206. public function append($expr)
  61207. {
  61208. $this->value->append($expr);
  61209. return $this;
  61210. }
  61211. public function isRegex()
  61212. {
  61213. return self::TYPE_REGEX === $this->value->getType();
  61214. }
  61215. public function isGlob()
  61216. {
  61217. return self::TYPE_GLOB === $this->value->getType();
  61218. }
  61219. public function getGlob()
  61220. {
  61221. if (self::TYPE_GLOB !== $this->value->getType()) {
  61222. throw new \LogicException('Regex can\'t be transformed to glob.');
  61223. }
  61224. return $this->value;
  61225. }
  61226. public function getRegex()
  61227. {
  61228. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  61229. }
  61230. }
  61231. <?php
  61232. namespace Symfony\Component\Finder\Expression;
  61233. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61234. use Symfony\Component\Finder\Glob as FinderGlob;
  61235. class Glob implements ValueInterface
  61236. {
  61237. private $pattern;
  61238. public function __construct($pattern)
  61239. {
  61240. $this->pattern = $pattern;
  61241. }
  61242. public function render()
  61243. {
  61244. return $this->pattern;
  61245. }
  61246. public function renderPattern()
  61247. {
  61248. return $this->pattern;
  61249. }
  61250. public function getType()
  61251. {
  61252. return Expression::TYPE_GLOB;
  61253. }
  61254. public function isCaseSensitive()
  61255. {
  61256. return true;
  61257. }
  61258. public function prepend($expr)
  61259. {
  61260. $this->pattern = $expr.$this->pattern;
  61261. return $this;
  61262. }
  61263. public function append($expr)
  61264. {
  61265. $this->pattern .= $expr;
  61266. return $this;
  61267. }
  61268. public function isExpandable()
  61269. {
  61270. return false !== strpos($this->pattern, '{')
  61271. && false !== strpos($this->pattern, '}');
  61272. }
  61273. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  61274. {
  61275. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  61276. return new Regex($regex);
  61277. }
  61278. }
  61279. <?php
  61280. namespace Symfony\Component\Finder\Expression;
  61281. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61282. class Regex implements ValueInterface
  61283. {
  61284. const START_FLAG = '^';
  61285. const END_FLAG = '$';
  61286. const BOUNDARY = '~';
  61287. const JOKER = '.*';
  61288. const ESCAPING = '\\';
  61289. private $pattern;
  61290. private $options;
  61291. private $startFlag;
  61292. private $endFlag;
  61293. private $startJoker;
  61294. private $endJoker;
  61295. public static function create($expr)
  61296. {
  61297. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  61298. $start = substr($m[1], 0, 1);
  61299. $end = substr($m[1], -1);
  61300. if (
  61301. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  61302. || ('{' === $start && '}' === $end)
  61303. || ('(' === $start && ')' === $end)
  61304. ) {
  61305. return new self(substr($m[1], 1, -1), $m[2], $end);
  61306. }
  61307. }
  61308. throw new \InvalidArgumentException('Given expression is not a regex.');
  61309. }
  61310. public function __construct($pattern, $options = '', $delimiter = null)
  61311. {
  61312. if (null !== $delimiter) {
  61313. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  61314. }
  61315. $this->parsePattern($pattern);
  61316. $this->options = $options;
  61317. }
  61318. public function __toString()
  61319. {
  61320. return $this->render();
  61321. }
  61322. public function render()
  61323. {
  61324. return self::BOUNDARY
  61325. .$this->renderPattern()
  61326. .self::BOUNDARY
  61327. .$this->options;
  61328. }
  61329. public function renderPattern()
  61330. {
  61331. return ($this->startFlag ? self::START_FLAG : '')
  61332. .($this->startJoker ? self::JOKER : '')
  61333. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  61334. .($this->endJoker ? self::JOKER : '')
  61335. .($this->endFlag ? self::END_FLAG : '');
  61336. }
  61337. public function isCaseSensitive()
  61338. {
  61339. return !$this->hasOption('i');
  61340. }
  61341. public function getType()
  61342. {
  61343. return Expression::TYPE_REGEX;
  61344. }
  61345. public function prepend($expr)
  61346. {
  61347. $this->pattern = $expr.$this->pattern;
  61348. return $this;
  61349. }
  61350. public function append($expr)
  61351. {
  61352. $this->pattern .= $expr;
  61353. return $this;
  61354. }
  61355. public function hasOption($option)
  61356. {
  61357. return false !== strpos($this->options, $option);
  61358. }
  61359. public function addOption($option)
  61360. {
  61361. if (!$this->hasOption($option)) {
  61362. $this->options .= $option;
  61363. }
  61364. return $this;
  61365. }
  61366. public function removeOption($option)
  61367. {
  61368. $this->options = str_replace($option, '', $this->options);
  61369. return $this;
  61370. }
  61371. public function setStartFlag($startFlag)
  61372. {
  61373. $this->startFlag = $startFlag;
  61374. return $this;
  61375. }
  61376. public function hasStartFlag()
  61377. {
  61378. return $this->startFlag;
  61379. }
  61380. public function setEndFlag($endFlag)
  61381. {
  61382. $this->endFlag = (bool) $endFlag;
  61383. return $this;
  61384. }
  61385. public function hasEndFlag()
  61386. {
  61387. return $this->endFlag;
  61388. }
  61389. public function setStartJoker($startJoker)
  61390. {
  61391. $this->startJoker = $startJoker;
  61392. return $this;
  61393. }
  61394. public function hasStartJoker()
  61395. {
  61396. return $this->startJoker;
  61397. }
  61398. public function setEndJoker($endJoker)
  61399. {
  61400. $this->endJoker = (bool) $endJoker;
  61401. return $this;
  61402. }
  61403. public function hasEndJoker()
  61404. {
  61405. return $this->endJoker;
  61406. }
  61407. public function replaceJokers($replacement)
  61408. {
  61409. $replace = function ($subject) use ($replacement) {
  61410. $subject = $subject[0];
  61411. $replace = 0 === substr_count($subject, '\\') % 2;
  61412. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  61413. };
  61414. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  61415. return $this;
  61416. }
  61417. private function parsePattern($pattern)
  61418. {
  61419. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  61420. $pattern = substr($pattern, 1);
  61421. }
  61422. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  61423. $pattern = substr($pattern, 2);
  61424. }
  61425. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  61426. $pattern = substr($pattern, 0, -1);
  61427. }
  61428. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  61429. $pattern = substr($pattern, 0, -2);
  61430. }
  61431. $this->pattern = $pattern;
  61432. }
  61433. }
  61434. <?php
  61435. namespace Symfony\Component\Finder\Expression;
  61436. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61437. interface ValueInterface
  61438. {
  61439. public function render();
  61440. public function renderPattern();
  61441. public function isCaseSensitive();
  61442. public function getType();
  61443. public function prepend($expr);
  61444. public function append($expr);
  61445. }
  61446. <?php
  61447. namespace Symfony\Component\Finder;
  61448. use Symfony\Component\Finder\Adapter\AdapterInterface;
  61449. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  61450. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  61451. use Symfony\Component\Finder\Adapter\PhpAdapter;
  61452. use Symfony\Component\Finder\Comparator\DateComparator;
  61453. use Symfony\Component\Finder\Comparator\NumberComparator;
  61454. use Symfony\Component\Finder\Exception\ExceptionInterface;
  61455. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  61456. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  61457. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  61458. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  61459. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  61460. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  61461. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  61462. use Symfony\Component\Finder\Iterator\SortableIterator;
  61463. class Finder implements \IteratorAggregate, \Countable
  61464. {
  61465. const IGNORE_VCS_FILES = 1;
  61466. const IGNORE_DOT_FILES = 2;
  61467. private $mode = 0;
  61468. private $names = array();
  61469. private $notNames = array();
  61470. private $exclude = array();
  61471. private $filters = array();
  61472. private $depths = array();
  61473. private $sizes = array();
  61474. private $followLinks = false;
  61475. private $sort = false;
  61476. private $ignore = 0;
  61477. private $dirs = array();
  61478. private $dates = array();
  61479. private $iterators = array();
  61480. private $contains = array();
  61481. private $notContains = array();
  61482. private $adapters = null;
  61483. private $paths = array();
  61484. private $notPaths = array();
  61485. private $ignoreUnreadableDirs = false;
  61486. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  61487. public function __construct()
  61488. {
  61489. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  61490. }
  61491. public static function create()
  61492. {
  61493. return new static();
  61494. }
  61495. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  61496. {
  61497. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61498. $this->initDefaultAdapters();
  61499. $this->adapters[$adapter->getName()] = array(
  61500. 'adapter' => $adapter,
  61501. 'priority' => $priority,
  61502. 'selected' => false,
  61503. );
  61504. return $this->sortAdapters();
  61505. }
  61506. public function useBestAdapter()
  61507. {
  61508. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61509. $this->initDefaultAdapters();
  61510. $this->resetAdapterSelection();
  61511. return $this->sortAdapters();
  61512. }
  61513. public function setAdapter($name)
  61514. {
  61515. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61516. $this->initDefaultAdapters();
  61517. if (!isset($this->adapters[$name])) {
  61518. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  61519. }
  61520. $this->resetAdapterSelection();
  61521. $this->adapters[$name]['selected'] = true;
  61522. return $this->sortAdapters();
  61523. }
  61524. public function removeAdapters()
  61525. {
  61526. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61527. $this->adapters = array();
  61528. return $this;
  61529. }
  61530. public function getAdapters()
  61531. {
  61532. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  61533. $this->initDefaultAdapters();
  61534. return array_values(array_map(function (array $adapter) {
  61535. return $adapter['adapter'];
  61536. }, $this->adapters));
  61537. }
  61538. public function directories()
  61539. {
  61540. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  61541. return $this;
  61542. }
  61543. public function files()
  61544. {
  61545. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  61546. return $this;
  61547. }
  61548. public function depth($level)
  61549. {
  61550. $this->depths[] = new Comparator\NumberComparator($level);
  61551. return $this;
  61552. }
  61553. public function date($date)
  61554. {
  61555. $this->dates[] = new Comparator\DateComparator($date);
  61556. return $this;
  61557. }
  61558. public function name($pattern)
  61559. {
  61560. $this->names[] = $pattern;
  61561. return $this;
  61562. }
  61563. public function notName($pattern)
  61564. {
  61565. $this->notNames[] = $pattern;
  61566. return $this;
  61567. }
  61568. public function contains($pattern)
  61569. {
  61570. $this->contains[] = $pattern;
  61571. return $this;
  61572. }
  61573. public function notContains($pattern)
  61574. {
  61575. $this->notContains[] = $pattern;
  61576. return $this;
  61577. }
  61578. public function path($pattern)
  61579. {
  61580. $this->paths[] = $pattern;
  61581. return $this;
  61582. }
  61583. public function notPath($pattern)
  61584. {
  61585. $this->notPaths[] = $pattern;
  61586. return $this;
  61587. }
  61588. public function size($size)
  61589. {
  61590. $this->sizes[] = new Comparator\NumberComparator($size);
  61591. return $this;
  61592. }
  61593. public function exclude($dirs)
  61594. {
  61595. $this->exclude = array_merge($this->exclude, (array) $dirs);
  61596. return $this;
  61597. }
  61598. public function ignoreDotFiles($ignoreDotFiles)
  61599. {
  61600. if ($ignoreDotFiles) {
  61601. $this->ignore |= static::IGNORE_DOT_FILES;
  61602. } else {
  61603. $this->ignore &= ~static::IGNORE_DOT_FILES;
  61604. }
  61605. return $this;
  61606. }
  61607. public function ignoreVCS($ignoreVCS)
  61608. {
  61609. if ($ignoreVCS) {
  61610. $this->ignore |= static::IGNORE_VCS_FILES;
  61611. } else {
  61612. $this->ignore &= ~static::IGNORE_VCS_FILES;
  61613. }
  61614. return $this;
  61615. }
  61616. public static function addVCSPattern($pattern)
  61617. {
  61618. foreach ((array) $pattern as $p) {
  61619. self::$vcsPatterns[] = $p;
  61620. }
  61621. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  61622. }
  61623. public function sort(\Closure $closure)
  61624. {
  61625. $this->sort = $closure;
  61626. return $this;
  61627. }
  61628. public function sortByName()
  61629. {
  61630. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  61631. return $this;
  61632. }
  61633. public function sortByType()
  61634. {
  61635. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  61636. return $this;
  61637. }
  61638. public function sortByAccessedTime()
  61639. {
  61640. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  61641. return $this;
  61642. }
  61643. public function sortByChangedTime()
  61644. {
  61645. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  61646. return $this;
  61647. }
  61648. public function sortByModifiedTime()
  61649. {
  61650. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  61651. return $this;
  61652. }
  61653. public function filter(\Closure $closure)
  61654. {
  61655. $this->filters[] = $closure;
  61656. return $this;
  61657. }
  61658. public function followLinks()
  61659. {
  61660. $this->followLinks = true;
  61661. return $this;
  61662. }
  61663. public function ignoreUnreadableDirs($ignore = true)
  61664. {
  61665. $this->ignoreUnreadableDirs = (bool) $ignore;
  61666. return $this;
  61667. }
  61668. public function in($dirs)
  61669. {
  61670. $resolvedDirs = array();
  61671. foreach ((array) $dirs as $dir) {
  61672. if (is_dir($dir)) {
  61673. $resolvedDirs[] = $this->normalizeDir($dir);
  61674. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  61675. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  61676. } else {
  61677. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  61678. }
  61679. }
  61680. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  61681. return $this;
  61682. }
  61683. public function getIterator()
  61684. {
  61685. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  61686. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  61687. }
  61688. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  61689. return $this->searchInDirectory($this->dirs[0]);
  61690. }
  61691. $iterator = new \AppendIterator();
  61692. foreach ($this->dirs as $dir) {
  61693. $iterator->append($this->searchInDirectory($dir));
  61694. }
  61695. foreach ($this->iterators as $it) {
  61696. $iterator->append($it);
  61697. }
  61698. return $iterator;
  61699. }
  61700. public function append($iterator)
  61701. {
  61702. if ($iterator instanceof \IteratorAggregate) {
  61703. $this->iterators[] = $iterator->getIterator();
  61704. } elseif ($iterator instanceof \Iterator) {
  61705. $this->iterators[] = $iterator;
  61706. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  61707. $it = new \ArrayIterator();
  61708. foreach ($iterator as $file) {
  61709. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  61710. }
  61711. $this->iterators[] = $it;
  61712. } else {
  61713. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  61714. }
  61715. return $this;
  61716. }
  61717. public function count()
  61718. {
  61719. return iterator_count($this->getIterator());
  61720. }
  61721. private function sortAdapters()
  61722. {
  61723. uasort($this->adapters, function (array $a, array $b) {
  61724. if ($a['selected'] || $b['selected']) {
  61725. return $a['selected'] ? -1 : 1;
  61726. }
  61727. return $a['priority'] > $b['priority'] ? -1 : 1;
  61728. });
  61729. return $this;
  61730. }
  61731. private function searchInDirectory($dir)
  61732. {
  61733. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  61734. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  61735. }
  61736. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  61737. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  61738. }
  61739. if ($this->adapters) {
  61740. foreach ($this->adapters as $adapter) {
  61741. if ($adapter['adapter']->isSupported()) {
  61742. try {
  61743. return $this
  61744. ->buildAdapter($adapter['adapter'])
  61745. ->searchInDirectory($dir);
  61746. } catch (ExceptionInterface $e) {
  61747. }
  61748. }
  61749. }
  61750. }
  61751. $minDepth = 0;
  61752. $maxDepth = PHP_INT_MAX;
  61753. foreach ($this->depths as $comparator) {
  61754. switch ($comparator->getOperator()) {
  61755. case '>':
  61756. $minDepth = $comparator->getTarget() + 1;
  61757. break;
  61758. case '>=':
  61759. $minDepth = $comparator->getTarget();
  61760. break;
  61761. case '<':
  61762. $maxDepth = $comparator->getTarget() - 1;
  61763. break;
  61764. case '<=':
  61765. $maxDepth = $comparator->getTarget();
  61766. break;
  61767. default:
  61768. $minDepth = $maxDepth = $comparator->getTarget();
  61769. }
  61770. }
  61771. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  61772. if ($this->followLinks) {
  61773. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  61774. }
  61775. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  61776. if ($this->exclude) {
  61777. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  61778. }
  61779. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  61780. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  61781. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  61782. }
  61783. if ($this->mode) {
  61784. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  61785. }
  61786. if ($this->names || $this->notNames) {
  61787. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  61788. }
  61789. if ($this->contains || $this->notContains) {
  61790. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  61791. }
  61792. if ($this->sizes) {
  61793. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  61794. }
  61795. if ($this->dates) {
  61796. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  61797. }
  61798. if ($this->filters) {
  61799. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  61800. }
  61801. if ($this->paths || $this->notPaths) {
  61802. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  61803. }
  61804. if ($this->sort) {
  61805. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  61806. $iterator = $iteratorAggregate->getIterator();
  61807. }
  61808. return $iterator;
  61809. }
  61810. private function buildAdapter(AdapterInterface $adapter)
  61811. {
  61812. return $adapter
  61813. ->setFollowLinks($this->followLinks)
  61814. ->setDepths($this->depths)
  61815. ->setMode($this->mode)
  61816. ->setExclude($this->exclude)
  61817. ->setNames($this->names)
  61818. ->setNotNames($this->notNames)
  61819. ->setContains($this->contains)
  61820. ->setNotContains($this->notContains)
  61821. ->setSizes($this->sizes)
  61822. ->setDates($this->dates)
  61823. ->setFilters($this->filters)
  61824. ->setSort($this->sort)
  61825. ->setPath($this->paths)
  61826. ->setNotPath($this->notPaths)
  61827. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  61828. }
  61829. private function resetAdapterSelection()
  61830. {
  61831. $this->adapters = array_map(function (array $properties) {
  61832. $properties['selected'] = false;
  61833. return $properties;
  61834. }, $this->adapters);
  61835. }
  61836. private function initDefaultAdapters()
  61837. {
  61838. if (null === $this->adapters) {
  61839. $this->adapters = array();
  61840. $this
  61841. ->addAdapter(new GnuFindAdapter())
  61842. ->addAdapter(new BsdFindAdapter())
  61843. ->addAdapter(new PhpAdapter(), -50)
  61844. ->setAdapter('php')
  61845. ;
  61846. }
  61847. }
  61848. private function normalizeDir($dir)
  61849. {
  61850. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  61851. }
  61852. }
  61853. <?php
  61854. namespace Symfony\Component\Finder;
  61855. class Glob
  61856. {
  61857. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  61858. {
  61859. $firstByte = true;
  61860. $escaping = false;
  61861. $inCurlies = 0;
  61862. $regex = '';
  61863. $sizeGlob = \strlen($glob);
  61864. for ($i = 0; $i < $sizeGlob; ++$i) {
  61865. $car = $glob[$i];
  61866. if ($firstByte) {
  61867. if ($strictLeadingDot && '.' !== $car) {
  61868. $regex .= '(?=[^\.])';
  61869. }
  61870. $firstByte = false;
  61871. }
  61872. if ('/' === $car) {
  61873. $firstByte = true;
  61874. }
  61875. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  61876. $regex .= "\\$car";
  61877. } elseif ('*' === $car) {
  61878. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  61879. } elseif ('?' === $car) {
  61880. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  61881. } elseif ('{' === $car) {
  61882. $regex .= $escaping ? '\\{' : '(';
  61883. if (!$escaping) {
  61884. ++$inCurlies;
  61885. }
  61886. } elseif ('}' === $car && $inCurlies) {
  61887. $regex .= $escaping ? '}' : ')';
  61888. if (!$escaping) {
  61889. --$inCurlies;
  61890. }
  61891. } elseif (',' === $car && $inCurlies) {
  61892. $regex .= $escaping ? ',' : '|';
  61893. } elseif ('\\' === $car) {
  61894. if ($escaping) {
  61895. $regex .= '\\\\';
  61896. $escaping = false;
  61897. } else {
  61898. $escaping = true;
  61899. }
  61900. continue;
  61901. } else {
  61902. $regex .= $car;
  61903. }
  61904. $escaping = false;
  61905. }
  61906. return $delimiter.'^'.$regex.'$'.$delimiter;
  61907. }
  61908. }
  61909. <?php
  61910. namespace Symfony\Component\Finder\Iterator;
  61911. class CustomFilterIterator extends FilterIterator
  61912. {
  61913. private $filters = array();
  61914. public function __construct(\Iterator $iterator, array $filters)
  61915. {
  61916. foreach ($filters as $filter) {
  61917. if (!\is_callable($filter)) {
  61918. throw new \InvalidArgumentException('Invalid PHP callback.');
  61919. }
  61920. }
  61921. $this->filters = $filters;
  61922. parent::__construct($iterator);
  61923. }
  61924. public function accept()
  61925. {
  61926. $fileinfo = $this->current();
  61927. foreach ($this->filters as $filter) {
  61928. if (false === \call_user_func($filter, $fileinfo)) {
  61929. return false;
  61930. }
  61931. }
  61932. return true;
  61933. }
  61934. }
  61935. <?php
  61936. namespace Symfony\Component\Finder\Iterator;
  61937. use Symfony\Component\Finder\Comparator\DateComparator;
  61938. class DateRangeFilterIterator extends FilterIterator
  61939. {
  61940. private $comparators = array();
  61941. public function __construct(\Iterator $iterator, array $comparators)
  61942. {
  61943. $this->comparators = $comparators;
  61944. parent::__construct($iterator);
  61945. }
  61946. public function accept()
  61947. {
  61948. $fileinfo = $this->current();
  61949. if (!file_exists($fileinfo->getPathname())) {
  61950. return false;
  61951. }
  61952. $filedate = $fileinfo->getMTime();
  61953. foreach ($this->comparators as $compare) {
  61954. if (!$compare->test($filedate)) {
  61955. return false;
  61956. }
  61957. }
  61958. return true;
  61959. }
  61960. }
  61961. <?php
  61962. namespace Symfony\Component\Finder\Iterator;
  61963. class DepthRangeFilterIterator extends FilterIterator
  61964. {
  61965. private $minDepth = 0;
  61966. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  61967. {
  61968. $this->minDepth = $minDepth;
  61969. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  61970. parent::__construct($iterator);
  61971. }
  61972. public function accept()
  61973. {
  61974. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  61975. }
  61976. }
  61977. <?php
  61978. namespace Symfony\Component\Finder\Iterator;
  61979. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  61980. {
  61981. private $iterator;
  61982. private $isRecursive;
  61983. private $excludedDirs = array();
  61984. private $excludedPattern;
  61985. public function __construct(\Iterator $iterator, array $directories)
  61986. {
  61987. $this->iterator = $iterator;
  61988. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  61989. $patterns = array();
  61990. foreach ($directories as $directory) {
  61991. $directory = rtrim($directory, '/');
  61992. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  61993. $patterns[] = preg_quote($directory, '#');
  61994. } else {
  61995. $this->excludedDirs[$directory] = true;
  61996. }
  61997. }
  61998. if ($patterns) {
  61999. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  62000. }
  62001. parent::__construct($iterator);
  62002. }
  62003. public function accept()
  62004. {
  62005. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  62006. return false;
  62007. }
  62008. if ($this->excludedPattern) {
  62009. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  62010. $path = str_replace('\\', '/', $path);
  62011. return !preg_match($this->excludedPattern, $path);
  62012. }
  62013. return true;
  62014. }
  62015. public function hasChildren()
  62016. {
  62017. return $this->isRecursive && $this->iterator->hasChildren();
  62018. }
  62019. public function getChildren()
  62020. {
  62021. $children = new self($this->iterator->getChildren(), array());
  62022. $children->excludedDirs = $this->excludedDirs;
  62023. $children->excludedPattern = $this->excludedPattern;
  62024. return $children;
  62025. }
  62026. }
  62027. <?php
  62028. namespace Symfony\Component\Finder\Iterator;
  62029. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  62030. use Symfony\Component\Finder\SplFileInfo;
  62031. class FilePathsIterator extends \ArrayIterator
  62032. {
  62033. private $baseDir;
  62034. private $baseDirLength;
  62035. private $subPath;
  62036. private $subPathname;
  62037. private $current;
  62038. public function __construct(array $paths, $baseDir)
  62039. {
  62040. $this->baseDir = $baseDir;
  62041. $this->baseDirLength = \strlen($baseDir);
  62042. parent::__construct($paths);
  62043. }
  62044. public function __call($name, array $arguments)
  62045. {
  62046. return \call_user_func_array(array($this->current(), $name), $arguments);
  62047. }
  62048. public function current()
  62049. {
  62050. return $this->current;
  62051. }
  62052. public function key()
  62053. {
  62054. return $this->current->getPathname();
  62055. }
  62056. public function next()
  62057. {
  62058. parent::next();
  62059. $this->buildProperties();
  62060. }
  62061. public function rewind()
  62062. {
  62063. parent::rewind();
  62064. $this->buildProperties();
  62065. }
  62066. public function getSubPath()
  62067. {
  62068. return $this->subPath;
  62069. }
  62070. public function getSubPathname()
  62071. {
  62072. return $this->subPathname;
  62073. }
  62074. private function buildProperties()
  62075. {
  62076. $absolutePath = parent::current();
  62077. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  62078. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  62079. $dir = \dirname($this->subPathname);
  62080. $this->subPath = '.' === $dir ? '' : $dir;
  62081. } else {
  62082. $this->subPath = $this->subPathname = '';
  62083. }
  62084. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  62085. }
  62086. }
  62087. <?php
  62088. namespace Symfony\Component\Finder\Iterator;
  62089. class FileTypeFilterIterator extends FilterIterator
  62090. {
  62091. const ONLY_FILES = 1;
  62092. const ONLY_DIRECTORIES = 2;
  62093. private $mode;
  62094. public function __construct(\Iterator $iterator, $mode)
  62095. {
  62096. $this->mode = $mode;
  62097. parent::__construct($iterator);
  62098. }
  62099. public function accept()
  62100. {
  62101. $fileinfo = $this->current();
  62102. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  62103. return false;
  62104. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  62105. return false;
  62106. }
  62107. return true;
  62108. }
  62109. }
  62110. <?php
  62111. namespace Symfony\Component\Finder\Iterator;
  62112. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  62113. {
  62114. public function accept()
  62115. {
  62116. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  62117. return true;
  62118. }
  62119. $fileinfo = $this->current();
  62120. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  62121. return false;
  62122. }
  62123. $content = $fileinfo->getContents();
  62124. if (!$content) {
  62125. return false;
  62126. }
  62127. return $this->isAccepted($content);
  62128. }
  62129. protected function toRegex($str)
  62130. {
  62131. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  62132. }
  62133. }
  62134. <?php
  62135. namespace Symfony\Component\Finder\Iterator;
  62136. use Symfony\Component\Finder\Glob;
  62137. class FilenameFilterIterator extends MultiplePcreFilterIterator
  62138. {
  62139. public function accept()
  62140. {
  62141. return $this->isAccepted($this->current()->getFilename());
  62142. }
  62143. protected function toRegex($str)
  62144. {
  62145. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  62146. }
  62147. }
  62148. <?php
  62149. namespace Symfony\Component\Finder\Iterator;
  62150. abstract class FilterIterator extends \FilterIterator
  62151. {
  62152. public function rewind()
  62153. {
  62154. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  62155. parent::rewind();
  62156. return;
  62157. }
  62158. $iterator = $this;
  62159. while ($iterator instanceof \OuterIterator) {
  62160. $innerIterator = $iterator->getInnerIterator();
  62161. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  62162. if ($innerIterator->isRewindable()) {
  62163. $innerIterator->next();
  62164. $innerIterator->rewind();
  62165. }
  62166. } elseif ($innerIterator instanceof \FilesystemIterator) {
  62167. $innerIterator->next();
  62168. $innerIterator->rewind();
  62169. }
  62170. $iterator = $innerIterator;
  62171. }
  62172. parent::rewind();
  62173. }
  62174. }
  62175. <?php
  62176. namespace Symfony\Component\Finder\Iterator;
  62177. abstract class MultiplePcreFilterIterator extends FilterIterator
  62178. {
  62179. protected $matchRegexps = array();
  62180. protected $noMatchRegexps = array();
  62181. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  62182. {
  62183. foreach ($matchPatterns as $pattern) {
  62184. $this->matchRegexps[] = $this->toRegex($pattern);
  62185. }
  62186. foreach ($noMatchPatterns as $pattern) {
  62187. $this->noMatchRegexps[] = $this->toRegex($pattern);
  62188. }
  62189. parent::__construct($iterator);
  62190. }
  62191. protected function isAccepted($string)
  62192. {
  62193. foreach ($this->noMatchRegexps as $regex) {
  62194. if (preg_match($regex, $string)) {
  62195. return false;
  62196. }
  62197. }
  62198. if ($this->matchRegexps) {
  62199. foreach ($this->matchRegexps as $regex) {
  62200. if (preg_match($regex, $string)) {
  62201. return true;
  62202. }
  62203. }
  62204. return false;
  62205. }
  62206. return true;
  62207. }
  62208. protected function isRegex($str)
  62209. {
  62210. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  62211. $start = substr($m[1], 0, 1);
  62212. $end = substr($m[1], -1);
  62213. if ($start === $end) {
  62214. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  62215. }
  62216. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  62217. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  62218. return true;
  62219. }
  62220. }
  62221. }
  62222. return false;
  62223. }
  62224. abstract protected function toRegex($str);
  62225. }
  62226. <?php
  62227. namespace Symfony\Component\Finder\Iterator;
  62228. class PathFilterIterator extends MultiplePcreFilterIterator
  62229. {
  62230. public function accept()
  62231. {
  62232. $filename = $this->current()->getRelativePathname();
  62233. if ('\\' === \DIRECTORY_SEPARATOR) {
  62234. $filename = str_replace('\\', '/', $filename);
  62235. }
  62236. return $this->isAccepted($filename);
  62237. }
  62238. protected function toRegex($str)
  62239. {
  62240. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  62241. }
  62242. }
  62243. <?php
  62244. namespace Symfony\Component\Finder\Iterator;
  62245. use Symfony\Component\Finder\Exception\AccessDeniedException;
  62246. use Symfony\Component\Finder\SplFileInfo;
  62247. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  62248. {
  62249. private $ignoreUnreadableDirs;
  62250. private $rewindable;
  62251. private $rootPath;
  62252. private $subPath;
  62253. private $directorySeparator = '/';
  62254. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  62255. {
  62256. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  62257. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  62258. }
  62259. parent::__construct($path, $flags);
  62260. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  62261. $this->rootPath = (string) $path;
  62262. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  62263. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  62264. }
  62265. }
  62266. public function current()
  62267. {
  62268. if (null === $subPathname = $this->subPath) {
  62269. $subPathname = $this->subPath = (string) $this->getSubPath();
  62270. }
  62271. if ('' !== $subPathname) {
  62272. $subPathname .= $this->directorySeparator;
  62273. }
  62274. $subPathname .= $this->getFilename();
  62275. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  62276. }
  62277. public function getChildren()
  62278. {
  62279. try {
  62280. $children = parent::getChildren();
  62281. if ($children instanceof self) {
  62282. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  62283. $children->rewindable = &$this->rewindable;
  62284. $children->rootPath = $this->rootPath;
  62285. }
  62286. return $children;
  62287. } catch (\UnexpectedValueException $e) {
  62288. if ($this->ignoreUnreadableDirs) {
  62289. return new \RecursiveArrayIterator(array());
  62290. } else {
  62291. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  62292. }
  62293. }
  62294. }
  62295. public function rewind()
  62296. {
  62297. if (false === $this->isRewindable()) {
  62298. return;
  62299. }
  62300. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  62301. parent::next();
  62302. }
  62303. parent::rewind();
  62304. }
  62305. public function isRewindable()
  62306. {
  62307. if (null !== $this->rewindable) {
  62308. return $this->rewindable;
  62309. }
  62310. if ('' === $this->getPath()) {
  62311. return $this->rewindable = false;
  62312. }
  62313. if (false !== $stream = @opendir($this->getPath())) {
  62314. $infos = stream_get_meta_data($stream);
  62315. closedir($stream);
  62316. if ($infos['seekable']) {
  62317. return $this->rewindable = true;
  62318. }
  62319. }
  62320. return $this->rewindable = false;
  62321. }
  62322. }
  62323. <?php
  62324. namespace Symfony\Component\Finder\Iterator;
  62325. use Symfony\Component\Finder\Comparator\NumberComparator;
  62326. class SizeRangeFilterIterator extends FilterIterator
  62327. {
  62328. private $comparators = array();
  62329. public function __construct(\Iterator $iterator, array $comparators)
  62330. {
  62331. $this->comparators = $comparators;
  62332. parent::__construct($iterator);
  62333. }
  62334. public function accept()
  62335. {
  62336. $fileinfo = $this->current();
  62337. if (!$fileinfo->isFile()) {
  62338. return true;
  62339. }
  62340. $filesize = $fileinfo->getSize();
  62341. foreach ($this->comparators as $compare) {
  62342. if (!$compare->test($filesize)) {
  62343. return false;
  62344. }
  62345. }
  62346. return true;
  62347. }
  62348. }
  62349. <?php
  62350. namespace Symfony\Component\Finder\Iterator;
  62351. class SortableIterator implements \IteratorAggregate
  62352. {
  62353. const SORT_BY_NAME = 1;
  62354. const SORT_BY_TYPE = 2;
  62355. const SORT_BY_ACCESSED_TIME = 3;
  62356. const SORT_BY_CHANGED_TIME = 4;
  62357. const SORT_BY_MODIFIED_TIME = 5;
  62358. private $iterator;
  62359. private $sort;
  62360. public function __construct(\Traversable $iterator, $sort)
  62361. {
  62362. $this->iterator = $iterator;
  62363. if (self::SORT_BY_NAME === $sort) {
  62364. $this->sort = function ($a, $b) {
  62365. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  62366. };
  62367. } elseif (self::SORT_BY_TYPE === $sort) {
  62368. $this->sort = function ($a, $b) {
  62369. if ($a->isDir() && $b->isFile()) {
  62370. return -1;
  62371. } elseif ($a->isFile() && $b->isDir()) {
  62372. return 1;
  62373. }
  62374. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  62375. };
  62376. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  62377. $this->sort = function ($a, $b) {
  62378. return $a->getATime() - $b->getATime();
  62379. };
  62380. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  62381. $this->sort = function ($a, $b) {
  62382. return $a->getCTime() - $b->getCTime();
  62383. };
  62384. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  62385. $this->sort = function ($a, $b) {
  62386. return $a->getMTime() - $b->getMTime();
  62387. };
  62388. } elseif (\is_callable($sort)) {
  62389. $this->sort = $sort;
  62390. } else {
  62391. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  62392. }
  62393. }
  62394. public function getIterator()
  62395. {
  62396. $array = iterator_to_array($this->iterator, true);
  62397. uasort($array, $this->sort);
  62398. return new \ArrayIterator($array);
  62399. }
  62400. }
  62401. Copyright (c) 2004-2018 Fabien Potencier
  62402. Permission is hereby granted, free of charge, to any person obtaining a copy
  62403. of this software and associated documentation files (the "Software"), to deal
  62404. in the Software without restriction, including without limitation the rights
  62405. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62406. copies of the Software, and to permit persons to whom the Software is furnished
  62407. to do so, subject to the following conditions:
  62408. The above copyright notice and this permission notice shall be included in all
  62409. copies or substantial portions of the Software.
  62410. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62411. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62412. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62413. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62414. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62415. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62416. THE SOFTWARE.
  62417. <?php
  62418. namespace Symfony\Component\Finder\Shell;
  62419. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  62420. class Command
  62421. {
  62422. private $parent;
  62423. private $bits = array();
  62424. private $labels = array();
  62425. private $errorHandler;
  62426. public function __construct(Command $parent = null)
  62427. {
  62428. $this->parent = $parent;
  62429. }
  62430. public function __toString()
  62431. {
  62432. return $this->join();
  62433. }
  62434. public static function create(Command $parent = null)
  62435. {
  62436. return new self($parent);
  62437. }
  62438. public static function escape($input)
  62439. {
  62440. return escapeshellcmd($input);
  62441. }
  62442. public static function quote($input)
  62443. {
  62444. return escapeshellarg($input);
  62445. }
  62446. public function add($bit)
  62447. {
  62448. $this->bits[] = $bit;
  62449. return $this;
  62450. }
  62451. public function top($bit)
  62452. {
  62453. array_unshift($this->bits, $bit);
  62454. foreach ($this->labels as $label => $index) {
  62455. ++$this->labels[$label];
  62456. }
  62457. return $this;
  62458. }
  62459. public function arg($arg)
  62460. {
  62461. $this->bits[] = self::quote($arg);
  62462. return $this;
  62463. }
  62464. public function cmd($esc)
  62465. {
  62466. $this->bits[] = self::escape($esc);
  62467. return $this;
  62468. }
  62469. public function ins($label)
  62470. {
  62471. if (isset($this->labels[$label])) {
  62472. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  62473. }
  62474. $this->bits[] = self::create($this);
  62475. $this->labels[$label] = \count($this->bits) - 1;
  62476. return $this->bits[$this->labels[$label]];
  62477. }
  62478. public function get($label)
  62479. {
  62480. if (!isset($this->labels[$label])) {
  62481. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  62482. }
  62483. return $this->bits[$this->labels[$label]];
  62484. }
  62485. public function end()
  62486. {
  62487. if (null === $this->parent) {
  62488. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  62489. }
  62490. return $this->parent;
  62491. }
  62492. public function length()
  62493. {
  62494. return \count($this->bits);
  62495. }
  62496. public function setErrorHandler(\Closure $errorHandler)
  62497. {
  62498. $this->errorHandler = $errorHandler;
  62499. return $this;
  62500. }
  62501. public function getErrorHandler()
  62502. {
  62503. return $this->errorHandler;
  62504. }
  62505. public function execute()
  62506. {
  62507. if (null === $errorHandler = $this->errorHandler) {
  62508. exec($this->join(), $output);
  62509. } else {
  62510. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  62511. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  62512. if ($error = stream_get_contents($pipes[2])) {
  62513. $errorHandler($error);
  62514. }
  62515. proc_close($process);
  62516. }
  62517. return $output ?: array();
  62518. }
  62519. public function join()
  62520. {
  62521. return implode(' ', array_filter(
  62522. array_map(function ($bit) {
  62523. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  62524. }, $this->bits),
  62525. function ($bit) { return null !== $bit; }
  62526. ));
  62527. }
  62528. public function addAtIndex($bit, $index)
  62529. {
  62530. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  62531. return $this;
  62532. }
  62533. }
  62534. <?php
  62535. namespace Symfony\Component\Finder\Shell;
  62536. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  62537. class Shell
  62538. {
  62539. const TYPE_UNIX = 1;
  62540. const TYPE_DARWIN = 2;
  62541. const TYPE_CYGWIN = 3;
  62542. const TYPE_WINDOWS = 4;
  62543. const TYPE_BSD = 5;
  62544. private $type;
  62545. public function getType()
  62546. {
  62547. if (null === $this->type) {
  62548. $this->type = $this->guessType();
  62549. }
  62550. return $this->type;
  62551. }
  62552. public function testCommand($command)
  62553. {
  62554. if (!\function_exists('exec')) {
  62555. return false;
  62556. }
  62557. $testCommand = 'which ';
  62558. if (self::TYPE_WINDOWS === $this->type) {
  62559. $testCommand = 'where ';
  62560. }
  62561. $command = escapeshellcmd($command);
  62562. exec($testCommand.$command, $output, $code);
  62563. return 0 === $code && \count($output) > 0;
  62564. }
  62565. private function guessType()
  62566. {
  62567. $os = strtolower(PHP_OS);
  62568. if (false !== strpos($os, 'cygwin')) {
  62569. return self::TYPE_CYGWIN;
  62570. }
  62571. if (false !== strpos($os, 'darwin')) {
  62572. return self::TYPE_DARWIN;
  62573. }
  62574. if (false !== strpos($os, 'bsd')) {
  62575. return self::TYPE_BSD;
  62576. }
  62577. if (0 === strpos($os, 'win')) {
  62578. return self::TYPE_WINDOWS;
  62579. }
  62580. return self::TYPE_UNIX;
  62581. }
  62582. }
  62583. <?php
  62584. namespace Symfony\Component\Finder;
  62585. class SplFileInfo extends \SplFileInfo
  62586. {
  62587. private $relativePath;
  62588. private $relativePathname;
  62589. public function __construct($file, $relativePath, $relativePathname)
  62590. {
  62591. parent::__construct($file);
  62592. $this->relativePath = $relativePath;
  62593. $this->relativePathname = $relativePathname;
  62594. }
  62595. public function getRelativePath()
  62596. {
  62597. return $this->relativePath;
  62598. }
  62599. public function getRelativePathname()
  62600. {
  62601. return $this->relativePathname;
  62602. }
  62603. public function getContents()
  62604. {
  62605. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  62606. $content = file_get_contents($this->getPathname());
  62607. restore_error_handler();
  62608. if (false === $content) {
  62609. throw new \RuntimeException($error);
  62610. }
  62611. return $content;
  62612. }
  62613. }
  62614. <?php
  62615. namespace Symfony\Polyfill\Ctype;
  62616. final class Ctype
  62617. {
  62618. public static function ctype_alnum($text)
  62619. {
  62620. $text = self::convert_int_to_char_for_ctype($text);
  62621. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  62622. }
  62623. public static function ctype_alpha($text)
  62624. {
  62625. $text = self::convert_int_to_char_for_ctype($text);
  62626. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  62627. }
  62628. public static function ctype_cntrl($text)
  62629. {
  62630. $text = self::convert_int_to_char_for_ctype($text);
  62631. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  62632. }
  62633. public static function ctype_digit($text)
  62634. {
  62635. $text = self::convert_int_to_char_for_ctype($text);
  62636. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  62637. }
  62638. public static function ctype_graph($text)
  62639. {
  62640. $text = self::convert_int_to_char_for_ctype($text);
  62641. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  62642. }
  62643. public static function ctype_lower($text)
  62644. {
  62645. $text = self::convert_int_to_char_for_ctype($text);
  62646. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  62647. }
  62648. public static function ctype_print($text)
  62649. {
  62650. $text = self::convert_int_to_char_for_ctype($text);
  62651. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  62652. }
  62653. public static function ctype_punct($text)
  62654. {
  62655. $text = self::convert_int_to_char_for_ctype($text);
  62656. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  62657. }
  62658. public static function ctype_space($text)
  62659. {
  62660. $text = self::convert_int_to_char_for_ctype($text);
  62661. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  62662. }
  62663. public static function ctype_upper($text)
  62664. {
  62665. $text = self::convert_int_to_char_for_ctype($text);
  62666. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  62667. }
  62668. public static function ctype_xdigit($text)
  62669. {
  62670. $text = self::convert_int_to_char_for_ctype($text);
  62671. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  62672. }
  62673. private static function convert_int_to_char_for_ctype($int)
  62674. {
  62675. if (!\is_int($int)) {
  62676. return $int;
  62677. }
  62678. if ($int < -128 || $int > 255) {
  62679. return (string) $int;
  62680. }
  62681. if ($int < 0) {
  62682. $int += 256;
  62683. }
  62684. return \chr($int);
  62685. }
  62686. }
  62687. Copyright (c) 2018-2019 Fabien Potencier
  62688. Permission is hereby granted, free of charge, to any person obtaining a copy
  62689. of this software and associated documentation files (the "Software"), to deal
  62690. in the Software without restriction, including without limitation the rights
  62691. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62692. copies of the Software, and to permit persons to whom the Software is furnished
  62693. to do so, subject to the following conditions:
  62694. The above copyright notice and this permission notice shall be included in all
  62695. copies or substantial portions of the Software.
  62696. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62697. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62698. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62699. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62700. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62701. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62702. THE SOFTWARE.
  62703. <?php
  62704. use Symfony\Polyfill\Ctype as p;
  62705. if (!function_exists('ctype_alnum')) {
  62706. function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); }
  62707. }
  62708. if (!function_exists('ctype_alpha')) {
  62709. function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); }
  62710. }
  62711. if (!function_exists('ctype_cntrl')) {
  62712. function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); }
  62713. }
  62714. if (!function_exists('ctype_digit')) {
  62715. function ctype_digit($input) { return p\Ctype::ctype_digit($input); }
  62716. }
  62717. if (!function_exists('ctype_graph')) {
  62718. function ctype_graph($input) { return p\Ctype::ctype_graph($input); }
  62719. }
  62720. if (!function_exists('ctype_lower')) {
  62721. function ctype_lower($input) { return p\Ctype::ctype_lower($input); }
  62722. }
  62723. if (!function_exists('ctype_print')) {
  62724. function ctype_print($input) { return p\Ctype::ctype_print($input); }
  62725. }
  62726. if (!function_exists('ctype_punct')) {
  62727. function ctype_punct($input) { return p\Ctype::ctype_punct($input); }
  62728. }
  62729. if (!function_exists('ctype_space')) {
  62730. function ctype_space($input) { return p\Ctype::ctype_space($input); }
  62731. }
  62732. if (!function_exists('ctype_upper')) {
  62733. function ctype_upper($input) { return p\Ctype::ctype_upper($input); }
  62734. }
  62735. if (!function_exists('ctype_xdigit')) {
  62736. function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); }
  62737. }
  62738. Copyright (c) 2015-2019 Fabien Potencier
  62739. Permission is hereby granted, free of charge, to any person obtaining a copy
  62740. of this software and associated documentation files (the "Software"), to deal
  62741. in the Software without restriction, including without limitation the rights
  62742. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62743. copies of the Software, and to permit persons to whom the Software is furnished
  62744. to do so, subject to the following conditions:
  62745. The above copyright notice and this permission notice shall be included in all
  62746. copies or substantial portions of the Software.
  62747. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62748. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62749. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62750. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62751. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62752. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62753. THE SOFTWARE.
  62754. <?php
  62755. namespace Symfony\Polyfill\Mbstring;
  62756. final class Mbstring
  62757. {
  62758. const MB_CASE_FOLD = PHP_INT_MAX;
  62759. private static $encodingList = array('ASCII', 'UTF-8');
  62760. private static $language = 'neutral';
  62761. private static $internalEncoding = 'UTF-8';
  62762. private static $caseFold = array(
  62763. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  62764. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  62765. );
  62766. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  62767. {
  62768. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  62769. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  62770. } else {
  62771. $fromEncoding = self::getEncoding($fromEncoding);
  62772. }
  62773. $toEncoding = self::getEncoding($toEncoding);
  62774. if ('BASE64' === $fromEncoding) {
  62775. $s = base64_decode($s);
  62776. $fromEncoding = $toEncoding;
  62777. }
  62778. if ('BASE64' === $toEncoding) {
  62779. return base64_encode($s);
  62780. }
  62781. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  62782. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  62783. $fromEncoding = 'Windows-1252';
  62784. }
  62785. if ('UTF-8' !== $fromEncoding) {
  62786. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  62787. }
  62788. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  62789. }
  62790. if ('HTML-ENTITIES' === $fromEncoding) {
  62791. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  62792. $fromEncoding = 'UTF-8';
  62793. }
  62794. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  62795. }
  62796. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  62797. {
  62798. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  62799. $ok = true;
  62800. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  62801. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  62802. $ok = false;
  62803. }
  62804. });
  62805. return $ok ? $fromEncoding : false;
  62806. }
  62807. public static function mb_decode_mimeheader($s)
  62808. {
  62809. return iconv_mime_decode($s, 2, self::$internalEncoding);
  62810. }
  62811. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  62812. {
  62813. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  62814. }
  62815. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  62816. {
  62817. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  62818. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  62819. return null;
  62820. }
  62821. if (!\is_array($convmap) || !$convmap) {
  62822. return false;
  62823. }
  62824. if (null !== $encoding && !\is_scalar($encoding)) {
  62825. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  62826. return '';
  62827. }
  62828. $s = (string) $s;
  62829. if ('' === $s) {
  62830. return '';
  62831. }
  62832. $encoding = self::getEncoding($encoding);
  62833. if ('UTF-8' === $encoding) {
  62834. $encoding = null;
  62835. if (!preg_match('//u', $s)) {
  62836. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  62837. }
  62838. } else {
  62839. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  62840. }
  62841. $cnt = floor(\count($convmap) / 4) * 4;
  62842. for ($i = 0; $i < $cnt; $i += 4) {
  62843. $convmap[$i] += $convmap[$i + 2];
  62844. $convmap[$i + 1] += $convmap[$i + 2];
  62845. }
  62846. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  62847. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  62848. for ($i = 0; $i < $cnt; $i += 4) {
  62849. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  62850. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  62851. }
  62852. }
  62853. return $m[0];
  62854. }, $s);
  62855. if (null === $encoding) {
  62856. return $s;
  62857. }
  62858. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  62859. }
  62860. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  62861. {
  62862. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  62863. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  62864. return null;
  62865. }
  62866. if (!\is_array($convmap) || !$convmap) {
  62867. return false;
  62868. }
  62869. if (null !== $encoding && !\is_scalar($encoding)) {
  62870. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  62871. return null;
  62872. }
  62873. if (null !== $is_hex && !\is_scalar($is_hex)) {
  62874. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  62875. return null;
  62876. }
  62877. $s = (string) $s;
  62878. if ('' === $s) {
  62879. return '';
  62880. }
  62881. $encoding = self::getEncoding($encoding);
  62882. if ('UTF-8' === $encoding) {
  62883. $encoding = null;
  62884. if (!preg_match('//u', $s)) {
  62885. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  62886. }
  62887. } else {
  62888. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  62889. }
  62890. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  62891. $cnt = floor(\count($convmap) / 4) * 4;
  62892. $i = 0;
  62893. $len = \strlen($s);
  62894. $result = '';
  62895. while ($i < $len) {
  62896. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  62897. $uchr = substr($s, $i, $ulen);
  62898. $i += $ulen;
  62899. $c = self::mb_ord($uchr);
  62900. for ($j = 0; $j < $cnt; $j += 4) {
  62901. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  62902. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  62903. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  62904. continue 2;
  62905. }
  62906. }
  62907. $result .= $uchr;
  62908. }
  62909. if (null === $encoding) {
  62910. return $result;
  62911. }
  62912. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  62913. }
  62914. public static function mb_convert_case($s, $mode, $encoding = null)
  62915. {
  62916. $s = (string) $s;
  62917. if ('' === $s) {
  62918. return '';
  62919. }
  62920. $encoding = self::getEncoding($encoding);
  62921. if ('UTF-8' === $encoding) {
  62922. $encoding = null;
  62923. if (!preg_match('//u', $s)) {
  62924. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  62925. }
  62926. } else {
  62927. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  62928. }
  62929. if (MB_CASE_TITLE == $mode) {
  62930. static $titleRegexp = null;
  62931. if (null === $titleRegexp) {
  62932. $titleRegexp = self::getData('titleCaseRegexp');
  62933. }
  62934. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  62935. } else {
  62936. if (MB_CASE_UPPER == $mode) {
  62937. static $upper = null;
  62938. if (null === $upper) {
  62939. $upper = self::getData('upperCase');
  62940. }
  62941. $map = $upper;
  62942. } else {
  62943. if (self::MB_CASE_FOLD === $mode) {
  62944. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  62945. }
  62946. static $lower = null;
  62947. if (null === $lower) {
  62948. $lower = self::getData('lowerCase');
  62949. }
  62950. $map = $lower;
  62951. }
  62952. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  62953. $i = 0;
  62954. $len = \strlen($s);
  62955. while ($i < $len) {
  62956. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  62957. $uchr = substr($s, $i, $ulen);
  62958. $i += $ulen;
  62959. if (isset($map[$uchr])) {
  62960. $uchr = $map[$uchr];
  62961. $nlen = \strlen($uchr);
  62962. if ($nlen == $ulen) {
  62963. $nlen = $i;
  62964. do {
  62965. $s[--$nlen] = $uchr[--$ulen];
  62966. } while ($ulen);
  62967. } else {
  62968. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  62969. $len += $nlen - $ulen;
  62970. $i += $nlen - $ulen;
  62971. }
  62972. }
  62973. }
  62974. }
  62975. if (null === $encoding) {
  62976. return $s;
  62977. }
  62978. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  62979. }
  62980. public static function mb_internal_encoding($encoding = null)
  62981. {
  62982. if (null === $encoding) {
  62983. return self::$internalEncoding;
  62984. }
  62985. $encoding = self::getEncoding($encoding);
  62986. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  62987. self::$internalEncoding = $encoding;
  62988. return true;
  62989. }
  62990. return false;
  62991. }
  62992. public static function mb_language($lang = null)
  62993. {
  62994. if (null === $lang) {
  62995. return self::$language;
  62996. }
  62997. switch ($lang = strtolower($lang)) {
  62998. case 'uni':
  62999. case 'neutral':
  63000. self::$language = $lang;
  63001. return true;
  63002. }
  63003. return false;
  63004. }
  63005. public static function mb_list_encodings()
  63006. {
  63007. return array('UTF-8');
  63008. }
  63009. public static function mb_encoding_aliases($encoding)
  63010. {
  63011. switch (strtoupper($encoding)) {
  63012. case 'UTF8':
  63013. case 'UTF-8':
  63014. return array('utf8');
  63015. }
  63016. return false;
  63017. }
  63018. public static function mb_check_encoding($var = null, $encoding = null)
  63019. {
  63020. if (null === $encoding) {
  63021. if (null === $var) {
  63022. return false;
  63023. }
  63024. $encoding = self::$internalEncoding;
  63025. }
  63026. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  63027. }
  63028. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  63029. {
  63030. if (null === $encodingList) {
  63031. $encodingList = self::$encodingList;
  63032. } else {
  63033. if (!\is_array($encodingList)) {
  63034. $encodingList = array_map('trim', explode(',', $encodingList));
  63035. }
  63036. $encodingList = array_map('strtoupper', $encodingList);
  63037. }
  63038. foreach ($encodingList as $enc) {
  63039. switch ($enc) {
  63040. case 'ASCII':
  63041. if (!preg_match('/[\x80-\xFF]/', $str)) {
  63042. return $enc;
  63043. }
  63044. break;
  63045. case 'UTF8':
  63046. case 'UTF-8':
  63047. if (preg_match('//u', $str)) {
  63048. return 'UTF-8';
  63049. }
  63050. break;
  63051. default:
  63052. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  63053. return $enc;
  63054. }
  63055. }
  63056. }
  63057. return false;
  63058. }
  63059. public static function mb_detect_order($encodingList = null)
  63060. {
  63061. if (null === $encodingList) {
  63062. return self::$encodingList;
  63063. }
  63064. if (!\is_array($encodingList)) {
  63065. $encodingList = array_map('trim', explode(',', $encodingList));
  63066. }
  63067. $encodingList = array_map('strtoupper', $encodingList);
  63068. foreach ($encodingList as $enc) {
  63069. switch ($enc) {
  63070. default:
  63071. if (strncmp($enc, 'ISO-8859-', 9)) {
  63072. return false;
  63073. }
  63074. case 'ASCII':
  63075. case 'UTF8':
  63076. case 'UTF-8':
  63077. }
  63078. }
  63079. self::$encodingList = $encodingList;
  63080. return true;
  63081. }
  63082. public static function mb_strlen($s, $encoding = null)
  63083. {
  63084. $encoding = self::getEncoding($encoding);
  63085. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  63086. return \strlen($s);
  63087. }
  63088. return @iconv_strlen($s, $encoding);
  63089. }
  63090. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  63091. {
  63092. $encoding = self::getEncoding($encoding);
  63093. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  63094. return strpos($haystack, $needle, $offset);
  63095. }
  63096. $needle = (string) $needle;
  63097. if ('' === $needle) {
  63098. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  63099. return false;
  63100. }
  63101. return iconv_strpos($haystack, $needle, $offset, $encoding);
  63102. }
  63103. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  63104. {
  63105. $encoding = self::getEncoding($encoding);
  63106. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  63107. return strrpos($haystack, $needle, $offset);
  63108. }
  63109. if ($offset != (int) $offset) {
  63110. $offset = 0;
  63111. } elseif ($offset = (int) $offset) {
  63112. if ($offset < 0) {
  63113. if (0 > $offset += self::mb_strlen($needle)) {
  63114. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  63115. }
  63116. $offset = 0;
  63117. } else {
  63118. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  63119. }
  63120. }
  63121. $pos = iconv_strrpos($haystack, $needle, $encoding);
  63122. return false !== $pos ? $offset + $pos : false;
  63123. }
  63124. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  63125. {
  63126. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
  63127. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
  63128. return null;
  63129. }
  63130. if (1 > $split_length = (int) $split_length) {
  63131. trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
  63132. return false;
  63133. }
  63134. if (null === $encoding) {
  63135. $encoding = mb_internal_encoding();
  63136. }
  63137. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  63138. $rx = '/(';
  63139. while (65535 < $split_length) {
  63140. $rx .= '.{65535}';
  63141. $split_length -= 65535;
  63142. }
  63143. $rx .= '.{'.$split_length.'})/us';
  63144. return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  63145. }
  63146. $result = array();
  63147. $length = mb_strlen($string, $encoding);
  63148. for ($i = 0; $i < $length; $i += $split_length) {
  63149. $result[] = mb_substr($string, $i, $split_length, $encoding);
  63150. }
  63151. return $result;
  63152. }
  63153. public static function mb_strtolower($s, $encoding = null)
  63154. {
  63155. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  63156. }
  63157. public static function mb_strtoupper($s, $encoding = null)
  63158. {
  63159. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  63160. }
  63161. public static function mb_substitute_character($c = null)
  63162. {
  63163. if (0 === strcasecmp($c, 'none')) {
  63164. return true;
  63165. }
  63166. return null !== $c ? false : 'none';
  63167. }
  63168. public static function mb_substr($s, $start, $length = null, $encoding = null)
  63169. {
  63170. $encoding = self::getEncoding($encoding);
  63171. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  63172. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  63173. }
  63174. if ($start < 0) {
  63175. $start = iconv_strlen($s, $encoding) + $start;
  63176. if ($start < 0) {
  63177. $start = 0;
  63178. }
  63179. }
  63180. if (null === $length) {
  63181. $length = 2147483647;
  63182. } elseif ($length < 0) {
  63183. $length = iconv_strlen($s, $encoding) + $length - $start;
  63184. if ($length < 0) {
  63185. return '';
  63186. }
  63187. }
  63188. return (string) iconv_substr($s, $start, $length, $encoding);
  63189. }
  63190. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  63191. {
  63192. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  63193. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  63194. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  63195. }
  63196. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  63197. {
  63198. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  63199. return self::getSubpart($pos, $part, $haystack, $encoding);
  63200. }
  63201. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  63202. {
  63203. $encoding = self::getEncoding($encoding);
  63204. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  63205. $pos = strrpos($haystack, $needle);
  63206. } else {
  63207. $needle = self::mb_substr($needle, 0, 1, $encoding);
  63208. $pos = iconv_strrpos($haystack, $needle, $encoding);
  63209. }
  63210. return self::getSubpart($pos, $part, $haystack, $encoding);
  63211. }
  63212. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  63213. {
  63214. $needle = self::mb_substr($needle, 0, 1, $encoding);
  63215. $pos = self::mb_strripos($haystack, $needle, $encoding);
  63216. return self::getSubpart($pos, $part, $haystack, $encoding);
  63217. }
  63218. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  63219. {
  63220. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  63221. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  63222. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  63223. }
  63224. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  63225. {
  63226. $pos = strpos($haystack, $needle);
  63227. if (false === $pos) {
  63228. return false;
  63229. }
  63230. if ($part) {
  63231. return substr($haystack, 0, $pos);
  63232. }
  63233. return substr($haystack, $pos);
  63234. }
  63235. public static function mb_get_info($type = 'all')
  63236. {
  63237. $info = array(
  63238. 'internal_encoding' => self::$internalEncoding,
  63239. 'http_output' => 'pass',
  63240. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  63241. 'func_overload' => 0,
  63242. 'func_overload_list' => 'no overload',
  63243. 'mail_charset' => 'UTF-8',
  63244. 'mail_header_encoding' => 'BASE64',
  63245. 'mail_body_encoding' => 'BASE64',
  63246. 'illegal_chars' => 0,
  63247. 'encoding_translation' => 'Off',
  63248. 'language' => self::$language,
  63249. 'detect_order' => self::$encodingList,
  63250. 'substitute_character' => 'none',
  63251. 'strict_detection' => 'Off',
  63252. );
  63253. if ('all' === $type) {
  63254. return $info;
  63255. }
  63256. if (isset($info[$type])) {
  63257. return $info[$type];
  63258. }
  63259. return false;
  63260. }
  63261. public static function mb_http_input($type = '')
  63262. {
  63263. return false;
  63264. }
  63265. public static function mb_http_output($encoding = null)
  63266. {
  63267. return null !== $encoding ? 'pass' === $encoding : 'pass';
  63268. }
  63269. public static function mb_strwidth($s, $encoding = null)
  63270. {
  63271. $encoding = self::getEncoding($encoding);
  63272. if ('UTF-8' !== $encoding) {
  63273. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  63274. }
  63275. $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);
  63276. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  63277. }
  63278. public static function mb_substr_count($haystack, $needle, $encoding = null)
  63279. {
  63280. return substr_count($haystack, $needle);
  63281. }
  63282. public static function mb_output_handler($contents, $status)
  63283. {
  63284. return $contents;
  63285. }
  63286. public static function mb_chr($code, $encoding = null)
  63287. {
  63288. if (0x80 > $code %= 0x200000) {
  63289. $s = \chr($code);
  63290. } elseif (0x800 > $code) {
  63291. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  63292. } elseif (0x10000 > $code) {
  63293. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  63294. } else {
  63295. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  63296. }
  63297. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  63298. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  63299. }
  63300. return $s;
  63301. }
  63302. public static function mb_ord($s, $encoding = null)
  63303. {
  63304. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  63305. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  63306. }
  63307. if (1 === \strlen($s)) {
  63308. return \ord($s);
  63309. }
  63310. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  63311. if (0xF0 <= $code) {
  63312. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  63313. }
  63314. if (0xE0 <= $code) {
  63315. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  63316. }
  63317. if (0xC0 <= $code) {
  63318. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  63319. }
  63320. return $code;
  63321. }
  63322. private static function getSubpart($pos, $part, $haystack, $encoding)
  63323. {
  63324. if (false === $pos) {
  63325. return false;
  63326. }
  63327. if ($part) {
  63328. return self::mb_substr($haystack, 0, $pos, $encoding);
  63329. }
  63330. return self::mb_substr($haystack, $pos, null, $encoding);
  63331. }
  63332. private static function html_encoding_callback(array $m)
  63333. {
  63334. $i = 1;
  63335. $entities = '';
  63336. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  63337. while (isset($m[$i])) {
  63338. if (0x80 > $m[$i]) {
  63339. $entities .= \chr($m[$i++]);
  63340. continue;
  63341. }
  63342. if (0xF0 <= $m[$i]) {
  63343. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  63344. } elseif (0xE0 <= $m[$i]) {
  63345. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  63346. } else {
  63347. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  63348. }
  63349. $entities .= '&#'.$c.';';
  63350. }
  63351. return $entities;
  63352. }
  63353. private static function title_case(array $s)
  63354. {
  63355. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  63356. }
  63357. private static function getData($file)
  63358. {
  63359. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  63360. return require $file;
  63361. }
  63362. return false;
  63363. }
  63364. private static function getEncoding($encoding)
  63365. {
  63366. if (null === $encoding) {
  63367. return self::$internalEncoding;
  63368. }
  63369. if ('UTF-8' === $encoding) {
  63370. return 'UTF-8';
  63371. }
  63372. $encoding = strtoupper($encoding);
  63373. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  63374. return 'CP850';
  63375. }
  63376. if ('UTF8' === $encoding) {
  63377. return 'UTF-8';
  63378. }
  63379. return $encoding;
  63380. }
  63381. }
  63382. <?php
  63383. use Symfony\Polyfill\Mbstring as p;
  63384. if (!function_exists('mb_convert_variables')) {
  63385. function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
  63386. {
  63387. $vars = [&$var, ...$vars];
  63388. $ok = true;
  63389. array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
  63390. if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
  63391. $ok = false;
  63392. }
  63393. });
  63394. return $ok ? $from_encoding : false;
  63395. }
  63396. }
  63397. <?php
  63398. return array (
  63399. 'A' => 'a',
  63400. 'B' => 'b',
  63401. 'C' => 'c',
  63402. 'D' => 'd',
  63403. 'E' => 'e',
  63404. 'F' => 'f',
  63405. 'G' => 'g',
  63406. 'H' => 'h',
  63407. 'I' => 'i',
  63408. 'J' => 'j',
  63409. 'K' => 'k',
  63410. 'L' => 'l',
  63411. 'M' => 'm',
  63412. 'N' => 'n',
  63413. 'O' => 'o',
  63414. 'P' => 'p',
  63415. 'Q' => 'q',
  63416. 'R' => 'r',
  63417. 'S' => 's',
  63418. 'T' => 't',
  63419. 'U' => 'u',
  63420. 'V' => 'v',
  63421. 'W' => 'w',
  63422. 'X' => 'x',
  63423. 'Y' => 'y',
  63424. 'Z' => 'z',
  63425. 'À' => 'à',
  63426. '�' => 'á',
  63427. 'Â' => 'â',
  63428. 'Ã' => 'ã',
  63429. 'Ä' => 'ä',
  63430. 'Ã…' => 'Ã¥',
  63431. 'Æ' => 'æ',
  63432. 'Ç' => 'ç',
  63433. 'È' => 'è',
  63434. 'É' => 'é',
  63435. 'Ê' => 'ê',
  63436. 'Ë' => 'ë',
  63437. 'Ì' => 'ì',
  63438. '�' => 'í',
  63439. 'Î' => 'î',
  63440. '�' => 'ï',
  63441. '�' => 'ð',
  63442. 'Ñ' => 'ñ',
  63443. 'Ò' => 'ò',
  63444. 'Ó' => 'ó',
  63445. 'Ô' => 'ô',
  63446. 'Õ' => 'õ',
  63447. 'Ö' => 'ö',
  63448. 'Ø' => 'ø',
  63449. 'Ù' => 'ù',
  63450. 'Ú' => 'ú',
  63451. 'Û' => 'û',
  63452. 'Ü' => 'ü',
  63453. '�' => 'ý',
  63454. 'Þ' => 'þ',
  63455. 'Ā' => '�',
  63456. 'Ă' => 'ă',
  63457. 'Ä„' => 'Ä…',
  63458. 'Ć' => 'ć',
  63459. 'Ĉ' => 'ĉ',
  63460. 'ÄŠ' => 'Ä‹',
  63461. 'Č' => '�',
  63462. 'Ď' => '�',
  63463. '�' => 'đ',
  63464. 'Ä’' => 'Ä“',
  63465. 'Ä”' => 'Ä•',
  63466. 'Ä–' => 'Ä—',
  63467. 'Ę' => 'ę',
  63468. 'Äš' => 'Ä›',
  63469. 'Ĝ' => '�',
  63470. 'Äž' => 'ÄŸ',
  63471. 'Ä ' => 'Ä¡',
  63472. 'Ä¢' => 'Ä£',
  63473. 'Ĥ' => 'ĥ',
  63474. 'Ħ' => 'ħ',
  63475. 'Ĩ' => 'ĩ',
  63476. 'Ī' => 'ī',
  63477. 'Ĭ' => 'ĭ',
  63478. 'Į' => 'į',
  63479. 'İ' => 'i',
  63480. 'IJ' => 'ij',
  63481. 'Ĵ' => 'ĵ',
  63482. 'Ķ' => 'ķ',
  63483. 'Ĺ' => 'ĺ',
  63484. 'Ļ' => 'ļ',
  63485. 'Ľ' => 'ľ',
  63486. 'Ä¿' => 'Å€',
  63487. '�' => 'ł',
  63488. 'Ń' => 'ń',
  63489. 'Ņ' => 'ņ',
  63490. 'Ň' => 'ň',
  63491. 'ÅŠ' => 'Å‹',
  63492. 'Ō' => '�',
  63493. 'Ŏ' => '�',
  63494. '�' => 'ő',
  63495. 'Å’' => 'Å“',
  63496. 'Å”' => 'Å•',
  63497. 'Å–' => 'Å—',
  63498. 'Ř' => 'ř',
  63499. 'Åš' => 'Å›',
  63500. 'Ŝ' => '�',
  63501. 'Åž' => 'ÅŸ',
  63502. 'Å ' => 'Å¡',
  63503. 'Å¢' => 'Å£',
  63504. 'Ť' => 'ť',
  63505. 'Ŧ' => 'ŧ',
  63506. 'Ũ' => 'ũ',
  63507. 'Ū' => 'ū',
  63508. 'Ŭ' => 'ŭ',
  63509. 'Ů' => 'ů',
  63510. 'Ű' => 'ű',
  63511. 'Ų' => 'ų',
  63512. 'Ŵ' => 'ŵ',
  63513. 'Ŷ' => 'ŷ',
  63514. 'Ÿ' => 'ÿ',
  63515. 'Ź' => 'ź',
  63516. 'Ż' => 'ż',
  63517. 'Ž' => 'ž',
  63518. '�' => 'ɓ',
  63519. 'Ƃ' => 'ƃ',
  63520. 'Æ„' => 'Æ…',
  63521. 'Ɔ' => 'ɔ',
  63522. 'Ƈ' => 'ƈ',
  63523. 'Ɖ' => 'ɖ',
  63524. 'ÆŠ' => 'É—',
  63525. 'Ƌ' => 'ƌ',
  63526. 'Ǝ' => '�',
  63527. '�' => 'ə',
  63528. '�' => 'ɛ',
  63529. 'Æ‘' => 'Æ’',
  63530. 'Æ“' => 'É ',
  63531. 'Æ”' => 'É£',
  63532. 'Æ–' => 'É©',
  63533. 'Ɨ' => 'ɨ',
  63534. 'Ƙ' => 'ƙ',
  63535. 'Ɯ' => 'ɯ',
  63536. '�' => 'ɲ',
  63537. 'Ɵ' => 'ɵ',
  63538. 'Æ ' => 'Æ¡',
  63539. 'Æ¢' => 'Æ£',
  63540. 'Ƥ' => 'ƥ',
  63541. 'Ʀ' => 'ʀ',
  63542. 'Ƨ' => 'ƨ',
  63543. 'Ʃ' => 'ʃ',
  63544. 'Ƭ' => 'ƭ',
  63545. 'Ʈ' => 'ʈ',
  63546. 'Ư' => 'ư',
  63547. 'Ʊ' => 'ʊ',
  63548. 'Ʋ' => 'ʋ',
  63549. 'Ƴ' => 'ƴ',
  63550. 'Ƶ' => 'ƶ',
  63551. 'Æ·' => 'Ê’',
  63552. 'Ƹ' => 'ƹ',
  63553. 'Ƽ' => 'ƽ',
  63554. 'DŽ' => 'dž',
  63555. 'Dž' => 'dž',
  63556. 'LJ' => 'lj',
  63557. 'Lj' => 'lj',
  63558. 'NJ' => 'nj',
  63559. 'Nj' => 'nj',
  63560. '�' => 'ǎ',
  63561. '�' => '�',
  63562. 'Ç‘' => 'Ç’',
  63563. 'Ç“' => 'Ç”',
  63564. 'Ç•' => 'Ç–',
  63565. 'Ǘ' => 'ǘ',
  63566. 'Ç™' => 'Çš',
  63567. 'Ǜ' => 'ǜ',
  63568. 'Çž' => 'ÇŸ',
  63569. 'Ç ' => 'Ç¡',
  63570. 'Ç¢' => 'Ç£',
  63571. 'Ǥ' => 'ǥ',
  63572. 'Ǧ' => 'ǧ',
  63573. 'Ǩ' => 'ǩ',
  63574. 'Ǫ' => 'ǫ',
  63575. 'Ǭ' => 'ǭ',
  63576. 'Ǯ' => 'ǯ',
  63577. 'DZ' => 'dz',
  63578. 'Dz' => 'dz',
  63579. 'Ǵ' => 'ǵ',
  63580. 'Ƕ' => 'ƕ',
  63581. 'Ç·' => 'Æ¿',
  63582. 'Ǹ' => 'ǹ',
  63583. 'Ǻ' => 'ǻ',
  63584. 'Ǽ' => 'ǽ',
  63585. 'Ǿ' => 'ǿ',
  63586. 'Ȁ' => '�',
  63587. 'Ȃ' => 'ȃ',
  63588. 'È„' => 'È…',
  63589. 'Ȇ' => 'ȇ',
  63590. 'Ȉ' => 'ȉ',
  63591. 'ÈŠ' => 'È‹',
  63592. 'Ȍ' => '�',
  63593. 'Ȏ' => '�',
  63594. '�' => 'ȑ',
  63595. 'È’' => 'È“',
  63596. 'È”' => 'È•',
  63597. 'È–' => 'È—',
  63598. 'Ș' => 'ș',
  63599. 'Èš' => 'È›',
  63600. 'Ȝ' => '�',
  63601. 'Èž' => 'ÈŸ',
  63602. 'È ' => 'Æž',
  63603. 'È¢' => 'È£',
  63604. 'Ȥ' => 'ȥ',
  63605. 'Ȧ' => 'ȧ',
  63606. 'Ȩ' => 'ȩ',
  63607. 'Ȫ' => 'ȫ',
  63608. 'Ȭ' => 'ȭ',
  63609. 'Ȯ' => 'ȯ',
  63610. 'Ȱ' => 'ȱ',
  63611. 'Ȳ' => 'ȳ',
  63612. 'Ⱥ' => 'ⱥ',
  63613. 'Ȼ' => 'ȼ',
  63614. 'Ƚ' => 'ƚ',
  63615. 'Ⱦ' => 'ⱦ',
  63616. '�' => 'ɂ',
  63617. 'Ƀ' => 'ƀ',
  63618. 'Ʉ' => 'ʉ',
  63619. 'Ʌ' => 'ʌ',
  63620. 'Ɇ' => 'ɇ',
  63621. 'Ɉ' => 'ɉ',
  63622. 'ÉŠ' => 'É‹',
  63623. 'Ɍ' => '�',
  63624. 'Ɏ' => '�',
  63625. 'Ͱ' => 'ͱ',
  63626. 'Ͳ' => 'ͳ',
  63627. 'Ͷ' => 'ͷ',
  63628. 'Ϳ' => 'ϳ',
  63629. 'Ά' => 'ά',
  63630. 'Έ' => 'έ',
  63631. 'Ή' => 'ή',
  63632. 'Ί' => 'ί',
  63633. 'Ό' => 'ό',
  63634. 'Ύ' => '�',
  63635. '�' => 'ώ',
  63636. 'Α' => 'α',
  63637. 'Β' => 'β',
  63638. 'Γ' => 'γ',
  63639. 'Δ' => 'δ',
  63640. 'Ε' => 'ε',
  63641. 'Ζ' => 'ζ',
  63642. 'Η' => 'η',
  63643. 'Θ' => 'θ',
  63644. 'Ι' => 'ι',
  63645. 'Κ' => 'κ',
  63646. 'Λ' => 'λ',
  63647. 'Μ' => 'μ',
  63648. '�' => 'ν',
  63649. 'Ξ' => 'ξ',
  63650. 'Ο' => 'ο',
  63651. 'Π' => 'π',
  63652. 'Ρ' => '�',
  63653. 'Σ' => 'σ',
  63654. 'Τ' => 'τ',
  63655. 'Î¥' => 'Ï…',
  63656. 'Φ' => 'φ',
  63657. 'Χ' => 'χ',
  63658. 'Ψ' => 'ψ',
  63659. 'Ω' => 'ω',
  63660. 'Ϊ' => 'ϊ',
  63661. 'Ϋ' => 'ϋ',
  63662. '�' => 'ϗ',
  63663. 'Ϙ' => 'ϙ',
  63664. 'Ïš' => 'Ï›',
  63665. 'Ϝ' => '�',
  63666. 'Ïž' => 'ÏŸ',
  63667. 'Ï ' => 'Ï¡',
  63668. 'Ï¢' => 'Ï£',
  63669. 'Ϥ' => 'ϥ',
  63670. 'Ϧ' => 'ϧ',
  63671. 'Ϩ' => 'ϩ',
  63672. 'Ϫ' => 'ϫ',
  63673. 'Ϭ' => 'ϭ',
  63674. 'Ϯ' => 'ϯ',
  63675. 'ϴ' => 'θ',
  63676. 'Ϸ' => 'ϸ',
  63677. 'Ϲ' => 'ϲ',
  63678. 'Ϻ' => 'ϻ',
  63679. 'Ͻ' => 'ͻ',
  63680. 'Ͼ' => 'ͼ',
  63681. 'Ͽ' => 'ͽ',
  63682. 'Ѐ' => '�',
  63683. '�' => 'ё',
  63684. 'Ђ' => 'ђ',
  63685. 'Ѓ' => 'ѓ',
  63686. 'Є' => 'є',
  63687. 'Ð…' => 'Ñ•',
  63688. 'І' => 'і',
  63689. 'Ї' => 'ї',
  63690. 'Ј' => 'ј',
  63691. 'Љ' => 'љ',
  63692. 'Њ' => 'њ',
  63693. 'Ћ' => 'ћ',
  63694. 'Ќ' => 'ќ',
  63695. '�' => '�',
  63696. 'ÐŽ' => 'Ñž',
  63697. '�' => 'џ',
  63698. '�' => 'а',
  63699. 'Б' => 'б',
  63700. 'В' => 'в',
  63701. 'Г' => 'г',
  63702. 'Д' => 'д',
  63703. 'Е' => 'е',
  63704. 'Ж' => 'ж',
  63705. 'З' => 'з',
  63706. 'И' => 'и',
  63707. 'Й' => 'й',
  63708. 'К' => 'к',
  63709. 'Л' => 'л',
  63710. 'М' => 'м',
  63711. '�' => 'н',
  63712. 'О' => 'о',
  63713. 'П' => 'п',
  63714. 'Р' => 'р',
  63715. 'С' => '�',
  63716. 'Т' => 'т',
  63717. 'У' => 'у',
  63718. 'Ф' => 'ф',
  63719. 'Ð¥' => 'Ñ…',
  63720. 'Ц' => 'ц',
  63721. 'Ч' => 'ч',
  63722. 'Ш' => 'ш',
  63723. 'Щ' => 'щ',
  63724. 'Ъ' => 'ъ',
  63725. 'Ы' => 'ы',
  63726. 'Ь' => 'ь',
  63727. 'Э' => '�',
  63728. 'Ю' => 'ю',
  63729. 'Я' => '�',
  63730. 'Ñ ' => 'Ñ¡',
  63731. 'Ñ¢' => 'Ñ£',
  63732. 'Ѥ' => 'ѥ',
  63733. 'Ѧ' => 'ѧ',
  63734. 'Ѩ' => 'ѩ',
  63735. 'Ѫ' => 'ѫ',
  63736. 'Ѭ' => 'ѭ',
  63737. 'Ѯ' => 'ѯ',
  63738. 'Ѱ' => 'ѱ',
  63739. 'Ѳ' => 'ѳ',
  63740. 'Ѵ' => 'ѵ',
  63741. 'Ѷ' => 'ѷ',
  63742. 'Ѹ' => 'ѹ',
  63743. 'Ѻ' => 'ѻ',
  63744. 'Ѽ' => 'ѽ',
  63745. 'Ѿ' => 'ѿ',
  63746. 'Ò€' => 'Ò�',
  63747. 'ÒŠ' => 'Ò‹',
  63748. 'Ҍ' => '�',
  63749. 'ÒŽ' => 'Ò�',
  63750. 'Ò�' => 'Ò‘',
  63751. 'Ò’' => 'Ò“',
  63752. 'Ò”' => 'Ò•',
  63753. 'Ò–' => 'Ò—',
  63754. 'Ò˜' => 'Ò™',
  63755. 'Òš' => 'Ò›',
  63756. 'Ҝ' => '�',
  63757. 'Òž' => 'ÒŸ',
  63758. 'Ò ' => 'Ò¡',
  63759. 'Ò¢' => 'Ò£',
  63760. 'Ò¤' => 'Ò¥',
  63761. 'Ò¦' => 'Ò§',
  63762. 'Ò¨' => 'Ò©',
  63763. 'Òª' => 'Ò«',
  63764. 'Ò¬' => 'Ò­',
  63765. 'Ò®' => 'Ò¯',
  63766. 'Ò°' => 'Ò±',
  63767. 'Ò²' => 'Ò³',
  63768. 'Ò´' => 'Òµ',
  63769. 'Ò¶' => 'Ò·',
  63770. 'Ò¸' => 'Ò¹',
  63771. 'Òº' => 'Ò»',
  63772. 'Ò¼' => 'Ò½',
  63773. 'Ò¾' => 'Ò¿',
  63774. 'Ó€' => 'Ó�',
  63775. 'Ó�' => 'Ó‚',
  63776. 'Óƒ' => 'Ó„',
  63777. 'Ó…' => 'Ó†',
  63778. 'Ó‡' => 'Óˆ',
  63779. 'Ó‰' => 'ÓŠ',
  63780. 'Ӌ' => 'ӌ',
  63781. 'Ó�' => 'ÓŽ',
  63782. 'Ó�' => 'Ó‘',
  63783. 'Ó’' => 'Ó“',
  63784. 'Ó”' => 'Ó•',
  63785. 'Ó–' => 'Ó—',
  63786. 'Ó˜' => 'Ó™',
  63787. 'Óš' => 'Ó›',
  63788. 'Ӝ' => '�',
  63789. 'Óž' => 'ÓŸ',
  63790. 'Ó ' => 'Ó¡',
  63791. 'Ó¢' => 'Ó£',
  63792. 'Ó¤' => 'Ó¥',
  63793. 'Ó¦' => 'Ó§',
  63794. 'Ó¨' => 'Ó©',
  63795. 'Óª' => 'Ó«',
  63796. 'Ó¬' => 'Ó­',
  63797. 'Ó®' => 'Ó¯',
  63798. 'Ó°' => 'Ó±',
  63799. 'Ó²' => 'Ó³',
  63800. 'Ó´' => 'Óµ',
  63801. 'Ó¶' => 'Ó·',
  63802. 'Ó¸' => 'Ó¹',
  63803. 'Óº' => 'Ó»',
  63804. 'Ó¼' => 'Ó½',
  63805. 'Ó¾' => 'Ó¿',
  63806. 'Ô€' => 'Ô�',
  63807. 'Ô‚' => 'Ôƒ',
  63808. 'Ô„' => 'Ô…',
  63809. 'Ô†' => 'Ô‡',
  63810. 'Ôˆ' => 'Ô‰',
  63811. 'ÔŠ' => 'Ô‹',
  63812. 'Ԍ' => '�',
  63813. 'ÔŽ' => 'Ô�',
  63814. 'Ô�' => 'Ô‘',
  63815. 'Ô’' => 'Ô“',
  63816. 'Ô”' => 'Ô•',
  63817. 'Ô–' => 'Ô—',
  63818. 'Ô˜' => 'Ô™',
  63819. 'Ôš' => 'Ô›',
  63820. 'Ԝ' => '�',
  63821. 'Ôž' => 'ÔŸ',
  63822. 'Ô ' => 'Ô¡',
  63823. 'Ô¢' => 'Ô£',
  63824. 'Ô¤' => 'Ô¥',
  63825. 'Ô¦' => 'Ô§',
  63826. 'Ô¨' => 'Ô©',
  63827. 'Ôª' => 'Ô«',
  63828. 'Ô¬' => 'Ô­',
  63829. 'Ô®' => 'Ô¯',
  63830. 'Ô±' => 'Õ¡',
  63831. 'Ô²' => 'Õ¢',
  63832. 'Ô³' => 'Õ£',
  63833. 'Ô´' => 'Õ¤',
  63834. 'Ôµ' => 'Õ¥',
  63835. 'Ô¶' => 'Õ¦',
  63836. 'Ô·' => 'Õ§',
  63837. 'Ô¸' => 'Õ¨',
  63838. 'Ô¹' => 'Õ©',
  63839. 'Ôº' => 'Õª',
  63840. 'Ô»' => 'Õ«',
  63841. 'Ô¼' => 'Õ¬',
  63842. 'Ô½' => 'Õ­',
  63843. 'Ô¾' => 'Õ®',
  63844. 'Ô¿' => 'Õ¯',
  63845. 'Õ€' => 'Õ°',
  63846. 'Õ�' => 'Õ±',
  63847. 'Õ‚' => 'Õ²',
  63848. 'Õƒ' => 'Õ³',
  63849. 'Õ„' => 'Õ´',
  63850. 'Õ…' => 'Õµ',
  63851. 'Õ†' => 'Õ¶',
  63852. 'Õ‡' => 'Õ·',
  63853. 'Õˆ' => 'Õ¸',
  63854. 'Õ‰' => 'Õ¹',
  63855. 'ÕŠ' => 'Õº',
  63856. 'Õ‹' => 'Õ»',
  63857. 'Ռ' => 'ռ',
  63858. 'Õ�' => 'Õ½',
  63859. 'ÕŽ' => 'Õ¾',
  63860. 'Õ�' => 'Õ¿',
  63861. 'Õ�' => 'Ö€',
  63862. 'Õ‘' => 'Ö�',
  63863. 'Õ’' => 'Ö‚',
  63864. 'Õ“' => 'Öƒ',
  63865. 'Õ”' => 'Ö„',
  63866. 'Õ•' => 'Ö…',
  63867. 'Õ–' => 'Ö†',
  63868. 'á‚ ' => 'â´€',
  63869. 'á‚¡' => 'â´�',
  63870. 'á‚¢' => 'â´‚',
  63871. 'á‚£' => 'â´ƒ',
  63872. 'Ⴄ' => 'ⴄ',
  63873. 'á‚¥' => 'â´…',
  63874. 'Ⴆ' => 'ⴆ',
  63875. 'á‚§' => 'â´‡',
  63876. 'Ⴈ' => 'ⴈ',
  63877. 'á‚©' => 'â´‰',
  63878. 'Ⴊ' => 'ⴊ',
  63879. 'á‚«' => 'â´‹',
  63880. 'Ⴌ' => 'ⴌ',
  63881. 'á‚­' => 'â´�',
  63882. 'á‚®' => 'â´Ž',
  63883. 'Ⴏ' => '�',
  63884. 'á‚°' => 'â´�',
  63885. 'Ⴑ' => 'ⴑ',
  63886. 'Ⴒ' => 'ⴒ',
  63887. 'Ⴓ' => 'ⴓ',
  63888. 'á‚´' => 'â´”',
  63889. 'Ⴕ' => 'ⴕ',
  63890. 'á‚¶' => 'â´–',
  63891. 'á‚·' => 'â´—',
  63892. 'Ⴘ' => 'ⴘ',
  63893. 'Ⴙ' => 'ⴙ',
  63894. 'Ⴚ' => 'ⴚ',
  63895. 'á‚»' => 'â´›',
  63896. 'Ⴜ' => 'ⴜ',
  63897. 'Ⴝ' => '�',
  63898. 'Ⴞ' => 'ⴞ',
  63899. 'á‚¿' => 'â´Ÿ',
  63900. 'Ⴠ' => 'ⴠ',
  63901. '�' => 'ⴡ',
  63902. 'Ⴢ' => 'ⴢ',
  63903. 'Ⴣ' => 'ⴣ',
  63904. 'Ⴤ' => 'ⴤ',
  63905. 'Ⴥ' => 'ⴥ',
  63906. 'Ⴧ' => 'ⴧ',
  63907. '�' => 'ⴭ',
  63908. 'Ꭰ' => 'ꭰ',
  63909. 'Ꭱ' => 'ꭱ',
  63910. 'Ꭲ' => 'ꭲ',
  63911. 'Ꭳ' => 'ꭳ',
  63912. 'Ꭴ' => 'ꭴ',
  63913. 'Ꭵ' => 'ꭵ',
  63914. 'Ꭶ' => 'ꭶ',
  63915. 'Ꭷ' => 'ꭷ',
  63916. 'Ꭸ' => 'ꭸ',
  63917. 'Ꭹ' => 'ꭹ',
  63918. 'Ꭺ' => 'ꭺ',
  63919. 'Ꭻ' => 'ꭻ',
  63920. 'Ꭼ' => 'ꭼ',
  63921. 'Ꭽ' => 'ꭽ',
  63922. 'Ꭾ' => 'ꭾ',
  63923. 'Ꭿ' => 'ꭿ',
  63924. 'Ꮀ' => 'ꮀ',
  63925. 'Ꮁ' => '�',
  63926. 'Ꮂ' => 'ꮂ',
  63927. 'Ꮃ' => 'ꮃ',
  63928. 'Ꮄ' => 'ꮄ',
  63929. 'Ꮅ' => 'ꮅ',
  63930. 'Ꮆ' => 'ꮆ',
  63931. 'Ꮇ' => 'ꮇ',
  63932. 'Ꮈ' => 'ꮈ',
  63933. 'Ꮉ' => 'ꮉ',
  63934. 'Ꮊ' => 'ꮊ',
  63935. 'Ꮋ' => 'ꮋ',
  63936. 'Ꮌ' => 'ꮌ',
  63937. 'Ꮍ' => '�',
  63938. 'Ꮎ' => 'ꮎ',
  63939. 'Ꮏ' => '�',
  63940. '�' => '�',
  63941. '�' => 'ꮑ',
  63942. '�' => 'ꮒ',
  63943. '�' => 'ꮓ',
  63944. '�' => 'ꮔ',
  63945. '�' => 'ꮕ',
  63946. '�' => 'ꮖ',
  63947. '�' => 'ꮗ',
  63948. '�' => 'ꮘ',
  63949. '�' => 'ꮙ',
  63950. '�' => 'ꮚ',
  63951. '�' => 'ꮛ',
  63952. '�' => 'ꮜ',
  63953. '�' => '�',
  63954. '�' => 'ꮞ',
  63955. '�' => 'ꮟ',
  63956. '�' => 'ꮠ',
  63957. '�' => 'ꮡ',
  63958. '�' => 'ꮢ',
  63959. '�' => 'ꮣ',
  63960. '�' => 'ꮤ',
  63961. '�' => 'ꮥ',
  63962. '�' => 'ꮦ',
  63963. '�' => 'ꮧ',
  63964. '�' => 'ꮨ',
  63965. '�' => 'ꮩ',
  63966. '�' => 'ꮪ',
  63967. '�' => 'ꮫ',
  63968. '�' => 'ꮬ',
  63969. '�' => 'ꮭ',
  63970. '�' => 'ꮮ',
  63971. '�' => 'ꮯ',
  63972. '�' => 'ꮰ',
  63973. '�' => 'ꮱ',
  63974. '�' => 'ꮲ',
  63975. '�' => 'ꮳ',
  63976. '�' => 'ꮴ',
  63977. '�' => 'ꮵ',
  63978. '�' => 'ꮶ',
  63979. '�' => 'ꮷ',
  63980. '�' => 'ꮸ',
  63981. '�' => 'ꮹ',
  63982. '�' => 'ꮺ',
  63983. '�' => 'ꮻ',
  63984. '�' => 'ꮼ',
  63985. '�' => 'ꮽ',
  63986. '�' => 'ꮾ',
  63987. '�' => 'ꮿ',
  63988. '�' => '�',
  63989. '�' => '�',
  63990. '�' => '�',
  63991. '�' => '�',
  63992. '�' => '�',
  63993. '�' => '�',
  63994. '�' => '�',
  63995. 'Ბ' => 'ბ',
  63996. 'Გ' => 'გ',
  63997. 'Დ' => 'დ',
  63998. 'Ე' => 'ე',
  63999. 'Ვ' => 'ვ',
  64000. 'Ზ' => 'ზ',
  64001. 'Თ' => 'თ',
  64002. 'Ი' => 'ი',
  64003. 'Კ' => 'კ',
  64004. 'Ლ' => 'ლ',
  64005. 'Მ' => 'მ',
  64006. 'Ნ' => 'ნ',
  64007. '�' => '�',
  64008. 'Პ' => 'პ',
  64009. 'Ჟ' => 'ჟ',
  64010. 'Რ' => 'რ',
  64011. 'Ს' => 'ს',
  64012. 'Ტ' => 'ტ',
  64013. 'Უ' => 'უ',
  64014. 'Ფ' => 'ფ',
  64015. 'Ქ' => 'ქ',
  64016. 'Ღ' => 'ღ',
  64017. 'Ყ' => 'ყ',
  64018. 'Შ' => 'შ',
  64019. 'Ჩ' => 'ჩ',
  64020. 'Ც' => 'ც',
  64021. 'Ძ' => 'ძ',
  64022. 'Წ' => 'წ',
  64023. 'Ჭ' => 'ჭ',
  64024. 'Ხ' => 'ხ',
  64025. 'Ჯ' => 'ჯ',
  64026. 'Ჰ' => 'ჰ',
  64027. 'Ჱ' => 'ჱ',
  64028. 'Ჲ' => 'ჲ',
  64029. 'Ჳ' => 'ჳ',
  64030. 'Ჴ' => 'ჴ',
  64031. 'Ჵ' => 'ჵ',
  64032. 'Ჶ' => 'ჶ',
  64033. 'Ჷ' => 'ჷ',
  64034. 'Ჸ' => 'ჸ',
  64035. 'Ჹ' => 'ჹ',
  64036. 'Ჺ' => 'ჺ',
  64037. 'Ჽ' => 'ჽ',
  64038. 'Ჾ' => 'ჾ',
  64039. 'Ჿ' => 'ჿ',
  64040. 'Ḁ' => '�',
  64041. 'Ḃ' => 'ḃ',
  64042. 'Ḅ' => 'ḅ',
  64043. 'Ḇ' => 'ḇ',
  64044. 'Ḉ' => 'ḉ',
  64045. 'Ḋ' => 'ḋ',
  64046. 'Ḍ' => '�',
  64047. 'Ḏ' => '�',
  64048. '�' => 'ḑ',
  64049. 'Ḓ' => 'ḓ',
  64050. 'Ḕ' => 'ḕ',
  64051. 'Ḗ' => 'ḗ',
  64052. 'Ḙ' => 'ḙ',
  64053. 'Ḛ' => 'ḛ',
  64054. 'Ḝ' => '�',
  64055. 'Ḟ' => 'ḟ',
  64056. 'Ḡ' => 'ḡ',
  64057. 'Ḣ' => 'ḣ',
  64058. 'Ḥ' => 'ḥ',
  64059. 'Ḧ' => 'ḧ',
  64060. 'Ḩ' => 'ḩ',
  64061. 'Ḫ' => 'ḫ',
  64062. 'Ḭ' => 'ḭ',
  64063. 'Ḯ' => 'ḯ',
  64064. 'Ḱ' => 'ḱ',
  64065. 'Ḳ' => 'ḳ',
  64066. 'Ḵ' => 'ḵ',
  64067. 'Ḷ' => 'ḷ',
  64068. 'Ḹ' => 'ḹ',
  64069. 'Ḻ' => 'ḻ',
  64070. 'Ḽ' => 'ḽ',
  64071. 'Ḿ' => 'ḿ',
  64072. 'Ṁ' => '�',
  64073. 'Ṃ' => 'ṃ',
  64074. 'Ṅ' => 'ṅ',
  64075. 'Ṇ' => 'ṇ',
  64076. 'Ṉ' => 'ṉ',
  64077. 'Ṋ' => 'ṋ',
  64078. 'Ṍ' => '�',
  64079. 'Ṏ' => '�',
  64080. '�' => 'ṑ',
  64081. 'Ṓ' => 'ṓ',
  64082. 'Ṕ' => 'ṕ',
  64083. 'á¹–' => 'á¹—',
  64084. 'Ṙ' => 'ṙ',
  64085. 'Ṛ' => 'ṛ',
  64086. 'Ṝ' => '�',
  64087. 'Ṟ' => 'ṟ',
  64088. 'Ṡ' => 'ṡ',
  64089. 'á¹¢' => 'á¹£',
  64090. 'Ṥ' => 'ṥ',
  64091. 'Ṧ' => 'ṧ',
  64092. 'Ṩ' => 'ṩ',
  64093. 'Ṫ' => 'ṫ',
  64094. 'Ṭ' => 'ṭ',
  64095. 'Ṯ' => 'ṯ',
  64096. 'á¹°' => 'á¹±',
  64097. 'á¹²' => 'á¹³',
  64098. 'á¹´' => 'á¹µ',
  64099. 'á¹¶' => 'á¹·',
  64100. 'Ṹ' => 'ṹ',
  64101. 'Ṻ' => 'ṻ',
  64102. 'á¹¼' => 'á¹½',
  64103. 'Ṿ' => 'ṿ',
  64104. 'Ẁ' => '�',
  64105. 'Ẃ' => 'ẃ',
  64106. 'Ẅ' => 'ẅ',
  64107. 'Ẇ' => 'ẇ',
  64108. 'Ẉ' => 'ẉ',
  64109. 'Ẋ' => 'ẋ',
  64110. 'Ẍ' => '�',
  64111. 'Ẏ' => '�',
  64112. '�' => 'ẑ',
  64113. 'Ẓ' => 'ẓ',
  64114. 'Ẕ' => 'ẕ',
  64115. 'ẞ' => 'ß',
  64116. 'Ạ' => 'ạ',
  64117. 'Ả' => 'ả',
  64118. 'Ấ' => 'ấ',
  64119. 'Ầ' => 'ầ',
  64120. 'Ẩ' => 'ẩ',
  64121. 'Ẫ' => 'ẫ',
  64122. 'Ậ' => 'ậ',
  64123. 'Ắ' => 'ắ',
  64124. 'Ằ' => 'ằ',
  64125. 'Ẳ' => 'ẳ',
  64126. 'Ẵ' => 'ẵ',
  64127. 'Ặ' => 'ặ',
  64128. 'Ẹ' => 'ẹ',
  64129. 'Ẻ' => 'ẻ',
  64130. 'Ẽ' => 'ẽ',
  64131. 'Ế' => 'ế',
  64132. 'Ề' => '�',
  64133. 'Ể' => 'ể',
  64134. 'Ễ' => 'ễ',
  64135. 'Ệ' => 'ệ',
  64136. 'Ỉ' => 'ỉ',
  64137. 'Ị' => 'ị',
  64138. 'Ọ' => '�',
  64139. 'Ỏ' => '�',
  64140. '�' => 'ố',
  64141. 'Ồ' => 'ồ',
  64142. 'Ổ' => 'ổ',
  64143. 'á»–' => 'á»—',
  64144. 'Ộ' => 'ộ',
  64145. 'Ớ' => 'ớ',
  64146. 'Ờ' => '�',
  64147. 'Ở' => 'ở',
  64148. 'Ỡ' => 'ỡ',
  64149. 'Ợ' => 'ợ',
  64150. 'Ụ' => 'ụ',
  64151. 'Ủ' => 'ủ',
  64152. 'Ứ' => 'ứ',
  64153. 'Ừ' => 'ừ',
  64154. 'Ử' => 'ử',
  64155. 'Ữ' => 'ữ',
  64156. 'á»°' => 'á»±',
  64157. 'Ỳ' => 'ỳ',
  64158. 'Ỵ' => 'ỵ',
  64159. 'á»¶' => 'á»·',
  64160. 'Ỹ' => 'ỹ',
  64161. 'Ỻ' => 'ỻ',
  64162. 'Ỽ' => 'ỽ',
  64163. 'Ỿ' => 'ỿ',
  64164. 'Ἀ' => 'ἀ',
  64165. 'Ἁ' => '�',
  64166. 'Ἂ' => 'ἂ',
  64167. 'Ἃ' => 'ἃ',
  64168. 'Ἄ' => 'ἄ',
  64169. '�' => 'ἅ',
  64170. 'Ἆ' => 'ἆ',
  64171. '�' => 'ἇ',
  64172. 'Ἐ' => '�',
  64173. 'Ἑ' => 'ἑ',
  64174. 'Ἒ' => 'ἒ',
  64175. 'Ἓ' => 'ἓ',
  64176. 'Ἔ' => 'ἔ',
  64177. '�' => 'ἕ',
  64178. 'Ἠ' => 'ἠ',
  64179. 'Ἡ' => 'ἡ',
  64180. 'Ἢ' => 'ἢ',
  64181. 'Ἣ' => 'ἣ',
  64182. 'Ἤ' => 'ἤ',
  64183. 'á¼­' => 'á¼¥',
  64184. 'Ἦ' => 'ἦ',
  64185. 'Ἧ' => 'ἧ',
  64186. 'Ἰ' => 'ἰ',
  64187. 'á¼¹' => 'á¼±',
  64188. 'Ἲ' => 'ἲ',
  64189. 'á¼»' => 'á¼³',
  64190. 'á¼¼' => 'á¼´',
  64191. 'á¼½' => 'á¼µ',
  64192. 'á¼¾' => 'á¼¶',
  64193. 'Ἷ' => 'ἷ',
  64194. 'Ὀ' => 'ὀ',
  64195. 'Ὁ' => '�',
  64196. 'Ὂ' => 'ὂ',
  64197. 'Ὃ' => 'ὃ',
  64198. 'Ὄ' => 'ὄ',
  64199. '�' => 'ὅ',
  64200. 'Ὑ' => 'ὑ',
  64201. 'Ὓ' => 'ὓ',
  64202. '�' => 'ὕ',
  64203. 'Ὗ' => 'ὗ',
  64204. 'Ὠ' => 'ὠ',
  64205. 'Ὡ' => 'ὡ',
  64206. 'Ὢ' => 'ὢ',
  64207. 'Ὣ' => 'ὣ',
  64208. 'Ὤ' => 'ὤ',
  64209. 'á½­' => 'á½¥',
  64210. 'Ὦ' => 'ὦ',
  64211. 'Ὧ' => 'ὧ',
  64212. 'ᾈ' => 'ᾀ',
  64213. 'ᾉ' => '�',
  64214. 'ᾊ' => 'ᾂ',
  64215. 'ᾋ' => 'ᾃ',
  64216. 'ᾌ' => 'ᾄ',
  64217. '�' => 'ᾅ',
  64218. 'ᾎ' => 'ᾆ',
  64219. '�' => 'ᾇ',
  64220. 'ᾘ' => '�',
  64221. 'ᾙ' => 'ᾑ',
  64222. 'ᾚ' => 'ᾒ',
  64223. 'ᾛ' => 'ᾓ',
  64224. 'ᾜ' => 'ᾔ',
  64225. '�' => 'ᾕ',
  64226. 'ᾞ' => 'ᾖ',
  64227. 'ᾟ' => 'ᾗ',
  64228. 'ᾨ' => 'ᾠ',
  64229. 'ᾩ' => 'ᾡ',
  64230. 'ᾪ' => 'ᾢ',
  64231. 'ᾫ' => 'ᾣ',
  64232. 'ᾬ' => 'ᾤ',
  64233. 'á¾­' => 'á¾¥',
  64234. 'ᾮ' => 'ᾦ',
  64235. 'ᾯ' => 'ᾧ',
  64236. 'Ᾰ' => 'ᾰ',
  64237. 'á¾¹' => 'á¾±',
  64238. 'Ὰ' => 'ὰ',
  64239. 'á¾»' => 'á½±',
  64240. 'á¾¼' => 'á¾³',
  64241. 'Ὲ' => 'ὲ',
  64242. 'Έ' => 'έ',
  64243. 'Ὴ' => 'ὴ',
  64244. 'á¿‹' => 'á½µ',
  64245. 'ῌ' => 'ῃ',
  64246. 'Ῐ' => '�',
  64247. 'á¿™' => 'á¿‘',
  64248. 'Ὶ' => 'ὶ',
  64249. 'á¿›' => 'á½·',
  64250. 'Ῠ' => 'ῠ',
  64251. 'á¿©' => 'á¿¡',
  64252. 'Ὺ' => 'ὺ',
  64253. 'á¿«' => 'á½»',
  64254. 'Ῥ' => 'ῥ',
  64255. 'Ὸ' => 'ὸ',
  64256. 'Ό' => 'ό',
  64257. 'Ὼ' => 'ὼ',
  64258. 'á¿»' => 'á½½',
  64259. 'ῼ' => 'ῳ',
  64260. 'Ω' => 'ω',
  64261. 'K' => 'k',
  64262. 'â„«' => 'Ã¥',
  64263. 'Ⅎ' => 'ⅎ',
  64264. 'â… ' => 'â…°',
  64265. 'â…¡' => 'â…±',
  64266. 'â…¢' => 'â…²',
  64267. 'â…£' => 'â…³',
  64268. 'â…¤' => 'â…´',
  64269. 'â…¥' => 'â…µ',
  64270. 'â…¦' => 'â…¶',
  64271. 'â…§' => 'â…·',
  64272. 'â…¨' => 'â…¸',
  64273. 'â…©' => 'â…¹',
  64274. 'â…ª' => 'â…º',
  64275. 'â…«' => 'â…»',
  64276. 'â…¬' => 'â…¼',
  64277. 'â…­' => 'â…½',
  64278. 'â…®' => 'â…¾',
  64279. 'â…¯' => 'â…¿',
  64280. 'Ↄ' => 'ↄ',
  64281. 'Ⓐ' => '�',
  64282. 'â’·' => 'â“‘',
  64283. 'â’¸' => 'â“’',
  64284. 'â’¹' => 'â““',
  64285. 'â’º' => 'â“”',
  64286. 'â’»' => 'â“•',
  64287. 'â’¼' => 'â“–',
  64288. 'â’½' => 'â“—',
  64289. 'Ⓘ' => 'ⓘ',
  64290. 'â’¿' => 'â“™',
  64291. 'Ⓚ' => 'ⓚ',
  64292. '�' => 'ⓛ',
  64293. 'Ⓜ' => 'ⓜ',
  64294. 'Ⓝ' => '�',
  64295. 'Ⓞ' => 'ⓞ',
  64296. 'Ⓟ' => 'ⓟ',
  64297. 'Ⓠ' => 'ⓠ',
  64298. 'Ⓡ' => 'ⓡ',
  64299. 'Ⓢ' => 'ⓢ',
  64300. 'Ⓣ' => 'ⓣ',
  64301. 'Ⓤ' => 'ⓤ',
  64302. 'â“‹' => 'â“¥',
  64303. 'Ⓦ' => 'ⓦ',
  64304. '�' => 'ⓧ',
  64305. 'Ⓨ' => 'ⓨ',
  64306. '�' => 'ⓩ',
  64307. 'â°€' => 'â°°',
  64308. 'â°�' => 'â°±',
  64309. 'â°‚' => 'â°²',
  64310. 'â°ƒ' => 'â°³',
  64311. 'â°„' => 'â°´',
  64312. 'â°…' => 'â°µ',
  64313. 'â°†' => 'â°¶',
  64314. 'â°‡' => 'â°·',
  64315. 'â°ˆ' => 'â°¸',
  64316. 'â°‰' => 'â°¹',
  64317. 'â°Š' => 'â°º',
  64318. 'â°‹' => 'â°»',
  64319. 'Ⰼ' => 'ⰼ',
  64320. 'â°�' => 'â°½',
  64321. 'â°Ž' => 'â°¾',
  64322. 'â°�' => 'â°¿',
  64323. 'â°�' => 'â±€',
  64324. 'Ⱁ' => '�',
  64325. 'Ⱂ' => 'ⱂ',
  64326. 'Ⱃ' => 'ⱃ',
  64327. 'Ⱄ' => 'ⱄ',
  64328. 'â°•' => 'â±…',
  64329. 'Ⱆ' => 'ⱆ',
  64330. 'Ⱇ' => 'ⱇ',
  64331. 'Ⱈ' => 'ⱈ',
  64332. 'Ⱉ' => 'ⱉ',
  64333. 'Ⱊ' => 'ⱊ',
  64334. 'Ⱋ' => 'ⱋ',
  64335. 'Ⱌ' => 'ⱌ',
  64336. '�' => '�',
  64337. 'Ⱎ' => 'ⱎ',
  64338. 'Ⱏ' => '�',
  64339. 'Ⱐ' => '�',
  64340. 'Ⱑ' => 'ⱑ',
  64341. 'â°¢' => 'â±’',
  64342. 'Ⱓ' => 'ⱓ',
  64343. 'â°¤' => 'â±”',
  64344. 'Ⱕ' => 'ⱕ',
  64345. 'â°¦' => 'â±–',
  64346. 'â°§' => 'â±—',
  64347. 'Ⱘ' => 'ⱘ',
  64348. 'â°©' => 'â±™',
  64349. 'Ⱚ' => 'ⱚ',
  64350. 'â°«' => 'â±›',
  64351. 'Ⱜ' => 'ⱜ',
  64352. 'Ⱝ' => '�',
  64353. 'Ⱞ' => 'ⱞ',
  64354. 'Ⱡ' => 'ⱡ',
  64355. 'â±¢' => 'É«',
  64356. 'â±£' => 'áµ½',
  64357. 'Ɽ' => 'ɽ',
  64358. 'Ⱨ' => 'ⱨ',
  64359. 'Ⱪ' => 'ⱪ',
  64360. 'Ⱬ' => 'ⱬ',
  64361. 'â±­' => 'É‘',
  64362. 'Ɱ' => 'ɱ',
  64363. 'Ɐ' => '�',
  64364. 'â±°' => 'É’',
  64365. 'â±²' => 'â±³',
  64366. 'â±µ' => 'â±¶',
  64367. 'â±¾' => 'È¿',
  64368. 'Ɀ' => 'ɀ',
  64369. 'Ⲁ' => '�',
  64370. 'Ⲃ' => 'ⲃ',
  64371. 'Ⲅ' => 'ⲅ',
  64372. 'Ⲇ' => 'ⲇ',
  64373. 'Ⲉ' => 'ⲉ',
  64374. 'Ⲋ' => 'ⲋ',
  64375. 'Ⲍ' => '�',
  64376. 'Ⲏ' => '�',
  64377. '�' => 'ⲑ',
  64378. 'Ⲓ' => 'ⲓ',
  64379. 'Ⲕ' => 'ⲕ',
  64380. 'â²–' => 'â²—',
  64381. 'Ⲙ' => 'ⲙ',
  64382. 'Ⲛ' => 'ⲛ',
  64383. 'Ⲝ' => '�',
  64384. 'Ⲟ' => 'ⲟ',
  64385. 'Ⲡ' => 'ⲡ',
  64386. 'â²¢' => 'â²£',
  64387. 'Ⲥ' => 'ⲥ',
  64388. 'Ⲧ' => 'ⲧ',
  64389. 'Ⲩ' => 'ⲩ',
  64390. 'Ⲫ' => 'ⲫ',
  64391. 'Ⲭ' => 'ⲭ',
  64392. 'Ⲯ' => 'ⲯ',
  64393. 'â²°' => 'â²±',
  64394. 'â²²' => 'â²³',
  64395. 'â²´' => 'â²µ',
  64396. 'â²¶' => 'â²·',
  64397. 'Ⲹ' => 'ⲹ',
  64398. 'Ⲻ' => 'ⲻ',
  64399. 'â²¼' => 'â²½',
  64400. 'Ⲿ' => 'ⲿ',
  64401. 'Ⳁ' => '�',
  64402. 'Ⳃ' => 'ⳃ',
  64403. 'Ⳅ' => 'ⳅ',
  64404. 'Ⳇ' => 'ⳇ',
  64405. 'Ⳉ' => 'ⳉ',
  64406. 'Ⳋ' => 'ⳋ',
  64407. 'Ⳍ' => '�',
  64408. 'Ⳏ' => '�',
  64409. '�' => 'ⳑ',
  64410. 'Ⳓ' => 'ⳓ',
  64411. 'Ⳕ' => 'ⳕ',
  64412. 'â³–' => 'â³—',
  64413. 'Ⳙ' => 'ⳙ',
  64414. 'Ⳛ' => 'ⳛ',
  64415. 'Ⳝ' => '�',
  64416. 'Ⳟ' => 'ⳟ',
  64417. 'Ⳡ' => 'ⳡ',
  64418. 'â³¢' => 'â³£',
  64419. 'Ⳬ' => 'ⳬ',
  64420. 'â³­' => 'â³®',
  64421. 'â³²' => 'â³³',
  64422. 'Ꙁ' => '�',
  64423. 'Ꙃ' => 'ꙃ',
  64424. 'Ꙅ' => 'ꙅ',
  64425. 'Ꙇ' => 'ꙇ',
  64426. 'Ꙉ' => 'ꙉ',
  64427. 'Ꙋ' => 'ꙋ',
  64428. 'Ꙍ' => '�',
  64429. 'Ꙏ' => '�',
  64430. '�' => 'ꙑ',
  64431. 'Ꙓ' => 'ꙓ',
  64432. 'Ꙕ' => 'ꙕ',
  64433. 'ê™–' => 'ê™—',
  64434. 'Ꙙ' => 'ꙙ',
  64435. 'Ꙛ' => 'ꙛ',
  64436. 'Ꙝ' => '�',
  64437. 'Ꙟ' => 'ꙟ',
  64438. 'Ꙡ' => 'ꙡ',
  64439. 'Ꙣ' => 'ꙣ',
  64440. 'Ꙥ' => 'ꙥ',
  64441. 'Ꙧ' => 'ꙧ',
  64442. 'Ꙩ' => 'ꙩ',
  64443. 'Ꙫ' => 'ꙫ',
  64444. 'Ꙭ' => 'ꙭ',
  64445. 'Ꚁ' => '�',
  64446. 'Ꚃ' => 'ꚃ',
  64447. 'êš„' => 'êš…',
  64448. 'Ꚇ' => 'ꚇ',
  64449. 'Ꚉ' => 'ꚉ',
  64450. 'Ꚋ' => 'ꚋ',
  64451. 'Ꚍ' => '�',
  64452. 'Ꚏ' => '�',
  64453. '�' => 'ꚑ',
  64454. 'êš’' => 'êš“',
  64455. 'êš”' => 'êš•',
  64456. 'êš–' => 'êš—',
  64457. 'Ꚙ' => 'ꚙ',
  64458. 'êšš' => 'êš›',
  64459. 'Ꜣ' => 'ꜣ',
  64460. 'Ꜥ' => 'ꜥ',
  64461. 'Ꜧ' => 'ꜧ',
  64462. 'Ꜩ' => 'ꜩ',
  64463. 'Ꜫ' => 'ꜫ',
  64464. 'Ꜭ' => 'ꜭ',
  64465. 'Ꜯ' => 'ꜯ',
  64466. 'Ꜳ' => 'ꜳ',
  64467. 'Ꜵ' => 'ꜵ',
  64468. 'Ꜷ' => 'ꜷ',
  64469. 'Ꜹ' => 'ꜹ',
  64470. 'Ꜻ' => 'ꜻ',
  64471. 'Ꜽ' => 'ꜽ',
  64472. 'Ꜿ' => 'ꜿ',
  64473. '�' => '�',
  64474. '�' => '�',
  64475. '�' => '�',
  64476. '�' => '�',
  64477. '�' => '�',
  64478. '�' => '�',
  64479. '�' => '�',
  64480. '�' => '�',
  64481. '�' => '�',
  64482. '�' => '�',
  64483. '�' => '�',
  64484. '�' => '�',
  64485. '�' => '�',
  64486. '�' => '�',
  64487. '�' => '�',
  64488. '�' => '�',
  64489. '�' => '�',
  64490. '�' => '�',
  64491. '�' => '�',
  64492. '�' => '�',
  64493. '�' => '�',
  64494. '�' => '�',
  64495. '�' => '�',
  64496. '�' => '�',
  64497. '�' => '�',
  64498. '�' => '�',
  64499. '�' => 'ᵹ',
  64500. '�' => '�',
  64501. 'Ꞁ' => '�',
  64502. 'Ꞃ' => 'ꞃ',
  64503. 'êž„' => 'êž…',
  64504. 'Ꞇ' => 'ꞇ',
  64505. 'Ꞌ' => 'ꞌ',
  64506. '�' => 'ɥ',
  64507. '�' => 'ꞑ',
  64508. 'êž’' => 'êž“',
  64509. 'êž–' => 'êž—',
  64510. 'Ꞙ' => 'ꞙ',
  64511. 'êžš' => 'êž›',
  64512. 'Ꞝ' => '�',
  64513. 'Ꞟ' => 'ꞟ',
  64514. 'êž ' => 'êž¡',
  64515. 'Ꞣ' => 'ꞣ',
  64516. 'Ꞥ' => 'ꞥ',
  64517. 'Ꞧ' => 'ꞧ',
  64518. 'Ꞩ' => 'ꞩ',
  64519. 'Ɦ' => 'ɦ',
  64520. 'Ɜ' => 'ɜ',
  64521. 'Ɡ' => 'ɡ',
  64522. 'Ɬ' => 'ɬ',
  64523. 'Ɪ' => 'ɪ',
  64524. 'êž°' => 'Êž',
  64525. 'Ʇ' => 'ʇ',
  64526. 'Ʝ' => '�',
  64527. 'êž³' => 'ê­“',
  64528. 'êž´' => 'êžµ',
  64529. 'êž¶' => 'êž·',
  64530. 'Ꞹ' => 'ꞹ',
  64531. 'Ꞻ' => 'ꞻ',
  64532. 'êž¼' => 'êž½',
  64533. 'êž¾' => 'êž¿',
  64534. 'Ꟃ' => 'ꟃ',
  64535. 'Ꞔ' => 'ꞔ',
  64536. 'Ʂ' => 'ʂ',
  64537. 'Ᶎ' => 'ᶎ',
  64538. 'Ꟈ' => 'ꟈ',
  64539. 'Ꟊ' => 'ꟊ',
  64540. 'Ꟶ' => 'ꟶ',
  64541. 'A' => '�',
  64542. 'B' => 'b',
  64543. 'C' => 'c',
  64544. 'D' => 'd',
  64545. 'ï¼¥' => 'ï½…',
  64546. 'F' => 'f',
  64547. 'G' => 'g',
  64548. 'H' => 'h',
  64549. 'I' => 'i',
  64550. 'J' => 'j',
  64551. 'K' => 'k',
  64552. 'L' => 'l',
  64553. 'M' => '�',
  64554. 'N' => 'n',
  64555. 'O' => '�',
  64556. 'P' => '�',
  64557. 'Q' => 'q',
  64558. 'ï¼²' => 'ï½’',
  64559. 'S' => 's',
  64560. 'ï¼´' => 'ï½”',
  64561. 'U' => 'u',
  64562. 'ï¼¶' => 'ï½–',
  64563. 'ï¼·' => 'ï½—',
  64564. 'X' => 'x',
  64565. 'ï¼¹' => 'ï½™',
  64566. 'Z' => 'z',
  64567. '�' => '�',
  64568. '�' => '�',
  64569. '�' => '�',
  64570. '�' => '�',
  64571. '�' => '�',
  64572. '�' => '�',
  64573. '�' => '�',
  64574. '�' => '�',
  64575. '�' => '�',
  64576. '�' => '�',
  64577. '�' => '�',
  64578. '�' => '�',
  64579. '�' => '�',
  64580. '�' => '�',
  64581. '�' => '�',
  64582. '�' => '�',
  64583. '�' => '�',
  64584. '�' => '�',
  64585. '�' => '�',
  64586. '�' => '�',
  64587. '�' => '�',
  64588. '�' => '�',
  64589. '�' => '�',
  64590. '�' => '�',
  64591. '�' => '�',
  64592. '�' => '�',
  64593. '�' => '�',
  64594. '�' => '�',
  64595. '�' => '�',
  64596. '�' => '�',
  64597. '�' => '�',
  64598. '�' => '�',
  64599. '�' => '�',
  64600. '�' => '�',
  64601. '�' => '�',
  64602. '�' => '�',
  64603. '�' => '�',
  64604. '�' => '�',
  64605. '�' => '�',
  64606. '�' => '�',
  64607. '�' => '�',
  64608. '�' => '�',
  64609. '�' => '�',
  64610. '�' => '�',
  64611. '�' => '�',
  64612. '�' => '�',
  64613. '�' => '�',
  64614. '�' => '�',
  64615. '�' => '�',
  64616. '�' => '�',
  64617. '�' => '�',
  64618. '�' => '�',
  64619. '�' => '�',
  64620. '�' => '�',
  64621. '�' => '�',
  64622. '�' => '�',
  64623. '�' => '�',
  64624. '�' => '�',
  64625. '�' => '�',
  64626. '�' => '�',
  64627. '�' => '�',
  64628. '�' => '�',
  64629. '�' => '�',
  64630. '�' => '�',
  64631. '�' => '�',
  64632. '�' => '�',
  64633. '�' => '�',
  64634. '�' => '�',
  64635. '�' => '�',
  64636. '�' => '�',
  64637. '�' => '�',
  64638. '�' => '�',
  64639. '�' => '�',
  64640. '�' => '�',
  64641. '�' => '�',
  64642. '�' => '�',
  64643. '�' => '�',
  64644. '�' => '�',
  64645. '�' => '�',
  64646. '�' => '�',
  64647. '�' => '�',
  64648. '�' => '�',
  64649. '�' => '�',
  64650. '�' => '�',
  64651. '�' => '�',
  64652. '�' => '�',
  64653. '�' => '�',
  64654. '�' => '�',
  64655. '�' => '�',
  64656. '�' => '�',
  64657. '�' => '�',
  64658. '�' => '�',
  64659. '�' => '�',
  64660. '�' => '�',
  64661. '�' => '�',
  64662. '�' => '�',
  64663. '�' => '�',
  64664. '�' => '�',
  64665. '�' => '�',
  64666. '�' => '�',
  64667. '�' => '�',
  64668. '�' => '�',
  64669. '�' => '�',
  64670. '�' => '�',
  64671. '�' => '�',
  64672. '�' => '�',
  64673. '�' => '�',
  64674. '�' => '�',
  64675. '�' => '�',
  64676. '�' => '�',
  64677. '�' => '�',
  64678. '�' => '�',
  64679. '�' => '�',
  64680. '�' => '�',
  64681. '�' => '�',
  64682. '�' => '�',
  64683. '�' => '�',
  64684. '�' => '�',
  64685. '�' => '�',
  64686. '�' => '�',
  64687. '�' => '�',
  64688. '�' => '�',
  64689. '�' => '�',
  64690. '�' => '�',
  64691. '�' => '�',
  64692. '�' => '�',
  64693. '�' => '�',
  64694. 'ð‘¢ ' => 'ð‘£€',
  64695. '𑢡' => '�',
  64696. '𑢢' => '𑣂',
  64697. '𑢣' => '𑣃',
  64698. '𑢤' => '𑣄',
  64699. 'ð‘¢¥' => 'ð‘£…',
  64700. '𑢦' => '𑣆',
  64701. '𑢧' => '𑣇',
  64702. '𑢨' => '𑣈',
  64703. '𑢩' => '𑣉',
  64704. '𑢪' => '𑣊',
  64705. '𑢫' => '𑣋',
  64706. '𑢬' => '𑣌',
  64707. '𑢭' => '�',
  64708. '𑢮' => '𑣎',
  64709. '𑢯' => '�',
  64710. '𑢰' => '�',
  64711. '𑢱' => '𑣑',
  64712. 'ð‘¢²' => 'ð‘£’',
  64713. '𑢳' => '𑣓',
  64714. 'ð‘¢´' => 'ð‘£”',
  64715. '𑢵' => '𑣕',
  64716. 'ð‘¢¶' => 'ð‘£–',
  64717. 'ð‘¢·' => 'ð‘£—',
  64718. '𑢸' => '𑣘',
  64719. 'ð‘¢¹' => 'ð‘£™',
  64720. '𑢺' => '𑣚',
  64721. 'ð‘¢»' => 'ð‘£›',
  64722. '𑢼' => '𑣜',
  64723. '𑢽' => '�',
  64724. '𑢾' => '𑣞',
  64725. '𑢿' => '𑣟',
  64726. 'ð–¹€' => 'ð–¹ ',
  64727. '�' => '𖹡',
  64728. '𖹂' => '𖹢',
  64729. '𖹃' => '𖹣',
  64730. '𖹄' => '𖹤',
  64731. 'ð–¹…' => 'ð–¹¥',
  64732. '𖹆' => '𖹦',
  64733. '𖹇' => '𖹧',
  64734. '𖹈' => '𖹨',
  64735. '𖹉' => '𖹩',
  64736. '𖹊' => '𖹪',
  64737. '𖹋' => '𖹫',
  64738. '𖹌' => '𖹬',
  64739. '�' => '𖹭',
  64740. '𖹎' => '𖹮',
  64741. '�' => '𖹯',
  64742. '�' => '𖹰',
  64743. '𖹑' => '𖹱',
  64744. 'ð–¹’' => 'ð–¹²',
  64745. '𖹓' => '𖹳',
  64746. 'ð–¹”' => 'ð–¹´',
  64747. '𖹕' => '𖹵',
  64748. 'ð–¹–' => 'ð–¹¶',
  64749. 'ð–¹—' => 'ð–¹·',
  64750. '𖹘' => '𖹸',
  64751. 'ð–¹™' => 'ð–¹¹',
  64752. '𖹚' => '𖹺',
  64753. 'ð–¹›' => 'ð–¹»',
  64754. '𖹜' => '𖹼',
  64755. '�' => '𖹽',
  64756. '𖹞' => '𖹾',
  64757. '𖹟' => '𖹿',
  64758. '𞤀' => '𞤢',
  64759. '�' => '𞤣',
  64760. '𞤂' => '𞤤',
  64761. '𞤃' => '𞤥',
  64762. '𞤄' => '𞤦',
  64763. '𞤅' => '𞤧',
  64764. '𞤆' => '𞤨',
  64765. '𞤇' => '𞤩',
  64766. '𞤈' => '𞤪',
  64767. '𞤉' => '𞤫',
  64768. '𞤊' => '𞤬',
  64769. '𞤋' => '𞤭',
  64770. '𞤌' => '𞤮',
  64771. '�' => '𞤯',
  64772. '𞤎' => '𞤰',
  64773. '�' => '𞤱',
  64774. '�' => '𞤲',
  64775. '𞤑' => '𞤳',
  64776. '𞤒' => '𞤴',
  64777. '𞤓' => '𞤵',
  64778. '𞤔' => '𞤶',
  64779. '𞤕' => '𞤷',
  64780. '𞤖' => '𞤸',
  64781. '𞤗' => '𞤹',
  64782. '𞤘' => '𞤺',
  64783. '𞤙' => '𞤻',
  64784. '𞤚' => '𞤼',
  64785. '𞤛' => '𞤽',
  64786. '𞤜' => '𞤾',
  64787. '�' => '𞤿',
  64788. '𞤞' => '𞥀',
  64789. '𞤟' => '�',
  64790. '𞤠' => '𞥂',
  64791. '𞤡' => '𞥃',
  64792. );
  64793. <?php
  64794. 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';
  64795. <?php
  64796. return array (
  64797. 'a' => 'A',
  64798. 'b' => 'B',
  64799. 'c' => 'C',
  64800. 'd' => 'D',
  64801. 'e' => 'E',
  64802. 'f' => 'F',
  64803. 'g' => 'G',
  64804. 'h' => 'H',
  64805. 'i' => 'I',
  64806. 'j' => 'J',
  64807. 'k' => 'K',
  64808. 'l' => 'L',
  64809. 'm' => 'M',
  64810. 'n' => 'N',
  64811. 'o' => 'O',
  64812. 'p' => 'P',
  64813. 'q' => 'Q',
  64814. 'r' => 'R',
  64815. 's' => 'S',
  64816. 't' => 'T',
  64817. 'u' => 'U',
  64818. 'v' => 'V',
  64819. 'w' => 'W',
  64820. 'x' => 'X',
  64821. 'y' => 'Y',
  64822. 'z' => 'Z',
  64823. 'µ' => 'Μ',
  64824. 'à' => 'À',
  64825. 'á' => '�',
  64826. 'â' => 'Â',
  64827. 'ã' => 'Ã',
  64828. 'ä' => 'Ä',
  64829. 'Ã¥' => 'Ã…',
  64830. 'æ' => 'Æ',
  64831. 'ç' => 'Ç',
  64832. 'è' => 'È',
  64833. 'é' => 'É',
  64834. 'ê' => 'Ê',
  64835. 'ë' => 'Ë',
  64836. 'ì' => 'Ì',
  64837. 'í' => '�',
  64838. 'î' => 'Î',
  64839. 'ï' => '�',
  64840. 'ð' => '�',
  64841. 'ñ' => 'Ñ',
  64842. 'ò' => 'Ò',
  64843. 'ó' => 'Ó',
  64844. 'ô' => 'Ô',
  64845. 'õ' => 'Õ',
  64846. 'ö' => 'Ö',
  64847. 'ø' => 'Ø',
  64848. 'ù' => 'Ù',
  64849. 'ú' => 'Ú',
  64850. 'û' => 'Û',
  64851. 'ü' => 'Ü',
  64852. 'ý' => '�',
  64853. 'þ' => 'Þ',
  64854. 'ÿ' => 'Ÿ',
  64855. '�' => 'Ā',
  64856. 'ă' => 'Ă',
  64857. 'Ä…' => 'Ä„',
  64858. 'ć' => 'Ć',
  64859. 'ĉ' => 'Ĉ',
  64860. 'Ä‹' => 'ÄŠ',
  64861. '�' => 'Č',
  64862. '�' => 'Ď',
  64863. 'đ' => '�',
  64864. 'Ä“' => 'Ä’',
  64865. 'Ä•' => 'Ä”',
  64866. 'Ä—' => 'Ä–',
  64867. 'ę' => 'Ę',
  64868. 'Ä›' => 'Äš',
  64869. '�' => 'Ĝ',
  64870. 'ÄŸ' => 'Äž',
  64871. 'Ä¡' => 'Ä ',
  64872. 'Ä£' => 'Ä¢',
  64873. 'ĥ' => 'Ĥ',
  64874. 'ħ' => 'Ħ',
  64875. 'ĩ' => 'Ĩ',
  64876. 'ī' => 'Ī',
  64877. 'ĭ' => 'Ĭ',
  64878. 'į' => 'Į',
  64879. 'ı' => 'I',
  64880. 'ij' => 'IJ',
  64881. 'ĵ' => 'Ĵ',
  64882. 'ķ' => 'Ķ',
  64883. 'ĺ' => 'Ĺ',
  64884. 'ļ' => 'Ļ',
  64885. 'ľ' => 'Ľ',
  64886. 'Å€' => 'Ä¿',
  64887. 'ł' => '�',
  64888. 'ń' => 'Ń',
  64889. 'ņ' => 'Ņ',
  64890. 'ň' => 'Ň',
  64891. 'Å‹' => 'ÅŠ',
  64892. '�' => 'Ō',
  64893. '�' => 'Ŏ',
  64894. 'ő' => '�',
  64895. 'Å“' => 'Å’',
  64896. 'Å•' => 'Å”',
  64897. 'Å—' => 'Å–',
  64898. 'ř' => 'Ř',
  64899. 'Å›' => 'Åš',
  64900. '�' => 'Ŝ',
  64901. 'ÅŸ' => 'Åž',
  64902. 'Å¡' => 'Å ',
  64903. 'Å£' => 'Å¢',
  64904. 'ť' => 'Ť',
  64905. 'ŧ' => 'Ŧ',
  64906. 'ũ' => 'Ũ',
  64907. 'ū' => 'Ū',
  64908. 'ŭ' => 'Ŭ',
  64909. 'ů' => 'Ů',
  64910. 'ű' => 'Ű',
  64911. 'ų' => 'Ų',
  64912. 'ŵ' => 'Ŵ',
  64913. 'ŷ' => 'Ŷ',
  64914. 'ź' => 'Ź',
  64915. 'ż' => 'Ż',
  64916. 'ž' => 'Ž',
  64917. 'Å¿' => 'S',
  64918. 'ƀ' => 'Ƀ',
  64919. 'ƃ' => 'Ƃ',
  64920. 'Æ…' => 'Æ„',
  64921. 'ƈ' => 'Ƈ',
  64922. 'ƌ' => 'Ƌ',
  64923. 'Æ’' => 'Æ‘',
  64924. 'ƕ' => 'Ƕ',
  64925. 'ƙ' => 'Ƙ',
  64926. 'ƚ' => 'Ƚ',
  64927. 'Æž' => 'È ',
  64928. 'Æ¡' => 'Æ ',
  64929. 'Æ£' => 'Æ¢',
  64930. 'ƥ' => 'Ƥ',
  64931. 'ƨ' => 'Ƨ',
  64932. 'ƭ' => 'Ƭ',
  64933. 'ư' => 'Ư',
  64934. 'ƴ' => 'Ƴ',
  64935. 'ƶ' => 'Ƶ',
  64936. 'ƹ' => 'Ƹ',
  64937. 'ƽ' => 'Ƽ',
  64938. 'Æ¿' => 'Ç·',
  64939. 'Ç…' => 'Ç„',
  64940. 'dž' => 'DŽ',
  64941. 'Lj' => 'LJ',
  64942. 'lj' => 'LJ',
  64943. 'Ç‹' => 'ÇŠ',
  64944. 'nj' => 'NJ',
  64945. 'ǎ' => '�',
  64946. '�' => '�',
  64947. 'Ç’' => 'Ç‘',
  64948. 'Ç”' => 'Ç“',
  64949. 'Ç–' => 'Ç•',
  64950. 'ǘ' => 'Ǘ',
  64951. 'Çš' => 'Ç™',
  64952. 'ǜ' => 'Ǜ',
  64953. '�' => 'Ǝ',
  64954. 'ÇŸ' => 'Çž',
  64955. 'Ç¡' => 'Ç ',
  64956. 'Ç£' => 'Ç¢',
  64957. 'ǥ' => 'Ǥ',
  64958. 'ǧ' => 'Ǧ',
  64959. 'ǩ' => 'Ǩ',
  64960. 'ǫ' => 'Ǫ',
  64961. 'ǭ' => 'Ǭ',
  64962. 'ǯ' => 'Ǯ',
  64963. 'Dz' => 'DZ',
  64964. 'dz' => 'DZ',
  64965. 'ǵ' => 'Ǵ',
  64966. 'ǹ' => 'Ǹ',
  64967. 'ǻ' => 'Ǻ',
  64968. 'ǽ' => 'Ǽ',
  64969. 'ǿ' => 'Ǿ',
  64970. '�' => 'Ȁ',
  64971. 'ȃ' => 'Ȃ',
  64972. 'È…' => 'È„',
  64973. 'ȇ' => 'Ȇ',
  64974. 'ȉ' => 'Ȉ',
  64975. 'È‹' => 'ÈŠ',
  64976. '�' => 'Ȍ',
  64977. '�' => 'Ȏ',
  64978. 'ȑ' => '�',
  64979. 'È“' => 'È’',
  64980. 'È•' => 'È”',
  64981. 'È—' => 'È–',
  64982. 'ș' => 'Ș',
  64983. 'È›' => 'Èš',
  64984. '�' => 'Ȝ',
  64985. 'ÈŸ' => 'Èž',
  64986. 'È£' => 'È¢',
  64987. 'ȥ' => 'Ȥ',
  64988. 'ȧ' => 'Ȧ',
  64989. 'ȩ' => 'Ȩ',
  64990. 'ȫ' => 'Ȫ',
  64991. 'ȭ' => 'Ȭ',
  64992. 'ȯ' => 'Ȯ',
  64993. 'ȱ' => 'Ȱ',
  64994. 'ȳ' => 'Ȳ',
  64995. 'ȼ' => 'Ȼ',
  64996. 'È¿' => 'â±¾',
  64997. 'ɀ' => 'Ɀ',
  64998. 'ɂ' => '�',
  64999. 'ɇ' => 'Ɇ',
  65000. 'ɉ' => 'Ɉ',
  65001. 'É‹' => 'ÉŠ',
  65002. '�' => 'Ɍ',
  65003. '�' => 'Ɏ',
  65004. '�' => 'Ɐ',
  65005. 'É‘' => 'â±­',
  65006. 'É’' => 'â±°',
  65007. 'ɓ' => '�',
  65008. 'ɔ' => 'Ɔ',
  65009. 'ɖ' => 'Ɖ',
  65010. 'É—' => 'ÆŠ',
  65011. 'ə' => '�',
  65012. 'ɛ' => '�',
  65013. 'ɜ' => 'Ɜ',
  65014. 'É ' => 'Æ“',
  65015. 'ɡ' => 'Ɡ',
  65016. 'É£' => 'Æ”',
  65017. 'ɥ' => '�',
  65018. 'ɦ' => 'Ɦ',
  65019. 'ɨ' => 'Ɨ',
  65020. 'É©' => 'Æ–',
  65021. 'ɪ' => 'Ɪ',
  65022. 'É«' => 'â±¢',
  65023. 'ɬ' => 'Ɬ',
  65024. 'ɯ' => 'Ɯ',
  65025. 'ɱ' => 'Ɱ',
  65026. 'ɲ' => '�',
  65027. 'ɵ' => 'Ɵ',
  65028. 'ɽ' => 'Ɽ',
  65029. 'ʀ' => 'Ʀ',
  65030. 'ʂ' => 'Ʂ',
  65031. 'ʃ' => 'Ʃ',
  65032. 'ʇ' => 'Ʇ',
  65033. 'ʈ' => 'Ʈ',
  65034. 'ʉ' => 'Ʉ',
  65035. 'ʊ' => 'Ʊ',
  65036. 'ʋ' => 'Ʋ',
  65037. 'ʌ' => 'Ʌ',
  65038. 'Ê’' => 'Æ·',
  65039. '�' => 'Ʝ',
  65040. 'Êž' => 'êž°',
  65041. 'ͅ' => 'Ι',
  65042. 'ͱ' => 'Ͱ',
  65043. 'ͳ' => 'Ͳ',
  65044. 'ͷ' => 'Ͷ',
  65045. 'ͻ' => 'Ͻ',
  65046. 'ͼ' => 'Ͼ',
  65047. 'ͽ' => 'Ͽ',
  65048. 'ά' => 'Ά',
  65049. 'έ' => 'Έ',
  65050. 'ή' => 'Ή',
  65051. 'ί' => 'Ί',
  65052. 'α' => 'Α',
  65053. 'β' => 'Β',
  65054. 'γ' => 'Γ',
  65055. 'δ' => 'Δ',
  65056. 'ε' => 'Ε',
  65057. 'ζ' => 'Ζ',
  65058. 'η' => 'Η',
  65059. 'θ' => 'Θ',
  65060. 'ι' => 'Ι',
  65061. 'κ' => 'Κ',
  65062. 'λ' => 'Λ',
  65063. 'μ' => 'Μ',
  65064. 'ν' => '�',
  65065. 'ξ' => 'Ξ',
  65066. 'ο' => 'Ο',
  65067. 'π' => 'Π',
  65068. '�' => 'Ρ',
  65069. 'ς' => 'Σ',
  65070. 'σ' => 'Σ',
  65071. 'τ' => 'Τ',
  65072. 'Ï…' => 'Î¥',
  65073. 'φ' => 'Φ',
  65074. 'χ' => 'Χ',
  65075. 'ψ' => 'Ψ',
  65076. 'ω' => 'Ω',
  65077. 'ϊ' => 'Ϊ',
  65078. 'ϋ' => 'Ϋ',
  65079. 'ό' => 'Ό',
  65080. '�' => 'Ύ',
  65081. 'ώ' => '�',
  65082. '�' => 'Β',
  65083. 'ϑ' => 'Θ',
  65084. 'ϕ' => 'Φ',
  65085. 'ϖ' => 'Π',
  65086. 'ϗ' => '�',
  65087. 'ϙ' => 'Ϙ',
  65088. 'Ï›' => 'Ïš',
  65089. '�' => 'Ϝ',
  65090. 'ÏŸ' => 'Ïž',
  65091. 'Ï¡' => 'Ï ',
  65092. 'Ï£' => 'Ï¢',
  65093. 'ϥ' => 'Ϥ',
  65094. 'ϧ' => 'Ϧ',
  65095. 'ϩ' => 'Ϩ',
  65096. 'ϫ' => 'Ϫ',
  65097. 'ϭ' => 'Ϭ',
  65098. 'ϯ' => 'Ϯ',
  65099. 'ϰ' => 'Κ',
  65100. 'ϱ' => 'Ρ',
  65101. 'ϲ' => 'Ϲ',
  65102. 'ϳ' => 'Ϳ',
  65103. 'ϵ' => 'Ε',
  65104. 'ϸ' => 'Ϸ',
  65105. 'ϻ' => 'Ϻ',
  65106. 'а' => '�',
  65107. 'б' => 'Б',
  65108. 'в' => 'В',
  65109. 'г' => 'Г',
  65110. 'д' => 'Д',
  65111. 'е' => 'Е',
  65112. 'ж' => 'Ж',
  65113. 'з' => 'З',
  65114. 'и' => 'И',
  65115. 'й' => 'Й',
  65116. 'к' => 'К',
  65117. 'л' => 'Л',
  65118. 'м' => 'М',
  65119. 'н' => '�',
  65120. 'о' => 'О',
  65121. 'п' => 'П',
  65122. 'р' => 'Р',
  65123. '�' => 'С',
  65124. 'т' => 'Т',
  65125. 'у' => 'У',
  65126. 'ф' => 'Ф',
  65127. 'Ñ…' => 'Ð¥',
  65128. 'ц' => 'Ц',
  65129. 'ч' => 'Ч',
  65130. 'ш' => 'Ш',
  65131. 'щ' => 'Щ',
  65132. 'ъ' => 'Ъ',
  65133. 'ы' => 'Ы',
  65134. 'ь' => 'Ь',
  65135. '�' => 'Э',
  65136. 'ю' => 'Ю',
  65137. '�' => 'Я',
  65138. '�' => 'Ѐ',
  65139. 'ё' => '�',
  65140. 'ђ' => 'Ђ',
  65141. 'ѓ' => 'Ѓ',
  65142. 'є' => 'Є',
  65143. 'Ñ•' => 'Ð…',
  65144. 'і' => 'І',
  65145. 'ї' => 'Ї',
  65146. 'ј' => 'Ј',
  65147. 'љ' => 'Љ',
  65148. 'њ' => 'Њ',
  65149. 'ћ' => 'Ћ',
  65150. 'ќ' => 'Ќ',
  65151. '�' => '�',
  65152. 'Ñž' => 'ÐŽ',
  65153. 'џ' => '�',
  65154. 'Ñ¡' => 'Ñ ',
  65155. 'Ñ£' => 'Ñ¢',
  65156. 'ѥ' => 'Ѥ',
  65157. 'ѧ' => 'Ѧ',
  65158. 'ѩ' => 'Ѩ',
  65159. 'ѫ' => 'Ѫ',
  65160. 'ѭ' => 'Ѭ',
  65161. 'ѯ' => 'Ѯ',
  65162. 'ѱ' => 'Ѱ',
  65163. 'ѳ' => 'Ѳ',
  65164. 'ѵ' => 'Ѵ',
  65165. 'ѷ' => 'Ѷ',
  65166. 'ѹ' => 'Ѹ',
  65167. 'ѻ' => 'Ѻ',
  65168. 'ѽ' => 'Ѽ',
  65169. 'ѿ' => 'Ѿ',
  65170. 'Ò�' => 'Ò€',
  65171. 'Ò‹' => 'ÒŠ',
  65172. '�' => 'Ҍ',
  65173. 'Ò�' => 'ÒŽ',
  65174. 'Ò‘' => 'Ò�',
  65175. 'Ò“' => 'Ò’',
  65176. 'Ò•' => 'Ò”',
  65177. 'Ò—' => 'Ò–',
  65178. 'Ò™' => 'Ò˜',
  65179. 'Ò›' => 'Òš',
  65180. '�' => 'Ҝ',
  65181. 'ÒŸ' => 'Òž',
  65182. 'Ò¡' => 'Ò ',
  65183. 'Ò£' => 'Ò¢',
  65184. 'Ò¥' => 'Ò¤',
  65185. 'Ò§' => 'Ò¦',
  65186. 'Ò©' => 'Ò¨',
  65187. 'Ò«' => 'Òª',
  65188. 'Ò­' => 'Ò¬',
  65189. 'Ò¯' => 'Ò®',
  65190. 'Ò±' => 'Ò°',
  65191. 'Ò³' => 'Ò²',
  65192. 'Òµ' => 'Ò´',
  65193. 'Ò·' => 'Ò¶',
  65194. 'Ò¹' => 'Ò¸',
  65195. 'Ò»' => 'Òº',
  65196. 'Ò½' => 'Ò¼',
  65197. 'Ò¿' => 'Ò¾',
  65198. 'Ó‚' => 'Ó�',
  65199. 'Ó„' => 'Óƒ',
  65200. 'Ó†' => 'Ó…',
  65201. 'Óˆ' => 'Ó‡',
  65202. 'ÓŠ' => 'Ó‰',
  65203. 'ӌ' => 'Ӌ',
  65204. 'ÓŽ' => 'Ó�',
  65205. 'Ó�' => 'Ó€',
  65206. 'Ó‘' => 'Ó�',
  65207. 'Ó“' => 'Ó’',
  65208. 'Ó•' => 'Ó”',
  65209. 'Ó—' => 'Ó–',
  65210. 'Ó™' => 'Ó˜',
  65211. 'Ó›' => 'Óš',
  65212. '�' => 'Ӝ',
  65213. 'ÓŸ' => 'Óž',
  65214. 'Ó¡' => 'Ó ',
  65215. 'Ó£' => 'Ó¢',
  65216. 'Ó¥' => 'Ó¤',
  65217. 'Ó§' => 'Ó¦',
  65218. 'Ó©' => 'Ó¨',
  65219. 'Ó«' => 'Óª',
  65220. 'Ó­' => 'Ó¬',
  65221. 'Ó¯' => 'Ó®',
  65222. 'Ó±' => 'Ó°',
  65223. 'Ó³' => 'Ó²',
  65224. 'Óµ' => 'Ó´',
  65225. 'Ó·' => 'Ó¶',
  65226. 'Ó¹' => 'Ó¸',
  65227. 'Ó»' => 'Óº',
  65228. 'Ó½' => 'Ó¼',
  65229. 'Ó¿' => 'Ó¾',
  65230. 'Ô�' => 'Ô€',
  65231. 'Ôƒ' => 'Ô‚',
  65232. 'Ô…' => 'Ô„',
  65233. 'Ô‡' => 'Ô†',
  65234. 'Ô‰' => 'Ôˆ',
  65235. 'Ô‹' => 'ÔŠ',
  65236. '�' => 'Ԍ',
  65237. 'Ô�' => 'ÔŽ',
  65238. 'Ô‘' => 'Ô�',
  65239. 'Ô“' => 'Ô’',
  65240. 'Ô•' => 'Ô”',
  65241. 'Ô—' => 'Ô–',
  65242. 'Ô™' => 'Ô˜',
  65243. 'Ô›' => 'Ôš',
  65244. '�' => 'Ԝ',
  65245. 'ÔŸ' => 'Ôž',
  65246. 'Ô¡' => 'Ô ',
  65247. 'Ô£' => 'Ô¢',
  65248. 'Ô¥' => 'Ô¤',
  65249. 'Ô§' => 'Ô¦',
  65250. 'Ô©' => 'Ô¨',
  65251. 'Ô«' => 'Ôª',
  65252. 'Ô­' => 'Ô¬',
  65253. 'Ô¯' => 'Ô®',
  65254. 'Õ¡' => 'Ô±',
  65255. 'Õ¢' => 'Ô²',
  65256. 'Õ£' => 'Ô³',
  65257. 'Õ¤' => 'Ô´',
  65258. 'Õ¥' => 'Ôµ',
  65259. 'Õ¦' => 'Ô¶',
  65260. 'Õ§' => 'Ô·',
  65261. 'Õ¨' => 'Ô¸',
  65262. 'Õ©' => 'Ô¹',
  65263. 'Õª' => 'Ôº',
  65264. 'Õ«' => 'Ô»',
  65265. 'Õ¬' => 'Ô¼',
  65266. 'Õ­' => 'Ô½',
  65267. 'Õ®' => 'Ô¾',
  65268. 'Õ¯' => 'Ô¿',
  65269. 'Õ°' => 'Õ€',
  65270. 'Õ±' => 'Õ�',
  65271. 'Õ²' => 'Õ‚',
  65272. 'Õ³' => 'Õƒ',
  65273. 'Õ´' => 'Õ„',
  65274. 'Õµ' => 'Õ…',
  65275. 'Õ¶' => 'Õ†',
  65276. 'Õ·' => 'Õ‡',
  65277. 'Õ¸' => 'Õˆ',
  65278. 'Õ¹' => 'Õ‰',
  65279. 'Õº' => 'ÕŠ',
  65280. 'Õ»' => 'Õ‹',
  65281. 'ռ' => 'Ռ',
  65282. 'Õ½' => 'Õ�',
  65283. 'Õ¾' => 'ÕŽ',
  65284. 'Õ¿' => 'Õ�',
  65285. 'Ö€' => 'Õ�',
  65286. 'Ö�' => 'Õ‘',
  65287. 'Ö‚' => 'Õ’',
  65288. 'Öƒ' => 'Õ“',
  65289. 'Ö„' => 'Õ”',
  65290. 'Ö…' => 'Õ•',
  65291. 'Ö†' => 'Õ–',
  65292. '�' => '�',
  65293. 'ბ' => 'Ბ',
  65294. 'გ' => 'Გ',
  65295. 'დ' => 'Დ',
  65296. 'ე' => 'Ე',
  65297. 'ვ' => 'Ვ',
  65298. 'ზ' => 'Ზ',
  65299. 'თ' => 'Თ',
  65300. 'ი' => 'Ი',
  65301. 'კ' => 'Კ',
  65302. 'ლ' => 'Ლ',
  65303. 'მ' => 'Მ',
  65304. 'ნ' => 'Ნ',
  65305. '�' => '�',
  65306. 'პ' => 'Პ',
  65307. 'ჟ' => 'Ჟ',
  65308. 'რ' => 'Რ',
  65309. 'ს' => 'Ს',
  65310. 'ტ' => 'Ტ',
  65311. 'უ' => 'Უ',
  65312. 'ფ' => 'Ფ',
  65313. 'ქ' => 'Ქ',
  65314. 'ღ' => 'Ღ',
  65315. 'ყ' => 'Ყ',
  65316. 'შ' => 'Შ',
  65317. 'ჩ' => 'Ჩ',
  65318. 'ც' => 'Ც',
  65319. 'ძ' => 'Ძ',
  65320. 'წ' => 'Წ',
  65321. 'ჭ' => 'Ჭ',
  65322. 'ხ' => 'Ხ',
  65323. 'ჯ' => 'Ჯ',
  65324. 'ჰ' => 'Ჰ',
  65325. 'ჱ' => 'Ჱ',
  65326. 'ჲ' => 'Ჲ',
  65327. 'ჳ' => 'Ჳ',
  65328. 'ჴ' => 'Ჴ',
  65329. 'ჵ' => 'Ჵ',
  65330. 'ჶ' => 'Ჶ',
  65331. 'ჷ' => 'Ჷ',
  65332. 'ჸ' => 'Ჸ',
  65333. 'ჹ' => 'Ჹ',
  65334. 'ჺ' => 'Ჺ',
  65335. 'ჽ' => 'Ჽ',
  65336. 'ჾ' => 'Ჾ',
  65337. 'ჿ' => 'Ჿ',
  65338. '�' => '�',
  65339. '�' => '�',
  65340. '�' => '�',
  65341. '�' => '�',
  65342. '�' => '�',
  65343. '�' => '�',
  65344. 'á²€' => 'Ð’',
  65345. '�' => 'Д',
  65346. 'ᲂ' => 'О',
  65347. 'ᲃ' => 'С',
  65348. 'ᲄ' => 'Т',
  65349. 'ᲅ' => 'Т',
  65350. 'ᲆ' => 'Ъ',
  65351. 'ᲇ' => 'Ѣ',
  65352. 'ᲈ' => 'Ꙋ',
  65353. 'ᵹ' => '�',
  65354. 'áµ½' => 'â±£',
  65355. 'ᶎ' => 'Ᶎ',
  65356. '�' => 'Ḁ',
  65357. 'ḃ' => 'Ḃ',
  65358. 'ḅ' => 'Ḅ',
  65359. 'ḇ' => 'Ḇ',
  65360. 'ḉ' => 'Ḉ',
  65361. 'ḋ' => 'Ḋ',
  65362. '�' => 'Ḍ',
  65363. '�' => 'Ḏ',
  65364. 'ḑ' => '�',
  65365. 'ḓ' => 'Ḓ',
  65366. 'ḕ' => 'Ḕ',
  65367. 'ḗ' => 'Ḗ',
  65368. 'ḙ' => 'Ḙ',
  65369. 'ḛ' => 'Ḛ',
  65370. '�' => 'Ḝ',
  65371. 'ḟ' => 'Ḟ',
  65372. 'ḡ' => 'Ḡ',
  65373. 'ḣ' => 'Ḣ',
  65374. 'ḥ' => 'Ḥ',
  65375. 'ḧ' => 'Ḧ',
  65376. 'ḩ' => 'Ḩ',
  65377. 'ḫ' => 'Ḫ',
  65378. 'ḭ' => 'Ḭ',
  65379. 'ḯ' => 'Ḯ',
  65380. 'ḱ' => 'Ḱ',
  65381. 'ḳ' => 'Ḳ',
  65382. 'ḵ' => 'Ḵ',
  65383. 'ḷ' => 'Ḷ',
  65384. 'ḹ' => 'Ḹ',
  65385. 'ḻ' => 'Ḻ',
  65386. 'ḽ' => 'Ḽ',
  65387. 'ḿ' => 'Ḿ',
  65388. '�' => 'Ṁ',
  65389. 'ṃ' => 'Ṃ',
  65390. 'ṅ' => 'Ṅ',
  65391. 'ṇ' => 'Ṇ',
  65392. 'ṉ' => 'Ṉ',
  65393. 'ṋ' => 'Ṋ',
  65394. '�' => 'Ṍ',
  65395. '�' => 'Ṏ',
  65396. 'ṑ' => '�',
  65397. 'ṓ' => 'Ṓ',
  65398. 'ṕ' => 'Ṕ',
  65399. 'á¹—' => 'á¹–',
  65400. 'ṙ' => 'Ṙ',
  65401. 'ṛ' => 'Ṛ',
  65402. '�' => 'Ṝ',
  65403. 'ṟ' => 'Ṟ',
  65404. 'ṡ' => 'Ṡ',
  65405. 'á¹£' => 'á¹¢',
  65406. 'ṥ' => 'Ṥ',
  65407. 'ṧ' => 'Ṧ',
  65408. 'ṩ' => 'Ṩ',
  65409. 'ṫ' => 'Ṫ',
  65410. 'ṭ' => 'Ṭ',
  65411. 'ṯ' => 'Ṯ',
  65412. 'á¹±' => 'á¹°',
  65413. 'á¹³' => 'á¹²',
  65414. 'á¹µ' => 'á¹´',
  65415. 'á¹·' => 'á¹¶',
  65416. 'ṹ' => 'Ṹ',
  65417. 'ṻ' => 'Ṻ',
  65418. 'á¹½' => 'á¹¼',
  65419. 'ṿ' => 'Ṿ',
  65420. '�' => 'Ẁ',
  65421. 'ẃ' => 'Ẃ',
  65422. 'ẅ' => 'Ẅ',
  65423. 'ẇ' => 'Ẇ',
  65424. 'ẉ' => 'Ẉ',
  65425. 'ẋ' => 'Ẋ',
  65426. '�' => 'Ẍ',
  65427. '�' => 'Ẏ',
  65428. 'ẑ' => '�',
  65429. 'ẓ' => 'Ẓ',
  65430. 'ẕ' => 'Ẕ',
  65431. 'ẛ' => 'Ṡ',
  65432. 'ạ' => 'Ạ',
  65433. 'ả' => 'Ả',
  65434. 'ấ' => 'Ấ',
  65435. 'ầ' => 'Ầ',
  65436. 'ẩ' => 'Ẩ',
  65437. 'ẫ' => 'Ẫ',
  65438. 'ậ' => 'Ậ',
  65439. 'ắ' => 'Ắ',
  65440. 'ằ' => 'Ằ',
  65441. 'ẳ' => 'Ẳ',
  65442. 'ẵ' => 'Ẵ',
  65443. 'ặ' => 'Ặ',
  65444. 'ẹ' => 'Ẹ',
  65445. 'ẻ' => 'Ẻ',
  65446. 'ẽ' => 'Ẽ',
  65447. 'ế' => 'Ế',
  65448. '�' => 'Ề',
  65449. 'ể' => 'Ể',
  65450. 'ễ' => 'Ễ',
  65451. 'ệ' => 'Ệ',
  65452. 'ỉ' => 'Ỉ',
  65453. 'ị' => 'Ị',
  65454. '�' => 'Ọ',
  65455. '�' => 'Ỏ',
  65456. 'ố' => '�',
  65457. 'ồ' => 'Ồ',
  65458. 'ổ' => 'Ổ',
  65459. 'á»—' => 'á»–',
  65460. 'ộ' => 'Ộ',
  65461. 'ớ' => 'Ớ',
  65462. '�' => 'Ờ',
  65463. 'ở' => 'Ở',
  65464. 'ỡ' => 'Ỡ',
  65465. 'ợ' => 'Ợ',
  65466. 'ụ' => 'Ụ',
  65467. 'ủ' => 'Ủ',
  65468. 'ứ' => 'Ứ',
  65469. 'ừ' => 'Ừ',
  65470. 'ử' => 'Ử',
  65471. 'ữ' => 'Ữ',
  65472. 'á»±' => 'á»°',
  65473. 'ỳ' => 'Ỳ',
  65474. 'ỵ' => 'Ỵ',
  65475. 'á»·' => 'á»¶',
  65476. 'ỹ' => 'Ỹ',
  65477. 'ỻ' => 'Ỻ',
  65478. 'ỽ' => 'Ỽ',
  65479. 'ỿ' => 'Ỿ',
  65480. 'ἀ' => 'Ἀ',
  65481. '�' => 'Ἁ',
  65482. 'ἂ' => 'Ἂ',
  65483. 'ἃ' => 'Ἃ',
  65484. 'ἄ' => 'Ἄ',
  65485. 'ἅ' => '�',
  65486. 'ἆ' => 'Ἆ',
  65487. 'ἇ' => '�',
  65488. '�' => 'Ἐ',
  65489. 'ἑ' => 'Ἑ',
  65490. 'ἒ' => 'Ἒ',
  65491. 'ἓ' => 'Ἓ',
  65492. 'ἔ' => 'Ἔ',
  65493. 'ἕ' => '�',
  65494. 'ἠ' => 'Ἠ',
  65495. 'ἡ' => 'Ἡ',
  65496. 'ἢ' => 'Ἢ',
  65497. 'ἣ' => 'Ἣ',
  65498. 'ἤ' => 'Ἤ',
  65499. 'á¼¥' => 'á¼­',
  65500. 'ἦ' => 'Ἦ',
  65501. 'ἧ' => 'Ἧ',
  65502. 'ἰ' => 'Ἰ',
  65503. 'á¼±' => 'á¼¹',
  65504. 'ἲ' => 'Ἲ',
  65505. 'á¼³' => 'á¼»',
  65506. 'á¼´' => 'á¼¼',
  65507. 'á¼µ' => 'á¼½',
  65508. 'á¼¶' => 'á¼¾',
  65509. 'ἷ' => 'Ἷ',
  65510. 'ὀ' => 'Ὀ',
  65511. '�' => 'Ὁ',
  65512. 'ὂ' => 'Ὂ',
  65513. 'ὃ' => 'Ὃ',
  65514. 'ὄ' => 'Ὄ',
  65515. 'ὅ' => '�',
  65516. 'ὑ' => 'Ὑ',
  65517. 'ὓ' => 'Ὓ',
  65518. 'ὕ' => '�',
  65519. 'ὗ' => 'Ὗ',
  65520. 'ὠ' => 'Ὠ',
  65521. 'ὡ' => 'Ὡ',
  65522. 'ὢ' => 'Ὢ',
  65523. 'ὣ' => 'Ὣ',
  65524. 'ὤ' => 'Ὤ',
  65525. 'á½¥' => 'á½­',
  65526. 'ὦ' => 'Ὦ',
  65527. 'ὧ' => 'Ὧ',
  65528. 'ὰ' => 'Ὰ',
  65529. 'á½±' => 'á¾»',
  65530. 'ὲ' => 'Ὲ',
  65531. 'έ' => 'Έ',
  65532. 'ὴ' => 'Ὴ',
  65533. 'á½µ' => 'á¿‹',
  65534. 'ὶ' => 'Ὶ',
  65535. 'á½·' => 'á¿›',
  65536. 'ὸ' => 'Ὸ',
  65537. 'ό' => 'Ό',
  65538. 'ὺ' => 'Ὺ',
  65539. 'á½»' => 'á¿«',
  65540. 'ὼ' => 'Ὼ',
  65541. 'á½½' => 'á¿»',
  65542. 'ᾀ' => 'ᾈ',
  65543. '�' => 'ᾉ',
  65544. 'ᾂ' => 'ᾊ',
  65545. 'ᾃ' => 'ᾋ',
  65546. 'ᾄ' => 'ᾌ',
  65547. 'ᾅ' => '�',
  65548. 'ᾆ' => 'ᾎ',
  65549. 'ᾇ' => '�',
  65550. '�' => 'ᾘ',
  65551. 'ᾑ' => 'ᾙ',
  65552. 'ᾒ' => 'ᾚ',
  65553. 'ᾓ' => 'ᾛ',
  65554. 'ᾔ' => 'ᾜ',
  65555. 'ᾕ' => '�',
  65556. 'ᾖ' => 'ᾞ',
  65557. 'ᾗ' => 'ᾟ',
  65558. 'ᾠ' => 'ᾨ',
  65559. 'ᾡ' => 'ᾩ',
  65560. 'ᾢ' => 'ᾪ',
  65561. 'ᾣ' => 'ᾫ',
  65562. 'ᾤ' => 'ᾬ',
  65563. 'á¾¥' => 'á¾­',
  65564. 'ᾦ' => 'ᾮ',
  65565. 'ᾧ' => 'ᾯ',
  65566. 'ᾰ' => 'Ᾰ',
  65567. 'á¾±' => 'á¾¹',
  65568. 'á¾³' => 'á¾¼',
  65569. 'ι' => 'Ι',
  65570. 'ῃ' => 'ῌ',
  65571. '�' => 'Ῐ',
  65572. 'á¿‘' => 'á¿™',
  65573. 'ῠ' => 'Ῠ',
  65574. 'á¿¡' => 'á¿©',
  65575. 'ῥ' => 'Ῥ',
  65576. 'ῳ' => 'ῼ',
  65577. 'ⅎ' => 'Ⅎ',
  65578. 'â…°' => 'â… ',
  65579. 'â…±' => 'â…¡',
  65580. 'â…²' => 'â…¢',
  65581. 'â…³' => 'â…£',
  65582. 'â…´' => 'â…¤',
  65583. 'â…µ' => 'â…¥',
  65584. 'â…¶' => 'â…¦',
  65585. 'â…·' => 'â…§',
  65586. 'â…¸' => 'â…¨',
  65587. 'â…¹' => 'â…©',
  65588. 'â…º' => 'â…ª',
  65589. 'â…»' => 'â…«',
  65590. 'â…¼' => 'â…¬',
  65591. 'â…½' => 'â…­',
  65592. 'â…¾' => 'â…®',
  65593. 'â…¿' => 'â…¯',
  65594. 'ↄ' => 'Ↄ',
  65595. '�' => 'Ⓐ',
  65596. 'â“‘' => 'â’·',
  65597. 'â“’' => 'â’¸',
  65598. 'â““' => 'â’¹',
  65599. 'â“”' => 'â’º',
  65600. 'â“•' => 'â’»',
  65601. 'â“–' => 'â’¼',
  65602. 'â“—' => 'â’½',
  65603. 'ⓘ' => 'Ⓘ',
  65604. 'â“™' => 'â’¿',
  65605. 'ⓚ' => 'Ⓚ',
  65606. 'ⓛ' => '�',
  65607. 'ⓜ' => 'Ⓜ',
  65608. '�' => 'Ⓝ',
  65609. 'ⓞ' => 'Ⓞ',
  65610. 'ⓟ' => 'Ⓟ',
  65611. 'ⓠ' => 'Ⓠ',
  65612. 'ⓡ' => 'Ⓡ',
  65613. 'ⓢ' => 'Ⓢ',
  65614. 'ⓣ' => 'Ⓣ',
  65615. 'ⓤ' => 'Ⓤ',
  65616. 'â“¥' => 'â“‹',
  65617. 'ⓦ' => 'Ⓦ',
  65618. 'ⓧ' => '�',
  65619. 'ⓨ' => 'Ⓨ',
  65620. 'ⓩ' => '�',
  65621. 'â°°' => 'â°€',
  65622. 'â°±' => 'â°�',
  65623. 'â°²' => 'â°‚',
  65624. 'â°³' => 'â°ƒ',
  65625. 'â°´' => 'â°„',
  65626. 'â°µ' => 'â°…',
  65627. 'â°¶' => 'â°†',
  65628. 'â°·' => 'â°‡',
  65629. 'â°¸' => 'â°ˆ',
  65630. 'â°¹' => 'â°‰',
  65631. 'â°º' => 'â°Š',
  65632. 'â°»' => 'â°‹',
  65633. 'ⰼ' => 'Ⰼ',
  65634. 'â°½' => 'â°�',
  65635. 'â°¾' => 'â°Ž',
  65636. 'â°¿' => 'â°�',
  65637. 'â±€' => 'â°�',
  65638. '�' => 'Ⱁ',
  65639. 'ⱂ' => 'Ⱂ',
  65640. 'ⱃ' => 'Ⱃ',
  65641. 'ⱄ' => 'Ⱄ',
  65642. 'â±…' => 'â°•',
  65643. 'ⱆ' => 'Ⱆ',
  65644. 'ⱇ' => 'Ⱇ',
  65645. 'ⱈ' => 'Ⱈ',
  65646. 'ⱉ' => 'Ⱉ',
  65647. 'ⱊ' => 'Ⱊ',
  65648. 'ⱋ' => 'Ⱋ',
  65649. 'ⱌ' => 'Ⱌ',
  65650. '�' => '�',
  65651. 'ⱎ' => 'Ⱎ',
  65652. '�' => 'Ⱏ',
  65653. '�' => 'Ⱐ',
  65654. 'ⱑ' => 'Ⱑ',
  65655. 'â±’' => 'â°¢',
  65656. 'ⱓ' => 'Ⱓ',
  65657. 'â±”' => 'â°¤',
  65658. 'ⱕ' => 'Ⱕ',
  65659. 'â±–' => 'â°¦',
  65660. 'â±—' => 'â°§',
  65661. 'ⱘ' => 'Ⱘ',
  65662. 'â±™' => 'â°©',
  65663. 'ⱚ' => 'Ⱚ',
  65664. 'â±›' => 'â°«',
  65665. 'ⱜ' => 'Ⱜ',
  65666. '�' => 'Ⱝ',
  65667. 'ⱞ' => 'Ⱞ',
  65668. 'ⱡ' => 'Ⱡ',
  65669. 'ⱥ' => 'Ⱥ',
  65670. 'ⱦ' => 'Ⱦ',
  65671. 'ⱨ' => 'Ⱨ',
  65672. 'ⱪ' => 'Ⱪ',
  65673. 'ⱬ' => 'Ⱬ',
  65674. 'â±³' => 'â±²',
  65675. 'â±¶' => 'â±µ',
  65676. '�' => 'Ⲁ',
  65677. 'ⲃ' => 'Ⲃ',
  65678. 'ⲅ' => 'Ⲅ',
  65679. 'ⲇ' => 'Ⲇ',
  65680. 'ⲉ' => 'Ⲉ',
  65681. 'ⲋ' => 'Ⲋ',
  65682. '�' => 'Ⲍ',
  65683. '�' => 'Ⲏ',
  65684. 'ⲑ' => '�',
  65685. 'ⲓ' => 'Ⲓ',
  65686. 'ⲕ' => 'Ⲕ',
  65687. 'â²—' => 'â²–',
  65688. 'ⲙ' => 'Ⲙ',
  65689. 'ⲛ' => 'Ⲛ',
  65690. '�' => 'Ⲝ',
  65691. 'ⲟ' => 'Ⲟ',
  65692. 'ⲡ' => 'Ⲡ',
  65693. 'â²£' => 'â²¢',
  65694. 'ⲥ' => 'Ⲥ',
  65695. 'ⲧ' => 'Ⲧ',
  65696. 'ⲩ' => 'Ⲩ',
  65697. 'ⲫ' => 'Ⲫ',
  65698. 'ⲭ' => 'Ⲭ',
  65699. 'ⲯ' => 'Ⲯ',
  65700. 'â²±' => 'â²°',
  65701. 'â²³' => 'â²²',
  65702. 'â²µ' => 'â²´',
  65703. 'â²·' => 'â²¶',
  65704. 'ⲹ' => 'Ⲹ',
  65705. 'ⲻ' => 'Ⲻ',
  65706. 'â²½' => 'â²¼',
  65707. 'ⲿ' => 'Ⲿ',
  65708. '�' => 'Ⳁ',
  65709. 'ⳃ' => 'Ⳃ',
  65710. 'ⳅ' => 'Ⳅ',
  65711. 'ⳇ' => 'Ⳇ',
  65712. 'ⳉ' => 'Ⳉ',
  65713. 'ⳋ' => 'Ⳋ',
  65714. '�' => 'Ⳍ',
  65715. '�' => 'Ⳏ',
  65716. 'ⳑ' => '�',
  65717. 'ⳓ' => 'Ⳓ',
  65718. 'ⳕ' => 'Ⳕ',
  65719. 'â³—' => 'â³–',
  65720. 'ⳙ' => 'Ⳙ',
  65721. 'ⳛ' => 'Ⳛ',
  65722. '�' => 'Ⳝ',
  65723. 'ⳟ' => 'Ⳟ',
  65724. 'ⳡ' => 'Ⳡ',
  65725. 'â³£' => 'â³¢',
  65726. 'ⳬ' => 'Ⳬ',
  65727. 'â³®' => 'â³­',
  65728. 'â³³' => 'â³²',
  65729. 'â´€' => 'á‚ ',
  65730. 'â´�' => 'á‚¡',
  65731. 'â´‚' => 'á‚¢',
  65732. 'â´ƒ' => 'á‚£',
  65733. 'ⴄ' => 'Ⴄ',
  65734. 'â´…' => 'á‚¥',
  65735. 'ⴆ' => 'Ⴆ',
  65736. 'â´‡' => 'á‚§',
  65737. 'ⴈ' => 'Ⴈ',
  65738. 'â´‰' => 'á‚©',
  65739. 'ⴊ' => 'Ⴊ',
  65740. 'â´‹' => 'á‚«',
  65741. 'ⴌ' => 'Ⴌ',
  65742. 'â´�' => 'á‚­',
  65743. 'â´Ž' => 'á‚®',
  65744. '�' => 'Ⴏ',
  65745. 'â´�' => 'á‚°',
  65746. 'ⴑ' => 'Ⴑ',
  65747. 'ⴒ' => 'Ⴒ',
  65748. 'ⴓ' => 'Ⴓ',
  65749. 'â´”' => 'á‚´',
  65750. 'ⴕ' => 'Ⴕ',
  65751. 'â´–' => 'á‚¶',
  65752. 'â´—' => 'á‚·',
  65753. 'ⴘ' => 'Ⴘ',
  65754. 'ⴙ' => 'Ⴙ',
  65755. 'ⴚ' => 'Ⴚ',
  65756. 'â´›' => 'á‚»',
  65757. 'ⴜ' => 'Ⴜ',
  65758. '�' => 'Ⴝ',
  65759. 'ⴞ' => 'Ⴞ',
  65760. 'â´Ÿ' => 'á‚¿',
  65761. 'ⴠ' => 'Ⴠ',
  65762. 'ⴡ' => '�',
  65763. 'ⴢ' => 'Ⴢ',
  65764. 'ⴣ' => 'Ⴣ',
  65765. 'ⴤ' => 'Ⴤ',
  65766. 'ⴥ' => 'Ⴥ',
  65767. 'ⴧ' => 'Ⴧ',
  65768. 'ⴭ' => '�',
  65769. '�' => 'Ꙁ',
  65770. 'ꙃ' => 'Ꙃ',
  65771. 'ꙅ' => 'Ꙅ',
  65772. 'ꙇ' => 'Ꙇ',
  65773. 'ꙉ' => 'Ꙉ',
  65774. 'ꙋ' => 'Ꙋ',
  65775. '�' => 'Ꙍ',
  65776. '�' => 'Ꙏ',
  65777. 'ꙑ' => '�',
  65778. 'ꙓ' => 'Ꙓ',
  65779. 'ꙕ' => 'Ꙕ',
  65780. 'ê™—' => 'ê™–',
  65781. 'ꙙ' => 'Ꙙ',
  65782. 'ꙛ' => 'Ꙛ',
  65783. '�' => 'Ꙝ',
  65784. 'ꙟ' => 'Ꙟ',
  65785. 'ꙡ' => 'Ꙡ',
  65786. 'ꙣ' => 'Ꙣ',
  65787. 'ꙥ' => 'Ꙥ',
  65788. 'ꙧ' => 'Ꙧ',
  65789. 'ꙩ' => 'Ꙩ',
  65790. 'ꙫ' => 'Ꙫ',
  65791. 'ꙭ' => 'Ꙭ',
  65792. '�' => 'Ꚁ',
  65793. 'ꚃ' => 'Ꚃ',
  65794. 'êš…' => 'êš„',
  65795. 'ꚇ' => 'Ꚇ',
  65796. 'ꚉ' => 'Ꚉ',
  65797. 'ꚋ' => 'Ꚋ',
  65798. '�' => 'Ꚍ',
  65799. '�' => 'Ꚏ',
  65800. 'ꚑ' => '�',
  65801. 'êš“' => 'êš’',
  65802. 'êš•' => 'êš”',
  65803. 'êš—' => 'êš–',
  65804. 'ꚙ' => 'Ꚙ',
  65805. 'êš›' => 'êšš',
  65806. 'ꜣ' => 'Ꜣ',
  65807. 'ꜥ' => 'Ꜥ',
  65808. 'ꜧ' => 'Ꜧ',
  65809. 'ꜩ' => 'Ꜩ',
  65810. 'ꜫ' => 'Ꜫ',
  65811. 'ꜭ' => 'Ꜭ',
  65812. 'ꜯ' => 'Ꜯ',
  65813. 'ꜳ' => 'Ꜳ',
  65814. 'ꜵ' => 'Ꜵ',
  65815. 'ꜷ' => 'Ꜷ',
  65816. 'ꜹ' => 'Ꜹ',
  65817. 'ꜻ' => 'Ꜻ',
  65818. 'ꜽ' => 'Ꜽ',
  65819. 'ꜿ' => 'Ꜿ',
  65820. '�' => '�',
  65821. '�' => '�',
  65822. '�' => '�',
  65823. '�' => '�',
  65824. '�' => '�',
  65825. '�' => '�',
  65826. '�' => '�',
  65827. '�' => '�',
  65828. '�' => '�',
  65829. '�' => '�',
  65830. '�' => '�',
  65831. '�' => '�',
  65832. '�' => '�',
  65833. '�' => '�',
  65834. '�' => '�',
  65835. '�' => '�',
  65836. '�' => '�',
  65837. '�' => '�',
  65838. '�' => '�',
  65839. '�' => '�',
  65840. '�' => '�',
  65841. '�' => '�',
  65842. '�' => '�',
  65843. '�' => '�',
  65844. '�' => '�',
  65845. '�' => '�',
  65846. '�' => '�',
  65847. '�' => 'Ꞁ',
  65848. 'ꞃ' => 'Ꞃ',
  65849. 'êž…' => 'êž„',
  65850. 'ꞇ' => 'Ꞇ',
  65851. 'ꞌ' => 'Ꞌ',
  65852. 'ꞑ' => '�',
  65853. 'êž“' => 'êž’',
  65854. 'ꞔ' => 'Ꞔ',
  65855. 'êž—' => 'êž–',
  65856. 'ꞙ' => 'Ꞙ',
  65857. 'êž›' => 'êžš',
  65858. '�' => 'Ꞝ',
  65859. 'ꞟ' => 'Ꞟ',
  65860. 'êž¡' => 'êž ',
  65861. 'ꞣ' => 'Ꞣ',
  65862. 'ꞥ' => 'Ꞥ',
  65863. 'ꞧ' => 'Ꞧ',
  65864. 'ꞩ' => 'Ꞩ',
  65865. 'êžµ' => 'êž´',
  65866. 'êž·' => 'êž¶',
  65867. 'ꞹ' => 'Ꞹ',
  65868. 'ꞻ' => 'Ꞻ',
  65869. 'êž½' => 'êž¼',
  65870. 'êž¿' => 'êž¾',
  65871. 'ꟃ' => 'Ꟃ',
  65872. 'ꟈ' => 'Ꟈ',
  65873. 'ꟊ' => 'Ꟊ',
  65874. 'ꟶ' => 'Ꟶ',
  65875. 'ê­“' => 'êž³',
  65876. 'ꭰ' => 'Ꭰ',
  65877. 'ꭱ' => 'Ꭱ',
  65878. 'ꭲ' => 'Ꭲ',
  65879. 'ꭳ' => 'Ꭳ',
  65880. 'ꭴ' => 'Ꭴ',
  65881. 'ꭵ' => 'Ꭵ',
  65882. 'ꭶ' => 'Ꭶ',
  65883. 'ꭷ' => 'Ꭷ',
  65884. 'ꭸ' => 'Ꭸ',
  65885. 'ꭹ' => 'Ꭹ',
  65886. 'ꭺ' => 'Ꭺ',
  65887. 'ꭻ' => 'Ꭻ',
  65888. 'ꭼ' => 'Ꭼ',
  65889. 'ꭽ' => 'Ꭽ',
  65890. 'ꭾ' => 'Ꭾ',
  65891. 'ꭿ' => 'Ꭿ',
  65892. 'ꮀ' => 'Ꮀ',
  65893. '�' => 'Ꮁ',
  65894. 'ꮂ' => 'Ꮂ',
  65895. 'ꮃ' => 'Ꮃ',
  65896. 'ꮄ' => 'Ꮄ',
  65897. 'ꮅ' => 'Ꮅ',
  65898. 'ꮆ' => 'Ꮆ',
  65899. 'ꮇ' => 'Ꮇ',
  65900. 'ꮈ' => 'Ꮈ',
  65901. 'ꮉ' => 'Ꮉ',
  65902. 'ꮊ' => 'Ꮊ',
  65903. 'ꮋ' => 'Ꮋ',
  65904. 'ꮌ' => 'Ꮌ',
  65905. '�' => 'Ꮍ',
  65906. 'ꮎ' => 'Ꮎ',
  65907. '�' => 'Ꮏ',
  65908. '�' => '�',
  65909. 'ꮑ' => '�',
  65910. 'ꮒ' => '�',
  65911. 'ꮓ' => '�',
  65912. 'ꮔ' => '�',
  65913. 'ꮕ' => '�',
  65914. 'ꮖ' => '�',
  65915. 'ꮗ' => '�',
  65916. 'ꮘ' => '�',
  65917. 'ꮙ' => '�',
  65918. 'ꮚ' => '�',
  65919. 'ꮛ' => '�',
  65920. 'ꮜ' => '�',
  65921. '�' => '�',
  65922. 'ꮞ' => '�',
  65923. 'ꮟ' => '�',
  65924. 'ꮠ' => '�',
  65925. 'ꮡ' => '�',
  65926. 'ꮢ' => '�',
  65927. 'ꮣ' => '�',
  65928. 'ꮤ' => '�',
  65929. 'ꮥ' => '�',
  65930. 'ꮦ' => '�',
  65931. 'ꮧ' => '�',
  65932. 'ꮨ' => '�',
  65933. 'ꮩ' => '�',
  65934. 'ꮪ' => '�',
  65935. 'ꮫ' => '�',
  65936. 'ꮬ' => '�',
  65937. 'ꮭ' => '�',
  65938. 'ꮮ' => '�',
  65939. 'ꮯ' => '�',
  65940. 'ꮰ' => '�',
  65941. 'ꮱ' => '�',
  65942. 'ꮲ' => '�',
  65943. 'ꮳ' => '�',
  65944. 'ꮴ' => '�',
  65945. 'ꮵ' => '�',
  65946. 'ꮶ' => '�',
  65947. 'ꮷ' => '�',
  65948. 'ꮸ' => '�',
  65949. 'ꮹ' => '�',
  65950. 'ꮺ' => '�',
  65951. 'ꮻ' => '�',
  65952. 'ꮼ' => '�',
  65953. 'ꮽ' => '�',
  65954. 'ꮾ' => '�',
  65955. 'ꮿ' => '�',
  65956. '�' => 'A',
  65957. 'b' => 'B',
  65958. 'c' => 'C',
  65959. 'd' => 'D',
  65960. 'ï½…' => 'ï¼¥',
  65961. 'f' => 'F',
  65962. 'g' => 'G',
  65963. 'h' => 'H',
  65964. 'i' => 'I',
  65965. 'j' => 'J',
  65966. 'k' => 'K',
  65967. 'l' => 'L',
  65968. '�' => 'M',
  65969. 'n' => 'N',
  65970. '�' => 'O',
  65971. '�' => 'P',
  65972. 'q' => 'Q',
  65973. 'ï½’' => 'ï¼²',
  65974. 's' => 'S',
  65975. 'ï½”' => 'ï¼´',
  65976. 'u' => 'U',
  65977. 'ï½–' => 'ï¼¶',
  65978. 'ï½—' => 'ï¼·',
  65979. 'x' => 'X',
  65980. 'ï½™' => 'ï¼¹',
  65981. 'z' => 'Z',
  65982. '�' => '�',
  65983. '�' => '�',
  65984. '�' => '�',
  65985. '�' => '�',
  65986. '�' => '�',
  65987. '�' => '�',
  65988. '�' => '�',
  65989. '�' => '�',
  65990. '�' => '�',
  65991. '�' => '�',
  65992. '�' => '�',
  65993. '�' => '�',
  65994. '�' => '�',
  65995. '�' => '�',
  65996. '�' => '�',
  65997. '�' => '�',
  65998. '�' => '�',
  65999. '�' => '�',
  66000. '�' => '�',
  66001. '�' => '�',
  66002. '�' => '�',
  66003. '�' => '�',
  66004. '�' => '�',
  66005. '�' => '�',
  66006. '�' => '�',
  66007. '�' => '�',
  66008. '�' => '�',
  66009. '�' => '�',
  66010. '�' => '�',
  66011. '�' => '�',
  66012. '�' => '�',
  66013. '�' => '�',
  66014. '�' => '�',
  66015. '�' => '�',
  66016. '�' => '�',
  66017. '�' => '�',
  66018. '�' => '�',
  66019. '�' => '�',
  66020. '�' => '�',
  66021. '�' => '�',
  66022. '�' => '�',
  66023. '�' => '�',
  66024. '�' => '�',
  66025. '�' => '�',
  66026. '�' => '�',
  66027. '�' => '�',
  66028. '�' => '�',
  66029. '�' => '�',
  66030. '�' => '�',
  66031. '�' => '�',
  66032. '�' => '�',
  66033. '�' => '�',
  66034. '�' => '�',
  66035. '�' => '�',
  66036. '�' => '�',
  66037. '�' => '�',
  66038. '�' => '�',
  66039. '�' => '�',
  66040. '�' => '�',
  66041. '�' => '�',
  66042. '�' => '�',
  66043. '�' => '�',
  66044. '�' => '�',
  66045. '�' => '�',
  66046. '�' => '�',
  66047. '�' => '�',
  66048. '�' => '�',
  66049. '�' => '�',
  66050. '�' => '�',
  66051. '�' => '�',
  66052. '�' => '�',
  66053. '�' => '�',
  66054. '�' => '�',
  66055. '�' => '�',
  66056. '�' => '�',
  66057. '�' => '�',
  66058. '�' => '�',
  66059. '�' => '�',
  66060. '�' => '�',
  66061. '�' => '�',
  66062. '�' => '�',
  66063. '�' => '�',
  66064. '�' => '�',
  66065. '�' => '�',
  66066. '�' => '�',
  66067. '�' => '�',
  66068. '�' => '�',
  66069. '�' => '�',
  66070. '�' => '�',
  66071. '�' => '�',
  66072. '�' => '�',
  66073. '�' => '�',
  66074. '�' => '�',
  66075. '�' => '�',
  66076. '�' => '�',
  66077. '�' => '�',
  66078. '�' => '�',
  66079. '�' => '�',
  66080. '�' => '�',
  66081. '�' => '�',
  66082. '�' => '�',
  66083. '�' => '�',
  66084. '�' => '�',
  66085. '�' => '�',
  66086. '�' => '�',
  66087. '�' => '�',
  66088. '�' => '�',
  66089. '�' => '�',
  66090. '�' => '�',
  66091. '�' => '�',
  66092. '�' => '�',
  66093. '�' => '�',
  66094. '�' => '�',
  66095. '�' => '�',
  66096. '�' => '�',
  66097. '�' => '�',
  66098. '�' => '�',
  66099. '�' => '�',
  66100. '�' => '�',
  66101. '�' => '�',
  66102. '�' => '�',
  66103. '�' => '�',
  66104. '�' => '�',
  66105. '�' => '�',
  66106. '�' => '�',
  66107. '�' => '�',
  66108. '�' => '�',
  66109. 'ð‘£€' => 'ð‘¢ ',
  66110. '�' => '𑢡',
  66111. '𑣂' => '𑢢',
  66112. '𑣃' => '𑢣',
  66113. '𑣄' => '𑢤',
  66114. 'ð‘£…' => 'ð‘¢¥',
  66115. '𑣆' => '𑢦',
  66116. '𑣇' => '𑢧',
  66117. '𑣈' => '𑢨',
  66118. '𑣉' => '𑢩',
  66119. '𑣊' => '𑢪',
  66120. '𑣋' => '𑢫',
  66121. '𑣌' => '𑢬',
  66122. '�' => '𑢭',
  66123. '𑣎' => '𑢮',
  66124. '�' => '𑢯',
  66125. '�' => '𑢰',
  66126. '𑣑' => '𑢱',
  66127. 'ð‘£’' => 'ð‘¢²',
  66128. '𑣓' => '𑢳',
  66129. 'ð‘£”' => 'ð‘¢´',
  66130. '𑣕' => '𑢵',
  66131. 'ð‘£–' => 'ð‘¢¶',
  66132. 'ð‘£—' => 'ð‘¢·',
  66133. '𑣘' => '𑢸',
  66134. 'ð‘£™' => 'ð‘¢¹',
  66135. '𑣚' => '𑢺',
  66136. 'ð‘£›' => 'ð‘¢»',
  66137. '𑣜' => '𑢼',
  66138. '�' => '𑢽',
  66139. '𑣞' => '𑢾',
  66140. '𑣟' => '𑢿',
  66141. 'ð–¹ ' => 'ð–¹€',
  66142. '𖹡' => '�',
  66143. '𖹢' => '𖹂',
  66144. '𖹣' => '𖹃',
  66145. '𖹤' => '𖹄',
  66146. 'ð–¹¥' => 'ð–¹…',
  66147. '𖹦' => '𖹆',
  66148. '𖹧' => '𖹇',
  66149. '𖹨' => '𖹈',
  66150. '𖹩' => '𖹉',
  66151. '𖹪' => '𖹊',
  66152. '𖹫' => '𖹋',
  66153. '𖹬' => '𖹌',
  66154. '𖹭' => '�',
  66155. '𖹮' => '𖹎',
  66156. '𖹯' => '�',
  66157. '𖹰' => '�',
  66158. '𖹱' => '𖹑',
  66159. 'ð–¹²' => 'ð–¹’',
  66160. '𖹳' => '𖹓',
  66161. 'ð–¹´' => 'ð–¹”',
  66162. '𖹵' => '𖹕',
  66163. 'ð–¹¶' => 'ð–¹–',
  66164. 'ð–¹·' => 'ð–¹—',
  66165. '𖹸' => '𖹘',
  66166. 'ð–¹¹' => 'ð–¹™',
  66167. '𖹺' => '𖹚',
  66168. 'ð–¹»' => 'ð–¹›',
  66169. '𖹼' => '𖹜',
  66170. '𖹽' => '�',
  66171. '𖹾' => '𖹞',
  66172. '𖹿' => '𖹟',
  66173. '𞤢' => '𞤀',
  66174. '𞤣' => '�',
  66175. '𞤤' => '𞤂',
  66176. '𞤥' => '𞤃',
  66177. '𞤦' => '𞤄',
  66178. '𞤧' => '𞤅',
  66179. '𞤨' => '𞤆',
  66180. '𞤩' => '𞤇',
  66181. '𞤪' => '𞤈',
  66182. '𞤫' => '𞤉',
  66183. '𞤬' => '𞤊',
  66184. '𞤭' => '𞤋',
  66185. '𞤮' => '𞤌',
  66186. '𞤯' => '�',
  66187. '𞤰' => '𞤎',
  66188. '𞤱' => '�',
  66189. '𞤲' => '�',
  66190. '𞤳' => '𞤑',
  66191. '𞤴' => '𞤒',
  66192. '𞤵' => '𞤓',
  66193. '𞤶' => '𞤔',
  66194. '𞤷' => '𞤕',
  66195. '𞤸' => '𞤖',
  66196. '𞤹' => '𞤗',
  66197. '𞤺' => '𞤘',
  66198. '𞤻' => '𞤙',
  66199. '𞤼' => '𞤚',
  66200. '𞤽' => '𞤛',
  66201. '𞤾' => '𞤜',
  66202. '𞤿' => '�',
  66203. '𞥀' => '𞤞',
  66204. '�' => '𞤟',
  66205. '𞥂' => '𞤠',
  66206. '𞥃' => '𞤡',
  66207. );
  66208. <?php
  66209. use Symfony\Polyfill\Mbstring as p;
  66210. if (!function_exists('mb_convert_encoding')) {
  66211. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  66212. }
  66213. if (!function_exists('mb_decode_mimeheader')) {
  66214. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  66215. }
  66216. if (!function_exists('mb_encode_mimeheader')) {
  66217. 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); }
  66218. }
  66219. if (!function_exists('mb_decode_numericentity')) {
  66220. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  66221. }
  66222. if (!function_exists('mb_encode_numericentity')) {
  66223. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  66224. }
  66225. if (!function_exists('mb_convert_case')) {
  66226. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  66227. }
  66228. if (!function_exists('mb_internal_encoding')) {
  66229. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  66230. }
  66231. if (!function_exists('mb_language')) {
  66232. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  66233. }
  66234. if (!function_exists('mb_list_encodings')) {
  66235. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  66236. }
  66237. if (!function_exists('mb_encoding_aliases')) {
  66238. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  66239. }
  66240. if (!function_exists('mb_check_encoding')) {
  66241. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  66242. }
  66243. if (!function_exists('mb_detect_encoding')) {
  66244. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  66245. }
  66246. if (!function_exists('mb_detect_order')) {
  66247. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  66248. }
  66249. if (!function_exists('mb_parse_str')) {
  66250. function mb_parse_str($string, &$result = array()) { parse_str($string, $result); }
  66251. }
  66252. if (!function_exists('mb_strlen')) {
  66253. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  66254. }
  66255. if (!function_exists('mb_strpos')) {
  66256. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  66257. }
  66258. if (!function_exists('mb_strtolower')) {
  66259. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  66260. }
  66261. if (!function_exists('mb_strtoupper')) {
  66262. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  66263. }
  66264. if (!function_exists('mb_substitute_character')) {
  66265. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  66266. }
  66267. if (!function_exists('mb_substr')) {
  66268. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  66269. }
  66270. if (!function_exists('mb_stripos')) {
  66271. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  66272. }
  66273. if (!function_exists('mb_stristr')) {
  66274. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  66275. }
  66276. if (!function_exists('mb_strrchr')) {
  66277. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  66278. }
  66279. if (!function_exists('mb_strrichr')) {
  66280. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  66281. }
  66282. if (!function_exists('mb_strripos')) {
  66283. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  66284. }
  66285. if (!function_exists('mb_strrpos')) {
  66286. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  66287. }
  66288. if (!function_exists('mb_strstr')) {
  66289. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  66290. }
  66291. if (!function_exists('mb_get_info')) {
  66292. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  66293. }
  66294. if (!function_exists('mb_http_output')) {
  66295. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  66296. }
  66297. if (!function_exists('mb_strwidth')) {
  66298. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  66299. }
  66300. if (!function_exists('mb_substr_count')) {
  66301. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  66302. }
  66303. if (!function_exists('mb_output_handler')) {
  66304. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  66305. }
  66306. if (!function_exists('mb_http_input')) {
  66307. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  66308. }
  66309. if (PHP_VERSION_ID >= 80000) {
  66310. require_once __DIR__.'/Resources/mb_convert_variables.php8';
  66311. } elseif (!function_exists('mb_convert_variables')) {
  66312. 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); }
  66313. }
  66314. if (!function_exists('mb_ord')) {
  66315. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  66316. }
  66317. if (!function_exists('mb_chr')) {
  66318. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  66319. }
  66320. if (!function_exists('mb_scrub')) {
  66321. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  66322. }
  66323. if (!function_exists('mb_str_split')) {
  66324. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  66325. }
  66326. if (extension_loaded('mbstring')) {
  66327. return;
  66328. }
  66329. if (!defined('MB_CASE_UPPER')) {
  66330. define('MB_CASE_UPPER', 0);
  66331. }
  66332. if (!defined('MB_CASE_LOWER')) {
  66333. define('MB_CASE_LOWER', 1);
  66334. }
  66335. if (!defined('MB_CASE_TITLE')) {
  66336. define('MB_CASE_TITLE', 2);
  66337. }
  66338. <?php
  66339. namespace Symfony\Component\Process\Exception;
  66340. interface ExceptionInterface
  66341. {
  66342. }
  66343. <?php
  66344. namespace Symfony\Component\Process\Exception;
  66345. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  66346. {
  66347. }
  66348. <?php
  66349. namespace Symfony\Component\Process\Exception;
  66350. class LogicException extends \LogicException implements ExceptionInterface
  66351. {
  66352. }
  66353. <?php
  66354. namespace Symfony\Component\Process\Exception;
  66355. use Symfony\Component\Process\Process;
  66356. class ProcessFailedException extends RuntimeException
  66357. {
  66358. private $process;
  66359. public function __construct(Process $process)
  66360. {
  66361. if ($process->isSuccessful()) {
  66362. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  66363. }
  66364. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  66365. $process->getCommandLine(),
  66366. $process->getExitCode(),
  66367. $process->getExitCodeText(),
  66368. $process->getWorkingDirectory()
  66369. );
  66370. if (!$process->isOutputDisabled()) {
  66371. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  66372. $process->getOutput(),
  66373. $process->getErrorOutput()
  66374. );
  66375. }
  66376. parent::__construct($error);
  66377. $this->process = $process;
  66378. }
  66379. public function getProcess()
  66380. {
  66381. return $this->process;
  66382. }
  66383. }
  66384. <?php
  66385. namespace Symfony\Component\Process\Exception;
  66386. use Symfony\Component\Process\Process;
  66387. class ProcessTimedOutException extends RuntimeException
  66388. {
  66389. const TYPE_GENERAL = 1;
  66390. const TYPE_IDLE = 2;
  66391. private $process;
  66392. private $timeoutType;
  66393. public function __construct(Process $process, $timeoutType)
  66394. {
  66395. $this->process = $process;
  66396. $this->timeoutType = $timeoutType;
  66397. parent::__construct(sprintf(
  66398. 'The process "%s" exceeded the timeout of %s seconds.',
  66399. $process->getCommandLine(),
  66400. $this->getExceededTimeout()
  66401. ));
  66402. }
  66403. public function getProcess()
  66404. {
  66405. return $this->process;
  66406. }
  66407. public function isGeneralTimeout()
  66408. {
  66409. return self::TYPE_GENERAL === $this->timeoutType;
  66410. }
  66411. public function isIdleTimeout()
  66412. {
  66413. return self::TYPE_IDLE === $this->timeoutType;
  66414. }
  66415. public function getExceededTimeout()
  66416. {
  66417. switch ($this->timeoutType) {
  66418. case self::TYPE_GENERAL:
  66419. return $this->process->getTimeout();
  66420. case self::TYPE_IDLE:
  66421. return $this->process->getIdleTimeout();
  66422. default:
  66423. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  66424. }
  66425. }
  66426. }
  66427. <?php
  66428. namespace Symfony\Component\Process\Exception;
  66429. class RuntimeException extends \RuntimeException implements ExceptionInterface
  66430. {
  66431. }
  66432. <?php
  66433. namespace Symfony\Component\Process;
  66434. class ExecutableFinder
  66435. {
  66436. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  66437. public function setSuffixes(array $suffixes)
  66438. {
  66439. $this->suffixes = $suffixes;
  66440. }
  66441. public function addSuffix($suffix)
  66442. {
  66443. $this->suffixes[] = $suffix;
  66444. }
  66445. public function find($name, $default = null, array $extraDirs = array())
  66446. {
  66447. if (ini_get('open_basedir')) {
  66448. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  66449. $dirs = array();
  66450. foreach ($searchPath as $path) {
  66451. if (@is_dir($path)) {
  66452. $dirs[] = $path;
  66453. } else {
  66454. if (basename($path) == $name && @is_executable($path)) {
  66455. return $path;
  66456. }
  66457. }
  66458. }
  66459. } else {
  66460. $dirs = array_merge(
  66461. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  66462. $extraDirs
  66463. );
  66464. }
  66465. $suffixes = array('');
  66466. if ('\\' === \DIRECTORY_SEPARATOR) {
  66467. $pathExt = getenv('PATHEXT');
  66468. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  66469. }
  66470. foreach ($suffixes as $suffix) {
  66471. foreach ($dirs as $dir) {
  66472. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  66473. return $file;
  66474. }
  66475. }
  66476. }
  66477. return $default;
  66478. }
  66479. }
  66480. Copyright (c) 2004-2018 Fabien Potencier
  66481. Permission is hereby granted, free of charge, to any person obtaining a copy
  66482. of this software and associated documentation files (the "Software"), to deal
  66483. in the Software without restriction, including without limitation the rights
  66484. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  66485. copies of the Software, and to permit persons to whom the Software is furnished
  66486. to do so, subject to the following conditions:
  66487. The above copyright notice and this permission notice shall be included in all
  66488. copies or substantial portions of the Software.
  66489. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  66490. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  66491. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  66492. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  66493. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  66494. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  66495. THE SOFTWARE.
  66496. <?php
  66497. namespace Symfony\Component\Process;
  66498. class PhpExecutableFinder
  66499. {
  66500. private $executableFinder;
  66501. public function __construct()
  66502. {
  66503. $this->executableFinder = new ExecutableFinder();
  66504. }
  66505. public function find($includeArgs = true)
  66506. {
  66507. $args = $this->findArguments();
  66508. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  66509. if (\defined('HHVM_VERSION')) {
  66510. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  66511. }
  66512. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  66513. return PHP_BINARY.$args;
  66514. }
  66515. if ($php = getenv('PHP_PATH')) {
  66516. if (!@is_executable($php)) {
  66517. return false;
  66518. }
  66519. return $php;
  66520. }
  66521. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  66522. if (@is_executable($php)) {
  66523. return $php;
  66524. }
  66525. }
  66526. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  66527. return $php;
  66528. }
  66529. $dirs = array(PHP_BINDIR);
  66530. if ('\\' === \DIRECTORY_SEPARATOR) {
  66531. $dirs[] = 'C:\xampp\php\\';
  66532. }
  66533. return $this->executableFinder->find('php', false, $dirs);
  66534. }
  66535. public function findArguments()
  66536. {
  66537. $arguments = array();
  66538. if (\defined('HHVM_VERSION')) {
  66539. $arguments[] = '--php';
  66540. } elseif ('phpdbg' === \PHP_SAPI) {
  66541. $arguments[] = '-qrr';
  66542. }
  66543. return $arguments;
  66544. }
  66545. }
  66546. <?php
  66547. namespace Symfony\Component\Process;
  66548. use Symfony\Component\Process\Exception\RuntimeException;
  66549. class PhpProcess extends Process
  66550. {
  66551. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  66552. {
  66553. $executableFinder = new PhpExecutableFinder();
  66554. if (false === $php = $executableFinder->find()) {
  66555. $php = null;
  66556. }
  66557. if ('phpdbg' === \PHP_SAPI) {
  66558. $file = tempnam(sys_get_temp_dir(), 'dbg');
  66559. file_put_contents($file, $script);
  66560. register_shutdown_function('unlink', $file);
  66561. $php .= ' '.ProcessUtils::escapeArgument($file);
  66562. $script = null;
  66563. }
  66564. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  66565. $php = 'exec '.$php;
  66566. }
  66567. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  66568. }
  66569. public function setPhpBinary($php)
  66570. {
  66571. $this->setCommandLine($php);
  66572. }
  66573. public function start($callback = null)
  66574. {
  66575. if (null === $this->getCommandLine()) {
  66576. throw new RuntimeException('Unable to find the PHP executable.');
  66577. }
  66578. parent::start($callback);
  66579. }
  66580. }
  66581. <?php
  66582. namespace Symfony\Component\Process\Pipes;
  66583. abstract class AbstractPipes implements PipesInterface
  66584. {
  66585. public $pipes = array();
  66586. private $inputBuffer = '';
  66587. private $input;
  66588. private $blocked = true;
  66589. private $lastError;
  66590. public function __construct($input)
  66591. {
  66592. if (\is_resource($input)) {
  66593. $this->input = $input;
  66594. } elseif (\is_string($input)) {
  66595. $this->inputBuffer = $input;
  66596. } else {
  66597. $this->inputBuffer = (string) $input;
  66598. }
  66599. }
  66600. public function close()
  66601. {
  66602. foreach ($this->pipes as $pipe) {
  66603. fclose($pipe);
  66604. }
  66605. $this->pipes = array();
  66606. }
  66607. protected function hasSystemCallBeenInterrupted()
  66608. {
  66609. $lastError = $this->lastError;
  66610. $this->lastError = null;
  66611. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  66612. }
  66613. protected function unblock()
  66614. {
  66615. if (!$this->blocked) {
  66616. return;
  66617. }
  66618. foreach ($this->pipes as $pipe) {
  66619. stream_set_blocking($pipe, 0);
  66620. }
  66621. if (null !== $this->input) {
  66622. stream_set_blocking($this->input, 0);
  66623. }
  66624. $this->blocked = false;
  66625. }
  66626. protected function write()
  66627. {
  66628. if (!isset($this->pipes[0])) {
  66629. return;
  66630. }
  66631. $input = $this->input;
  66632. $r = $e = array();
  66633. $w = array($this->pipes[0]);
  66634. if (false === @stream_select($r, $w, $e, 0, 0)) {
  66635. return;
  66636. }
  66637. foreach ($w as $stdin) {
  66638. if (isset($this->inputBuffer[0])) {
  66639. $written = fwrite($stdin, $this->inputBuffer);
  66640. $this->inputBuffer = substr($this->inputBuffer, $written);
  66641. if (isset($this->inputBuffer[0])) {
  66642. return array($this->pipes[0]);
  66643. }
  66644. }
  66645. if ($input) {
  66646. for (;;) {
  66647. $data = fread($input, self::CHUNK_SIZE);
  66648. if (!isset($data[0])) {
  66649. break;
  66650. }
  66651. $written = fwrite($stdin, $data);
  66652. $data = substr($data, $written);
  66653. if (isset($data[0])) {
  66654. $this->inputBuffer = $data;
  66655. return array($this->pipes[0]);
  66656. }
  66657. }
  66658. if (feof($input)) {
  66659. $this->input = null;
  66660. }
  66661. }
  66662. }
  66663. if (null === $this->input && !isset($this->inputBuffer[0])) {
  66664. fclose($this->pipes[0]);
  66665. unset($this->pipes[0]);
  66666. } elseif (!$w) {
  66667. return array($this->pipes[0]);
  66668. }
  66669. }
  66670. public function handleError($type, $msg)
  66671. {
  66672. $this->lastError = $msg;
  66673. }
  66674. }
  66675. <?php
  66676. namespace Symfony\Component\Process\Pipes;
  66677. interface PipesInterface
  66678. {
  66679. const CHUNK_SIZE = 16384;
  66680. public function getDescriptors();
  66681. public function getFiles();
  66682. public function readAndWrite($blocking, $close = false);
  66683. public function areOpen();
  66684. public function close();
  66685. }
  66686. <?php
  66687. namespace Symfony\Component\Process\Pipes;
  66688. use Symfony\Component\Process\Process;
  66689. class UnixPipes extends AbstractPipes
  66690. {
  66691. private $ttyMode;
  66692. private $ptyMode;
  66693. private $disableOutput;
  66694. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  66695. {
  66696. $this->ttyMode = (bool) $ttyMode;
  66697. $this->ptyMode = (bool) $ptyMode;
  66698. $this->disableOutput = (bool) $disableOutput;
  66699. parent::__construct($input);
  66700. }
  66701. public function __destruct()
  66702. {
  66703. $this->close();
  66704. }
  66705. public function getDescriptors()
  66706. {
  66707. if ($this->disableOutput) {
  66708. $nullstream = fopen('/dev/null', 'c');
  66709. return array(
  66710. array('pipe', 'r'),
  66711. $nullstream,
  66712. $nullstream,
  66713. );
  66714. }
  66715. if ($this->ttyMode) {
  66716. return array(
  66717. array('file', '/dev/tty', 'r'),
  66718. array('file', '/dev/tty', 'w'),
  66719. array('file', '/dev/tty', 'w'),
  66720. );
  66721. }
  66722. if ($this->ptyMode && Process::isPtySupported()) {
  66723. return array(
  66724. array('pty'),
  66725. array('pty'),
  66726. array('pty'),
  66727. );
  66728. }
  66729. return array(
  66730. array('pipe', 'r'),
  66731. array('pipe', 'w'),
  66732. array('pipe', 'w'),
  66733. );
  66734. }
  66735. public function getFiles()
  66736. {
  66737. return array();
  66738. }
  66739. public function readAndWrite($blocking, $close = false)
  66740. {
  66741. $this->unblock();
  66742. $w = $this->write();
  66743. $read = $e = array();
  66744. $r = $this->pipes;
  66745. unset($r[0]);
  66746. set_error_handler(array($this, 'handleError'));
  66747. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  66748. restore_error_handler();
  66749. if (!$this->hasSystemCallBeenInterrupted()) {
  66750. $this->pipes = array();
  66751. }
  66752. return $read;
  66753. }
  66754. restore_error_handler();
  66755. foreach ($r as $pipe) {
  66756. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  66757. do {
  66758. $data = fread($pipe, self::CHUNK_SIZE);
  66759. $read[$type] .= $data;
  66760. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  66761. if (!isset($read[$type][0])) {
  66762. unset($read[$type]);
  66763. }
  66764. if ($close && feof($pipe)) {
  66765. fclose($pipe);
  66766. unset($this->pipes[$type]);
  66767. }
  66768. }
  66769. return $read;
  66770. }
  66771. public function areOpen()
  66772. {
  66773. return (bool) $this->pipes;
  66774. }
  66775. public static function create(Process $process, $input)
  66776. {
  66777. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  66778. }
  66779. }
  66780. <?php
  66781. namespace Symfony\Component\Process\Pipes;
  66782. use Symfony\Component\Process\Exception\RuntimeException;
  66783. use Symfony\Component\Process\Process;
  66784. class WindowsPipes extends AbstractPipes
  66785. {
  66786. private $files = array();
  66787. private $fileHandles = array();
  66788. private $lockHandles = array();
  66789. private $readBytes = array(
  66790. Process::STDOUT => 0,
  66791. Process::STDERR => 0,
  66792. );
  66793. private $disableOutput;
  66794. public function __construct($disableOutput, $input)
  66795. {
  66796. $this->disableOutput = (bool) $disableOutput;
  66797. if (!$this->disableOutput) {
  66798. $pipes = array(
  66799. Process::STDOUT => Process::OUT,
  66800. Process::STDERR => Process::ERR,
  66801. );
  66802. $tmpDir = sys_get_temp_dir();
  66803. $lastError = 'unknown reason';
  66804. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  66805. for ($i = 0;; ++$i) {
  66806. foreach ($pipes as $pipe => $name) {
  66807. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  66808. if (!$h = fopen($file.'.lock', 'w')) {
  66809. restore_error_handler();
  66810. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  66811. }
  66812. if (!flock($h, LOCK_EX | LOCK_NB)) {
  66813. continue 2;
  66814. }
  66815. if (isset($this->lockHandles[$pipe])) {
  66816. flock($this->lockHandles[$pipe], LOCK_UN);
  66817. fclose($this->lockHandles[$pipe]);
  66818. }
  66819. $this->lockHandles[$pipe] = $h;
  66820. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  66821. flock($this->lockHandles[$pipe], LOCK_UN);
  66822. fclose($this->lockHandles[$pipe]);
  66823. unset($this->lockHandles[$pipe]);
  66824. continue 2;
  66825. }
  66826. $this->fileHandles[$pipe] = $h;
  66827. $this->files[$pipe] = $file;
  66828. }
  66829. break;
  66830. }
  66831. restore_error_handler();
  66832. }
  66833. parent::__construct($input);
  66834. }
  66835. public function __destruct()
  66836. {
  66837. $this->close();
  66838. }
  66839. public function getDescriptors()
  66840. {
  66841. if ($this->disableOutput) {
  66842. $nullstream = fopen('NUL', 'c');
  66843. return array(
  66844. array('pipe', 'r'),
  66845. $nullstream,
  66846. $nullstream,
  66847. );
  66848. }
  66849. return array(
  66850. array('pipe', 'r'),
  66851. array('file', 'NUL', 'w'),
  66852. array('file', 'NUL', 'w'),
  66853. );
  66854. }
  66855. public function getFiles()
  66856. {
  66857. return $this->files;
  66858. }
  66859. public function readAndWrite($blocking, $close = false)
  66860. {
  66861. $this->unblock();
  66862. $w = $this->write();
  66863. $read = $r = $e = array();
  66864. if ($blocking) {
  66865. if ($w) {
  66866. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  66867. } elseif ($this->fileHandles) {
  66868. usleep(Process::TIMEOUT_PRECISION * 1E6);
  66869. }
  66870. }
  66871. foreach ($this->fileHandles as $type => $fileHandle) {
  66872. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  66873. if (isset($data[0])) {
  66874. $this->readBytes[$type] += \strlen($data);
  66875. $read[$type] = $data;
  66876. }
  66877. if ($close) {
  66878. ftruncate($fileHandle, 0);
  66879. fclose($fileHandle);
  66880. flock($this->lockHandles[$type], LOCK_UN);
  66881. fclose($this->lockHandles[$type]);
  66882. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  66883. }
  66884. }
  66885. return $read;
  66886. }
  66887. public function areOpen()
  66888. {
  66889. return $this->pipes && $this->fileHandles;
  66890. }
  66891. public function close()
  66892. {
  66893. parent::close();
  66894. foreach ($this->fileHandles as $type => $handle) {
  66895. ftruncate($handle, 0);
  66896. fclose($handle);
  66897. flock($this->lockHandles[$type], LOCK_UN);
  66898. fclose($this->lockHandles[$type]);
  66899. }
  66900. $this->fileHandles = $this->lockHandles = array();
  66901. }
  66902. public static function create(Process $process, $input)
  66903. {
  66904. return new static($process->isOutputDisabled(), $input);
  66905. }
  66906. }
  66907. <?php
  66908. namespace Symfony\Component\Process;
  66909. use Symfony\Component\Process\Exception\InvalidArgumentException;
  66910. use Symfony\Component\Process\Exception\LogicException;
  66911. use Symfony\Component\Process\Exception\ProcessFailedException;
  66912. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  66913. use Symfony\Component\Process\Exception\RuntimeException;
  66914. use Symfony\Component\Process\Pipes\PipesInterface;
  66915. use Symfony\Component\Process\Pipes\UnixPipes;
  66916. use Symfony\Component\Process\Pipes\WindowsPipes;
  66917. class Process
  66918. {
  66919. const ERR = 'err';
  66920. const OUT = 'out';
  66921. const STATUS_READY = 'ready';
  66922. const STATUS_STARTED = 'started';
  66923. const STATUS_TERMINATED = 'terminated';
  66924. const STDIN = 0;
  66925. const STDOUT = 1;
  66926. const STDERR = 2;
  66927. const TIMEOUT_PRECISION = 0.2;
  66928. private $callback;
  66929. private $commandline;
  66930. private $cwd;
  66931. private $env;
  66932. private $input;
  66933. private $starttime;
  66934. private $lastOutputTime;
  66935. private $timeout;
  66936. private $idleTimeout;
  66937. private $options;
  66938. private $exitcode;
  66939. private $fallbackStatus = array();
  66940. private $processInformation;
  66941. private $outputDisabled = false;
  66942. private $stdout;
  66943. private $stderr;
  66944. private $enhanceWindowsCompatibility = true;
  66945. private $enhanceSigchildCompatibility;
  66946. private $process;
  66947. private $status = self::STATUS_READY;
  66948. private $incrementalOutputOffset = 0;
  66949. private $incrementalErrorOutputOffset = 0;
  66950. private $tty;
  66951. private $pty;
  66952. private $useFileHandles = false;
  66953. private $processPipes;
  66954. private $latestSignal;
  66955. private static $sigchild;
  66956. public static $exitCodes = array(
  66957. 0 => 'OK',
  66958. 1 => 'General error',
  66959. 2 => 'Misuse of shell builtins',
  66960. 126 => 'Invoked command cannot execute',
  66961. 127 => 'Command not found',
  66962. 128 => 'Invalid exit argument',
  66963. 129 => 'Hangup',
  66964. 130 => 'Interrupt',
  66965. 131 => 'Quit and dump core',
  66966. 132 => 'Illegal instruction',
  66967. 133 => 'Trace/breakpoint trap',
  66968. 134 => 'Process aborted',
  66969. 135 => 'Bus error: "access to undefined portion of memory object"',
  66970. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  66971. 137 => 'Kill (terminate immediately)',
  66972. 138 => 'User-defined 1',
  66973. 139 => 'Segmentation violation',
  66974. 140 => 'User-defined 2',
  66975. 141 => 'Write to pipe with no one reading',
  66976. 142 => 'Signal raised by alarm',
  66977. 143 => 'Termination (request to terminate)',
  66978. 145 => 'Child process terminated, stopped (or continued*)',
  66979. 146 => 'Continue if stopped',
  66980. 147 => 'Stop executing temporarily',
  66981. 148 => 'Terminal stop signal',
  66982. 149 => 'Background process attempting to read from tty ("in")',
  66983. 150 => 'Background process attempting to write to tty ("out")',
  66984. 151 => 'Urgent data available on socket',
  66985. 152 => 'CPU time limit exceeded',
  66986. 153 => 'File size limit exceeded',
  66987. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  66988. 155 => 'Profiling timer expired',
  66989. 157 => 'Pollable event',
  66990. 159 => 'Bad syscall',
  66991. );
  66992. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  66993. {
  66994. if (!\function_exists('proc_open')) {
  66995. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  66996. }
  66997. $this->commandline = $commandline;
  66998. $this->cwd = $cwd;
  66999. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  67000. $this->cwd = getcwd();
  67001. }
  67002. if (null !== $env) {
  67003. $this->setEnv($env);
  67004. }
  67005. $this->setInput($input);
  67006. $this->setTimeout($timeout);
  67007. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  67008. $this->pty = false;
  67009. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  67010. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  67011. }
  67012. public function __destruct()
  67013. {
  67014. $this->stop(0);
  67015. }
  67016. public function __clone()
  67017. {
  67018. $this->resetProcessData();
  67019. }
  67020. public function run($callback = null)
  67021. {
  67022. $this->start($callback);
  67023. return $this->wait();
  67024. }
  67025. public function mustRun($callback = null)
  67026. {
  67027. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  67028. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  67029. }
  67030. if (0 !== $this->run($callback)) {
  67031. throw new ProcessFailedException($this);
  67032. }
  67033. return $this;
  67034. }
  67035. public function start($callback = null)
  67036. {
  67037. if ($this->isRunning()) {
  67038. throw new RuntimeException('Process is already running');
  67039. }
  67040. if ($this->outputDisabled && null !== $callback) {
  67041. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  67042. }
  67043. $this->resetProcessData();
  67044. $this->starttime = $this->lastOutputTime = microtime(true);
  67045. $this->callback = $this->buildCallback($callback);
  67046. $descriptors = $this->getDescriptors();
  67047. $commandline = $this->commandline;
  67048. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  67049. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  67050. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  67051. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  67052. }
  67053. $commandline .= '"';
  67054. if (!isset($this->options['bypass_shell'])) {
  67055. $this->options['bypass_shell'] = true;
  67056. }
  67057. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  67058. $descriptors[3] = array('pipe', 'w');
  67059. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  67060. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  67061. $ptsWorkaround = fopen(__FILE__, 'r');
  67062. }
  67063. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  67064. if (!\is_resource($this->process)) {
  67065. throw new RuntimeException('Unable to launch a new process.');
  67066. }
  67067. $this->status = self::STATUS_STARTED;
  67068. if (isset($descriptors[3])) {
  67069. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  67070. }
  67071. if ($this->tty) {
  67072. return;
  67073. }
  67074. $this->updateStatus(false);
  67075. $this->checkTimeout();
  67076. }
  67077. public function restart($callback = null)
  67078. {
  67079. if ($this->isRunning()) {
  67080. throw new RuntimeException('Process is already running');
  67081. }
  67082. $process = clone $this;
  67083. $process->start($callback);
  67084. return $process;
  67085. }
  67086. public function wait($callback = null)
  67087. {
  67088. $this->requireProcessIsStarted(__FUNCTION__);
  67089. $this->updateStatus(false);
  67090. if (null !== $callback) {
  67091. $this->callback = $this->buildCallback($callback);
  67092. }
  67093. do {
  67094. $this->checkTimeout();
  67095. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  67096. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  67097. } while ($running);
  67098. while ($this->isRunning()) {
  67099. usleep(1000);
  67100. }
  67101. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  67102. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  67103. }
  67104. return $this->exitcode;
  67105. }
  67106. public function getPid()
  67107. {
  67108. return $this->isRunning() ? $this->processInformation['pid'] : null;
  67109. }
  67110. public function signal($signal)
  67111. {
  67112. $this->doSignal($signal, true);
  67113. return $this;
  67114. }
  67115. public function disableOutput()
  67116. {
  67117. if ($this->isRunning()) {
  67118. throw new RuntimeException('Disabling output while the process is running is not possible.');
  67119. }
  67120. if (null !== $this->idleTimeout) {
  67121. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  67122. }
  67123. $this->outputDisabled = true;
  67124. return $this;
  67125. }
  67126. public function enableOutput()
  67127. {
  67128. if ($this->isRunning()) {
  67129. throw new RuntimeException('Enabling output while the process is running is not possible.');
  67130. }
  67131. $this->outputDisabled = false;
  67132. return $this;
  67133. }
  67134. public function isOutputDisabled()
  67135. {
  67136. return $this->outputDisabled;
  67137. }
  67138. public function getOutput()
  67139. {
  67140. $this->readPipesForOutput(__FUNCTION__);
  67141. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  67142. return '';
  67143. }
  67144. return $ret;
  67145. }
  67146. public function getIncrementalOutput()
  67147. {
  67148. $this->readPipesForOutput(__FUNCTION__);
  67149. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  67150. $this->incrementalOutputOffset = ftell($this->stdout);
  67151. if (false === $latest) {
  67152. return '';
  67153. }
  67154. return $latest;
  67155. }
  67156. public function clearOutput()
  67157. {
  67158. ftruncate($this->stdout, 0);
  67159. fseek($this->stdout, 0);
  67160. $this->incrementalOutputOffset = 0;
  67161. return $this;
  67162. }
  67163. public function getErrorOutput()
  67164. {
  67165. $this->readPipesForOutput(__FUNCTION__);
  67166. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  67167. return '';
  67168. }
  67169. return $ret;
  67170. }
  67171. public function getIncrementalErrorOutput()
  67172. {
  67173. $this->readPipesForOutput(__FUNCTION__);
  67174. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  67175. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  67176. if (false === $latest) {
  67177. return '';
  67178. }
  67179. return $latest;
  67180. }
  67181. public function clearErrorOutput()
  67182. {
  67183. ftruncate($this->stderr, 0);
  67184. fseek($this->stderr, 0);
  67185. $this->incrementalErrorOutputOffset = 0;
  67186. return $this;
  67187. }
  67188. public function getExitCode()
  67189. {
  67190. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  67191. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  67192. }
  67193. $this->updateStatus(false);
  67194. return $this->exitcode;
  67195. }
  67196. public function getExitCodeText()
  67197. {
  67198. if (null === $exitcode = $this->getExitCode()) {
  67199. return;
  67200. }
  67201. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  67202. }
  67203. public function isSuccessful()
  67204. {
  67205. return 0 === $this->getExitCode();
  67206. }
  67207. public function hasBeenSignaled()
  67208. {
  67209. $this->requireProcessIsTerminated(__FUNCTION__);
  67210. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  67211. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  67212. }
  67213. return $this->processInformation['signaled'];
  67214. }
  67215. public function getTermSignal()
  67216. {
  67217. $this->requireProcessIsTerminated(__FUNCTION__);
  67218. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  67219. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  67220. }
  67221. return $this->processInformation['termsig'];
  67222. }
  67223. public function hasBeenStopped()
  67224. {
  67225. $this->requireProcessIsTerminated(__FUNCTION__);
  67226. return $this->processInformation['stopped'];
  67227. }
  67228. public function getStopSignal()
  67229. {
  67230. $this->requireProcessIsTerminated(__FUNCTION__);
  67231. return $this->processInformation['stopsig'];
  67232. }
  67233. public function isRunning()
  67234. {
  67235. if (self::STATUS_STARTED !== $this->status) {
  67236. return false;
  67237. }
  67238. $this->updateStatus(false);
  67239. return $this->processInformation['running'];
  67240. }
  67241. public function isStarted()
  67242. {
  67243. return self::STATUS_READY != $this->status;
  67244. }
  67245. public function isTerminated()
  67246. {
  67247. $this->updateStatus(false);
  67248. return self::STATUS_TERMINATED == $this->status;
  67249. }
  67250. public function getStatus()
  67251. {
  67252. $this->updateStatus(false);
  67253. return $this->status;
  67254. }
  67255. public function stop($timeout = 10, $signal = null)
  67256. {
  67257. $timeoutMicro = microtime(true) + $timeout;
  67258. if ($this->isRunning()) {
  67259. $this->doSignal(15, false);
  67260. do {
  67261. usleep(1000);
  67262. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  67263. if ($this->isRunning()) {
  67264. $this->doSignal($signal ?: 9, false);
  67265. }
  67266. }
  67267. if ($this->isRunning()) {
  67268. if (isset($this->fallbackStatus['pid'])) {
  67269. unset($this->fallbackStatus['pid']);
  67270. return $this->stop(0, $signal);
  67271. }
  67272. $this->close();
  67273. }
  67274. return $this->exitcode;
  67275. }
  67276. public function addOutput($line)
  67277. {
  67278. $this->lastOutputTime = microtime(true);
  67279. fseek($this->stdout, 0, SEEK_END);
  67280. fwrite($this->stdout, $line);
  67281. fseek($this->stdout, $this->incrementalOutputOffset);
  67282. }
  67283. public function addErrorOutput($line)
  67284. {
  67285. $this->lastOutputTime = microtime(true);
  67286. fseek($this->stderr, 0, SEEK_END);
  67287. fwrite($this->stderr, $line);
  67288. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  67289. }
  67290. public function getCommandLine()
  67291. {
  67292. return $this->commandline;
  67293. }
  67294. public function setCommandLine($commandline)
  67295. {
  67296. $this->commandline = $commandline;
  67297. return $this;
  67298. }
  67299. public function getTimeout()
  67300. {
  67301. return $this->timeout;
  67302. }
  67303. public function getIdleTimeout()
  67304. {
  67305. return $this->idleTimeout;
  67306. }
  67307. public function setTimeout($timeout)
  67308. {
  67309. $this->timeout = $this->validateTimeout($timeout);
  67310. return $this;
  67311. }
  67312. public function setIdleTimeout($timeout)
  67313. {
  67314. if (null !== $timeout && $this->outputDisabled) {
  67315. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  67316. }
  67317. $this->idleTimeout = $this->validateTimeout($timeout);
  67318. return $this;
  67319. }
  67320. public function setTty($tty)
  67321. {
  67322. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  67323. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  67324. }
  67325. if ($tty) {
  67326. static $isTtySupported;
  67327. if (null === $isTtySupported) {
  67328. $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);
  67329. }
  67330. if (!$isTtySupported) {
  67331. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  67332. }
  67333. }
  67334. $this->tty = (bool) $tty;
  67335. return $this;
  67336. }
  67337. public function isTty()
  67338. {
  67339. return $this->tty;
  67340. }
  67341. public function setPty($bool)
  67342. {
  67343. $this->pty = (bool) $bool;
  67344. return $this;
  67345. }
  67346. public function isPty()
  67347. {
  67348. return $this->pty;
  67349. }
  67350. public function getWorkingDirectory()
  67351. {
  67352. if (null === $this->cwd) {
  67353. return getcwd() ?: null;
  67354. }
  67355. return $this->cwd;
  67356. }
  67357. public function setWorkingDirectory($cwd)
  67358. {
  67359. $this->cwd = $cwd;
  67360. return $this;
  67361. }
  67362. public function getEnv()
  67363. {
  67364. return $this->env;
  67365. }
  67366. public function setEnv(array $env)
  67367. {
  67368. $env = array_filter($env, function ($value) {
  67369. return !\is_array($value);
  67370. });
  67371. $this->env = array();
  67372. foreach ($env as $key => $value) {
  67373. $this->env[$key] = (string) $value;
  67374. }
  67375. return $this;
  67376. }
  67377. public function getStdin()
  67378. {
  67379. @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);
  67380. return $this->getInput();
  67381. }
  67382. public function getInput()
  67383. {
  67384. return $this->input;
  67385. }
  67386. public function setStdin($stdin)
  67387. {
  67388. @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);
  67389. return $this->setInput($stdin);
  67390. }
  67391. public function setInput($input)
  67392. {
  67393. if ($this->isRunning()) {
  67394. throw new LogicException('Input can not be set while the process is running.');
  67395. }
  67396. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  67397. return $this;
  67398. }
  67399. public function getOptions()
  67400. {
  67401. return $this->options;
  67402. }
  67403. public function setOptions(array $options)
  67404. {
  67405. $this->options = $options;
  67406. return $this;
  67407. }
  67408. public function getEnhanceWindowsCompatibility()
  67409. {
  67410. return $this->enhanceWindowsCompatibility;
  67411. }
  67412. public function setEnhanceWindowsCompatibility($enhance)
  67413. {
  67414. $this->enhanceWindowsCompatibility = (bool) $enhance;
  67415. return $this;
  67416. }
  67417. public function getEnhanceSigchildCompatibility()
  67418. {
  67419. return $this->enhanceSigchildCompatibility;
  67420. }
  67421. public function setEnhanceSigchildCompatibility($enhance)
  67422. {
  67423. $this->enhanceSigchildCompatibility = (bool) $enhance;
  67424. return $this;
  67425. }
  67426. public function checkTimeout()
  67427. {
  67428. if (self::STATUS_STARTED !== $this->status) {
  67429. return;
  67430. }
  67431. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  67432. $this->stop(0);
  67433. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  67434. }
  67435. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  67436. $this->stop(0);
  67437. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  67438. }
  67439. }
  67440. public static function isPtySupported()
  67441. {
  67442. static $result;
  67443. if (null !== $result) {
  67444. return $result;
  67445. }
  67446. if ('\\' === \DIRECTORY_SEPARATOR) {
  67447. return $result = false;
  67448. }
  67449. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  67450. }
  67451. private function getDescriptors()
  67452. {
  67453. if ('\\' === \DIRECTORY_SEPARATOR) {
  67454. $this->processPipes = WindowsPipes::create($this, $this->input);
  67455. } else {
  67456. $this->processPipes = UnixPipes::create($this, $this->input);
  67457. }
  67458. return $this->processPipes->getDescriptors();
  67459. }
  67460. protected function buildCallback($callback)
  67461. {
  67462. $that = $this;
  67463. $out = self::OUT;
  67464. $callback = function ($type, $data) use ($that, $callback, $out) {
  67465. if ($out == $type) {
  67466. $that->addOutput($data);
  67467. } else {
  67468. $that->addErrorOutput($data);
  67469. }
  67470. if (null !== $callback) {
  67471. \call_user_func($callback, $type, $data);
  67472. }
  67473. };
  67474. return $callback;
  67475. }
  67476. protected function updateStatus($blocking)
  67477. {
  67478. if (self::STATUS_STARTED !== $this->status) {
  67479. return;
  67480. }
  67481. $this->processInformation = proc_get_status($this->process);
  67482. $running = $this->processInformation['running'];
  67483. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  67484. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  67485. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  67486. }
  67487. if (!$running) {
  67488. $this->close();
  67489. }
  67490. }
  67491. protected function isSigchildEnabled()
  67492. {
  67493. if (null !== self::$sigchild) {
  67494. return self::$sigchild;
  67495. }
  67496. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  67497. return self::$sigchild = false;
  67498. }
  67499. ob_start();
  67500. phpinfo(INFO_GENERAL);
  67501. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  67502. }
  67503. private function readPipesForOutput($caller)
  67504. {
  67505. if ($this->outputDisabled) {
  67506. throw new LogicException('Output has been disabled.');
  67507. }
  67508. $this->requireProcessIsStarted($caller);
  67509. $this->updateStatus(false);
  67510. }
  67511. private function validateTimeout($timeout)
  67512. {
  67513. $timeout = (float) $timeout;
  67514. if (0.0 === $timeout) {
  67515. $timeout = null;
  67516. } elseif ($timeout < 0) {
  67517. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  67518. }
  67519. return $timeout;
  67520. }
  67521. private function readPipes($blocking, $close)
  67522. {
  67523. $result = $this->processPipes->readAndWrite($blocking, $close);
  67524. $callback = $this->callback;
  67525. foreach ($result as $type => $data) {
  67526. if (3 !== $type) {
  67527. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  67528. } elseif (!isset($this->fallbackStatus['signaled'])) {
  67529. $this->fallbackStatus['exitcode'] = (int) $data;
  67530. }
  67531. }
  67532. }
  67533. private function close()
  67534. {
  67535. $this->processPipes->close();
  67536. if (\is_resource($this->process)) {
  67537. proc_close($this->process);
  67538. }
  67539. $this->exitcode = $this->processInformation['exitcode'];
  67540. $this->status = self::STATUS_TERMINATED;
  67541. if (-1 === $this->exitcode) {
  67542. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  67543. $this->exitcode = 128 + $this->processInformation['termsig'];
  67544. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  67545. $this->processInformation['signaled'] = true;
  67546. $this->processInformation['termsig'] = -1;
  67547. }
  67548. }
  67549. $this->callback = null;
  67550. return $this->exitcode;
  67551. }
  67552. private function resetProcessData()
  67553. {
  67554. $this->starttime = null;
  67555. $this->callback = null;
  67556. $this->exitcode = null;
  67557. $this->fallbackStatus = array();
  67558. $this->processInformation = null;
  67559. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  67560. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  67561. $this->process = null;
  67562. $this->latestSignal = null;
  67563. $this->status = self::STATUS_READY;
  67564. $this->incrementalOutputOffset = 0;
  67565. $this->incrementalErrorOutputOffset = 0;
  67566. }
  67567. private function doSignal($signal, $throwException)
  67568. {
  67569. if (null === $pid = $this->getPid()) {
  67570. if ($throwException) {
  67571. throw new LogicException('Can not send signal on a non running process.');
  67572. }
  67573. return false;
  67574. }
  67575. if ('\\' === \DIRECTORY_SEPARATOR) {
  67576. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  67577. if ($exitCode && $this->isRunning()) {
  67578. if ($throwException) {
  67579. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  67580. }
  67581. return false;
  67582. }
  67583. } else {
  67584. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  67585. $ok = @proc_terminate($this->process, $signal);
  67586. } elseif (\function_exists('posix_kill')) {
  67587. $ok = @posix_kill($pid, $signal);
  67588. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  67589. $ok = false === fgets($pipes[2]);
  67590. }
  67591. if (!$ok) {
  67592. if ($throwException) {
  67593. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  67594. }
  67595. return false;
  67596. }
  67597. }
  67598. $this->latestSignal = (int) $signal;
  67599. $this->fallbackStatus['signaled'] = true;
  67600. $this->fallbackStatus['exitcode'] = -1;
  67601. $this->fallbackStatus['termsig'] = $this->latestSignal;
  67602. return true;
  67603. }
  67604. private function requireProcessIsStarted($functionName)
  67605. {
  67606. if (!$this->isStarted()) {
  67607. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  67608. }
  67609. }
  67610. private function requireProcessIsTerminated($functionName)
  67611. {
  67612. if (!$this->isTerminated()) {
  67613. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  67614. }
  67615. }
  67616. }
  67617. <?php
  67618. namespace Symfony\Component\Process;
  67619. use Symfony\Component\Process\Exception\InvalidArgumentException;
  67620. use Symfony\Component\Process\Exception\LogicException;
  67621. class ProcessBuilder
  67622. {
  67623. private $arguments;
  67624. private $cwd;
  67625. private $env = array();
  67626. private $input;
  67627. private $timeout = 60;
  67628. private $options = array();
  67629. private $inheritEnv = true;
  67630. private $prefix = array();
  67631. private $outputDisabled = false;
  67632. public function __construct(array $arguments = array())
  67633. {
  67634. $this->arguments = $arguments;
  67635. }
  67636. public static function create(array $arguments = array())
  67637. {
  67638. return new static($arguments);
  67639. }
  67640. public function add($argument)
  67641. {
  67642. $this->arguments[] = $argument;
  67643. return $this;
  67644. }
  67645. public function setPrefix($prefix)
  67646. {
  67647. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  67648. return $this;
  67649. }
  67650. public function setArguments(array $arguments)
  67651. {
  67652. $this->arguments = $arguments;
  67653. return $this;
  67654. }
  67655. public function setWorkingDirectory($cwd)
  67656. {
  67657. $this->cwd = $cwd;
  67658. return $this;
  67659. }
  67660. public function inheritEnvironmentVariables($inheritEnv = true)
  67661. {
  67662. $this->inheritEnv = $inheritEnv;
  67663. return $this;
  67664. }
  67665. public function setEnv($name, $value)
  67666. {
  67667. $this->env[$name] = $value;
  67668. return $this;
  67669. }
  67670. public function addEnvironmentVariables(array $variables)
  67671. {
  67672. $this->env = array_replace($this->env, $variables);
  67673. return $this;
  67674. }
  67675. public function setInput($input)
  67676. {
  67677. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  67678. return $this;
  67679. }
  67680. public function setTimeout($timeout)
  67681. {
  67682. if (null === $timeout) {
  67683. $this->timeout = null;
  67684. return $this;
  67685. }
  67686. $timeout = (float) $timeout;
  67687. if ($timeout < 0) {
  67688. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  67689. }
  67690. $this->timeout = $timeout;
  67691. return $this;
  67692. }
  67693. public function setOption($name, $value)
  67694. {
  67695. $this->options[$name] = $value;
  67696. return $this;
  67697. }
  67698. public function disableOutput()
  67699. {
  67700. $this->outputDisabled = true;
  67701. return $this;
  67702. }
  67703. public function enableOutput()
  67704. {
  67705. $this->outputDisabled = false;
  67706. return $this;
  67707. }
  67708. public function getProcess()
  67709. {
  67710. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  67711. throw new LogicException('You must add() command arguments before calling getProcess().');
  67712. }
  67713. $options = $this->options;
  67714. $arguments = array_merge($this->prefix, $this->arguments);
  67715. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  67716. if ($this->inheritEnv) {
  67717. $env = array_replace($_ENV, $_SERVER, $this->env);
  67718. } else {
  67719. $env = $this->env;
  67720. }
  67721. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  67722. if ($this->outputDisabled) {
  67723. $process->disableOutput();
  67724. }
  67725. return $process;
  67726. }
  67727. }
  67728. <?php
  67729. namespace Symfony\Component\Process;
  67730. use Symfony\Component\Process\Exception\InvalidArgumentException;
  67731. class ProcessUtils
  67732. {
  67733. private function __construct()
  67734. {
  67735. }
  67736. public static function escapeArgument($argument)
  67737. {
  67738. if ('\\' === \DIRECTORY_SEPARATOR) {
  67739. if ('' === $argument) {
  67740. return escapeshellarg($argument);
  67741. }
  67742. $escapedArgument = '';
  67743. $quote = false;
  67744. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  67745. if ('"' === $part) {
  67746. $escapedArgument .= '\\"';
  67747. } elseif (self::isSurroundedBy($part, '%')) {
  67748. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  67749. } else {
  67750. if ('\\' === substr($part, -1)) {
  67751. $part .= '\\';
  67752. }
  67753. $quote = true;
  67754. $escapedArgument .= $part;
  67755. }
  67756. }
  67757. if ($quote) {
  67758. $escapedArgument = '"'.$escapedArgument.'"';
  67759. }
  67760. return $escapedArgument;
  67761. }
  67762. return "'".str_replace("'", "'\\''", $argument)."'";
  67763. }
  67764. public static function validateInput($caller, $input)
  67765. {
  67766. if (null !== $input) {
  67767. if (\is_resource($input)) {
  67768. return $input;
  67769. }
  67770. if (\is_string($input)) {
  67771. return $input;
  67772. }
  67773. if (is_scalar($input)) {
  67774. return (string) $input;
  67775. }
  67776. if (\is_object($input) && method_exists($input, '__toString')) {
  67777. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  67778. return (string) $input;
  67779. }
  67780. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  67781. }
  67782. return $input;
  67783. }
  67784. private static function isSurroundedBy($arg, $char)
  67785. {
  67786. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  67787. }
  67788. }
  67789. <?php
  67790. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  67791. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  67792. }
  67793. setlocale(LC_ALL, 'C');
  67794. require __DIR__.'/../src/bootstrap.php';
  67795. use Composer\Console\Application;
  67796. use Composer\XdebugHandler\XdebugHandler;
  67797. use Composer\Util\Platform;
  67798. use Composer\Util\ErrorHandler;
  67799. error_reporting(-1);
  67800. // Restart without Xdebug
  67801. $xdebug = new XdebugHandler('Composer');
  67802. $xdebug->check();
  67803. unset($xdebug);
  67804. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  67805. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  67806. exit(1);
  67807. }
  67808. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  67809. echo 'The iconv OR mbstring extension is required and both are missing.'
  67810. .PHP_EOL.'Install either of them or recompile php without --disable-iconv.'
  67811. .PHP_EOL.'Aborting.'.PHP_EOL;
  67812. exit(1);
  67813. }
  67814. if (function_exists('ini_set')) {
  67815. @ini_set('display_errors', '1');
  67816. // Set user defined memory limit
  67817. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  67818. @ini_set('memory_limit', $memoryLimit);
  67819. } else {
  67820. $memoryInBytes = function ($value) {
  67821. $unit = strtolower(substr($value, -1, 1));
  67822. $value = (int) $value;
  67823. switch($unit) {
  67824. case 'g':
  67825. $value *= 1024;
  67826. // no break (cumulative multiplier)
  67827. case 'm':
  67828. $value *= 1024;
  67829. // no break (cumulative multiplier)
  67830. case 'k':
  67831. $value *= 1024;
  67832. }
  67833. return $value;
  67834. };
  67835. $memoryLimit = trim(ini_get('memory_limit'));
  67836. // Increase memory_limit if it is lower than 1.5GB
  67837. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  67838. @ini_set('memory_limit', '1536M');
  67839. }
  67840. unset($memoryInBytes);
  67841. }
  67842. unset($memoryLimit);
  67843. }
  67844. // Workaround PHP bug on Windows where env vars containing Unicode chars are mangled in $_SERVER
  67845. // see https://github.com/php/php-src/issues/7896
  67846. if (PHP_VERSION_ID >= 70113 && (PHP_VERSION_ID < 80016 || (PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80103)) && Platform::isWindows()) {
  67847. foreach ($_SERVER as $serverVar => $serverVal) {
  67848. if (($serverVal = getenv($serverVar)) !== false) {
  67849. $_SERVER[$serverVar] = $serverVal;
  67850. }
  67851. }
  67852. }
  67853. Platform::putEnv('COMPOSER_BINARY', realpath($_SERVER['argv'][0]));
  67854. ErrorHandler::register();
  67855. // run the command application
  67856. $application = new Application();
  67857. $application->run();
  67858. Copyright (c) Nils Adermann, Jordi Boggiano
  67859. Permission is hereby granted, free of charge, to any person obtaining a copy
  67860. of this software and associated documentation files (the "Software"), to deal
  67861. in the Software without restriction, including without limitation the rights
  67862. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  67863. copies of the Software, and to permit persons to whom the Software is furnished
  67864. to do so, subject to the following conditions:
  67865. The above copyright notice and this permission notice shall be included in all
  67866. copies or substantial portions of the Software.
  67867. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  67868. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67869. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  67870. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  67871. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  67872. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  67873. THE SOFTWARE.
  67874. ÖÍ¨ØØT“Hõê»Ë‹Žm„T—ÌgZ@ ¶Æ[à'AõÁm«}úß“Þ!eæ6Îm›šm„:šl¼û>���GBMB