composer.phar 1.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of Composer.
  5. *
  6. * (c) Nils Adermann <[email protected]>
  7. * Jordi Boggiano <[email protected]>
  8. *
  9. * For the full copyright and license information, please view
  10. * the license that is located at the bottom of this file.
  11. */
  12. // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
  13. if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) {
  14. if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
  15. ini_set('apc.cache_by_default', 0);
  16. } else {
  17. fwrite(STDERR, 'Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.'.PHP_EOL);
  18. fwrite(STDERR, 'Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.'.PHP_EOL);
  19. }
  20. }
  21. Phar::mapPhar('composer.phar');
  22. require 'phar://composer.phar/bin/composer';
  23. __HALT_COMPILER(); ?>
  24. 4•��ö������ ���composer.phar����+���src/Composer/Autoload/AutoloadGenerator.phpŠe��ä÷\Še��ÃØ…w¶������+���src/Composer/Autoload/ClassMapGenerator.php‹��ä÷\‹��Mè�Ķ���������src/Composer/Cache.php’��ä÷\’��­bš0¶������%���src/Composer/Command/AboutCommand.phpÍ��ä÷\Í��ÿÌŒ4¶������'���src/Composer/Command/ArchiveCommand.phpc��ä÷\c��¥{ï¶������$���src/Composer/Command/BaseCommand.phpÜ ��ä÷\Ü ��gô1¶������.���src/Composer/Command/BaseDependencyCommand.phpñ��ä÷\ñ��XgFð¶������1���src/Composer/Command/CheckPlatformReqsCommand.phpë ��ä÷\ë ��kâ¶������*���src/Composer/Command/ClearCacheCommand.php^��ä÷\^��¨ãj¶������&���src/Composer/Command/ConfigCommand.php‰I��ä÷\‰I��ä³ï€¶������-���src/Composer/Command/CreateProjectCommand.php%5��ä÷\%5��èP-¶������'���src/Composer/Command/DependsCommand.php¸��ä÷\¸��K°¶������(���src/Composer/Command/DiagnoseCommand.php©M��ä÷\©M��Pä�¶������,���src/Composer/Command/DumpAutoloadCommand.phpñ ��ä÷\ñ ��Ub‚¶������$���src/Composer/Command/ExecCommand.phpk��ä÷\k��¼“À[¶������&���src/Composer/Command/GlobalCommand.php@ ��ä÷\@ ��·©ð¶������$���src/Composer/Command/HomeCommand.phpÄ��ä÷\Ä��ÇH¶������$���src/Composer/Command/InitCommand.phpO��ä÷\O��Ø&b¶������'���src/Composer/Command/InstallCommand.php��ä÷\��[ š¶������(���src/Composer/Command/LicensesCommand.php;��ä÷\;��™�U¶������(���src/Composer/Command/OutdatedCommand.phpÇ ��ä÷\Ç ��Ñnë(¶������)���src/Composer/Command/ProhibitsCommand.phpÌ��ä÷\Ì��¨[®¶������&���src/Composer/Command/RemoveCommand.php§��ä÷\§��ÉäÚ�¶������'���src/Composer/Command/RequireCommand.phpK#��ä÷\K#��i’:¶������)���src/Composer/Command/RunScriptCommand.phpã��ä÷\ã��˜Ô¶������+���src/Composer/Command/ScriptAliasCommand.phpp��ä÷\p��g †(¶������&���src/Composer/Command/SearchCommand.php ��ä÷\ ��Ò=Á‹¶������*���src/Composer/Command/SelfUpdateCommand.phpå2��ä÷\å2��ÔÛ„¶������$���src/Composer/Command/ShowCommand.php0q��ä÷\0q��lÇ'ض������&���src/Composer/Command/StatusCommand.php\��ä÷\\��«In¶������(���src/Composer/Command/SuggestsCommand.php© ��ä÷\© ��<Qþ¶������&���src/Composer/Command/UpdateCommand.phpµ#��ä÷\µ#��@Š4-¶������(���src/Composer/Command/ValidateCommand.php)��ä÷\)��<¬¶���������src/Composer/Composer.phpù ��ä÷\ù ��‹}çÓ¶���������src/Composer/Config.phpÎ"��ä÷\Î"��)Î\¶������-���src/Composer/Config/ConfigSourceInterface.php��ä÷\��³ [/¶������(���src/Composer/Config/JsonConfigSource.phpu��ä÷\u��=¤ƒ¶������$���src/Composer/Console/Application.php\4��ä÷\\4��à
  25. »¶������,���src/Composer/Console/HtmlOutputFormatter.php3��ä÷\3��Ú�Eu¶������-���src/Composer/DependencyResolver/Decisions.phpQ��ä÷\Q��?˜¬$¶������1���src/Composer/DependencyResolver/DefaultPolicy.php��ä÷\��õÝv¶������/���src/Composer/DependencyResolver/GenericRule.phpµ��ä÷\µ��᫤¶������>���src/Composer/DependencyResolver/Operation/InstallOperation.phpC��ä÷\C��´\õ*¶������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php÷��ä÷\÷��ïÎà÷¶������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.phpý��ä÷\ý��3#†¶������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÓ���ä÷\Ó���Ùâ&ä¶������=���src/Composer/DependencyResolver/Operation/SolverOperation.php¹��ä÷\¹��&¢e
  26. ¶������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpI��ä÷\I��FûÂɶ������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phph��ä÷\h��öSÕ]¶������3���src/Composer/DependencyResolver/PolicyInterface.php­��ä÷\­��Ÿ‹R¶������(���src/Composer/DependencyResolver/Pool.php¯"��ä÷\¯"��m½ ¶������+���src/Composer/DependencyResolver/Problem.php¤��ä÷\¤���Þ¶������+���src/Composer/DependencyResolver/Request.phpƒ��ä÷\ƒ��åVP„¶������(���src/Composer/DependencyResolver/Rule.phpš��ä÷\š��ø@J‘¶������1���src/Composer/DependencyResolver/Rule2Literals.php��ä÷\��tZÅɶ������+���src/Composer/DependencyResolver/RuleSet.phpª
  27. ��ä÷\ª
  28. ��_΂¶������4���src/Composer/DependencyResolver/RuleSetGenerator.php&��ä÷\&��gÇF£¶������3���src/Composer/DependencyResolver/RuleSetIterator.php��ä÷\��›Cü$¶������2���src/Composer/DependencyResolver/RuleWatchChain.phpi��ä÷\i��hïš,¶������2���src/Composer/DependencyResolver/RuleWatchGraph.phpá��ä÷\á��‰rôv¶������1���src/Composer/DependencyResolver/RuleWatchNode.php��ä÷\���Gd7¶������*���src/Composer/DependencyResolver/Solver.php,:��ä÷\,:��²ã~œ¶������6���src/Composer/DependencyResolver/SolverBugException.php™��ä÷\™��Xg6¶������;���src/Composer/DependencyResolver/SolverProblemsException.phpô��ä÷\ô��×|Ŧ¶������/���src/Composer/DependencyResolver/Transaction.php×��ä÷\×��Vm쟶������-���src/Composer/Downloader/ArchiveDownloader.phpÆ ��ä÷\Æ ��G s0¶������1���src/Composer/Downloader/ChangeReportInterface.phpÌ���ä÷\Ì���¯à¨¿¶������+���src/Composer/Downloader/DownloadManager.php`��ä÷\`��#ÏX¶������/���src/Composer/Downloader/DownloaderInterface.phpÊ��ä÷\Ê��gs!l¶������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ���ä÷\Ñ���&Áœ¿¶������*���src/Composer/Downloader/FileDownloader.php?��ä÷\?��"Aý¶������/���src/Composer/Downloader/FilesystemException.php
  29. ��ä÷\
  30. ��.-‹¶������,���src/Composer/Downloader/FossilDownloader.php‚ ��ä÷\‚ ��Ü�Ii¶������)���src/Composer/Downloader/GitDownloader.phpq4��ä÷\q4��ZÎÇ×¶������*���src/Composer/Downloader/GzipDownloader.phpó��ä÷\ó��}Úo¶������(���src/Composer/Downloader/HgDownloader.php”��ä÷\”��ßis̶������*���src/Composer/Downloader/PathDownloader.phpQ��ä÷\Q��Cn¤¶������0���src/Composer/Downloader/PearPackageExtractor.phpu��ä÷\u��z„‡¶������.���src/Composer/Downloader/PerforceDownloader.php§��ä÷\§��⃨¶������*���src/Composer/Downloader/PharDownloader.phpå���ä÷\å���ÞÉç¶������)���src/Composer/Downloader/RarDownloader.phpž��ä÷\ž��6 3U¶������)���src/Composer/Downloader/SvnDownloader.phpG��ä÷\G��M#j¶������)���src/Composer/Downloader/TarDownloader.phpã���ä÷\ã���Í’X?¶������.���src/Composer/Downloader/TransportException.php=��ä÷\=��ZÎÈÞ¶������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ���ä÷\Ô���`§ôö¶������)���src/Composer/Downloader/VcsDownloader.php¡��ä÷\¡��( à>¶������(���src/Composer/Downloader/XzDownloader.php§��ä÷\§��W$;á¶������)���src/Composer/Downloader/ZipDownloader.phpk��ä÷\k��Òo”ζ������&���src/Composer/EventDispatcher/Event.php ��ä÷\ ��±™jï¶������0���src/Composer/EventDispatcher/EventDispatcher.phpY3��ä÷\Y3��ã&=q¶������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©���ä÷\©���h·0¶������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv���ä÷\v���wZ8S¶������)���src/Composer/Exception/NoSslException.phpf���ä÷\f���ËíM�¶���������src/Composer/Factory.phpW=��ä÷\W=��gMý¶���������src/Composer/IO/BaseIO.phpŒ��ä÷\Œ��(‚l‘¶���������src/Composer/IO/BufferIO.php*��ä÷\*��¢®hT¶���������src/Composer/IO/ConsoleIO.php6��ä÷\6��ö#$¶���������src/Composer/IO/IOInterface.phpì��ä÷\ì���Õ�¶���������src/Composer/IO/NullIO.phpÀ��ä÷\À��F`sʶ���������src/Composer/Installer.php|œ��ä÷\|œ��âƒ!¶������*���src/Composer/Installer/BinaryInstaller.php×��ä÷\×��£æq¶������2���src/Composer/Installer/BinaryPresenceInterface.phpË���ä÷\Ë���À5š¨¶������.���src/Composer/Installer/InstallationManager.php-��ä÷\-��¾}Œ7¶������)���src/Composer/Installer/InstallerEvent.php��ä÷\��lÔzi¶������*���src/Composer/Installer/InstallerEvents.phpÞ���ä÷\Þ���ìŸ@G¶������-���src/Composer/Installer/InstallerInterface.phpã��ä÷\ã��^ƒ“ʶ������+���src/Composer/Installer/LibraryInstaller.php%��ä÷\%�� »�̶������/���src/Composer/Installer/MetapackageInstaller.phpœ��ä÷\œ��ÆÅ!¶������(���src/Composer/Installer/NoopInstaller.php+��ä÷\+��À·M}¶������'���src/Composer/Installer/PackageEvent.phpe��ä÷\e��;° ¶������(���src/Composer/Installer/PackageEvents.php¸��ä÷\¸��dbØs¶������.���src/Composer/Installer/PearBinaryInstaller.phpø ��ä÷\ø ��*ë•k¶������(���src/Composer/Installer/PearInstaller.php¢��ä÷\¢��È‚¶Ñ¶������*���src/Composer/Installer/PluginInstaller.php‹��ä÷\‹��ÒX8¶������+���src/Composer/Installer/ProjectInstaller.php��ä÷\��*0@P¶������4���src/Composer/Installer/SuggestedPackagesReporter.php:��ä÷\:��‚´UV¶���������src/Composer/Json/JsonFile.phpî��ä÷\î��b-~¶������#���src/Composer/Json/JsonFormatter.phpb��ä÷\b��ÝNš¶������%���src/Composer/Json/JsonManipulator.php’3��ä÷\’3��é7¶������-���src/Composer/Json/JsonValidationException.php\��ä÷\\��.Xóܶ������%���src/Composer/Package/AliasPackage.php��ä÷\��¹—~š¶������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php ��ä÷\ ��yY+¦¶������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpÞ��ä÷\Þ�� ²²¹¶������0���src/Composer/Package/Archiver/ArchiveManager.php† ��ä÷\† ��ß5°¶������3���src/Composer/Package/Archiver/ArchiverInterface.php��ä÷\��ñ´> ¶������3���src/Composer/Package/Archiver/BaseExcludeFilter.php–��ä÷\–��y¶=ƶ������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php��ä÷\��‹SZ0¶������2���src/Composer/Package/Archiver/GitExcludeFilter.phpr��ä÷\r��3‘Mh¶������1���src/Composer/Package/Archiver/HgExcludeFilter.php ��ä÷\ �� •¦S¶������.���src/Composer/Package/Archiver/PharArchiver.php?��ä÷\?��®— u¶������-���src/Composer/Package/Archiver/ZipArchiver.php½��ä÷\½��VÀ‚¨¶������$���src/Composer/Package/BasePackage.phpü ��ä÷\ü ��¬ÊyÚ¶������*���src/Composer/Package/Comparer/Comparer.phpR��ä÷\R��ÏØ³î¶������(���src/Composer/Package/CompletePackage.phpü��ä÷\ü��þM˶¶������1���src/Composer/Package/CompletePackageInterface.phpõ��ä÷\õ��¦Ê�ò¶������+���src/Composer/Package/Dumper/ArrayDumper.phpë ��ä÷\ë ��Ó8WE¶���������src/Composer/Package/Link.phpˆ��ä÷\ˆ��å¶Y«¶������7���src/Composer/Package/LinkConstraint/EmptyConstraint.php‚��ä÷\‚��é~‹¶������?���src/Composer/Package/LinkConstraint/LinkConstraintInterface.phpd��ä÷\d��¤ôLn¶������7���src/Composer/Package/LinkConstraint/MultiConstraint.php‚��ä÷\‚��ób`ý¶������:���src/Composer/Package/LinkConstraint/SpecificConstraint.phpi��ä÷\i��Þ”š%¶������9���src/Composer/Package/LinkConstraint/VersionConstraint.phpX��ä÷\X��}`y¶������+���src/Composer/Package/Loader/ArrayLoader.php��ä÷\��n~œ›¶������7���src/Composer/Package/Loader/InvalidPackageException.phpE��ä÷\E��xb¾¶������*���src/Composer/Package/Loader/JsonLoader.phpù��ä÷\ù��!~ˆ{¶������/���src/Composer/Package/Loader/LoaderInterface.php²���ä÷\²���¦}úζ������1���src/Composer/Package/Loader/RootPackageLoader.php��ä÷\��-‚£{¶������5���src/Composer/Package/Loader/ValidatingArrayLoader.php½6��ä÷\½6��¶Î x¶���������src/Composer/Package/Locker.php¥!��ä÷\¥!��/=xö¶������ ���src/Composer/Package/Package.phpÉ��ä÷\É��cÃ�h¶������)���src/Composer/Package/PackageInterface.php ��ä÷\ ��ûÇ^ƶ������)���src/Composer/Package/RootAliasPackage.php ��ä÷\ �� _€ø¶������$���src/Composer/Package/RootPackage.php��ä÷\��ŽÎ_¶������-���src/Composer/Package/RootPackageInterface.php¹��ä÷\¹��"maV¶������/���src/Composer/Package/Version/VersionGuesser.phpÏ��ä÷\Ï��ÌÂß¶������.���src/Composer/Package/Version/VersionParser.php¥��ä÷\¥��ô´à¶������0���src/Composer/Package/Version/VersionSelector.phpK ��ä÷\K ��²<ȶ������-���src/Composer/Plugin/Capability/Capability.phpW���ä÷\W���æ_¨1¶������2���src/Composer/Plugin/Capability/CommandProvider.php—���ä÷\—���ûOâ>¶���������src/Composer/Plugin/Capable.php���ä÷\���Æq+¶������$���src/Composer/Plugin/CommandEvent.phpâ��ä÷\â��³ÆÇW¶������$���src/Composer/Plugin/PluginEvents.phpö���ä÷\ö���á1=z¶������'���src/Composer/Plugin/PluginInterface.phpô���ä÷\ô���)'*ض������%���src/Composer/Plugin/PluginManager.php$��ä÷\$��‹K©¶������*���src/Composer/Plugin/PreCommandRunEvent.phpõ��ä÷\õ��:ðd¶������,���src/Composer/Plugin/PreFileDownloadEvent.php`��ä÷\`���9-ζ������4���src/Composer/Question/StrictConfirmationQuestion.php��ä÷\��'.³è¶������+���src/Composer/Repository/ArrayRepository.php��ä÷\��éÌt�¶������.���src/Composer/Repository/ArtifactRepository.php ��ä÷\ ��Fœâò¶������*���src/Composer/Repository/BaseRepository.phpv ��ä÷\v ��„ÜL¶������.���src/Composer/Repository/ComposerRepository.phpÐU��ä÷\ÐU��ü­l�¶������/���src/Composer/Repository/CompositeRepository.php;��ä÷\;��¤¯S¶������;���src/Composer/Repository/ConfigurableRepositoryInterface.php…���ä÷\…���±Ÿ_¶������0���src/Composer/Repository/FilesystemRepository.php$��ä÷\$��¾Ãá…¶������4���src/Composer/Repository/InstalledArrayRepository.php£���ä÷\£���/ö~>¶������9���src/Composer/Repository/InstalledFilesystemRepository.php£���ä÷\£���V
  31. •_¶������8���src/Composer/Repository/InstalledRepositoryInterface.php‡���ä÷\‡���£9p¶������6���src/Composer/Repository/InvalidRepositoryException.phpn���ä÷\n���à“똶������-���src/Composer/Repository/PackageRepository.phpj��ä÷\j��¥ôò̶������*���src/Composer/Repository/PathRepository.php– ��ä÷\– ��WÛ¶������2���src/Composer/Repository/Pear/BaseChannelReader.phpI��ä÷\I��c6³¶������,���src/Composer/Repository/Pear/ChannelInfo.phpÄ��ä÷\Ä��:T*ɶ������.���src/Composer/Repository/Pear/ChannelReader.phpí��ä÷\í��?ÈYT¶������4���src/Composer/Repository/Pear/ChannelRest10Reader.php® ��ä÷\® ��™ÖÛú¶������4���src/Composer/Repository/Pear/ChannelRest11Reader.php& ��ä÷\& ��òUb¶������5���src/Composer/Repository/Pear/DependencyConstraint.phpq��ä÷\q��9=¶������/���src/Composer/Repository/Pear/DependencyInfo.phpq��ä÷\q��fºTò¶������8���src/Composer/Repository/Pear/PackageDependencyParser.php…��ä÷\…��÷$Li¶������,���src/Composer/Repository/Pear/PackageInfo.php°��ä÷\°��Ÿ ¸ ¶������,���src/Composer/Repository/Pear/ReleaseInfo.php’��ä÷\’��o“ŠÃ¶������*���src/Composer/Repository/PearRepository.phpª��ä÷\ª��)Ÿƒ}¶������.���src/Composer/Repository/PlatformRepository.phpþ��ä÷\þ��õfëõ¶������-���src/Composer/Repository/RepositoryFactory.php2��ä÷\2��t>¶������/���src/Composer/Repository/RepositoryInterface.phpÛ��ä÷\Û��’âÁ¶������-���src/Composer/Repository/RepositoryManager.php2
  32. ��ä÷\2
  33. ��á…5#¶������7���src/Composer/Repository/RepositorySecurityException.phpo���ä÷\o���pÕ«ª¶������/���src/Composer/Repository/Vcs/BitbucketDriver.phpå��ä÷\å��vãâ¶������,���src/Composer/Repository/Vcs/FossilDriver.php©��ä÷\©��t1Ú®¶������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpê��ä÷\ê��ÃŽ»¶������)���src/Composer/Repository/Vcs/GitDriver.php¼��ä÷\¼��Š©Ðê¶������,���src/Composer/Repository/Vcs/GitHubDriver.php¡(��ä÷\¡(��‚º ¶������,���src/Composer/Repository/Vcs/GitLabDriver.phpÍ#��ä÷\Í#��ßNìʶ������1���src/Composer/Repository/Vcs/HgBitbucketDriver.phpä��ä÷\ä��i›üà¶������(���src/Composer/Repository/Vcs/HgDriver.php\��ä÷\\��sàØ¶������.���src/Composer/Repository/Vcs/PerforceDriver.php' ��ä÷\' ��ÙóH¶������)���src/Composer/Repository/Vcs/SvnDriver.php¤��ä÷\¤�� ¶������)���src/Composer/Repository/Vcs/VcsDriver.phpæ
  34. ��ä÷\æ
  35. ��eׯ-¶������2���src/Composer/Repository/Vcs/VcsDriverInterface.php÷��ä÷\÷��ÇX[‰¶������)���src/Composer/Repository/VcsRepository.php±&��ä÷\±&��¢Þ¸t¶������1���src/Composer/Repository/VersionCacheInterface.php”���ä÷\”���A?Rï¶������3���src/Composer/Repository/WritableArrayRepository.php��ä÷\��¾G*¶������7���src/Composer/Repository/WritableRepositoryInterface.php‰��ä÷\‰��‘/sï¶������$���src/Composer/Script/CommandEvent.phpW���ä÷\W���£VZt¶���������src/Composer/Script/Event.phpµ��ä÷\µ��lt¦M¶������$���src/Composer/Script/PackageEvent.phpœ���ä÷\œ���§ÿÉ ¶������$���src/Composer/Script/ScriptEvents.phpP��ä÷\P��‡�¶¶������ ���src/Composer/SelfUpdate/Keys.php���ä÷\��� îÊN¶������$���src/Composer/SelfUpdate/Versions.phpì��ä÷\ì��͵‘ƒ¶������ ���src/Composer/Util/AuthHelper.phpË��ä÷\Ë��>zx–¶���������src/Composer/Util/Bitbucket.php*��ä÷\*��,Lšk¶������$���src/Composer/Util/ComposerMirror.php±��ä÷\±��­½øØ¶������%���src/Composer/Util/ConfigValidator.php÷��ä÷\÷��v•Ͷ������"���src/Composer/Util/ErrorHandler.php¬��ä÷\¬��š^`ƶ������ ���src/Composer/Util/Filesystem.phpj/��ä÷\j/��„ú?ý¶���������src/Composer/Util/Git.phpg&��ä÷\g&��]ó²´¶���������src/Composer/Util/GitHub.php| ��ä÷\| ��`0tü¶���������src/Composer/Util/GitLab.phpœ ��ä÷\œ �� `YÖ¶���������src/Composer/Util/Hg.php¾��ä÷\¾��LÓ �¶���������src/Composer/Util/IniHelper.phph��ä÷\h��;FP¶������$���src/Composer/Util/NoProxyPattern.php¾��ä÷\¾��Z+°m¶���������src/Composer/Util/Perforce.php2��ä÷\2��*¦·®¶���������src/Composer/Util/Platform.phpü��ä÷\ü��s­fç¶������%���src/Composer/Util/ProcessExecutor.phpO ��ä÷\O ��ÅN‘v¶������&���src/Composer/Util/RemoteFilesystem.phpÙj��ä÷\Ùj��¹¸;¶���������src/Composer/Util/Silencer.phpé��ä÷\é��“Vjf¶������!���src/Composer/Util/SpdxLicense.php��ä÷\��¾7
  36. ñ¶������*���src/Composer/Util/StreamContextFactory.php8��ä÷\8��¸š2+¶���������src/Composer/Util/Svn.php,��ä÷\,��Ì žÄ¶���������src/Composer/Util/TlsHelper.phpn
  37. ��ä÷\n
  38. ��S¯Í:¶���������src/Composer/Util/Url.php£��ä÷\£��3œÉܶ���������src/Composer/XdebugHandler.phpð��ä÷\ð��zÓf~¶���������src/bootstrap.php¹��ä÷\¹��I}œ¶������%���src/Composer/Autoload/ClassLoader.php“4��ä÷\“4��²z�–¶������#���res/composer-repository-schema.jsonð��ä÷\ð���GÐà¶���������res/composer-schema.json…–��ä÷\…–�� º,˜¶������6���vendor/composer/spdx-licenses/res/spdx-exceptions.jsonJ ��ä÷\J ��ñR�¶������4���vendor/composer/spdx-licenses/res/spdx-licenses.jsonË’��ä÷\Ë’��p'V¶������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��ä÷\�$��•�¥v¶������&���vendor/symfony/console/Application.php=X��ä÷\=X��� S’¶������*���vendor/symfony/console/Command/Command.phpî"��ä÷\î"��x°jÕ¶������.���vendor/symfony/console/Command/HelpCommand.phpØ��ä÷\Ø��¦Ú-:¶������.���vendor/symfony/console/Command/ListCommand.phpZ��ä÷\Z��»w`¶������(���vendor/symfony/console/ConsoleEvents.phpé���ä÷\é���RÛÔe¶������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÐ��ä÷\Ð��™Ž5°¶������0���vendor/symfony/console/Descriptor/Descriptor.php���ä÷\���¿N•¶������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü���ä÷\ü���±Qµ¶������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ��ä÷\Ü ��*û�ɶ������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶��ä÷\¶��·Ô;ݶ������4���vendor/symfony/console/Descriptor/TextDescriptor.php¼��ä÷\¼��òç$¶������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��ä÷\��b{<¶������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°��ä÷\°��!�ȶ������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ��ä÷\Å��ÒxÛ\¶������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php��ä÷\��á2é¶������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz��ä÷\z��³,îL¶������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ��ä÷\Ô��È÷ L¶������7���vendor/symfony/console/Exception/ExceptionInterface.phpf���ä÷\f���¡ABª¶������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���ä÷\¦���Ö̽Z¶������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���ä÷\¦���Ë×H¶������3���vendor/symfony/console/Exception/LogicException.php’���ä÷\’���ÍO\e¶������5���vendor/symfony/console/Exception/RuntimeException.php–���ä÷\–���Ùí,6¶������4���vendor/symfony/console/Formatter/OutputFormatter.php6��ä÷\6��?=¨¶������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ��ä÷\Œ��òññÀ¶������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF��ä÷\F��𦴶������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„��ä÷\„��÷½G¶������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@��ä÷\@��G¨ýU¶������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy��ä÷\y��Ì8ÆÐ¶������2���vendor/symfony/console/Helper/DescriptorHelper.phpw��ä÷\w��|¦C¶������.���vendor/symfony/console/Helper/DialogHelper.php��ä÷\��¹ÜÃ_¶������1���vendor/symfony/console/Helper/FormatterHelper.phpd��ä÷\d��§×,¸¶������(���vendor/symfony/console/Helper/Helper.php«��ä÷\«��!�§—¶������1���vendor/symfony/console/Helper/HelperInterface.phpå���ä÷\å���Š ¶������+���vendor/symfony/console/Helper/HelperSet.phpÊ��ä÷\Ê��áÏW"¶������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��ä÷\c��Ìøƒ¶������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ��ä÷\Ó ��©w‚R¶������-���vendor/symfony/console/Helper/ProgressBar.phpl%��ä÷\l%�� díÛ¶������0���vendor/symfony/console/Helper/ProgressHelper.php]��ä÷\]��ù»‰X¶������3���vendor/symfony/console/Helper/ProgressIndicator.phpN��ä÷\N��ÿ§³l¶������0���vendor/symfony/console/Helper/QuestionHelper.phpl��ä÷\l��Ntó¶������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php–
  39. ��ä÷\–
  40. ��- ض������'���vendor/symfony/console/Helper/Table.phpÄ*��ä÷\Ä*��¾™ØT¶������+���vendor/symfony/console/Helper/TableCell.php���ä÷\���åV^¶������-���vendor/symfony/console/Helper/TableHelper.php ��ä÷\ ��›uô™¶������0���vendor/symfony/console/Helper/TableSeparator.phpÊ���ä÷\Ê���az¶������,���vendor/symfony/console/Helper/TableStyle.php
  41. ��ä÷\
  42. ��_ÍI"¶������*���vendor/symfony/console/Input/ArgvInput.php��ä÷\��×ö†›¶������+���vendor/symfony/console/Input/ArrayInput.php) ��ä÷\) ��¥ÑC¶������&���vendor/symfony/console/Input/Input.php£ ��ä÷\£ ��f¡?¶������.���vendor/symfony/console/Input/InputArgument.php��ä÷\��D £¶������4���vendor/symfony/console/Input/InputAwareInterface.php˜���ä÷\˜���­O°¶������0���vendor/symfony/console/Input/InputDefinition.php†��ä÷\†��¤U)¤¶������/���vendor/symfony/console/Input/InputInterface.php£��ä÷\£��ÆBŒ'¶������,���vendor/symfony/console/Input/InputOption.php ��ä÷\ ��\¢Ü=¶������,���vendor/symfony/console/Input/StringInput.phpš��ä÷\š��žµ è¶���������vendor/symfony/console/LICENSE)��ä÷\)��NUN½¶������/���vendor/symfony/console/Logger/ConsoleLogger.php0 ��ä÷\0 ��…� ¸¶������0���vendor/symfony/console/Output/BufferedOutput.php_��ä÷\_��‹ >P¶������/���vendor/symfony/console/Output/ConsoleOutput.php±��ä÷\±��nì!f¶������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà���ä÷\à���‡†ÆÊ¶������,���vendor/symfony/console/Output/NullOutput.phpÏ��ä÷\Ï��®˜‹Z¶������(���vendor/symfony/console/Output/Output.php˜ ��ä÷\˜ ��0p¶������1���vendor/symfony/console/Output/OutputInterface.php��ä÷\���ì&¶������.���vendor/symfony/console/Output/StreamOutput.php���ä÷\���Ä’Oç¶������2���vendor/symfony/console/Question/ChoiceQuestion.phpx
  43. ��ä÷\x
  44. ��W€!¶������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè��ä÷\è��/Ô�¶������,���vendor/symfony/console/Question/Question.phpÎ ��ä÷\Î ��lF¶������ ���vendor/symfony/console/Shell.phpæ��ä÷\æ��¼XÒA¶������,���vendor/symfony/console/Style/OutputStyle.php\��ä÷\\��wפ¶������/���vendor/symfony/console/Style/StyleInterface.phpÏ��ä÷\Ï��&nÅѶ������-���vendor/symfony/console/Style/SymfonyStyle.phpä��ä÷\ä��­å (¶������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ��ä÷\Ï��sž9i¶������/���vendor/symfony/console/Tester/CommandTester.phpª��ä÷\ª��¬K z¶������(���vendor/symfony/debug/BufferingLogger.phpt��ä÷\t��=�hܶ���������vendor/symfony/debug/Debug.php,��ä÷\,��Ë~Ž.¶������)���vendor/symfony/debug/DebugClassLoader.phpµ��ä÷\µ��1rEÓ¶������%���vendor/symfony/debug/ErrorHandler.phpH��ä÷\H��¹:D#¶������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–��ä÷\–��i‰æô¶������8���vendor/symfony/debug/Exception/ContextErrorException.php˜��ä÷\˜��-
  45. d2¶������1���vendor/symfony/debug/Exception/DummyException.php��ä÷\��®+Ãê¶������6���vendor/symfony/debug/Exception/FatalErrorException.php��ä÷\��™Ä¶������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW��ä÷\W��?àèK¶������3���vendor/symfony/debug/Exception/FlattenException.php¼��ä÷\¼�� ×¶������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~���ä÷\~���ë¨oâ¶������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš��ä÷\š���ñJÀ¶������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜��ä÷\˜��nöêØ¶������)���vendor/symfony/debug/ExceptionHandler.php)3��ä÷\)3���h5=¶������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.phpA��ä÷\A��Ϥ¹l¶������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php��ä÷\��ĹBV¶������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx��ä÷\x��~ò"¶������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpO��ä÷\O���ž¦*¶���������vendor/symfony/debug/LICENSE)��ä÷\)��NUN½¶������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi���ä÷\i���$ ÿ›¶������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼��ä÷\¼��pí\¶¶������3���vendor/symfony/filesystem/Exception/IOException.php‡��ä÷\‡��€ü#Ѷ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���ä÷\¦���jÙwM¶������(���vendor/symfony/filesystem/Filesystem.phpc4��ä÷\c4��‹×@þ¶������!���vendor/symfony/filesystem/LICENSE)��ä÷\)��NUN½¶������)���vendor/symfony/filesystem/LockHandler.phpö��ä÷\ö��ŸZµ1¶������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ��ä÷\\ ��hˆB¶������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.php���ä÷\���HC€/¶������2���vendor/symfony/finder/Adapter/AdapterInterface.php›��ä÷\›��Mþ¶������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php3��ä÷\3��75$·¶������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php��ä÷\��Ÿ`]¶������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô��ä÷\ô��Þdè;¶������/���vendor/symfony/finder/Comparator/Comparator.php���ä÷\���¾üœµ¶������3���vendor/symfony/finder/Comparator/DateComparator.php#��ä÷\#��°ζ������5���vendor/symfony/finder/Comparator/NumberComparator.php|��ä÷\|��ITÇͶ������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���ä÷\„���½¾sœ¶������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬��ä÷\¬��wR¶������6���vendor/symfony/finder/Exception/ExceptionInterface.php„���ä÷\„���Gz-¶������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)��ä÷\)��x§e¶������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº��ä÷\º��˜þ˜¶������/���vendor/symfony/finder/Expression/Expression.php��ä÷\��i¥:Ŷ������)���vendor/symfony/finder/Expression/Glob.phpf��ä÷\f��DÞcj¶������*���vendor/symfony/finder/Expression/Regex.php��ä÷\��ü(Ã϶������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ��ä÷\Í��\p4†¶������ ���vendor/symfony/finder/Finder.phpc.��ä÷\c.��:ˆ5g¶���������vendor/symfony/finder/Glob.phpL��ä÷\L��jÍ9×¶������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]��ä÷\]��ÎoÅÆ¶������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx��ä÷\x��ôP¶������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî��ä÷\î��üÍ�q¶������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí��ä÷\í��nõH¶������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#��ä÷\#��G?T½¶������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ��ä÷\Z��(&ø¶������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5��ä÷\5��ší¶������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr��ä÷\r��tu¶������1���vendor/symfony/finder/Iterator/FilterIterator.phpÃ��ä÷\Ã��š+µÞ¶������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php-��ä÷\-��ºÎÒ_¶������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ��ä÷\Ð��‚c¶������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ��ä÷\ ��ë]í»¶������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe��ä÷\e��Ÿ’áé¶������3���vendor/symfony/finder/Iterator/SortableIterator.php+��ä÷\+��õÝË ¶���������vendor/symfony/finder/LICENSE)��ä÷\)��NUN½¶������'���vendor/symfony/finder/Shell/Command.php> ��ä÷\> ��_~u ¶������%���vendor/symfony/finder/Shell/Shell.phpr��ä÷\r��þpN¶������%���vendor/symfony/finder/SplFileInfo.php��ä÷\��þ�íù¶������'���vendor/symfony/polyfill-ctype/Ctype.phpH ��ä÷\H ��³�Õݶ������%���vendor/symfony/polyfill-ctype/LICENSE$��ä÷\$��?‡s:¶������+���vendor/symfony/polyfill-ctype/bootstrap.phpI��ä÷\I���D!e¶������(���vendor/symfony/polyfill-mbstring/LICENSE)��ä÷\)��±íж������-���vendor/symfony/polyfill-mbstring/Mbstring.phpC��ä÷\C��ãZ?¶������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷@��ä÷\÷@��õžØ¶������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��ä÷\ã��öy_•¶������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpfA��ä÷\fA��Úf”ß¶������.���vendor/symfony/polyfill-mbstring/bootstrap.phpË��ä÷\Ë��ó<Ë¢¶������7���vendor/symfony/process/Exception/ExceptionInterface.phpf���ä÷\f���]ö>T¶������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���ä÷\¨���ÐÀ+_¶������3���vendor/symfony/process/Exception/LogicException.php”���ä÷\”��� ³ãñ¶������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��ä÷\x��¨Ìzy¶������=���vendor/symfony/process/Exception/ProcessTimedOutException.php��ä÷\��ï«¶������5���vendor/symfony/process/Exception/RuntimeException.php˜���ä÷\˜���¢Ø:¶������+���vendor/symfony/process/ExecutableFinder.php���ä÷\���ûus€¶���������vendor/symfony/process/LICENSE)��ä÷\)��NUN½¶������.���vendor/symfony/process/PhpExecutableFinder.phpÏ��ä÷\Ï��Î%h¶������%���vendor/symfony/process/PhpProcess.phpü��ä÷\ü��‡jûü¶������.���vendor/symfony/process/Pipes/AbstractPipes.php½��ä÷\½��憶������/���vendor/symfony/process/Pipes/PipesInterface.phpD��ä÷\D��vØî¡¶������*���vendor/symfony/process/Pipes/UnixPipes.php>��ä÷\>��ª•ir¶������-���vendor/symfony/process/Pipes/WindowsPipes.phpp ��ä÷\p ��âU~ɶ������"���vendor/symfony/process/Process.php·R��ä÷\·R��Š`Õ¶������)���vendor/symfony/process/ProcessBuilder.phpâ
  46. ��ä÷\â
  47. ��†M¶¶������'���vendor/symfony/process/ProcessUtils.phpQ��ä÷\Q��b-$m¶���������vendor/seld/jsonlint/LICENSE"��ä÷\"��aƒsy¶������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.php*��ä÷\*��•pñ¶������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php/2��ä÷\/2��­ß˜ö¶������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php��ä÷\��%ÿ3N¶������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php��ä÷\��‰²ñ¶������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���ä÷\>���ÿqŸŸ¶������(���vendor/justinrainbow/json-schema/LICENSE ��ä÷\ ��ºç©¶������.���vendor/justinrainbow/json-schema/demo/demo.phpñ��ä÷\ñ��fC¶������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��ä÷\¡ ��†wÌl¶������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php) ��ä÷\) ��#©¶������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php§ ��ä÷\§ ��›Vض������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��ä÷\¼��ÿ Qœ¶������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php]��ä÷\]��VŽU<¶������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpã ��ä÷\ã ��á0;¶������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.php…��ä÷\…��“TœÚ¶������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpš
  48. ��ä÷\š
  49. ��z&¶������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.phpÃ��ä÷\Ã��©Å¼x¶������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php0 ��ä÷\0 ��×j´˜¶������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.php��ä÷\��¥wš‡¶������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��ä÷\a�� qö������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.phpp��ä÷\p��rë¶������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��ä÷\‰��“µ+j¶������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php&��ä÷\&��4˜©T¶������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php,"��ä÷\,"��ulÙ·¶������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��ä÷\è��{N–¶������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���ä÷\I���%|°¶������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���ä÷\•���‹àG¶������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���ä÷\l���A!L×¶������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���ä÷\l���è2÷þ¶������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���ä÷\u���=hç¶������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���ä÷\w���N-ò[¶������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��ä÷\Þ��\¸
  50. ¶������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���ä÷\o���píÛù¶������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���ä÷\…���%…—¶������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���ä÷\€���u-#1¶������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���ä÷\j���å>�¶������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���ä÷\f���¬¤„þ¶������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��ä÷\þ��M�„õ¶������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��ä÷\ ��f4÷³¶������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.phpœ ��ä÷\œ ��åfO¶������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��ä÷\��oŠ+}¶������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���ä÷\á���[þA�¶������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php¥��ä÷\¥��Ô§Lb¶������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php%��ä÷\%��5" ¶������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��ä÷\,��1•5þ¶������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���ä÷\®���ÿ‹Áå¶������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��ä÷\ ��£Ÿ)à¶������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php&��ä÷\&��¼î‚¢¶������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���ä÷\ƒ���J€¶������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���ä÷\…���íæe¶������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phpx��ä÷\x��eÃþ¶������%���vendor/composer/spdx-licenses/LICENSE��ä÷\��Bhí¶������2���vendor/composer/spdx-licenses/src/SpdxLicenses.phpH��ä÷\H��͉T¶���������vendor/composer/semver/LICENSE��ä÷\��Bhí¶������)���vendor/composer/semver/src/Comparator.php��ä÷\��wlƒï¶������<���vendor/composer/semver/src/Constraint/AbstractConstraint.php×��ä÷\×��õî>޶������4���vendor/composer/semver/src/Constraint/Constraint.phpª ��ä÷\ª ��ÇO7²¶������=���vendor/composer/semver/src/Constraint/ConstraintInterface.phpß���ä÷\ß���0C,‡¶������9���vendor/composer/semver/src/Constraint/EmptyConstraint.phpé��ä÷\é��!-Ø™¶������9���vendor/composer/semver/src/Constraint/MultiConstraint.php1��ä÷\1��í xU¶������%���vendor/composer/semver/src/Semver.phpv��ä÷\v��‹×È›¶������,���vendor/composer/semver/src/VersionParser.php¿*��ä÷\¿*��)mƶ������!���vendor/composer/ca-bundle/LICENSE��ä÷\��*!^`¶������*���vendor/composer/ca-bundle/src/CaBundle.php��ä÷\��Ê ~Ķ������&���vendor/composer/xdebug-handler/LICENSE)��ä÷\)��#Ô;^¶������0���vendor/composer/xdebug-handler/src/PhpConfig.php´��ä÷\´��*D’�¶������.���vendor/composer/xdebug-handler/src/Process.phpt��ä÷\t��ÛŒú&¶������-���vendor/composer/xdebug-handler/src/Status.php
  51. ��ä÷\
  52. ��²‚²¶������4���vendor/composer/xdebug-handler/src/XdebugHandler.phpå��ä÷\å��Ȱ̜¶���������vendor/psr/log/LICENSE=��ä÷\=��p±ŽO¶������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��ä÷\;��ñ>3[¶������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���ä÷\`��� ˆX1¶������#���vendor/psr/log/Psr/Log/LogLevel.phpû���ä÷\û���jðñ8¶������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���ä÷\|���$£ˆ¶������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���ä÷\§���T½úB¶������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÆ��ä÷\Æ��»sg¶������&���vendor/psr/log/Psr/Log/LoggerTrait.phpi��ä÷\i��35§Þ¶������%���vendor/psr/log/Psr/Log/NullLogger.phpž���ä÷\ž���Çö������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.phpI ��ä÷\I ��õÇAs¶������*���vendor/psr/log/Psr/Log/Test/TestLogger.php ��ä÷\ ��ôc�›¶���������vendor/autoload.php‚���ä÷\‚���òö�p¶������'���vendor/composer/autoload_namespaces.phpd���ä÷\d���Z¡¦H¶������!���vendor/composer/autoload_psr4.php÷��ä÷\÷��Å*š¶������%���vendor/composer/autoload_classmap.phpd���ä÷\d���Z¡¦H¶������"���vendor/composer/autoload_files.php��ä÷\��¥� ®¶������!���vendor/composer/autoload_real.phpI��ä÷\I��5KYš¶������#���vendor/composer/autoload_static.php§
  53. ��ä÷\§
  54. ��`‘~g¶���������vendor/composer/ClassLoader.php¨��ä÷\¨��xää`¶������(���vendor/composer/ca-bundle/res/cacert.pem�1�ä÷\�1��Xó¶������ ���bin/composer ��ä÷\ ��‘¹Û¶���������LICENSE.��ä÷\.�� Õ¶������<?php
  55. namespace Composer\Autoload;
  56. use Composer\Config;
  57. use Composer\EventDispatcher\EventDispatcher;
  58. use Composer\Installer\InstallationManager;
  59. use Composer\IO\IOInterface;
  60. use Composer\Package\AliasPackage;
  61. use Composer\Package\PackageInterface;
  62. use Composer\Repository\InstalledRepositoryInterface;
  63. use Composer\Util\Filesystem;
  64. use Composer\Script\ScriptEvents;
  65. class AutoloadGenerator
  66. {
  67. private $eventDispatcher;
  68. private $io;
  69. private $devMode = false;
  70. private $classMapAuthoritative = false;
  71. private $apcu = false;
  72. private $runScripts = false;
  73. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  74. {
  75. $this->eventDispatcher = $eventDispatcher;
  76. $this->io = $io;
  77. }
  78. public function setDevMode($devMode = true)
  79. {
  80. $this->devMode = (bool) $devMode;
  81. }
  82. public function setClassMapAuthoritative($classMapAuthoritative)
  83. {
  84. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  85. }
  86. public function setApcu($apcu)
  87. {
  88. $this->apcu = (bool) $apcu;
  89. }
  90. public function setRunScripts($runScripts = true)
  91. {
  92. $this->runScripts = (bool) $runScripts;
  93. }
  94. public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
  95. {
  96. if ($this->classMapAuthoritative) {
  97. $scanPsr0Packages = true;
  98. }
  99. if ($this->runScripts) {
  100. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  101. 'optimize' => (bool) $scanPsr0Packages,
  102. ));
  103. }
  104. $filesystem = new Filesystem();
  105. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  106. $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
  107. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  108. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  109. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  110. $targetDir = $vendorPath.'/'.$targetDir;
  111. $filesystem->ensureDirectoryExists($targetDir);
  112. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  113. $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
  114. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  115. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  116. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  117. $namespacesFile = <<<EOF
  118. <?php
  119. // autoload_namespaces.php @generated by Composer
  120. \$vendorDir = $vendorPathCode52;
  121. \$baseDir = $appBaseDirCode;
  122. return array(
  123. EOF;
  124. $psr4File = <<<EOF
  125. <?php
  126. // autoload_psr4.php @generated by Composer
  127. \$vendorDir = $vendorPathCode52;
  128. \$baseDir = $appBaseDirCode;
  129. return array(
  130. EOF;
  131. $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());
  132. $autoloads = $this->parseAutoloads($packageMap, $mainPackage, $this->devMode === false);
  133. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  134. $exportedPaths = array();
  135. foreach ($paths as $path) {
  136. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  137. }
  138. $exportedPrefix = var_export($namespace, true);
  139. $namespacesFile .= " $exportedPrefix => ";
  140. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  141. }
  142. $namespacesFile .= ");\n";
  143. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  144. $exportedPaths = array();
  145. foreach ($paths as $path) {
  146. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  147. }
  148. $exportedPrefix = var_export($namespace, true);
  149. $psr4File .= " $exportedPrefix => ";
  150. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  151. }
  152. $psr4File .= ");\n";
  153. $classmapFile = <<<EOF
  154. <?php
  155. // autoload_classmap.php @generated by Composer
  156. \$vendorDir = $vendorPathCode52;
  157. \$baseDir = $appBaseDirCode;
  158. return array(
  159. EOF;
  160. $targetDirLoader = null;
  161. $mainAutoload = $mainPackage->getAutoload();
  162. if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  163. $levels = substr_count($filesystem->normalizePath($mainPackage->getTargetDir()), '/') + 1;
  164. $prefixes = implode(', ', array_map(function ($prefix) {
  165. return var_export($prefix, true);
  166. }, array_keys($mainAutoload['psr-0'])));
  167. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  168. $targetDirLoader = <<<EOF
  169. public static function autoload(\$class)
  170. {
  171. \$dir = $baseDirFromTargetDirCode . '/';
  172. \$prefixes = array($prefixes);
  173. foreach (\$prefixes as \$prefix) {
  174. if (0 !== strpos(\$class, \$prefix)) {
  175. continue;
  176. }
  177. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  178. if (!\$path = stream_resolve_include_path(\$path)) {
  179. return false;
  180. }
  181. require \$path;
  182. return true;
  183. }
  184. }
  185. EOF;
  186. }
  187. $blacklist = null;
  188. if (!empty($autoloads['exclude-from-classmap'])) {
  189. $blacklist = '{(' . implode('|', $autoloads['exclude-from-classmap']) . ')}';
  190. }
  191. $classMap = array();
  192. if ($scanPsr0Packages) {
  193. $namespacesToScan = array();
  194. foreach (array('psr-0', 'psr-4') as $psrType) {
  195. foreach ($autoloads[$psrType] as $namespace => $paths) {
  196. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  197. }
  198. }
  199. krsort($namespacesToScan);
  200. foreach ($namespacesToScan as $namespace => $groups) {
  201. foreach ($groups as $group) {
  202. foreach ($group['paths'] as $dir) {
  203. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  204. if (!is_dir($dir)) {
  205. continue;
  206. }
  207. $namespaceFilter = $namespace === '' ? null : $namespace;
  208. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $blacklist, $namespaceFilter, $classMap);
  209. }
  210. }
  211. }
  212. }
  213. foreach ($autoloads['classmap'] as $dir) {
  214. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $blacklist, null, $classMap);
  215. }
  216. ksort($classMap);
  217. foreach ($classMap as $class => $code) {
  218. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  219. }
  220. $classmapFile .= ");\n";
  221. if (!$suffix) {
  222. if (!$config->get('autoloader-suffix') && is_readable($vendorPath.'/autoload.php')) {
  223. $content = file_get_contents($vendorPath.'/autoload.php');
  224. if (preg_match('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  225. $suffix = $match[1];
  226. }
  227. }
  228. if (!$suffix) {
  229. $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
  230. }
  231. }
  232. file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile);
  233. file_put_contents($targetDir.'/autoload_psr4.php', $psr4File);
  234. file_put_contents($targetDir.'/autoload_classmap.php', $classmapFile);
  235. $includePathFilePath = $targetDir.'/include_paths.php';
  236. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  237. file_put_contents($includePathFilePath, $includePathFileContents);
  238. } elseif (file_exists($includePathFilePath)) {
  239. unlink($includePathFilePath);
  240. }
  241. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  242. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  243. file_put_contents($includeFilesFilePath, $includeFilesFileContents);
  244. } elseif (file_exists($includeFilesFilePath)) {
  245. unlink($includeFilesFilePath);
  246. }
  247. file_put_contents($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
  248. file_put_contents($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  249. file_put_contents($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion));
  250. $this->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  251. $this->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  252. if ($this->runScripts) {
  253. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  254. 'optimize' => (bool) $scanPsr0Packages,
  255. ));
  256. }
  257. return count($classMap);
  258. }
  259. private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $blacklist = null, $namespaceFilter = null, array $classMap = array())
  260. {
  261. foreach ($this->generateClassMap($dir, $blacklist, $namespaceFilter) as $class => $path) {
  262. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  263. if (!isset($classMap[$class])) {
  264. $classMap[$class] = $pathCode;
  265. } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  266. $this->io->writeError(
  267. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  268. ' was found in both "'.str_replace(array('$vendorDir . \'', "',\n"), array($vendorPath, ''), $classMap[$class]).'" and "'.$path.'", the first will be used.</warning>'
  269. );
  270. }
  271. }
  272. return $classMap;
  273. }
  274. private function generateClassMap($dir, $blacklist = null, $namespaceFilter = null, $showAmbiguousWarning = true)
  275. {
  276. return ClassMapGenerator::createMap($dir, $blacklist, $showAmbiguousWarning ? $this->io : null, $namespaceFilter);
  277. }
  278. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
  279. {
  280. $packageMap = array(array($mainPackage, ''));
  281. foreach ($packages as $package) {
  282. if ($package instanceof AliasPackage) {
  283. continue;
  284. }
  285. $this->validatePackage($package);
  286. $packageMap[] = array(
  287. $package,
  288. $installationManager->getInstallPath($package),
  289. );
  290. }
  291. return $packageMap;
  292. }
  293. protected function validatePackage(PackageInterface $package)
  294. {
  295. $autoload = $package->getAutoload();
  296. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  297. $name = $package->getName();
  298. $package->getTargetDir();
  299. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  300. }
  301. if (!empty($autoload['psr-4'])) {
  302. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  303. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  304. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  305. }
  306. }
  307. }
  308. }
  309. public function parseAutoloads(array $packageMap, PackageInterface $mainPackage, $filterOutRequireDevPackages = false)
  310. {
  311. $mainPackageMap = array_shift($packageMap);
  312. if ($filterOutRequireDevPackages) {
  313. $packageMap = $this->filterPackageMap($packageMap, $mainPackage);
  314. }
  315. $sortedPackageMap = $this->sortPackageMap($packageMap);
  316. $sortedPackageMap[] = $mainPackageMap;
  317. array_unshift($packageMap, $mainPackageMap);
  318. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $mainPackage);
  319. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $mainPackage);
  320. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $mainPackage);
  321. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $mainPackage);
  322. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $mainPackage);
  323. krsort($psr0);
  324. krsort($psr4);
  325. return array(
  326. 'psr-0' => $psr0,
  327. 'psr-4' => $psr4,
  328. 'classmap' => $classmap,
  329. 'files' => $files,
  330. 'exclude-from-classmap' => $exclude,
  331. );
  332. }
  333. public function createLoader(array $autoloads)
  334. {
  335. $loader = new ClassLoader();
  336. if (isset($autoloads['psr-0'])) {
  337. foreach ($autoloads['psr-0'] as $namespace => $path) {
  338. $loader->add($namespace, $path);
  339. }
  340. }
  341. if (isset($autoloads['psr-4'])) {
  342. foreach ($autoloads['psr-4'] as $namespace => $path) {
  343. $loader->addPsr4($namespace, $path);
  344. }
  345. }
  346. if (isset($autoloads['classmap'])) {
  347. $blacklist = null;
  348. if (!empty($autoloads['exclude-from-classmap'])) {
  349. $blacklist = '{(' . implode('|', $autoloads['exclude-from-classmap']) . ')}';
  350. }
  351. foreach ($autoloads['classmap'] as $dir) {
  352. try {
  353. $loader->addClassMap($this->generateClassMap($dir, $blacklist, null, false));
  354. } catch (\RuntimeException $e) {
  355. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  356. }
  357. }
  358. }
  359. return $loader;
  360. }
  361. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  362. {
  363. $includePaths = array();
  364. foreach ($packageMap as $item) {
  365. list($package, $installPath) = $item;
  366. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  367. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  368. }
  369. foreach ($package->getIncludePaths() as $includePath) {
  370. $includePath = trim($includePath, '/');
  371. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  372. }
  373. }
  374. if (!$includePaths) {
  375. return;
  376. }
  377. $includePathsCode = '';
  378. foreach ($includePaths as $path) {
  379. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  380. }
  381. return <<<EOF
  382. <?php
  383. // include_paths.php @generated by Composer
  384. \$vendorDir = $vendorPathCode;
  385. \$baseDir = $appBaseDirCode;
  386. return array(
  387. $includePathsCode);
  388. EOF;
  389. }
  390. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  391. {
  392. $filesCode = '';
  393. foreach ($files as $fileIdentifier => $functionFile) {
  394. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  395. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  396. }
  397. if (!$filesCode) {
  398. return false;
  399. }
  400. return <<<EOF
  401. <?php
  402. // autoload_files.php @generated by Composer
  403. \$vendorDir = $vendorPathCode;
  404. \$baseDir = $appBaseDirCode;
  405. return array(
  406. $filesCode);
  407. EOF;
  408. }
  409. protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
  410. {
  411. if (!$filesystem->isAbsolutePath($path)) {
  412. $path = $basePath . '/' . $path;
  413. }
  414. $path = $filesystem->normalizePath($path);
  415. $baseDir = '';
  416. if (strpos($path.'/', $vendorPath.'/') === 0) {
  417. $path = substr($path, strlen($vendorPath));
  418. $baseDir = '$vendorDir';
  419. if ($path !== false) {
  420. $baseDir .= " . ";
  421. }
  422. } else {
  423. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  424. if (!$filesystem->isAbsolutePath($path)) {
  425. $baseDir = '$baseDir . ';
  426. $path = '/' . $path;
  427. }
  428. }
  429. if (preg_match('/\.phar.+$/', $path)) {
  430. $baseDir = "'phar://' . " . $baseDir;
  431. }
  432. return $baseDir . (($path !== false) ? var_export($path, true) : "");
  433. }
  434. protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
  435. {
  436. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  437. if ("'" === $lastChar || '"' === $lastChar) {
  438. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  439. } else {
  440. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  441. }
  442. return <<<AUTOLOAD
  443. <?php
  444. // autoload.php @generated by Composer
  445. require_once $vendorPathToTargetDirCode;
  446. return ComposerAutoloaderInit$suffix::getLoader();
  447. AUTOLOAD;
  448. }
  449. protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion = 70000)
  450. {
  451. $file = <<<HEADER
  452. <?php
  453. // autoload_real.php @generated by Composer
  454. class ComposerAutoloaderInit$suffix
  455. {
  456. private static \$loader;
  457. public static function loadClassLoader(\$class)
  458. {
  459. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  460. require __DIR__ . '/ClassLoader.php';
  461. }
  462. }
  463. public static function getLoader()
  464. {
  465. if (null !== self::\$loader) {
  466. return self::\$loader;
  467. }
  468. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  469. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
  470. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  471. HEADER;
  472. if ($useIncludePath) {
  473. $file .= <<<'INCLUDE_PATH'
  474. $includePaths = require __DIR__ . '/include_paths.php';
  475. $includePaths[] = get_include_path();
  476. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  477. INCLUDE_PATH;
  478. }
  479. $file .= <<<STATIC_INIT
  480. \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  481. if (\$useStaticLoader) {
  482. require_once __DIR__ . '/autoload_static.php';
  483. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  484. } else {
  485. STATIC_INIT;
  486. if (!$this->classMapAuthoritative) {
  487. $file .= <<<'PSR04'
  488. $map = require __DIR__ . '/autoload_namespaces.php';
  489. foreach ($map as $namespace => $path) {
  490. $loader->set($namespace, $path);
  491. }
  492. $map = require __DIR__ . '/autoload_psr4.php';
  493. foreach ($map as $namespace => $path) {
  494. $loader->setPsr4($namespace, $path);
  495. }
  496. PSR04;
  497. }
  498. if ($useClassMap) {
  499. $file .= <<<'CLASSMAP'
  500. $classMap = require __DIR__ . '/autoload_classmap.php';
  501. if ($classMap) {
  502. $loader->addClassMap($classMap);
  503. }
  504. CLASSMAP;
  505. }
  506. $file .= " }\n\n";
  507. if ($this->classMapAuthoritative) {
  508. $file .= <<<'CLASSMAPAUTHORITATIVE'
  509. $loader->setClassMapAuthoritative(true);
  510. CLASSMAPAUTHORITATIVE;
  511. }
  512. if ($this->apcu) {
  513. $apcuPrefix = substr(base64_encode(md5(uniqid('', true), true)), 0, -3);
  514. $file .= <<<APCU
  515. \$loader->setApcuPrefix('$apcuPrefix');
  516. APCU;
  517. }
  518. if ($useGlobalIncludePath) {
  519. $file .= <<<'INCLUDEPATH'
  520. $loader->setUseIncludePath(true);
  521. INCLUDEPATH;
  522. }
  523. if ($targetDirLoader) {
  524. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  525. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  526. REGISTER_TARGET_DIR_AUTOLOAD;
  527. }
  528. $file .= <<<REGISTER_LOADER
  529. \$loader->register($prependAutoloader);
  530. REGISTER_LOADER;
  531. if ($useIncludeFiles) {
  532. $file .= <<<INCLUDE_FILES
  533. if (\$useStaticLoader) {
  534. \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
  535. } else {
  536. \$includeFiles = require __DIR__ . '/autoload_files.php';
  537. }
  538. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  539. composerRequire$suffix(\$fileIdentifier, \$file);
  540. }
  541. INCLUDE_FILES;
  542. }
  543. $file .= <<<METHOD_FOOTER
  544. return \$loader;
  545. }
  546. METHOD_FOOTER;
  547. $file .= $targetDirLoader;
  548. if ($useIncludeFiles) {
  549. return $file . <<<FOOTER
  550. }
  551. function composerRequire$suffix(\$fileIdentifier, \$file)
  552. {
  553. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  554. require \$file;
  555. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  556. }
  557. }
  558. FOOTER;
  559. }
  560. return $file . <<<FOOTER
  561. }
  562. FOOTER;
  563. }
  564. protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
  565. {
  566. $staticPhpVersion = 50600;
  567. $file = <<<HEADER
  568. <?php
  569. // autoload_static.php @generated by Composer
  570. namespace Composer\Autoload;
  571. class ComposerStaticInit$suffix
  572. {
  573. HEADER;
  574. $loader = new ClassLoader();
  575. $map = require $targetDir . '/autoload_namespaces.php';
  576. foreach ($map as $namespace => $path) {
  577. $loader->set($namespace, $path);
  578. }
  579. $map = require $targetDir . '/autoload_psr4.php';
  580. foreach ($map as $namespace => $path) {
  581. $loader->setPsr4($namespace, $path);
  582. }
  583. $classMap = require $targetDir . '/autoload_classmap.php';
  584. if ($classMap) {
  585. $loader->addClassMap($classMap);
  586. }
  587. $filesystem = new Filesystem();
  588. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  589. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  590. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  591. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  592. $initializer = '';
  593. $prefix = "\0Composer\Autoload\ClassLoader\0";
  594. $prefixLen = strlen($prefix);
  595. if (file_exists($targetDir . '/autoload_files.php')) {
  596. $maps = array('files' => require $targetDir . '/autoload_files.php');
  597. } else {
  598. $maps = array();
  599. }
  600. foreach ((array) $loader as $prop => $value) {
  601. if ($value && 0 === strpos($prop, $prefix)) {
  602. $maps[substr($prop, $prefixLen)] = $value;
  603. }
  604. }
  605. foreach ($maps as $prop => $value) {
  606. if (count($value) > 32767) {
  607. $staticPhpVersion = 70000;
  608. }
  609. $value = var_export($value, true);
  610. $value = str_replace($absoluteVendorPathCode, $vendorPathCode, $value);
  611. $value = str_replace($absoluteAppBaseDirCode, $appBaseDirCode, $value);
  612. $value = ltrim(preg_replace('/^ */m', ' $0$0', $value));
  613. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  614. if ('files' !== $prop) {
  615. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  616. }
  617. }
  618. return $file . <<<INITIALIZER
  619. public static function getInitializer(ClassLoader \$loader)
  620. {
  621. return \Closure::bind(function () use (\$loader) {
  622. $initializer
  623. }, null, ClassLoader::class);
  624. }
  625. }
  626. INITIALIZER;
  627. }
  628. protected function parseAutoloadsType(array $packageMap, $type, PackageInterface $mainPackage)
  629. {
  630. $autoloads = array();
  631. foreach ($packageMap as $item) {
  632. list($package, $installPath) = $item;
  633. $autoload = $package->getAutoload();
  634. if ($this->devMode && $package === $mainPackage) {
  635. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  636. }
  637. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  638. continue;
  639. }
  640. if (null !== $package->getTargetDir() && $package !== $mainPackage) {
  641. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  642. }
  643. foreach ($autoload[$type] as $namespace => $paths) {
  644. foreach ((array) $paths as $path) {
  645. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !is_readable($installPath.'/'.$path)) {
  646. if ($package === $mainPackage) {
  647. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  648. $path = ltrim(preg_replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  649. } else {
  650. $path = $package->getTargetDir() . '/' . $path;
  651. }
  652. }
  653. if ($type === 'exclude-from-classmap') {
  654. $path = preg_replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  655. $path = str_replace('\\*\\*', '.+?', $path);
  656. $path = str_replace('\\*', '[^/]+?', $path);
  657. $updir = null;
  658. $path = preg_replace_callback(
  659. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  660. function ($matches) use (&$updir) {
  661. if (isset($matches[1])) {
  662. $updir = str_replace('\\.', '.', $matches[1]);
  663. }
  664. return '';
  665. },
  666. $path
  667. );
  668. if (empty($installPath)) {
  669. $installPath = strtr(getcwd(), '\\', '/');
  670. }
  671. $resolvedPath = realpath($installPath . '/' . $updir);
  672. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path;
  673. continue;
  674. }
  675. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  676. if ($type === 'files') {
  677. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  678. continue;
  679. } elseif ($type === 'classmap') {
  680. $autoloads[] = $relativePath;
  681. continue;
  682. }
  683. $autoloads[$namespace][] = $relativePath;
  684. }
  685. }
  686. }
  687. return $autoloads;
  688. }
  689. protected function getFileIdentifier(PackageInterface $package, $path)
  690. {
  691. return md5($package->getName() . ':' . $path);
  692. }
  693. protected function filterPackageMap(array $packageMap, PackageInterface $mainPackage)
  694. {
  695. $packages = array();
  696. $include = array();
  697. foreach ($packageMap as $item) {
  698. $package = $item[0];
  699. $name = $package->getName();
  700. $packages[$name] = $package;
  701. }
  702. $add = function (PackageInterface $package) use (&$add, $packages, &$include) {
  703. foreach ($package->getRequires() as $link) {
  704. $target = $link->getTarget();
  705. if (!isset($include[$target])) {
  706. $include[$target] = true;
  707. if (isset($packages[$target])) {
  708. $add($packages[$target]);
  709. }
  710. }
  711. }
  712. };
  713. $add($mainPackage);
  714. return array_filter(
  715. $packageMap,
  716. function ($item) use ($include) {
  717. $package = $item[0];
  718. $name = $package->getName();
  719. return isset($include[$name]);
  720. }
  721. );
  722. }
  723. protected function sortPackageMap(array $packageMap)
  724. {
  725. $packages = array();
  726. $paths = array();
  727. $usageList = array();
  728. foreach ($packageMap as $item) {
  729. list($package, $path) = $item;
  730. $name = $package->getName();
  731. $packages[$name] = $package;
  732. $paths[$name] = $path;
  733. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  734. $target = $link->getTarget();
  735. $usageList[$target][] = $name;
  736. }
  737. }
  738. $computing = array();
  739. $computed = array();
  740. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  741. if (isset($computed[$name])) {
  742. return $computed[$name];
  743. }
  744. if (isset($computing[$name])) {
  745. return 0;
  746. }
  747. $computing[$name] = true;
  748. $weight = 0;
  749. if (isset($usageList[$name])) {
  750. foreach ($usageList[$name] as $user) {
  751. $weight -= 1 - $computeImportance($user);
  752. }
  753. }
  754. unset($computing[$name]);
  755. $computed[$name] = $weight;
  756. return $weight;
  757. };
  758. $weightList = array();
  759. foreach ($packages as $name => $package) {
  760. $weight = $computeImportance($name);
  761. $weightList[$name] = $weight;
  762. }
  763. $stable_sort = function (&$array) {
  764. static $transform, $restore;
  765. $i = 0;
  766. if (!$transform) {
  767. $transform = function (&$v, $k) use (&$i) {
  768. $v = array($v, ++$i, $k, $v);
  769. };
  770. $restore = function (&$v, $k) {
  771. $v = $v[3];
  772. };
  773. }
  774. array_walk($array, $transform);
  775. asort($array);
  776. array_walk($array, $restore);
  777. };
  778. $stable_sort($weightList);
  779. $sortedPackageMap = array();
  780. foreach (array_keys($weightList) as $name) {
  781. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  782. }
  783. return $sortedPackageMap;
  784. }
  785. protected function safeCopy($source, $target)
  786. {
  787. $source = fopen($source, 'r');
  788. $target = fopen($target, 'w+');
  789. stream_copy_to_stream($source, $target);
  790. fclose($source);
  791. fclose($target);
  792. }
  793. }
  794. <?php
  795. namespace Composer\Autoload;
  796. use Symfony\Component\Finder\Finder;
  797. use Composer\IO\IOInterface;
  798. use Composer\Util\Filesystem;
  799. class ClassMapGenerator
  800. {
  801. public static function dump($dirs, $file)
  802. {
  803. $maps = array();
  804. foreach ($dirs as $dir) {
  805. $maps = array_merge($maps, static::createMap($dir));
  806. }
  807. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  808. }
  809. public static function createMap($path, $blacklist = null, IOInterface $io = null, $namespace = null)
  810. {
  811. if (is_string($path)) {
  812. if (is_file($path)) {
  813. $path = array(new \SplFileInfo($path));
  814. } elseif (is_dir($path)) {
  815. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  816. } else {
  817. throw new \RuntimeException(
  818. 'Could not scan for classes inside "'.$path.
  819. '" which does not appear to be a file nor a folder'
  820. );
  821. }
  822. }
  823. $map = array();
  824. $filesystem = new Filesystem();
  825. $cwd = realpath(getcwd());
  826. foreach ($path as $file) {
  827. $filePath = $file->getPathname();
  828. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  829. continue;
  830. }
  831. if (!$filesystem->isAbsolutePath($filePath)) {
  832. $filePath = $cwd . '/' . $filePath;
  833. $filePath = $filesystem->normalizePath($filePath);
  834. } else {
  835. $filePath = preg_replace('{[\\\\/]{2,}}', '/', $filePath);
  836. }
  837. if ($blacklist && preg_match($blacklist, strtr(realpath($filePath), '\\', '/'))) {
  838. continue;
  839. }
  840. if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) {
  841. continue;
  842. }
  843. $classes = self::findClasses($filePath);
  844. foreach ($classes as $class) {
  845. if (null !== $namespace && 0 !== strpos($class, $namespace)) {
  846. continue;
  847. }
  848. if (!isset($map[$class])) {
  849. $map[$class] = $filePath;
  850. } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  851. $io->writeError(
  852. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  853. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  854. );
  855. }
  856. }
  857. }
  858. return $map;
  859. }
  860. private static function findClasses($path)
  861. {
  862. $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
  863. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
  864. $extraTypes .= '|enum';
  865. }
  866. $contents = @php_strip_whitespace($path);
  867. if (!$contents) {
  868. if (!file_exists($path)) {
  869. $message = 'File at "%s" does not exist, check your classmap definitions';
  870. } elseif (!is_readable($path)) {
  871. $message = 'File at "%s" is not readable, check its permissions';
  872. } elseif ('' === trim(file_get_contents($path))) {
  873. return array();
  874. } else {
  875. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  876. }
  877. $error = error_get_last();
  878. if (isset($error['message'])) {
  879. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  880. }
  881. throw new \RuntimeException(sprintf($message, $path));
  882. }
  883. if (!preg_match('{\b(?:class|interface'.$extraTypes.')\s}i', $contents)) {
  884. return array();
  885. }
  886. $contents = preg_replace('{<<<\s*(\'?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)\\2(?=\r\n|\n|\r|;)}s', 'null', $contents);
  887. $contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
  888. if (substr($contents, 0, 2) !== '<?') {
  889. $contents = preg_replace('{^.+?<\?}s', '<?', $contents, 1, $replacements);
  890. if ($replacements === 0) {
  891. return array();
  892. }
  893. }
  894. $contents = preg_replace('{\?>.+<\?}s', '?><?', $contents);
  895. $pos = strrpos($contents, '?>');
  896. if (false !== $pos && false === strpos(substr($contents, $pos), '<?')) {
  897. $contents = substr($contents, 0, $pos);
  898. }
  899. if (preg_match('{(<\?)(?!(php|hh))}i', $contents)) {
  900. $contents = preg_replace('{//.* | /\*(?:[^*]++|\*(?!/))*\*/}x', '', $contents);
  901. }
  902. preg_match_all('{
  903. (?:
  904. \b(?<![\$:>])(?P<type>class|interface'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  905. | \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*+ [\{;]
  906. )
  907. }ix', $contents, $matches);
  908. $classes = array();
  909. $namespace = '';
  910. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  911. if (!empty($matches['ns'][$i])) {
  912. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
  913. } else {
  914. $name = $matches['name'][$i];
  915. if ($name === 'extends' || $name === 'implements') {
  916. continue;
  917. }
  918. if ($name[0] === ':') {
  919. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  920. } elseif ($matches['type'][$i] === 'enum') {
  921. $name = rtrim($name, ':');
  922. }
  923. $classes[] = ltrim($namespace . $name, '\\');
  924. }
  925. }
  926. return $classes;
  927. }
  928. }
  929. <?php
  930. namespace Composer;
  931. use Composer\IO\IOInterface;
  932. use Composer\Util\Filesystem;
  933. use Composer\Util\Silencer;
  934. use Symfony\Component\Finder\Finder;
  935. class Cache
  936. {
  937. private static $cacheCollected = false;
  938. private $io;
  939. private $root;
  940. private $enabled = true;
  941. private $whitelist;
  942. private $filesystem;
  943. public function __construct(IOInterface $io, $cacheDir, $whitelist = 'a-z0-9.', Filesystem $filesystem = null)
  944. {
  945. $this->io = $io;
  946. $this->root = rtrim($cacheDir, '/\\') . '/';
  947. $this->whitelist = $whitelist;
  948. $this->filesystem = $filesystem ?: new Filesystem();
  949. if (preg_match('{(^|[\\\\/])(\$null|NUL|/dev/null)([\\\\/]|$)}', $cacheDir)) {
  950. $this->enabled = false;
  951. return;
  952. }
  953. if (
  954. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  955. || !is_writable($this->root)
  956. ) {
  957. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  958. $this->enabled = false;
  959. }
  960. }
  961. public function isEnabled()
  962. {
  963. return $this->enabled;
  964. }
  965. public function getRoot()
  966. {
  967. return $this->root;
  968. }
  969. public function read($file)
  970. {
  971. if ($this->enabled) {
  972. $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
  973. if (file_exists($this->root . $file)) {
  974. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  975. return file_get_contents($this->root . $file);
  976. }
  977. }
  978. return false;
  979. }
  980. public function write($file, $contents)
  981. {
  982. if ($this->enabled) {
  983. $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
  984. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  985. try {
  986. return file_put_contents($this->root . $file, $contents);
  987. } catch (\ErrorException $e) {
  988. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  989. if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  990. unlink($this->root . $file);
  991. $message = sprintf(
  992. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  993. $this->root . $file,
  994. $m[1],
  995. $m[2],
  996. @disk_free_space($this->root . dirname($file))
  997. );
  998. $this->io->writeError($message);
  999. return false;
  1000. }
  1001. throw $e;
  1002. }
  1003. }
  1004. return false;
  1005. }
  1006. public function copyFrom($file, $source)
  1007. {
  1008. if ($this->enabled) {
  1009. $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
  1010. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1011. if (!file_exists($source)) {
  1012. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1013. } elseif ($this->io->isDebug()) {
  1014. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1015. }
  1016. return copy($source, $this->root . $file);
  1017. }
  1018. return false;
  1019. }
  1020. public function copyTo($file, $target)
  1021. {
  1022. if ($this->enabled) {
  1023. $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
  1024. if (file_exists($this->root . $file)) {
  1025. try {
  1026. touch($this->root . $file, filemtime($this->root . $file), time());
  1027. } catch (\ErrorException $e) {
  1028. Silencer::call('touch', $this->root . $file);
  1029. }
  1030. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1031. return copy($this->root . $file, $target);
  1032. }
  1033. }
  1034. return false;
  1035. }
  1036. public function gcIsNecessary()
  1037. {
  1038. return (!self::$cacheCollected && !mt_rand(0, 50));
  1039. }
  1040. public function remove($file)
  1041. {
  1042. if ($this->enabled) {
  1043. $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
  1044. if (file_exists($this->root . $file)) {
  1045. return $this->filesystem->unlink($this->root . $file);
  1046. }
  1047. }
  1048. return false;
  1049. }
  1050. public function clear()
  1051. {
  1052. if ($this->enabled) {
  1053. return $this->filesystem->removeDirectory($this->root);
  1054. }
  1055. return false;
  1056. }
  1057. public function gc($ttl, $maxSize)
  1058. {
  1059. if ($this->enabled) {
  1060. $expire = new \DateTime();
  1061. $expire->modify('-'.$ttl.' seconds');
  1062. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1063. foreach ($finder as $file) {
  1064. $this->filesystem->unlink($file->getPathname());
  1065. }
  1066. $totalSize = $this->filesystem->size($this->root);
  1067. if ($totalSize > $maxSize) {
  1068. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1069. while ($totalSize > $maxSize && $iterator->valid()) {
  1070. $filepath = $iterator->current()->getPathname();
  1071. $totalSize -= $this->filesystem->size($filepath);
  1072. $this->filesystem->unlink($filepath);
  1073. $iterator->next();
  1074. }
  1075. }
  1076. self::$cacheCollected = true;
  1077. return true;
  1078. }
  1079. return false;
  1080. }
  1081. public function sha1($file)
  1082. {
  1083. if ($this->enabled) {
  1084. $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
  1085. if (file_exists($this->root . $file)) {
  1086. return sha1_file($this->root . $file);
  1087. }
  1088. }
  1089. return false;
  1090. }
  1091. public function sha256($file)
  1092. {
  1093. if ($this->enabled) {
  1094. $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
  1095. if (file_exists($this->root . $file)) {
  1096. return hash_file('sha256', $this->root . $file);
  1097. }
  1098. }
  1099. return false;
  1100. }
  1101. protected function getFinder()
  1102. {
  1103. return Finder::create()->in($this->root)->files();
  1104. }
  1105. }
  1106. <?php
  1107. namespace Composer\Command;
  1108. use Symfony\Component\Console\Input\InputInterface;
  1109. use Symfony\Component\Console\Output\OutputInterface;
  1110. class AboutCommand extends BaseCommand
  1111. {
  1112. protected function configure()
  1113. {
  1114. $this
  1115. ->setName('about')
  1116. ->setDescription('Shows the short information about Composer.')
  1117. ->setHelp(
  1118. <<<EOT
  1119. <info>php composer.phar about</info>
  1120. EOT
  1121. )
  1122. ;
  1123. }
  1124. protected function execute(InputInterface $input, OutputInterface $output)
  1125. {
  1126. $this->getIO()->write(
  1127. <<<EOT
  1128. <info>Composer - Dependency Manager for PHP</info>
  1129. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1130. See https://getcomposer.org/ for more information.</comment>
  1131. EOT
  1132. );
  1133. }
  1134. }
  1135. <?php
  1136. namespace Composer\Command;
  1137. use Composer\Factory;
  1138. use Composer\IO\IOInterface;
  1139. use Composer\Config;
  1140. use Composer\Composer;
  1141. use Composer\Repository\CompositeRepository;
  1142. use Composer\Repository\RepositoryFactory;
  1143. use Composer\Script\ScriptEvents;
  1144. use Composer\Plugin\CommandEvent;
  1145. use Composer\Plugin\PluginEvents;
  1146. use Composer\Util\Filesystem;
  1147. use Symfony\Component\Console\Input\InputArgument;
  1148. use Symfony\Component\Console\Input\InputInterface;
  1149. use Symfony\Component\Console\Input\InputOption;
  1150. use Symfony\Component\Console\Output\OutputInterface;
  1151. class ArchiveCommand extends BaseCommand
  1152. {
  1153. protected function configure()
  1154. {
  1155. $this
  1156. ->setName('archive')
  1157. ->setDescription('Creates an archive of this composer package.')
  1158. ->setDefinition(array(
  1159. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1160. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1161. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'),
  1162. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1163. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1164. .' Note that the format will be appended.'),
  1165. new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1166. ))
  1167. ->setHelp(
  1168. <<<EOT
  1169. The <info>archive</info> command creates an archive of the specified format
  1170. containing the files and directories of the Composer project or the specified
  1171. package in the specified version and writes it to the specified directory.
  1172. <info>php composer.phar archive [--format=zip] [--dir=/foo] [package [version]]</info>
  1173. EOT
  1174. )
  1175. ;
  1176. }
  1177. protected function execute(InputInterface $input, OutputInterface $output)
  1178. {
  1179. $config = Factory::createConfig();
  1180. $composer = $this->getComposer(false);
  1181. if ($composer) {
  1182. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1183. $eventDispatcher = $composer->getEventDispatcher();
  1184. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1185. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1186. }
  1187. if (null === $input->getOption('format')) {
  1188. $input->setOption('format', $config->get('archive-format'));
  1189. }
  1190. if (null === $input->getOption('dir')) {
  1191. $input->setOption('dir', $config->get('archive-dir'));
  1192. }
  1193. $returnCode = $this->archive(
  1194. $this->getIO(),
  1195. $config,
  1196. $input->getArgument('package'),
  1197. $input->getArgument('version'),
  1198. $input->getOption('format'),
  1199. $input->getOption('dir'),
  1200. $input->getOption('file'),
  1201. $input->getOption('ignore-filters'),
  1202. $composer
  1203. );
  1204. if (0 === $returnCode && $composer) {
  1205. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1206. }
  1207. return $returnCode;
  1208. }
  1209. protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
  1210. {
  1211. if ($composer) {
  1212. $archiveManager = $composer->getArchiveManager();
  1213. } else {
  1214. $factory = new Factory;
  1215. $downloadManager = $factory->createDownloadManager($io, $config);
  1216. $archiveManager = $factory->createArchiveManager($config, $downloadManager);
  1217. }
  1218. if ($packageName) {
  1219. $package = $this->selectPackage($io, $packageName, $version);
  1220. if (!$package) {
  1221. return 1;
  1222. }
  1223. } else {
  1224. $package = $this->getComposer()->getPackage();
  1225. }
  1226. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1227. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1228. $fs = new Filesystem;
  1229. $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
  1230. $io->writeError('Created: ', false);
  1231. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1232. return 0;
  1233. }
  1234. protected function selectPackage(IOInterface $io, $packageName, $version = null)
  1235. {
  1236. $io->writeError('<info>Searching for the specified package.</info>');
  1237. if ($composer = $this->getComposer(false)) {
  1238. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1239. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1240. } else {
  1241. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1242. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1243. $repo = new CompositeRepository($defaultRepos);
  1244. }
  1245. $packages = $repo->findPackages($packageName, $version);
  1246. if (count($packages) > 1) {
  1247. $package = reset($packages);
  1248. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1249. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {
  1250. return $p->getPrettyString();
  1251. }, $packages)).'.');
  1252. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1253. } elseif ($packages) {
  1254. $package = reset($packages);
  1255. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1256. } else {
  1257. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1258. return false;
  1259. }
  1260. return $package;
  1261. }
  1262. }
  1263. <?php
  1264. namespace Composer\Command;
  1265. use Composer\Composer;
  1266. use Composer\Config;
  1267. use Composer\Console\Application;
  1268. use Composer\Factory;
  1269. use Composer\IO\IOInterface;
  1270. use Composer\IO\NullIO;
  1271. use Composer\Plugin\PreCommandRunEvent;
  1272. use Composer\Plugin\PluginEvents;
  1273. use Symfony\Component\Console\Input\InputInterface;
  1274. use Symfony\Component\Console\Output\OutputInterface;
  1275. use Symfony\Component\Console\Command\Command;
  1276. abstract class BaseCommand extends Command
  1277. {
  1278. private $composer;
  1279. private $io;
  1280. public function getComposer($required = true, $disablePlugins = null)
  1281. {
  1282. if (null === $this->composer) {
  1283. $application = $this->getApplication();
  1284. if ($application instanceof Application) {
  1285. $this->composer = $application->getComposer($required, $disablePlugins);
  1286. } elseif ($required) {
  1287. throw new \RuntimeException(
  1288. 'Could not create a Composer\Composer instance, you must inject '.
  1289. 'one if this command is not used with a Composer\Console\Application instance'
  1290. );
  1291. }
  1292. }
  1293. return $this->composer;
  1294. }
  1295. public function setComposer(Composer $composer)
  1296. {
  1297. $this->composer = $composer;
  1298. }
  1299. public function resetComposer()
  1300. {
  1301. $this->composer = null;
  1302. $this->getApplication()->resetComposer();
  1303. }
  1304. public function isProxyCommand()
  1305. {
  1306. return false;
  1307. }
  1308. public function getIO()
  1309. {
  1310. if (null === $this->io) {
  1311. $application = $this->getApplication();
  1312. if ($application instanceof Application) {
  1313. $this->io = $application->getIO();
  1314. } else {
  1315. $this->io = new NullIO();
  1316. }
  1317. }
  1318. return $this->io;
  1319. }
  1320. public function setIO(IOInterface $io)
  1321. {
  1322. $this->io = $io;
  1323. }
  1324. protected function initialize(InputInterface $input, OutputInterface $output)
  1325. {
  1326. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1327. $composer = $this->getComposer(false, $disablePlugins);
  1328. if (null === $composer) {
  1329. $composer = Factory::createGlobal($this->getIO(), $disablePlugins);
  1330. }
  1331. if ($composer) {
  1332. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1333. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1334. }
  1335. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1336. $input->setOption('no-progress', true);
  1337. }
  1338. parent::initialize($input, $output);
  1339. }
  1340. protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
  1341. {
  1342. $preferSource = false;
  1343. $preferDist = false;
  1344. switch ($config->get('preferred-install')) {
  1345. case 'source':
  1346. $preferSource = true;
  1347. break;
  1348. case 'dist':
  1349. $preferDist = true;
  1350. break;
  1351. case 'auto':
  1352. default:
  1353. break;
  1354. }
  1355. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1356. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1357. $preferDist = $input->getOption('prefer-dist');
  1358. }
  1359. return array($preferSource, $preferDist);
  1360. }
  1361. }
  1362. <?php
  1363. namespace Composer\Command;
  1364. use Composer\DependencyResolver\Pool;
  1365. use Composer\Package\Link;
  1366. use Composer\Package\PackageInterface;
  1367. use Composer\Repository\ArrayRepository;
  1368. use Composer\Repository\CompositeRepository;
  1369. use Composer\Repository\PlatformRepository;
  1370. use Composer\Repository\RepositoryFactory;
  1371. use Composer\Plugin\CommandEvent;
  1372. use Composer\Plugin\PluginEvents;
  1373. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1374. use Composer\Package\Version\VersionParser;
  1375. use Symfony\Component\Console\Helper\Table;
  1376. use Symfony\Component\Console\Input\InputArgument;
  1377. use Symfony\Component\Console\Input\InputInterface;
  1378. use Symfony\Component\Console\Input\InputOption;
  1379. use Symfony\Component\Console\Output\OutputInterface;
  1380. class BaseDependencyCommand extends BaseCommand
  1381. {
  1382. const ARGUMENT_PACKAGE = 'package';
  1383. const ARGUMENT_CONSTRAINT = 'constraint';
  1384. const OPTION_RECURSIVE = 'recursive';
  1385. const OPTION_TREE = 'tree';
  1386. protected $colors;
  1387. protected function configure()
  1388. {
  1389. $this->setDefinition(array(
  1390. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  1391. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::OPTIONAL, 'Optional version constraint', '*'),
  1392. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  1393. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  1394. ));
  1395. }
  1396. protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
  1397. {
  1398. $composer = $this->getComposer();
  1399. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1400. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1401. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1402. $repository = new CompositeRepository(array(
  1403. new ArrayRepository(array($composer->getPackage())),
  1404. $composer->getRepositoryManager()->getLocalRepository(),
  1405. new PlatformRepository(array(), $platformOverrides),
  1406. ));
  1407. $pool = new Pool();
  1408. $pool->addRepository($repository);
  1409. list($needle, $textConstraint) = array_pad(
  1410. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1411. 2,
  1412. $input->getArgument(self::ARGUMENT_CONSTRAINT)
  1413. );
  1414. $packages = $pool->whatProvides(strtolower($needle));
  1415. if (empty($packages)) {
  1416. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1417. }
  1418. if (!$repository->findPackage($needle, $textConstraint)) {
  1419. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  1420. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  1421. $repository->addRepository(new ArrayRepository(array(clone $match)));
  1422. }
  1423. }
  1424. $needles = array($needle);
  1425. if ($inverted) {
  1426. foreach ($packages as $package) {
  1427. $needles = array_merge($needles, array_map(function (Link $link) {
  1428. return $link->getTarget();
  1429. }, $package->getReplaces()));
  1430. }
  1431. }
  1432. if ('*' !== $textConstraint) {
  1433. $versionParser = new VersionParser();
  1434. $constraint = $versionParser->parseConstraints($textConstraint);
  1435. } else {
  1436. $constraint = null;
  1437. }
  1438. $renderTree = $input->getOption(self::OPTION_TREE);
  1439. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  1440. $results = $repository->getDependents($needles, $constraint, $inverted, $recursive);
  1441. if (empty($results)) {
  1442. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  1443. $this->getIO()->writeError(sprintf(
  1444. '<info>There is no installed package depending on "%s"%s</info>',
  1445. $needle,
  1446. $extra
  1447. ));
  1448. } elseif ($renderTree) {
  1449. $this->initStyles($output);
  1450. $root = $packages[0];
  1451. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root->getDescription()));
  1452. $this->printTree($results);
  1453. } else {
  1454. $this->printTable($output, $results);
  1455. }
  1456. return 0;
  1457. }
  1458. protected function printTable(OutputInterface $output, $results)
  1459. {
  1460. $table = array();
  1461. $doubles = array();
  1462. do {
  1463. $queue = array();
  1464. $rows = array();
  1465. foreach ($results as $result) {
  1466. list($package, $link, $children) = $result;
  1467. $unique = (string) $link;
  1468. if (isset($doubles[$unique])) {
  1469. continue;
  1470. }
  1471. $doubles[$unique] = true;
  1472. $version = (strpos($package->getPrettyVersion(), 'No version set') === 0) ? '-' : $package->getPrettyVersion();
  1473. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  1474. if ($children) {
  1475. $queue = array_merge($queue, $children);
  1476. }
  1477. }
  1478. $results = $queue;
  1479. $table = array_merge($rows, $table);
  1480. } while (!empty($results));
  1481. $renderer = new Table($output);
  1482. $renderer->setStyle('compact');
  1483. $rendererStyle = $renderer->getStyle();
  1484. $rendererStyle->setVerticalBorderChar('');
  1485. $rendererStyle->setCellRowContentFormat('%s ');
  1486. $renderer->setRows($table)->render();
  1487. }
  1488. protected function initStyles(OutputInterface $output)
  1489. {
  1490. $this->colors = array(
  1491. 'green',
  1492. 'yellow',
  1493. 'cyan',
  1494. 'magenta',
  1495. 'blue',
  1496. );
  1497. foreach ($this->colors as $color) {
  1498. $style = new OutputFormatterStyle($color);
  1499. $output->getFormatter()->setStyle($color, $style);
  1500. }
  1501. }
  1502. protected function printTree($results, $prefix = '', $level = 1)
  1503. {
  1504. $count = count($results);
  1505. $idx = 0;
  1506. foreach ($results as $result) {
  1507. list($package, $link, $children) = $result;
  1508. $color = $this->colors[$level % count($this->colors)];
  1509. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  1510. $isLast = (++$idx == $count);
  1511. $versionText = (strpos($package->getPrettyVersion(), 'No version set') === 0) ? '' : $package->getPrettyVersion();
  1512. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  1513. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  1514. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  1515. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  1516. if ($children) {
  1517. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  1518. }
  1519. }
  1520. }
  1521. private function writeTreeLine($line)
  1522. {
  1523. $io = $this->getIO();
  1524. if (!$io->isDecorated()) {
  1525. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  1526. }
  1527. $io->write($line);
  1528. }
  1529. }
  1530. <?php
  1531. namespace Composer\Command;
  1532. use Composer\Package\Link;
  1533. use Composer\Package\PackageInterface;
  1534. use Composer\Semver\Constraint\Constraint;
  1535. use Symfony\Component\Console\Helper\Table;
  1536. use Symfony\Component\Console\Input\InputInterface;
  1537. use Symfony\Component\Console\Input\InputOption;
  1538. use Symfony\Component\Console\Output\OutputInterface;
  1539. use Composer\Repository\PlatformRepository;
  1540. class CheckPlatformReqsCommand extends BaseCommand
  1541. {
  1542. protected function configure()
  1543. {
  1544. $this->setName('check-platform-reqs')
  1545. ->setDescription('Check that platform requirements are satisfied.')
  1546. ->setDefinition(array(
  1547. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  1548. ))
  1549. ->setHelp(
  1550. <<<EOT
  1551. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  1552. <info>php composer.phar check-platform-reqs</info>
  1553. EOT
  1554. );
  1555. }
  1556. protected function execute(InputInterface $input, OutputInterface $output)
  1557. {
  1558. $composer = $this->getComposer();
  1559. $requires = $composer->getPackage()->getRequires();
  1560. if ($input->getOption('no-dev')) {
  1561. $dependencies = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'))->getPackages();
  1562. } else {
  1563. $dependencies = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  1564. $requires += $composer->getPackage()->getDevRequires();
  1565. }
  1566. foreach ($requires as $require => $link) {
  1567. $requires[$require] = array($link);
  1568. }
  1569. foreach ($dependencies as $package) {
  1570. foreach ($package->getRequires() as $require => $link) {
  1571. $requires[$require][] = $link;
  1572. }
  1573. }
  1574. ksort($requires);
  1575. $platformRepo = new PlatformRepository(array(), array());
  1576. $currentPlatformPackages = $platformRepo->getPackages();
  1577. $currentPlatformPackageMap = array();
  1578. foreach ($currentPlatformPackages as $currentPlatformPackage) {
  1579. $currentPlatformPackageMap[$currentPlatformPackage->getName()] = $currentPlatformPackage;
  1580. }
  1581. $results = array();
  1582. $exitCode = 0;
  1583. foreach ($requires as $require => $links) {
  1584. if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $require)) {
  1585. if (isset($currentPlatformPackageMap[$require])) {
  1586. $pass = true;
  1587. $version = $currentPlatformPackageMap[$require]->getVersion();
  1588. foreach ($links as $link) {
  1589. if (!$link->getConstraint()->matches(new Constraint('=', $version))) {
  1590. $results[] = array(
  1591. $currentPlatformPackageMap[$require]->getPrettyName(),
  1592. $currentPlatformPackageMap[$require]->getPrettyVersion(),
  1593. $link,
  1594. '<error>failed</error>',
  1595. );
  1596. $pass = false;
  1597. $exitCode = max($exitCode, 1);
  1598. }
  1599. }
  1600. if ($pass) {
  1601. $results[] = array(
  1602. $currentPlatformPackageMap[$require]->getPrettyName(),
  1603. $currentPlatformPackageMap[$require]->getPrettyVersion(),
  1604. null,
  1605. '<info>success</info>',
  1606. );
  1607. }
  1608. } else {
  1609. $results[] = array(
  1610. $require,
  1611. 'n/a',
  1612. $links[0],
  1613. '<error>missing</error>',
  1614. );
  1615. $exitCode = max($exitCode, 2);
  1616. }
  1617. }
  1618. }
  1619. $this->printTable($output, $results);
  1620. return $exitCode;
  1621. }
  1622. protected function printTable(OutputInterface $output, $results)
  1623. {
  1624. $table = array();
  1625. $rows = array();
  1626. foreach ($results as $result) {
  1627. list($platformPackage, $version, $link, $status) = $result;
  1628. $rows[] = array(
  1629. $platformPackage,
  1630. $version,
  1631. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  1632. $status,
  1633. );
  1634. }
  1635. $table = array_merge($rows, $table);
  1636. $renderer = new Table($output);
  1637. $renderer->setStyle('compact');
  1638. $rendererStyle = $renderer->getStyle();
  1639. $rendererStyle->setVerticalBorderChar('');
  1640. $rendererStyle->setCellRowContentFormat('%s ');
  1641. $renderer->setRows($table)->render();
  1642. }
  1643. }
  1644. <?php
  1645. namespace Composer\Command;
  1646. use Composer\Cache;
  1647. use Composer\Factory;
  1648. use Symfony\Component\Console\Input\InputInterface;
  1649. use Symfony\Component\Console\Output\OutputInterface;
  1650. class ClearCacheCommand extends BaseCommand
  1651. {
  1652. protected function configure()
  1653. {
  1654. $this
  1655. ->setName('clear-cache')
  1656. ->setAliases(array('clearcache'))
  1657. ->setDescription('Clears composer\'s internal package cache.')
  1658. ->setHelp(
  1659. <<<EOT
  1660. The <info>clear-cache</info> deletes all cached packages from composer's
  1661. cache directory.
  1662. EOT
  1663. )
  1664. ;
  1665. }
  1666. protected function execute(InputInterface $input, OutputInterface $output)
  1667. {
  1668. $config = Factory::createConfig();
  1669. $io = $this->getIO();
  1670. $cachePaths = array(
  1671. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  1672. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  1673. 'cache-files-dir' => $config->get('cache-files-dir'),
  1674. 'cache-dir' => $config->get('cache-dir'),
  1675. );
  1676. foreach ($cachePaths as $key => $cachePath) {
  1677. $cachePath = realpath($cachePath);
  1678. if (!$cachePath) {
  1679. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  1680. continue;
  1681. }
  1682. $cache = new Cache($io, $cachePath);
  1683. if (!$cache->isEnabled()) {
  1684. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  1685. continue;
  1686. }
  1687. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  1688. $cache->clear();
  1689. }
  1690. $io->writeError('<info>All caches cleared.</info>');
  1691. }
  1692. }
  1693. <?php
  1694. namespace Composer\Command;
  1695. use Composer\Util\Platform;
  1696. use Composer\Util\Silencer;
  1697. use Symfony\Component\Console\Input\InputInterface;
  1698. use Symfony\Component\Console\Input\InputArgument;
  1699. use Symfony\Component\Console\Input\InputOption;
  1700. use Symfony\Component\Console\Output\OutputInterface;
  1701. use Composer\Config;
  1702. use Composer\Config\JsonConfigSource;
  1703. use Composer\Factory;
  1704. use Composer\Json\JsonFile;
  1705. use Composer\Semver\VersionParser;
  1706. use Composer\Package\BasePackage;
  1707. class ConfigCommand extends BaseCommand
  1708. {
  1709. protected $config;
  1710. protected $configFile;
  1711. protected $configSource;
  1712. protected $authConfigFile;
  1713. protected $authConfigSource;
  1714. protected function configure()
  1715. {
  1716. $this
  1717. ->setName('config')
  1718. ->setDescription('Sets config options.')
  1719. ->setDefinition(array(
  1720. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  1721. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  1722. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  1723. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  1724. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  1725. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  1726. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  1727. new InputArgument('setting-key', null, 'Setting key'),
  1728. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  1729. ))
  1730. ->setHelp(
  1731. <<<EOT
  1732. This command allows you to edit composer config settings and repositories
  1733. in either the local composer.json file or the global config.json file.
  1734. Additionally it lets you edit most properties in the local composer.json.
  1735. To set a config setting:
  1736. <comment>%command.full_name% bin-dir bin/</comment>
  1737. To read a config setting:
  1738. <comment>%command.full_name% bin-dir</comment>
  1739. Outputs: <info>bin</info>
  1740. To edit the global config.json file:
  1741. <comment>%command.full_name% --global</comment>
  1742. To add a repository:
  1743. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  1744. To remove a repository (repo is a short alias for repositories):
  1745. <comment>%command.full_name% --unset repo.foo</comment>
  1746. To disable packagist:
  1747. <comment>%command.full_name% repo.packagist false</comment>
  1748. You can alter repositories in the global config.json file by passing in the
  1749. <info>--global</info> option.
  1750. To edit the file in an external editor:
  1751. <comment>%command.full_name% --editor</comment>
  1752. To choose your editor you can set the "EDITOR" env variable.
  1753. To get a list of configuration values in the file:
  1754. <comment>%command.full_name% --list</comment>
  1755. You can always pass more than one option. As an example, if you want to edit the
  1756. global config.json file.
  1757. <comment>%command.full_name% --editor --global</comment>
  1758. EOT
  1759. )
  1760. ;
  1761. }
  1762. protected function initialize(InputInterface $input, OutputInterface $output)
  1763. {
  1764. parent::initialize($input, $output);
  1765. if ($input->getOption('global') && null !== $input->getOption('file')) {
  1766. throw new \RuntimeException('--file and --global can not be combined');
  1767. }
  1768. $io = $this->getIO();
  1769. $this->config = Factory::createConfig($io);
  1770. $configFile = $input->getOption('global')
  1771. ? ($this->config->get('home') . '/config.json')
  1772. : ($input->getOption('file') ?: Factory::getComposerFile());
  1773. if (
  1774. ($configFile === 'composer.json' || $configFile === './composer.json')
  1775. && !file_exists($configFile)
  1776. && realpath(getcwd()) === realpath($this->config->get('home'))
  1777. ) {
  1778. file_put_contents($configFile, "{\n}\n");
  1779. }
  1780. $this->configFile = new JsonFile($configFile, null, $io);
  1781. $this->configSource = new JsonConfigSource($this->configFile);
  1782. $authConfigFile = $input->getOption('global')
  1783. ? ($this->config->get('home') . '/auth.json')
  1784. : dirname(realpath($configFile)) . '/auth.json';
  1785. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  1786. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  1787. if ($input->getOption('global') && !$this->configFile->exists()) {
  1788. touch($this->configFile->getPath());
  1789. $this->configFile->write(array('config' => new \ArrayObject));
  1790. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  1791. }
  1792. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  1793. touch($this->authConfigFile->getPath());
  1794. $this->authConfigFile->write(array('bitbucket-oauth' => new \ArrayObject, 'github-oauth' => new \ArrayObject, 'gitlab-oauth' => new \ArrayObject, 'gitlab-token' => new \ArrayObject, 'http-basic' => new \ArrayObject));
  1795. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  1796. }
  1797. if (!$this->configFile->exists()) {
  1798. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  1799. }
  1800. }
  1801. protected function execute(InputInterface $input, OutputInterface $output)
  1802. {
  1803. if ($input->getOption('editor')) {
  1804. $editor = escapeshellcmd(getenv('EDITOR'));
  1805. if (!$editor) {
  1806. if (Platform::isWindows()) {
  1807. $editor = 'notepad';
  1808. } else {
  1809. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  1810. if (exec('which '.$candidate)) {
  1811. $editor = $candidate;
  1812. break;
  1813. }
  1814. }
  1815. }
  1816. }
  1817. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  1818. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  1819. return 0;
  1820. }
  1821. if (!$input->getOption('global')) {
  1822. $this->config->merge($this->configFile->read());
  1823. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
  1824. }
  1825. if ($input->getOption('list')) {
  1826. $this->listConfiguration($this->config->all(), $this->config->raw(), $output);
  1827. return 0;
  1828. }
  1829. $settingKey = $input->getArgument('setting-key');
  1830. if (!$settingKey) {
  1831. return 0;
  1832. }
  1833. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  1834. throw new \RuntimeException('You can not combine a setting value with --unset');
  1835. }
  1836. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  1837. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  1838. $rawData = $this->configFile->read();
  1839. $data = $this->config->all();
  1840. if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  1841. if (!isset($matches[1]) || $matches[1] === '') {
  1842. $value = isset($data['repositories']) ? $data['repositories'] : array();
  1843. } else {
  1844. if (!isset($data['repositories'][$matches[1]])) {
  1845. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  1846. }
  1847. $value = $data['repositories'][$matches[1]];
  1848. }
  1849. } elseif (strpos($settingKey, '.')) {
  1850. $bits = explode('.', $settingKey);
  1851. if ($bits[0] === 'extra') {
  1852. $data = $rawData;
  1853. } else {
  1854. $data = $data['config'];
  1855. }
  1856. $match = false;
  1857. foreach ($bits as $bit) {
  1858. $key = isset($key) ? $key.'.'.$bit : $bit;
  1859. $match = false;
  1860. if (isset($data[$key])) {
  1861. $match = true;
  1862. $data = $data[$key];
  1863. unset($key);
  1864. }
  1865. }
  1866. if (!$match) {
  1867. throw new \RuntimeException($settingKey.' is not defined.');
  1868. }
  1869. $value = $data;
  1870. } elseif (isset($data['config'][$settingKey])) {
  1871. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  1872. } elseif (in_array($settingKey, $properties, true) && isset($rawData[$settingKey])) {
  1873. $value = $rawData[$settingKey];
  1874. } else {
  1875. throw new \RuntimeException($settingKey.' is not defined');
  1876. }
  1877. if (is_array($value)) {
  1878. $value = json_encode($value);
  1879. }
  1880. $this->getIO()->write($value);
  1881. return 0;
  1882. }
  1883. $values = $input->getArgument('setting-value');
  1884. $booleanValidator = function ($val) {
  1885. return in_array($val, array('true', 'false', '1', '0'), true);
  1886. };
  1887. $booleanNormalizer = function ($val) {
  1888. return $val !== 'false' && (bool) $val;
  1889. };
  1890. $uniqueConfigValues = array(
  1891. 'process-timeout' => array('is_numeric', 'intval'),
  1892. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  1893. 'preferred-install' => array(
  1894. function ($val) {
  1895. return in_array($val, array('auto', 'source', 'dist'), true);
  1896. },
  1897. function ($val) {
  1898. return $val;
  1899. },
  1900. ),
  1901. 'store-auths' => array(
  1902. function ($val) {
  1903. return in_array($val, array('true', 'false', 'prompt'), true);
  1904. },
  1905. function ($val) {
  1906. if ('prompt' === $val) {
  1907. return 'prompt';
  1908. }
  1909. return $val !== 'false' && (bool) $val;
  1910. },
  1911. ),
  1912. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  1913. 'vendor-dir' => array('is_string', function ($val) {
  1914. return $val;
  1915. }),
  1916. 'bin-dir' => array('is_string', function ($val) {
  1917. return $val;
  1918. }),
  1919. 'archive-dir' => array('is_string', function ($val) {
  1920. return $val;
  1921. }),
  1922. 'archive-format' => array('is_string', function ($val) {
  1923. return $val;
  1924. }),
  1925. 'data-dir' => array('is_string', function ($val) {
  1926. return $val;
  1927. }),
  1928. 'cache-dir' => array('is_string', function ($val) {
  1929. return $val;
  1930. }),
  1931. 'cache-files-dir' => array('is_string', function ($val) {
  1932. return $val;
  1933. }),
  1934. 'cache-repo-dir' => array('is_string', function ($val) {
  1935. return $val;
  1936. }),
  1937. 'cache-vcs-dir' => array('is_string', function ($val) {
  1938. return $val;
  1939. }),
  1940. 'cache-ttl' => array('is_numeric', 'intval'),
  1941. 'cache-files-ttl' => array('is_numeric', 'intval'),
  1942. 'cache-files-maxsize' => array(
  1943. function ($val) {
  1944. return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0;
  1945. },
  1946. function ($val) {
  1947. return $val;
  1948. },
  1949. ),
  1950. 'bin-compat' => array(
  1951. function ($val) {
  1952. return in_array($val, array('auto', 'full'));
  1953. },
  1954. function ($val) {
  1955. return $val;
  1956. },
  1957. ),
  1958. 'discard-changes' => array(
  1959. function ($val) {
  1960. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  1961. },
  1962. function ($val) {
  1963. if ('stash' === $val) {
  1964. return 'stash';
  1965. }
  1966. return $val !== 'false' && (bool) $val;
  1967. },
  1968. ),
  1969. 'autoloader-suffix' => array('is_string', function ($val) {
  1970. return $val === 'null' ? null : $val;
  1971. }),
  1972. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  1973. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  1974. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  1975. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  1976. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  1977. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  1978. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  1979. 'cafile' => array(
  1980. function ($val) {
  1981. return file_exists($val) && is_readable($val);
  1982. },
  1983. function ($val) {
  1984. return $val === 'null' ? null : $val;
  1985. },
  1986. ),
  1987. 'capath' => array(
  1988. function ($val) {
  1989. return is_dir($val) && is_readable($val);
  1990. },
  1991. function ($val) {
  1992. return $val === 'null' ? null : $val;
  1993. },
  1994. ),
  1995. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  1996. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  1997. );
  1998. $multiConfigValues = array(
  1999. 'github-protocols' => array(
  2000. function ($vals) {
  2001. if (!is_array($vals)) {
  2002. return 'array expected';
  2003. }
  2004. foreach ($vals as $val) {
  2005. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2006. return 'valid protocols include: git, https, ssh';
  2007. }
  2008. }
  2009. return true;
  2010. },
  2011. function ($vals) {
  2012. return $vals;
  2013. },
  2014. ),
  2015. 'github-domains' => array(
  2016. function ($vals) {
  2017. if (!is_array($vals)) {
  2018. return 'array expected';
  2019. }
  2020. return true;
  2021. },
  2022. function ($vals) {
  2023. return $vals;
  2024. },
  2025. ),
  2026. 'gitlab-domains' => array(
  2027. function ($vals) {
  2028. if (!is_array($vals)) {
  2029. return 'array expected';
  2030. }
  2031. return true;
  2032. },
  2033. function ($vals) {
  2034. return $vals;
  2035. },
  2036. ),
  2037. );
  2038. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2039. return $this->configSource->removeConfigSetting($settingKey);
  2040. }
  2041. if (isset($uniqueConfigValues[$settingKey])) {
  2042. return $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2043. }
  2044. if (isset($multiConfigValues[$settingKey])) {
  2045. return $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2046. }
  2047. $uniqueProps = array(
  2048. 'name' => array('is_string', function ($val) {
  2049. return $val;
  2050. }),
  2051. 'type' => array('is_string', function ($val) {
  2052. return $val;
  2053. }),
  2054. 'description' => array('is_string', function ($val) {
  2055. return $val;
  2056. }),
  2057. 'homepage' => array('is_string', function ($val) {
  2058. return $val;
  2059. }),
  2060. 'version' => array('is_string', function ($val) {
  2061. return $val;
  2062. }),
  2063. 'minimum-stability' => array(
  2064. function ($val) {
  2065. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2066. },
  2067. function ($val) {
  2068. return VersionParser::normalizeStability($val);
  2069. },
  2070. ),
  2071. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2072. );
  2073. $multiProps = array(
  2074. 'keywords' => array(
  2075. function ($vals) {
  2076. if (!is_array($vals)) {
  2077. return 'array expected';
  2078. }
  2079. return true;
  2080. },
  2081. function ($vals) {
  2082. return $vals;
  2083. },
  2084. ),
  2085. 'license' => array(
  2086. function ($vals) {
  2087. if (!is_array($vals)) {
  2088. return 'array expected';
  2089. }
  2090. return true;
  2091. },
  2092. function ($vals) {
  2093. return $vals;
  2094. },
  2095. ),
  2096. );
  2097. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || substr($settingKey, 0, 6) === 'extra.')) {
  2098. 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');
  2099. }
  2100. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2101. return $this->configSource->removeProperty($settingKey);
  2102. }
  2103. if (isset($uniqueProps[$settingKey])) {
  2104. return $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2105. }
  2106. if (isset($multiProps[$settingKey])) {
  2107. return $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2108. }
  2109. if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2110. if ($input->getOption('unset')) {
  2111. return $this->configSource->removeRepository($matches[1]);
  2112. }
  2113. if (2 === count($values)) {
  2114. return $this->configSource->addRepository($matches[1], array(
  2115. 'type' => $values[0],
  2116. 'url' => $values[1],
  2117. ));
  2118. }
  2119. if (1 === count($values)) {
  2120. $value = strtolower($values[0]);
  2121. if (true === $booleanValidator($value)) {
  2122. if (false === $booleanNormalizer($value)) {
  2123. return $this->configSource->addRepository($matches[1], false);
  2124. }
  2125. } else {
  2126. $value = JsonFile::parseJson($values[0]);
  2127. return $this->configSource->addRepository($matches[1], $value);
  2128. }
  2129. }
  2130. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2131. }
  2132. if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
  2133. if ($input->getOption('unset')) {
  2134. return $this->configSource->removeProperty($settingKey);
  2135. }
  2136. return $this->configSource->addProperty($settingKey, $values[0]);
  2137. }
  2138. if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
  2139. if ($input->getOption('unset')) {
  2140. return $this->configSource->removeConfigSetting($settingKey);
  2141. }
  2142. return $this->configSource->addConfigSetting($settingKey, $values[0]);
  2143. }
  2144. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2145. return $this->configSource->removeConfigSetting($settingKey);
  2146. }
  2147. if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic)\.(.+)/', $settingKey, $matches)) {
  2148. if ($input->getOption('unset')) {
  2149. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2150. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2151. return;
  2152. }
  2153. if ($matches[1] === 'bitbucket-oauth') {
  2154. if (2 !== count($values)) {
  2155. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2156. }
  2157. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2158. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2159. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token'), true)) {
  2160. if (1 !== count($values)) {
  2161. throw new \RuntimeException('Too many arguments, expected only one token');
  2162. }
  2163. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2164. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2165. } elseif ($matches[1] === 'http-basic') {
  2166. if (2 !== count($values)) {
  2167. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2168. }
  2169. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2170. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2171. }
  2172. return;
  2173. }
  2174. if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
  2175. if ($input->getOption('unset')) {
  2176. return $this->configSource->removeProperty($settingKey);
  2177. }
  2178. return $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2179. }
  2180. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2181. }
  2182. protected function handleSingleValue($key, array $callbacks, array $values, $method)
  2183. {
  2184. list($validator, $normalizer) = $callbacks;
  2185. if (1 !== count($values)) {
  2186. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2187. }
  2188. if (true !== $validation = $validator($values[0])) {
  2189. throw new \RuntimeException(sprintf(
  2190. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2191. $values[0]
  2192. ));
  2193. }
  2194. return call_user_func(array($this->configSource, $method), $key, $normalizer($values[0]));
  2195. }
  2196. protected function handleMultiValue($key, array $callbacks, array $values, $method)
  2197. {
  2198. list($validator, $normalizer) = $callbacks;
  2199. if (true !== $validation = $validator($values)) {
  2200. throw new \RuntimeException(sprintf(
  2201. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2202. json_encode($values)
  2203. ));
  2204. }
  2205. return call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2206. }
  2207. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
  2208. {
  2209. $origK = $k;
  2210. $io = $this->getIO();
  2211. foreach ($contents as $key => $value) {
  2212. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2213. continue;
  2214. }
  2215. $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
  2216. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2217. $k .= preg_replace('{^config\.}', '', $key . '.');
  2218. $this->listConfiguration($value, $rawVal, $output, $k);
  2219. $k = $origK;
  2220. continue;
  2221. }
  2222. if (is_array($value)) {
  2223. $value = array_map(function ($val) {
  2224. return is_array($val) ? json_encode($val) : $val;
  2225. }, $value);
  2226. $value = '['.implode(', ', $value).']';
  2227. }
  2228. if (is_bool($value)) {
  2229. $value = var_export($value, true);
  2230. }
  2231. if (is_string($rawVal) && $rawVal != $value) {
  2232. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
  2233. } else {
  2234. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
  2235. }
  2236. }
  2237. }
  2238. }
  2239. <?php
  2240. namespace Composer\Command;
  2241. use Composer\Config;
  2242. use Composer\Factory;
  2243. use Composer\Installer;
  2244. use Composer\Installer\ProjectInstaller;
  2245. use Composer\Installer\InstallationManager;
  2246. use Composer\Installer\SuggestedPackagesReporter;
  2247. use Composer\IO\IOInterface;
  2248. use Composer\Package\BasePackage;
  2249. use Composer\DependencyResolver\Pool;
  2250. use Composer\DependencyResolver\Operation\InstallOperation;
  2251. use Composer\Package\Version\VersionSelector;
  2252. use Composer\Package\AliasPackage;
  2253. use Composer\Repository\RepositoryFactory;
  2254. use Composer\Repository\CompositeRepository;
  2255. use Composer\Repository\PlatformRepository;
  2256. use Composer\Repository\InstalledFilesystemRepository;
  2257. use Composer\Script\ScriptEvents;
  2258. use Composer\Util\Silencer;
  2259. use Symfony\Component\Console\Input\InputArgument;
  2260. use Symfony\Component\Console\Input\InputInterface;
  2261. use Symfony\Component\Console\Input\InputOption;
  2262. use Symfony\Component\Console\Output\OutputInterface;
  2263. use Symfony\Component\Finder\Finder;
  2264. use Composer\Json\JsonFile;
  2265. use Composer\Config\JsonConfigSource;
  2266. use Composer\Util\Filesystem;
  2267. use Composer\Package\Version\VersionParser;
  2268. class CreateProjectCommand extends BaseCommand
  2269. {
  2270. protected $suggestedPackagesReporter;
  2271. protected function configure()
  2272. {
  2273. $this
  2274. ->setName('create-project')
  2275. ->setDescription('Creates new project from a package into given directory.')
  2276. ->setDefinition(array(
  2277. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  2278. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  2279. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  2280. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  2281. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  2282. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  2283. new InputOption('repository', null, InputOption::VALUE_REQUIRED, 'Pick a different repository (as url or json config) to look for the package.'),
  2284. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  2285. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  2286. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  2287. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  2288. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  2289. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  2290. 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.'),
  2291. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  2292. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  2293. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  2294. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'),
  2295. ))
  2296. ->setHelp(
  2297. <<<EOT
  2298. The <info>create-project</info> command creates a new project from a given
  2299. package into a new directory. If executed without params and in a directory
  2300. with a composer.json file it installs the packages for the current project.
  2301. You can use this command to bootstrap new projects or setup a clean
  2302. version-controlled installation for developers of your project.
  2303. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  2304. You can also specify the version with the package name using = or : as separator.
  2305. <info>php composer.phar create-project vendor/project:version target-directory</info>
  2306. To install unstable packages, either specify the version you want, or use the
  2307. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  2308. To setup a developer workable version you should create the project using the source
  2309. controlled code by appending the <info>'--prefer-source'</info> flag.
  2310. To install a package from another repository than the default one you
  2311. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  2312. EOT
  2313. )
  2314. ;
  2315. }
  2316. protected function execute(InputInterface $input, OutputInterface $output)
  2317. {
  2318. $config = Factory::createConfig();
  2319. $io = $this->getIO();
  2320. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  2321. if ($input->getOption('dev')) {
  2322. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  2323. }
  2324. if ($input->getOption('no-custom-installers')) {
  2325. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  2326. $input->setOption('no-plugins', true);
  2327. }
  2328. return $this->installProject(
  2329. $io,
  2330. $config,
  2331. $input,
  2332. $input->getArgument('package'),
  2333. $input->getArgument('directory'),
  2334. $input->getArgument('version'),
  2335. $input->getOption('stability'),
  2336. $preferSource,
  2337. $preferDist,
  2338. !$input->getOption('no-dev'),
  2339. $input->getOption('repository') ?: $input->getOption('repository-url'),
  2340. $input->getOption('no-plugins'),
  2341. $input->getOption('no-scripts'),
  2342. $input->getOption('no-progress'),
  2343. $input->getOption('no-install'),
  2344. $input->getOption('ignore-platform-reqs'),
  2345. !$input->getOption('no-secure-http')
  2346. );
  2347. }
  2348. public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repository = null, $disablePlugins = false, $noScripts = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, $secureHttp = true)
  2349. {
  2350. $oldCwd = getcwd();
  2351. $io->loadConfiguration($config);
  2352. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  2353. if ($packageName !== null) {
  2354. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repository, $disablePlugins, $noScripts, $noProgress, $ignorePlatformReqs, $secureHttp);
  2355. } else {
  2356. $installedFromVcs = false;
  2357. }
  2358. $composer = Factory::create($io, null, $disablePlugins);
  2359. $composer->getDownloadManager()->setOutputProgress(!$noProgress);
  2360. $fs = new Filesystem();
  2361. if ($noScripts === false) {
  2362. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  2363. }
  2364. $config = $composer->getConfig();
  2365. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  2366. if ($noInstall === false) {
  2367. $installer = Installer::create($io, $composer);
  2368. $installer->setPreferSource($preferSource)
  2369. ->setPreferDist($preferDist)
  2370. ->setDevMode($installDevPackages)
  2371. ->setRunScripts(!$noScripts)
  2372. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  2373. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  2374. ->setOptimizeAutoloader($config->get('optimize-autoloader'));
  2375. if ($disablePlugins) {
  2376. $installer->disablePlugins();
  2377. }
  2378. $status = $installer->run();
  2379. if (0 !== $status) {
  2380. return $status;
  2381. }
  2382. }
  2383. $hasVcs = $installedFromVcs;
  2384. if (
  2385. !$input->getOption('keep-vcs')
  2386. && $installedFromVcs
  2387. && (
  2388. $input->getOption('remove-vcs')
  2389. || !$io->isInteractive()
  2390. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ', true)
  2391. )
  2392. ) {
  2393. $finder = new Finder();
  2394. $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
  2395. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  2396. $finder->name($vcsName);
  2397. }
  2398. try {
  2399. $dirs = iterator_to_array($finder);
  2400. unset($finder);
  2401. foreach ($dirs as $dir) {
  2402. if (!$fs->removeDirectory($dir)) {
  2403. throw new \RuntimeException('Could not remove '.$dir);
  2404. }
  2405. }
  2406. } catch (\Exception $e) {
  2407. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  2408. }
  2409. $hasVcs = false;
  2410. }
  2411. if (!$hasVcs) {
  2412. $package = $composer->getPackage();
  2413. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2414. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  2415. foreach ($package->{'get'.$meta['method']}() as $link) {
  2416. if ($link->getPrettyConstraint() === 'self.version') {
  2417. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  2418. }
  2419. }
  2420. }
  2421. }
  2422. if ($noScripts === false) {
  2423. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  2424. }
  2425. chdir($oldCwd);
  2426. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  2427. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  2428. Silencer::call('rmdir', $vendorComposerDir);
  2429. $vendorDir = $config->get('vendor-dir');
  2430. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  2431. Silencer::call('rmdir', $vendorDir);
  2432. }
  2433. }
  2434. return 0;
  2435. }
  2436. protected function installRootPackage(IOInterface $io, Config $config, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repository = null, $disablePlugins = false, $noScripts = false, $noProgress = false, $ignorePlatformReqs = false, $secureHttp = true)
  2437. {
  2438. if (!$secureHttp) {
  2439. $config->merge(array('config' => array('secure-http' => false)));
  2440. }
  2441. if (null === $repository) {
  2442. $sourceRepo = new CompositeRepository(RepositoryFactory::defaultRepos($io, $config));
  2443. } else {
  2444. $sourceRepo = RepositoryFactory::fromString($io, $config, $repository, true);
  2445. }
  2446. $parser = new VersionParser();
  2447. $requirements = $parser->parseNameVersionPairs(array($packageName));
  2448. $name = strtolower($requirements[0]['name']);
  2449. if (!$packageVersion && isset($requirements[0]['version'])) {
  2450. $packageVersion = $requirements[0]['version'];
  2451. }
  2452. if (null === $stability) {
  2453. if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  2454. $stability = $match[1];
  2455. } else {
  2456. $stability = VersionParser::parseStability($packageVersion);
  2457. }
  2458. }
  2459. $stability = VersionParser::normalizeStability($stability);
  2460. if (!isset(BasePackage::$stabilities[$stability])) {
  2461. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  2462. }
  2463. $pool = new Pool($stability);
  2464. $pool->addRepository($sourceRepo);
  2465. $phpVersion = null;
  2466. $prettyPhpVersion = null;
  2467. if (!$ignorePlatformReqs) {
  2468. $platformOverrides = $config->get('platform') ?: array();
  2469. $platform = new PlatformRepository(array(), $platformOverrides);
  2470. $phpPackage = $platform->findPackage('php', '*');
  2471. $phpVersion = $phpPackage->getVersion();
  2472. $prettyPhpVersion = $phpPackage->getPrettyVersion();
  2473. }
  2474. $versionSelector = new VersionSelector($pool);
  2475. $package = $versionSelector->findBestCandidate($name, $packageVersion, $phpVersion, $stability);
  2476. if (!$package) {
  2477. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  2478. if ($phpVersion && $versionSelector->findBestCandidate($name, $packageVersion, null, $stability)) {
  2479. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version '.$prettyPhpVersion.'.');
  2480. }
  2481. throw new \InvalidArgumentException($errorMessage .'.');
  2482. }
  2483. if (null === $directory) {
  2484. $parts = explode("/", $name, 2);
  2485. $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  2486. }
  2487. if (function_exists('pcntl_async_signals')) {
  2488. @mkdir($directory, 0777, true);
  2489. if ($realDir = realpath($directory)) {
  2490. pcntl_async_signals(true);
  2491. pcntl_signal(SIGINT, function () use ($realDir) {
  2492. $fs = new Filesystem();
  2493. $fs->removeDirectory($realDir);
  2494. exit(130);
  2495. });
  2496. }
  2497. }
  2498. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  2499. if ($disablePlugins) {
  2500. $io->writeError('<info>Plugins have been disabled.</info>');
  2501. }
  2502. if ($package instanceof AliasPackage) {
  2503. $package = $package->getAliasOf();
  2504. }
  2505. $dm = $this->createDownloadManager($io, $config);
  2506. $dm->setPreferSource($preferSource)
  2507. ->setPreferDist($preferDist)
  2508. ->setOutputProgress(!$noProgress);
  2509. $projectInstaller = new ProjectInstaller($directory, $dm);
  2510. $im = $this->createInstallationManager();
  2511. $im->addInstaller($projectInstaller);
  2512. $im->install(new InstalledFilesystemRepository(new JsonFile('php://memory')), new InstallOperation($package));
  2513. $im->notifyInstalls($io);
  2514. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  2515. $installedFromVcs = 'source' === $package->getInstallationSource();
  2516. $io->writeError('<info>Created project in ' . $directory . '</info>');
  2517. chdir($directory);
  2518. $_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion();
  2519. putenv('COMPOSER_ROOT_VERSION='.$_SERVER['COMPOSER_ROOT_VERSION']);
  2520. return $installedFromVcs;
  2521. }
  2522. protected function createDownloadManager(IOInterface $io, Config $config)
  2523. {
  2524. $factory = new Factory();
  2525. return $factory->createDownloadManager($io, $config);
  2526. }
  2527. protected function createInstallationManager()
  2528. {
  2529. return new InstallationManager();
  2530. }
  2531. }
  2532. <?php
  2533. namespace Composer\Command;
  2534. use Symfony\Component\Console\Input\InputInterface;
  2535. use Symfony\Component\Console\Output\OutputInterface;
  2536. class DependsCommand extends BaseDependencyCommand
  2537. {
  2538. protected function configure()
  2539. {
  2540. parent::configure();
  2541. $this
  2542. ->setName('depends')
  2543. ->setAliases(array('why'))
  2544. ->setDescription('Shows which packages cause the given package to be installed.')
  2545. ->setHelp(
  2546. <<<EOT
  2547. Displays detailed information about where a package is referenced.
  2548. <info>php composer.phar depends composer/composer</info>
  2549. EOT
  2550. )
  2551. ;
  2552. }
  2553. protected function execute(InputInterface $input, OutputInterface $output)
  2554. {
  2555. return parent::doExecute($input, $output, false);
  2556. }
  2557. }
  2558. <?php
  2559. namespace Composer\Command;
  2560. use Composer\Composer;
  2561. use Composer\Factory;
  2562. use Composer\Config;
  2563. use Composer\Downloader\TransportException;
  2564. use Composer\Repository\PlatformRepository;
  2565. use Composer\Plugin\CommandEvent;
  2566. use Composer\Plugin\PluginEvents;
  2567. use Composer\Util\ConfigValidator;
  2568. use Composer\Util\IniHelper;
  2569. use Composer\Util\ProcessExecutor;
  2570. use Composer\Util\RemoteFilesystem;
  2571. use Composer\Util\StreamContextFactory;
  2572. use Composer\SelfUpdate\Keys;
  2573. use Composer\SelfUpdate\Versions;
  2574. use Composer\IO\NullIO;
  2575. use Symfony\Component\Console\Input\InputInterface;
  2576. use Symfony\Component\Console\Output\OutputInterface;
  2577. class DiagnoseCommand extends BaseCommand
  2578. {
  2579. protected $rfs;
  2580. protected $process;
  2581. protected $exitCode = 0;
  2582. protected function configure()
  2583. {
  2584. $this
  2585. ->setName('diagnose')
  2586. ->setDescription('Diagnoses the system to identify common errors.')
  2587. ->setHelp(
  2588. <<<EOT
  2589. The <info>diagnose</info> command checks common errors to help debugging problems.
  2590. The process exit code will be 1 in case of warnings and 2 for errors.
  2591. EOT
  2592. )
  2593. ;
  2594. }
  2595. protected function execute(InputInterface $input, OutputInterface $output)
  2596. {
  2597. $composer = $this->getComposer(false);
  2598. $io = $this->getIO();
  2599. if ($composer) {
  2600. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  2601. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  2602. $io->write('Checking composer.json: ', false);
  2603. $this->outputResult($this->checkComposerSchema());
  2604. }
  2605. if ($composer) {
  2606. $config = $composer->getConfig();
  2607. } else {
  2608. $config = Factory::createConfig();
  2609. }
  2610. $config->merge(array('config' => array('secure-http' => false)));
  2611. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  2612. $this->rfs = Factory::createRemoteFilesystem($io, $config);
  2613. $this->process = new ProcessExecutor($io);
  2614. $io->write('Checking platform settings: ', false);
  2615. $this->outputResult($this->checkPlatform());
  2616. $io->write('Checking git settings: ', false);
  2617. $this->outputResult($this->checkGit());
  2618. $io->write('Checking http connectivity to packagist: ', false);
  2619. $this->outputResult($this->checkHttp('http', $config));
  2620. $io->write('Checking https connectivity to packagist: ', false);
  2621. $this->outputResult($this->checkHttp('https', $config));
  2622. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  2623. if (!empty($opts['http']['proxy'])) {
  2624. $io->write('Checking HTTP proxy: ', false);
  2625. $this->outputResult($this->checkHttpProxy());
  2626. $io->write('Checking HTTP proxy support for request_fulluri: ', false);
  2627. $this->outputResult($this->checkHttpProxyFullUriRequestParam());
  2628. $io->write('Checking HTTPS proxy support for request_fulluri: ', false);
  2629. $this->outputResult($this->checkHttpsProxyFullUriRequestParam());
  2630. }
  2631. if ($oauth = $config->get('github-oauth')) {
  2632. foreach ($oauth as $domain => $token) {
  2633. $io->write('Checking '.$domain.' oauth access: ', false);
  2634. $this->outputResult($this->checkGithubOauth($domain, $token));
  2635. }
  2636. } else {
  2637. $io->write('Checking github.com rate limit: ', false);
  2638. try {
  2639. $rate = $this->getGithubRateLimit('github.com');
  2640. if (!is_array($rate)) {
  2641. $this->outputResult($rate);
  2642. } elseif (10 > $rate['remaining']) {
  2643. $io->write('<warning>WARNING</warning>');
  2644. $io->write(sprintf(
  2645. '<comment>Github has a rate limit on their API. '
  2646. . 'You currently have <options=bold>%u</options=bold> '
  2647. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  2648. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  2649. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  2650. $rate['remaining'],
  2651. $rate['limit']
  2652. ));
  2653. } else {
  2654. $this->outputResult(true);
  2655. }
  2656. } catch (\Exception $e) {
  2657. if ($e instanceof TransportException && $e->getCode() === 401) {
  2658. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  2659. } else {
  2660. $this->outputResult($e);
  2661. }
  2662. }
  2663. }
  2664. $io->write('Checking disk free space: ', false);
  2665. $this->outputResult($this->checkDiskSpace($config));
  2666. if ('phar:' === substr(__FILE__, 0, 5)) {
  2667. $io->write('Checking pubkeys: ', false);
  2668. $this->outputResult($this->checkPubKeys($config));
  2669. $io->write('Checking composer version: ', false);
  2670. $this->outputResult($this->checkVersion($config));
  2671. }
  2672. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::VERSION));
  2673. $platformOverrides = $config->get('platform') ?: array();
  2674. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  2675. $phpPkg = $platformRepo->findPackage('php', '*');
  2676. $phpVersion = $phpPkg->getPrettyVersion();
  2677. if (false !== strpos($phpPkg->getDescription(), 'overridden')) {
  2678. $phpVersion .= ' - ' . $phpPkg->getDescription();
  2679. }
  2680. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  2681. if (defined('PHP_BINARY')) {
  2682. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  2683. }
  2684. return $this->exitCode;
  2685. }
  2686. private function checkComposerSchema()
  2687. {
  2688. $validator = new ConfigValidator($this->getIO());
  2689. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  2690. if ($errors || $warnings) {
  2691. $messages = array(
  2692. 'error' => $errors,
  2693. 'warning' => $warnings,
  2694. );
  2695. $output = '';
  2696. foreach ($messages as $style => $msgs) {
  2697. foreach ($msgs as $msg) {
  2698. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  2699. }
  2700. }
  2701. return rtrim($output);
  2702. }
  2703. return true;
  2704. }
  2705. private function checkGit()
  2706. {
  2707. $this->process->execute('git config color.ui', $output);
  2708. if (strtolower(trim($output)) === 'always') {
  2709. 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>';
  2710. }
  2711. return true;
  2712. }
  2713. private function checkHttp($proto, Config $config)
  2714. {
  2715. $result = $this->checkConnectivity();
  2716. if ($result !== true) {
  2717. return $result;
  2718. }
  2719. $disableTls = false;
  2720. $result = array();
  2721. if ($proto === 'https' && $config->get('disable-tls') === true) {
  2722. $disableTls = true;
  2723. $result[] = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  2724. }
  2725. if ($proto === 'https' && !extension_loaded('openssl') && !$disableTls) {
  2726. $result[] = '<error>Composer is configured to use SSL/TLS protection but the openssl extension is not available.</error>';
  2727. }
  2728. try {
  2729. $this->rfs->getContents('packagist.org', $proto . '://repo.packagist.org/packages.json', false);
  2730. } catch (TransportException $e) {
  2731. if (false !== strpos($e->getMessage(), 'cafile')) {
  2732. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  2733. $result[] = '<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>';
  2734. $result[] = '<error>You can alternatively disable this error, at your own risk, by enabling the \'disable-tls\' option.</error>';
  2735. } else {
  2736. array_unshift($result, '[' . get_class($e) . '] ' . $e->getMessage());
  2737. }
  2738. }
  2739. if (count($result) > 0) {
  2740. return $result;
  2741. }
  2742. return true;
  2743. }
  2744. private function checkHttpProxy()
  2745. {
  2746. $result = $this->checkConnectivity();
  2747. if ($result !== true) {
  2748. return $result;
  2749. }
  2750. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  2751. try {
  2752. $json = json_decode($this->rfs->getContents('packagist.org', $protocol . '://repo.packagist.org/packages.json', false), true);
  2753. $hash = reset($json['provider-includes']);
  2754. $hash = $hash['sha256'];
  2755. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  2756. $provider = $this->rfs->getContents('packagist.org', $protocol . '://repo.packagist.org/'.$path, false);
  2757. if (hash('sha256', $provider) !== $hash) {
  2758. return 'It seems that your proxy is modifying http traffic on the fly';
  2759. }
  2760. } catch (\Exception $e) {
  2761. return $e;
  2762. }
  2763. return true;
  2764. }
  2765. private function checkHttpProxyFullUriRequestParam()
  2766. {
  2767. $result = $this->checkConnectivity();
  2768. if ($result !== true) {
  2769. return $result;
  2770. }
  2771. $url = 'http://repo.packagist.org/packages.json';
  2772. try {
  2773. $this->rfs->getContents('packagist.org', $url, false);
  2774. } catch (TransportException $e) {
  2775. try {
  2776. $this->rfs->getContents('packagist.org', $url, false, array('http' => array('request_fulluri' => false)));
  2777. } catch (TransportException $e) {
  2778. return 'Unable to assess the situation, maybe packagist.org is down ('.$e->getMessage().')';
  2779. }
  2780. return 'It seems there is a problem with your proxy server, try setting the "HTTP_PROXY_REQUEST_FULLURI" and "HTTPS_PROXY_REQUEST_FULLURI" environment variables to "false"';
  2781. }
  2782. return true;
  2783. }
  2784. private function checkHttpsProxyFullUriRequestParam()
  2785. {
  2786. $result = $this->checkConnectivity();
  2787. if ($result !== true) {
  2788. return $result;
  2789. }
  2790. if (!extension_loaded('openssl')) {
  2791. return 'You need the openssl extension installed for this check';
  2792. }
  2793. $url = 'https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0';
  2794. try {
  2795. $this->rfs->getContents('github.com', $url, false);
  2796. } catch (TransportException $e) {
  2797. try {
  2798. $this->rfs->getContents('github.com', $url, false, array('http' => array('request_fulluri' => false)));
  2799. } catch (TransportException $e) {
  2800. return 'Unable to assess the situation, maybe github is down ('.$e->getMessage().')';
  2801. }
  2802. return 'It seems there is a problem with your proxy server, try setting the "HTTPS_PROXY_REQUEST_FULLURI" environment variable to "false"';
  2803. }
  2804. return true;
  2805. }
  2806. private function checkGithubOauth($domain, $token)
  2807. {
  2808. $result = $this->checkConnectivity();
  2809. if ($result !== true) {
  2810. return $result;
  2811. }
  2812. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  2813. try {
  2814. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  2815. return $this->rfs->getContents($domain, $url, false, array(
  2816. 'retry-auth-failure' => false,
  2817. )) ? true : 'Unexpected error';
  2818. } catch (\Exception $e) {
  2819. if ($e instanceof TransportException && $e->getCode() === 401) {
  2820. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  2821. }
  2822. return $e;
  2823. }
  2824. }
  2825. private function getGithubRateLimit($domain, $token = null)
  2826. {
  2827. $result = $this->checkConnectivity();
  2828. if ($result !== true) {
  2829. return $result;
  2830. }
  2831. if ($token) {
  2832. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  2833. }
  2834. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  2835. $json = $this->rfs->getContents($domain, $url, false, array('retry-auth-failure' => false));
  2836. $data = json_decode($json, true);
  2837. return $data['resources']['core'];
  2838. }
  2839. private function checkDiskSpace($config)
  2840. {
  2841. $minSpaceFree = 1024 * 1024;
  2842. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  2843. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  2844. ) {
  2845. return '<error>The disk hosting '.$dir.' is full</error>';
  2846. }
  2847. return true;
  2848. }
  2849. private function checkPubKeys($config)
  2850. {
  2851. $home = $config->get('home');
  2852. $errors = array();
  2853. $io = $this->getIO();
  2854. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  2855. $io->write('');
  2856. }
  2857. if (file_exists($home.'/keys.tags.pub')) {
  2858. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  2859. } else {
  2860. $errors[] = '<error>Missing pubkey for tags verification</error>';
  2861. }
  2862. if (file_exists($home.'/keys.dev.pub')) {
  2863. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  2864. } else {
  2865. $errors[] = '<error>Missing pubkey for dev verification</error>';
  2866. }
  2867. if ($errors) {
  2868. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  2869. }
  2870. return $errors ?: true;
  2871. }
  2872. private function checkVersion($config)
  2873. {
  2874. $result = $this->checkConnectivity();
  2875. if ($result !== true) {
  2876. return $result;
  2877. }
  2878. $versionsUtil = new Versions($config, $this->rfs);
  2879. $latest = $versionsUtil->getLatest();
  2880. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  2881. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  2882. }
  2883. return true;
  2884. }
  2885. private function outputResult($result)
  2886. {
  2887. $io = $this->getIO();
  2888. if (true === $result) {
  2889. $io->write('<info>OK</info>');
  2890. return;
  2891. }
  2892. $hadError = false;
  2893. $hadWarning = false;
  2894. if ($result instanceof \Exception) {
  2895. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  2896. }
  2897. if (!$result) {
  2898. $hadError = true;
  2899. } else {
  2900. if (!is_array($result)) {
  2901. $result = array($result);
  2902. }
  2903. foreach ($result as $message) {
  2904. if (false !== strpos($message, '<error>')) {
  2905. $hadError = true;
  2906. } elseif (false !== strpos($message, '<warning>')) {
  2907. $hadWarning = true;
  2908. }
  2909. }
  2910. }
  2911. if ($hadError) {
  2912. $io->write('<error>FAIL</error>');
  2913. $this->exitCode = max($this->exitCode, 2);
  2914. } elseif ($hadWarning) {
  2915. $io->write('<warning>WARNING</warning>');
  2916. $this->exitCode = max($this->exitCode, 1);
  2917. }
  2918. if ($result) {
  2919. foreach ($result as $message) {
  2920. $io->write($message);
  2921. }
  2922. }
  2923. }
  2924. private function checkPlatform()
  2925. {
  2926. $output = '';
  2927. $out = function ($msg, $style) use (&$output) {
  2928. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  2929. };
  2930. $errors = array();
  2931. $warnings = array();
  2932. $displayIniMessage = false;
  2933. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  2934. $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.';
  2935. if (!function_exists('json_decode')) {
  2936. $errors['json'] = true;
  2937. }
  2938. if (!extension_loaded('Phar')) {
  2939. $errors['phar'] = true;
  2940. }
  2941. if (!extension_loaded('filter')) {
  2942. $errors['filter'] = true;
  2943. }
  2944. if (!extension_loaded('hash')) {
  2945. $errors['hash'] = true;
  2946. }
  2947. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  2948. $errors['iconv_mbstring'] = true;
  2949. }
  2950. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  2951. $errors['allow_url_fopen'] = true;
  2952. }
  2953. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  2954. $errors['ioncube'] = ioncube_loader_version();
  2955. }
  2956. if (PHP_VERSION_ID < 50302) {
  2957. $errors['php'] = PHP_VERSION;
  2958. }
  2959. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  2960. $warnings['php'] = PHP_VERSION;
  2961. }
  2962. if (!extension_loaded('openssl')) {
  2963. $errors['openssl'] = true;
  2964. }
  2965. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  2966. $warnings['openssl_version'] = true;
  2967. }
  2968. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  2969. $warnings['apc_cli'] = true;
  2970. }
  2971. if (!extension_loaded('zlib')) {
  2972. $warnings['zlib'] = true;
  2973. }
  2974. ob_start();
  2975. phpinfo(INFO_GENERAL);
  2976. $phpinfo = ob_get_clean();
  2977. if (preg_match('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  2978. $configure = $match[1];
  2979. if (false !== strpos($configure, '--enable-sigchild')) {
  2980. $warnings['sigchild'] = true;
  2981. }
  2982. if (false !== strpos($configure, '--with-curlwrappers')) {
  2983. $warnings['curlwrappers'] = true;
  2984. }
  2985. }
  2986. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  2987. $warnings['xdebug_profile'] = true;
  2988. } elseif (extension_loaded('xdebug')) {
  2989. $warnings['xdebug_loaded'] = true;
  2990. }
  2991. if (!empty($errors)) {
  2992. foreach ($errors as $error => $current) {
  2993. switch ($error) {
  2994. case 'json':
  2995. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  2996. $text .= "Install it or recompile php without --disable-json";
  2997. break;
  2998. case 'phar':
  2999. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3000. $text .= "Install it or recompile php without --disable-phar";
  3001. break;
  3002. case 'filter':
  3003. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3004. $text .= "Install it or recompile php without --disable-filter";
  3005. break;
  3006. case 'hash':
  3007. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3008. $text .= "Install it or recompile php without --disable-hash";
  3009. break;
  3010. case 'iconv_mbstring':
  3011. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3012. $text .= "Install either of them or recompile php without --disable-iconv";
  3013. break;
  3014. case 'unicode':
  3015. $text = PHP_EOL."The detect_unicode setting must be disabled.".PHP_EOL;
  3016. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3017. $text .= " detect_unicode = Off";
  3018. $displayIniMessage = true;
  3019. break;
  3020. case 'suhosin':
  3021. $text = PHP_EOL."The suhosin.executor.include.whitelist setting is incorrect.".PHP_EOL;
  3022. $text .= "Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):".PHP_EOL;
  3023. $text .= " suhosin.executor.include.whitelist = phar ".$current;
  3024. $displayIniMessage = true;
  3025. break;
  3026. case 'php':
  3027. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  3028. break;
  3029. case 'allow_url_fopen':
  3030. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3031. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3032. $text .= " allow_url_fopen = On";
  3033. $displayIniMessage = true;
  3034. break;
  3035. case 'ioncube':
  3036. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3037. $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;
  3038. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3039. $displayIniMessage = true;
  3040. break;
  3041. case 'openssl':
  3042. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3043. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3044. break;
  3045. }
  3046. $out($text, 'error');
  3047. }
  3048. $output .= PHP_EOL;
  3049. }
  3050. if (!empty($warnings)) {
  3051. foreach ($warnings as $warning => $current) {
  3052. switch ($warning) {
  3053. case 'apc_cli':
  3054. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3055. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3056. $text .= " apc.enable_cli = Off";
  3057. $displayIniMessage = true;
  3058. break;
  3059. case 'zlib':
  3060. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3061. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3062. $displayIniMessage = true;
  3063. break;
  3064. case 'sigchild':
  3065. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3066. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3067. $text .= " https://bugs.php.net/bug.php?id=22999";
  3068. break;
  3069. case 'curlwrappers':
  3070. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3071. $text .= " Recompile it without this flag if possible";
  3072. break;
  3073. case 'php':
  3074. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  3075. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  3076. break;
  3077. case 'openssl_version':
  3078. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3079. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3080. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3081. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3082. break;
  3083. case 'xdebug_loaded':
  3084. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3085. $text .= " Disabling it when using Composer is recommended.";
  3086. break;
  3087. case 'xdebug_profile':
  3088. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3089. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3090. $text .= " xdebug.profiler_enabled = 0";
  3091. $displayIniMessage = true;
  3092. break;
  3093. }
  3094. $out($text, 'comment');
  3095. }
  3096. }
  3097. if ($displayIniMessage) {
  3098. $out($iniMessage, 'comment');
  3099. }
  3100. return !$warnings && !$errors ? true : $output;
  3101. }
  3102. private function checkConnectivity()
  3103. {
  3104. if (!ini_get('allow_url_fopen')) {
  3105. $result = '<info>Skipped because allow_url_fopen is missing.</info>';
  3106. return $result;
  3107. }
  3108. return true;
  3109. }
  3110. }
  3111. <?php
  3112. namespace Composer\Command;
  3113. use Composer\Plugin\CommandEvent;
  3114. use Composer\Plugin\PluginEvents;
  3115. use Symfony\Component\Console\Input\InputInterface;
  3116. use Symfony\Component\Console\Input\InputOption;
  3117. use Symfony\Component\Console\Output\OutputInterface;
  3118. class DumpAutoloadCommand extends BaseCommand
  3119. {
  3120. protected function configure()
  3121. {
  3122. $this
  3123. ->setName('dump-autoload')
  3124. ->setAliases(array('dumpautoload'))
  3125. ->setDescription('Dumps the autoloader.')
  3126. ->setDefinition(array(
  3127. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  3128. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3129. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3130. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3131. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules.'),
  3132. ))
  3133. ->setHelp(
  3134. <<<EOT
  3135. <info>php composer.phar dump-autoload</info>
  3136. EOT
  3137. )
  3138. ;
  3139. }
  3140. protected function execute(InputInterface $input, OutputInterface $output)
  3141. {
  3142. $composer = $this->getComposer();
  3143. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3144. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3145. $installationManager = $composer->getInstallationManager();
  3146. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3147. $package = $composer->getPackage();
  3148. $config = $composer->getConfig();
  3149. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3150. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3151. $apcu = $input->getOption('apcu') || $config->get('apcu-autoloader');
  3152. if ($authoritative) {
  3153. $this->getIO()->writeError('<info>Generating optimized autoload files (authoritative)</info>', false);
  3154. } elseif ($optimize) {
  3155. $this->getIO()->writeError('<info>Generating optimized autoload files</info>', false);
  3156. } else {
  3157. $this->getIO()->writeError('<info>Generating autoload files</info>', false);
  3158. }
  3159. $generator = $composer->getAutoloadGenerator();
  3160. $generator->setDevMode(!$input->getOption('no-dev'));
  3161. $generator->setClassMapAuthoritative($authoritative);
  3162. $generator->setApcu($apcu);
  3163. $generator->setRunScripts(!$input->getOption('no-scripts'));
  3164. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3165. if ($authoritative) {
  3166. $this->getIO()->overwriteError('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3167. } elseif ($optimize) {
  3168. $this->getIO()->overwriteError('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3169. } else {
  3170. $this->getIO()->overwriteError('<info>Generated autoload files containing '. $numberOfClasses .' classes</info>');
  3171. }
  3172. }
  3173. }
  3174. <?php
  3175. namespace Composer\Command;
  3176. use Symfony\Component\Console\Input\InputInterface;
  3177. use Symfony\Component\Console\Input\InputOption;
  3178. use Symfony\Component\Console\Output\OutputInterface;
  3179. use Symfony\Component\Console\Input\InputArgument;
  3180. class ExecCommand extends BaseCommand
  3181. {
  3182. protected function configure()
  3183. {
  3184. $this
  3185. ->setName('exec')
  3186. ->setDescription('Executes a vendored binary/script.')
  3187. ->setDefinition(array(
  3188. new InputOption('list', 'l', InputOption::VALUE_NONE),
  3189. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  3190. new InputArgument(
  3191. 'args',
  3192. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  3193. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  3194. ),
  3195. ))
  3196. ;
  3197. }
  3198. protected function execute(InputInterface $input, OutputInterface $output)
  3199. {
  3200. $composer = $this->getComposer();
  3201. $binDir = $composer->getConfig()->get('bin-dir');
  3202. if ($input->getOption('list') || !$input->getArgument('binary')) {
  3203. $bins = glob($binDir . '/*');
  3204. $bins = array_merge($bins, array_map(function ($e) {
  3205. return "$e (local)";
  3206. }, $composer->getPackage()->getBinaries()));
  3207. if (!$bins) {
  3208. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  3209. }
  3210. $this->getIO()->write(
  3211. <<<EOT
  3212. <comment>Available binaries:</comment>
  3213. EOT
  3214. );
  3215. foreach ($bins as $bin) {
  3216. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  3217. continue;
  3218. }
  3219. $previousBin = $bin;
  3220. $bin = basename($bin);
  3221. $this->getIO()->write(
  3222. <<<EOT
  3223. <info>- $bin</info>
  3224. EOT
  3225. );
  3226. }
  3227. return 0;
  3228. }
  3229. $binary = $input->getArgument('binary');
  3230. $dispatcher = $composer->getEventDispatcher();
  3231. $dispatcher->addListener('__exec_command', $binary);
  3232. if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
  3233. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  3234. }
  3235. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  3236. }
  3237. }
  3238. <?php
  3239. namespace Composer\Command;
  3240. use Composer\Factory;
  3241. use Composer\Util\Filesystem;
  3242. use Symfony\Component\Console\Input\InputInterface;
  3243. use Symfony\Component\Console\Input\InputArgument;
  3244. use Symfony\Component\Console\Input\StringInput;
  3245. use Symfony\Component\Console\Output\OutputInterface;
  3246. class GlobalCommand extends BaseCommand
  3247. {
  3248. protected function configure()
  3249. {
  3250. $this
  3251. ->setName('global')
  3252. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  3253. ->setDefinition(array(
  3254. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  3255. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  3256. ))
  3257. ->setHelp(
  3258. <<<EOT
  3259. Use this command as a wrapper to run other Composer commands
  3260. within the global context of COMPOSER_HOME.
  3261. You can use this to install CLI utilities globally, all you need
  3262. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  3263. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  3264. and /home/<user>/.composer on unix systems.
  3265. If your system uses freedesktop.org standards, then it will first check
  3266. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  3267. Note: This path may vary depending on customizations to bin-dir in
  3268. composer.json or the environmental variable COMPOSER_BIN_DIR.
  3269. EOT
  3270. )
  3271. ;
  3272. }
  3273. public function run(InputInterface $input, OutputInterface $output)
  3274. {
  3275. $tokens = preg_split('{\s+}', $input->__toString());
  3276. $args = array();
  3277. foreach ($tokens as $token) {
  3278. if ($token && $token[0] !== '-') {
  3279. $args[] = $token;
  3280. if (count($args) >= 2) {
  3281. break;
  3282. }
  3283. }
  3284. }
  3285. if (count($args) < 2) {
  3286. return parent::run($input, $output);
  3287. }
  3288. $config = Factory::createConfig();
  3289. $home = $config->get('home');
  3290. if (!is_dir($home)) {
  3291. $fs = new Filesystem();
  3292. $fs->ensureDirectoryExists($home);
  3293. if (!is_dir($home)) {
  3294. throw new \RuntimeException('Could not create home directory');
  3295. }
  3296. }
  3297. try {
  3298. chdir($home);
  3299. } catch (\Exception $e) {
  3300. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  3301. }
  3302. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  3303. $input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  3304. $this->getApplication()->resetComposer();
  3305. return $this->getApplication()->run($input, $output);
  3306. }
  3307. public function isProxyCommand()
  3308. {
  3309. return true;
  3310. }
  3311. }
  3312. <?php
  3313. namespace Composer\Command;
  3314. use Composer\Package\CompletePackageInterface;
  3315. use Composer\Repository\RepositoryInterface;
  3316. use Composer\Repository\ArrayRepository;
  3317. use Composer\Repository\RepositoryFactory;
  3318. use Composer\Util\Platform;
  3319. use Composer\Util\ProcessExecutor;
  3320. use Symfony\Component\Console\Input\InputArgument;
  3321. use Symfony\Component\Console\Input\InputOption;
  3322. use Symfony\Component\Console\Input\InputInterface;
  3323. use Symfony\Component\Console\Output\OutputInterface;
  3324. class HomeCommand extends BaseCommand
  3325. {
  3326. protected function configure()
  3327. {
  3328. $this
  3329. ->setName('browse')
  3330. ->setAliases(array('home'))
  3331. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  3332. ->setDefinition(array(
  3333. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  3334. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  3335. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  3336. ))
  3337. ->setHelp(
  3338. <<<EOT
  3339. The home command opens or shows a package's repository URL or
  3340. homepage in your default browser.
  3341. To open the homepage by default, use -H or --homepage.
  3342. To show instead of open the repository or homepage URL, use -s or --show.
  3343. EOT
  3344. );
  3345. }
  3346. protected function execute(InputInterface $input, OutputInterface $output)
  3347. {
  3348. $repos = $this->initializeRepos();
  3349. $io = $this->getIO();
  3350. $return = 0;
  3351. $packages = $input->getArgument('packages');
  3352. if (!$packages) {
  3353. $io->writeError('No package specified, opening homepage for the root package');
  3354. $packages = array($this->getComposer()->getPackage()->getName());
  3355. }
  3356. foreach ($packages as $packageName) {
  3357. $handled = false;
  3358. $packageExists = false;
  3359. foreach ($repos as $repo) {
  3360. foreach ($repo->findPackages($packageName) as $package) {
  3361. $packageExists = true;
  3362. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  3363. $handled = true;
  3364. break 2;
  3365. }
  3366. }
  3367. }
  3368. if (!$packageExists) {
  3369. $return = 1;
  3370. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  3371. }
  3372. if (!$handled) {
  3373. $return = 1;
  3374. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  3375. }
  3376. }
  3377. return $return;
  3378. }
  3379. private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
  3380. {
  3381. $support = $package->getSupport();
  3382. $url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
  3383. if (!$url || $showHomepage) {
  3384. $url = $package->getHomepage();
  3385. }
  3386. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  3387. return false;
  3388. }
  3389. if ($showOnly) {
  3390. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  3391. } else {
  3392. $this->openBrowser($url);
  3393. }
  3394. return true;
  3395. }
  3396. private function openBrowser($url)
  3397. {
  3398. $url = ProcessExecutor::escape($url);
  3399. $process = new ProcessExecutor($this->getIO());
  3400. if (Platform::isWindows()) {
  3401. return $process->execute('start "web" explorer "' . $url . '"', $output);
  3402. }
  3403. $linux = $process->execute('which xdg-open', $output);
  3404. $osx = $process->execute('which open', $output);
  3405. if (0 === $linux) {
  3406. $process->execute('xdg-open ' . $url, $output);
  3407. } elseif (0 === $osx) {
  3408. $process->execute('open ' . $url, $output);
  3409. } else {
  3410. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  3411. }
  3412. }
  3413. private function initializeRepos()
  3414. {
  3415. $composer = $this->getComposer(false);
  3416. if ($composer) {
  3417. return array_merge(
  3418. array(new ArrayRepository(array($composer->getPackage()))),
  3419. array($composer->getRepositoryManager()->getLocalRepository()),
  3420. $composer->getRepositoryManager()->getRepositories()
  3421. );
  3422. }
  3423. return RepositoryFactory::defaultRepos($this->getIO());
  3424. }
  3425. }
  3426. <?php
  3427. namespace Composer\Command;
  3428. use Composer\DependencyResolver\Pool;
  3429. use Composer\Factory;
  3430. use Composer\Json\JsonFile;
  3431. use Composer\Package\BasePackage;
  3432. use Composer\Package\Version\VersionParser;
  3433. use Composer\Package\Version\VersionSelector;
  3434. use Composer\Repository\CompositeRepository;
  3435. use Composer\Repository\PlatformRepository;
  3436. use Composer\Repository\RepositoryFactory;
  3437. use Composer\Util\ProcessExecutor;
  3438. use Symfony\Component\Console\Input\ArrayInput;
  3439. use Symfony\Component\Console\Input\InputInterface;
  3440. use Symfony\Component\Console\Input\InputOption;
  3441. use Symfony\Component\Console\Output\OutputInterface;
  3442. use Symfony\Component\Process\ExecutableFinder;
  3443. use Symfony\Component\Process\Process;
  3444. class InitCommand extends BaseCommand
  3445. {
  3446. protected $repos;
  3447. private $gitConfig;
  3448. private $pools;
  3449. protected function configure()
  3450. {
  3451. $this
  3452. ->setName('init')
  3453. ->setDescription('Creates a basic composer.json file in current directory.')
  3454. ->setDefinition(array(
  3455. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  3456. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  3457. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  3458. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  3459. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  3460. 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"'),
  3461. 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"'),
  3462. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  3463. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  3464. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  3465. ))
  3466. ->setHelp(
  3467. <<<EOT
  3468. The <info>init</info> command creates a basic composer.json file
  3469. in the current directory.
  3470. <info>php composer.phar init</info>
  3471. EOT
  3472. )
  3473. ;
  3474. }
  3475. protected function execute(InputInterface $input, OutputInterface $output)
  3476. {
  3477. $io = $this->getIO();
  3478. $whitelist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license');
  3479. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($whitelist)));
  3480. if (isset($options['author'])) {
  3481. $options['authors'] = $this->formatAuthors($options['author']);
  3482. unset($options['author']);
  3483. }
  3484. $repositories = $input->getOption('repository');
  3485. if ($repositories) {
  3486. $config = Factory::createConfig($io);
  3487. foreach ($repositories as $repo) {
  3488. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo);
  3489. }
  3490. }
  3491. if (isset($options['stability'])) {
  3492. $options['minimum-stability'] = $options['stability'];
  3493. unset($options['stability']);
  3494. }
  3495. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  3496. if (array() === $options['require']) {
  3497. $options['require'] = new \stdClass;
  3498. }
  3499. if (isset($options['require-dev'])) {
  3500. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  3501. if (array() === $options['require-dev']) {
  3502. $options['require-dev'] = new \stdClass;
  3503. }
  3504. }
  3505. $file = new JsonFile(Factory::getComposerFile());
  3506. $json = $file->encode($options);
  3507. if ($input->isInteractive()) {
  3508. $io->writeError(array('', $json, ''));
  3509. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ', true)) {
  3510. $io->writeError('<error>Command aborted</error>');
  3511. return 1;
  3512. }
  3513. }
  3514. $file->write($options);
  3515. if ($input->isInteractive() && is_dir('.git')) {
  3516. $ignoreFile = realpath('.gitignore');
  3517. if (false === $ignoreFile) {
  3518. $ignoreFile = realpath('.') . '/.gitignore';
  3519. }
  3520. if (!$this->hasVendorIgnore($ignoreFile)) {
  3521. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  3522. if ($io->askConfirmation($question, true)) {
  3523. $this->addVendorIgnore($ignoreFile);
  3524. }
  3525. }
  3526. }
  3527. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  3528. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question, true)) {
  3529. $this->installDependencies($output);
  3530. }
  3531. }
  3532. protected function interact(InputInterface $input, OutputInterface $output)
  3533. {
  3534. $git = $this->getGitConfig();
  3535. $io = $this->getIO();
  3536. $formatter = $this->getHelperSet()->get('formatter');
  3537. $repositories = $input->getOption('repository');
  3538. if ($repositories) {
  3539. $config = Factory::createConfig($io);
  3540. $repos = array(new PlatformRepository);
  3541. foreach ($repositories as $repo) {
  3542. $repos[] = RepositoryFactory::fromString($io, $config, $repo);
  3543. }
  3544. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  3545. 'type' => 'composer',
  3546. 'url' => 'https://repo.packagist.org',
  3547. ));
  3548. $this->repos = new CompositeRepository($repos);
  3549. unset($repos, $config, $repositories);
  3550. }
  3551. $io->writeError(array(
  3552. '',
  3553. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  3554. '',
  3555. ));
  3556. $io->writeError(array(
  3557. '',
  3558. 'This command will guide you through creating your composer.json config.',
  3559. '',
  3560. ));
  3561. $cwd = realpath(".");
  3562. if (!$name = $input->getOption('name')) {
  3563. $name = basename($cwd);
  3564. $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  3565. $name = strtolower($name);
  3566. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  3567. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  3568. } elseif (isset($git['github.user'])) {
  3569. $name = $git['github.user'] . '/' . $name;
  3570. } elseif (!empty($_SERVER['USERNAME'])) {
  3571. $name = $_SERVER['USERNAME'] . '/' . $name;
  3572. } elseif (!empty($_SERVER['USER'])) {
  3573. $name = $_SERVER['USER'] . '/' . $name;
  3574. } elseif (get_current_user()) {
  3575. $name = get_current_user() . '/' . $name;
  3576. } else {
  3577. $name .= '/' . $name;
  3578. }
  3579. $name = strtolower($name);
  3580. } else {
  3581. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $name)) {
  3582. throw new \InvalidArgumentException(
  3583. 'The package name '.$name.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
  3584. );
  3585. }
  3586. }
  3587. $name = $io->askAndValidate(
  3588. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  3589. function ($value) use ($name) {
  3590. if (null === $value) {
  3591. return $name;
  3592. }
  3593. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  3594. throw new \InvalidArgumentException(
  3595. '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_.-]+'
  3596. );
  3597. }
  3598. return $value;
  3599. },
  3600. null,
  3601. $name
  3602. );
  3603. $input->setOption('name', $name);
  3604. $description = $input->getOption('description') ?: false;
  3605. $description = $io->ask(
  3606. 'Description [<comment>'.$description.'</comment>]: ',
  3607. $description
  3608. );
  3609. $input->setOption('description', $description);
  3610. if (null === $author = $input->getOption('author')) {
  3611. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  3612. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  3613. } elseif (isset($git['user.name'])) {
  3614. $author_name = $git['user.name'];
  3615. }
  3616. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  3617. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  3618. } elseif (isset($git['user.email'])) {
  3619. $author_email = $git['user.email'];
  3620. }
  3621. if (isset($author_name) && isset($author_email)) {
  3622. $author = sprintf('%s <%s>', $author_name, $author_email);
  3623. }
  3624. }
  3625. $self = $this;
  3626. $author = $io->askAndValidate(
  3627. 'Author [<comment>'.$author.'</comment>, n to skip]: ',
  3628. function ($value) use ($self, $author) {
  3629. if ($value === 'n' || $value === 'no') {
  3630. return;
  3631. }
  3632. $value = $value ?: $author;
  3633. $author = $self->parseAuthorString($value);
  3634. return sprintf('%s <%s>', $author['name'], $author['email']);
  3635. },
  3636. null,
  3637. $author
  3638. );
  3639. $input->setOption('author', $author);
  3640. $minimumStability = $input->getOption('stability') ?: null;
  3641. $minimumStability = $io->askAndValidate(
  3642. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  3643. function ($value) use ($minimumStability) {
  3644. if (null === $value) {
  3645. return $minimumStability;
  3646. }
  3647. if (!isset(BasePackage::$stabilities[$value])) {
  3648. throw new \InvalidArgumentException(
  3649. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  3650. implode(', ', array_keys(BasePackage::$stabilities))
  3651. );
  3652. }
  3653. return $value;
  3654. },
  3655. null,
  3656. $minimumStability
  3657. );
  3658. $input->setOption('stability', $minimumStability);
  3659. $type = $input->getOption('type') ?: false;
  3660. $type = $io->ask(
  3661. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  3662. $type
  3663. );
  3664. $input->setOption('type', $type);
  3665. if (null === $license = $input->getOption('license')) {
  3666. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  3667. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  3668. }
  3669. }
  3670. $license = $io->ask(
  3671. 'License [<comment>'.$license.'</comment>]: ',
  3672. $license
  3673. );
  3674. $input->setOption('license', $license);
  3675. $io->writeError(array('', 'Define your dependencies.', ''));
  3676. $repos = $this->getRepos();
  3677. $preferredStability = $minimumStability ?: 'stable';
  3678. $phpVersion = $repos->findPackage('php', '*')->getPrettyVersion();
  3679. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  3680. $require = $input->getOption('require');
  3681. $requirements = array();
  3682. if ($require || $io->askConfirmation($question, true)) {
  3683. $requirements = $this->determineRequirements($input, $output, $require, $phpVersion, $preferredStability);
  3684. }
  3685. $input->setOption('require', $requirements);
  3686. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  3687. $requireDev = $input->getOption('require-dev');
  3688. $devRequirements = array();
  3689. if ($requireDev || $io->askConfirmation($question, true)) {
  3690. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $phpVersion, $preferredStability);
  3691. }
  3692. $input->setOption('require-dev', $devRequirements);
  3693. }
  3694. public function parseAuthorString($author)
  3695. {
  3696. if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
  3697. if ($this->isValidEmail($match['email'])) {
  3698. return array(
  3699. 'name' => trim($match['name']),
  3700. 'email' => $match['email'],
  3701. );
  3702. }
  3703. }
  3704. throw new \InvalidArgumentException(
  3705. 'Invalid author string. Must be in the format: '.
  3706. 'John Smith <[email protected]>'
  3707. );
  3708. }
  3709. protected function findPackages($name)
  3710. {
  3711. return $this->getRepos()->search($name);
  3712. }
  3713. protected function getRepos()
  3714. {
  3715. if (!$this->repos) {
  3716. $this->repos = new CompositeRepository(array_merge(
  3717. array(new PlatformRepository),
  3718. RepositoryFactory::defaultRepos($this->getIO())
  3719. ));
  3720. }
  3721. return $this->repos;
  3722. }
  3723. protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), $phpVersion = null, $preferredStability = 'stable', $checkProvidedVersions = true)
  3724. {
  3725. if ($requires) {
  3726. $requires = $this->normalizeRequirements($requires);
  3727. $result = array();
  3728. $io = $this->getIO();
  3729. foreach ($requires as $requirement) {
  3730. if (!isset($requirement['version'])) {
  3731. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $phpVersion, $preferredStability);
  3732. $requirement['version'] = $version;
  3733. $requirement['name'] = $name;
  3734. $io->writeError(sprintf(
  3735. 'Using version <info>%s</info> for <info>%s</info>',
  3736. $requirement['version'],
  3737. $requirement['name']
  3738. ));
  3739. } else {
  3740. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $phpVersion, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev');
  3741. $requirement['name'] = $name;
  3742. }
  3743. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  3744. }
  3745. return $result;
  3746. }
  3747. $versionParser = new VersionParser();
  3748. $io = $this->getIO();
  3749. while (null !== $package = $io->ask('Search for a package: ')) {
  3750. $matches = $this->findPackages($package);
  3751. if (count($matches)) {
  3752. $exactMatch = null;
  3753. $choices = array();
  3754. foreach ($matches as $position => $foundPackage) {
  3755. $abandoned = '';
  3756. if (isset($foundPackage['abandoned'])) {
  3757. if (is_string($foundPackage['abandoned'])) {
  3758. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  3759. } else {
  3760. $replacement = 'No replacement was suggested';
  3761. }
  3762. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  3763. }
  3764. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  3765. if ($foundPackage['name'] === $package) {
  3766. $exactMatch = true;
  3767. break;
  3768. }
  3769. }
  3770. if (!$exactMatch) {
  3771. $io->writeError(array(
  3772. '',
  3773. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  3774. '',
  3775. ));
  3776. $io->writeError($choices);
  3777. $io->writeError('');
  3778. $validator = function ($selection) use ($matches, $versionParser) {
  3779. if ('' === $selection) {
  3780. return false;
  3781. }
  3782. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  3783. $package = $matches[(int) $selection];
  3784. return $package['name'];
  3785. }
  3786. if (preg_match('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  3787. if (isset($packageMatches['version'])) {
  3788. $versionParser->parseConstraints($packageMatches['version']);
  3789. return $packageMatches['name'].' '.$packageMatches['version'];
  3790. }
  3791. return $packageMatches['name'];
  3792. }
  3793. throw new \Exception('Not a valid selection');
  3794. };
  3795. $package = $io->askAndValidate(
  3796. 'Enter package # to add, or the complete package name if it is not listed: ',
  3797. $validator,
  3798. 3,
  3799. false
  3800. );
  3801. }
  3802. if (false !== $package && false === strpos($package, ' ')) {
  3803. $validator = function ($input) {
  3804. $input = trim($input);
  3805. return $input ?: false;
  3806. };
  3807. $constraint = $io->askAndValidate(
  3808. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  3809. $validator,
  3810. 3,
  3811. false
  3812. );
  3813. if (false === $constraint) {
  3814. list($name, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $phpVersion, $preferredStability);
  3815. $io->writeError(sprintf(
  3816. 'Using version <info>%s</info> for <info>%s</info>',
  3817. $constraint,
  3818. $package
  3819. ));
  3820. }
  3821. $package .= ' '.$constraint;
  3822. }
  3823. if (false !== $package) {
  3824. $requires[] = $package;
  3825. }
  3826. }
  3827. }
  3828. return $requires;
  3829. }
  3830. protected function formatAuthors($author)
  3831. {
  3832. return array($this->parseAuthorString($author));
  3833. }
  3834. protected function formatRequirements(array $requirements)
  3835. {
  3836. $requires = array();
  3837. $requirements = $this->normalizeRequirements($requirements);
  3838. foreach ($requirements as $requirement) {
  3839. $requires[$requirement['name']] = $requirement['version'];
  3840. }
  3841. return $requires;
  3842. }
  3843. protected function getGitConfig()
  3844. {
  3845. if (null !== $this->gitConfig) {
  3846. return $this->gitConfig;
  3847. }
  3848. $finder = new ExecutableFinder();
  3849. $gitBin = $finder->find('git');
  3850. $cmd = new Process(sprintf('%s config -l', ProcessExecutor::escape($gitBin)));
  3851. $cmd->run();
  3852. if ($cmd->isSuccessful()) {
  3853. $this->gitConfig = array();
  3854. preg_match_all('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches, PREG_SET_ORDER);
  3855. foreach ($matches as $match) {
  3856. $this->gitConfig[$match[1]] = $match[2];
  3857. }
  3858. return $this->gitConfig;
  3859. }
  3860. return $this->gitConfig = array();
  3861. }
  3862. protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
  3863. {
  3864. if (!file_exists($ignoreFile)) {
  3865. return false;
  3866. }
  3867. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  3868. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  3869. foreach ($lines as $line) {
  3870. if (preg_match($pattern, $line)) {
  3871. return true;
  3872. }
  3873. }
  3874. return false;
  3875. }
  3876. protected function normalizeRequirements(array $requirements)
  3877. {
  3878. $parser = new VersionParser();
  3879. return $parser->parseNameVersionPairs($requirements);
  3880. }
  3881. protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
  3882. {
  3883. $contents = "";
  3884. if (file_exists($ignoreFile)) {
  3885. $contents = file_get_contents($ignoreFile);
  3886. if ("\n" !== substr($contents, 0, -1)) {
  3887. $contents .= "\n";
  3888. }
  3889. }
  3890. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  3891. }
  3892. protected function isValidEmail($email)
  3893. {
  3894. if (!function_exists('filter_var')) {
  3895. return true;
  3896. }
  3897. if (PHP_VERSION_ID < 50303) {
  3898. return true;
  3899. }
  3900. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  3901. }
  3902. private function getPool(InputInterface $input, $minimumStability = null)
  3903. {
  3904. $key = $minimumStability ?: 'default';
  3905. if (!isset($this->pools[$key])) {
  3906. $this->pools[$key] = $pool = new Pool($minimumStability ?: $this->getMinimumStability($input));
  3907. $pool->addRepository($this->getRepos());
  3908. }
  3909. return $this->pools[$key];
  3910. }
  3911. private function getMinimumStability(InputInterface $input)
  3912. {
  3913. if ($input->hasOption('stability')) {
  3914. return $input->getOption('stability') ?: 'stable';
  3915. }
  3916. $file = Factory::getComposerFile();
  3917. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  3918. if (!empty($composer['minimum-stability'])) {
  3919. return $composer['minimum-stability'];
  3920. }
  3921. }
  3922. return 'stable';
  3923. }
  3924. private function findBestVersionAndNameForPackage(InputInterface $input, $name, $phpVersion, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null)
  3925. {
  3926. $versionSelector = new VersionSelector($this->getPool($input, $minimumStability));
  3927. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $phpVersion, $preferredStability);
  3928. if ($input->hasOption('ignore-platform-reqs') && $input->getOption('ignore-platform-reqs')) {
  3929. $phpVersion = null;
  3930. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $phpVersion, $preferredStability);
  3931. }
  3932. if (!$package) {
  3933. if ($phpVersion && $versionSelector->findBestCandidate($name, $requiredVersion, null, $preferredStability)) {
  3934. throw new \InvalidArgumentException(sprintf(
  3935. 'Package %s at version %s has a PHP requirement incompatible with your PHP version (%s)',
  3936. $name,
  3937. $requiredVersion,
  3938. $phpVersion
  3939. ));
  3940. }
  3941. if ($requiredVersion && $versionSelector->findBestCandidate($name, null, $phpVersion, $preferredStability)) {
  3942. throw new \InvalidArgumentException(sprintf(
  3943. 'Could not find package %s in a version matching %s',
  3944. $name,
  3945. $requiredVersion
  3946. ));
  3947. }
  3948. if ($phpVersion && $versionSelector->findBestCandidate($name)) {
  3949. throw new \InvalidArgumentException(sprintf(
  3950. 'Could not find package %s in any version matching your PHP version (%s)',
  3951. $name,
  3952. $phpVersion
  3953. ));
  3954. }
  3955. $similar = $this->findSimilar($name);
  3956. if ($similar) {
  3957. if ($requiredVersion === null && in_array($name, $similar, true)) {
  3958. throw new \InvalidArgumentException(sprintf(
  3959. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  3960. $name,
  3961. $this->getMinimumStability($input)
  3962. ));
  3963. }
  3964. throw new \InvalidArgumentException(sprintf(
  3965. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  3966. $name,
  3967. implode("\n ", $similar)
  3968. ));
  3969. }
  3970. throw new \InvalidArgumentException(sprintf(
  3971. '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).',
  3972. $name,
  3973. $this->getMinimumStability($input)
  3974. ));
  3975. }
  3976. return array(
  3977. $package->getPrettyName(),
  3978. $versionSelector->findRecommendedRequireVersion($package),
  3979. );
  3980. }
  3981. private function findSimilar($package)
  3982. {
  3983. try {
  3984. $results = $this->repos->search($package);
  3985. } catch (\Exception $e) {
  3986. return array();
  3987. }
  3988. $similarPackages = array();
  3989. foreach ($results as $result) {
  3990. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  3991. }
  3992. asort($similarPackages);
  3993. return array_keys(array_slice($similarPackages, 0, 5));
  3994. }
  3995. private function installDependencies($output)
  3996. {
  3997. try {
  3998. $installCommand = $this->getApplication()->find('install');
  3999. $installCommand->run(new ArrayInput(array()), $output);
  4000. } catch (\Exception $e) {
  4001. $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.');
  4002. }
  4003. }
  4004. private function hasDependencies($options)
  4005. {
  4006. $requires = (array) $options['require'];
  4007. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  4008. return !empty($requires) || !empty($devRequires);
  4009. }
  4010. }
  4011. <?php
  4012. namespace Composer\Command;
  4013. use Composer\Installer;
  4014. use Composer\Plugin\CommandEvent;
  4015. use Composer\Plugin\PluginEvents;
  4016. use Symfony\Component\Console\Input\InputInterface;
  4017. use Symfony\Component\Console\Input\InputOption;
  4018. use Symfony\Component\Console\Input\InputArgument;
  4019. use Symfony\Component\Console\Output\OutputInterface;
  4020. class InstallCommand extends BaseCommand
  4021. {
  4022. protected function configure()
  4023. {
  4024. $this
  4025. ->setName('install')
  4026. ->setAliases(array('i'))
  4027. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  4028. ->setDefinition(array(
  4029. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4030. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  4031. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4032. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4033. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4034. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  4035. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  4036. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4037. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4038. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'Do not show package suggestions.'),
  4039. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  4040. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4041. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4042. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4043. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'),
  4044. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  4045. ))
  4046. ->setHelp(
  4047. <<<EOT
  4048. The <info>install</info> command reads the composer.lock file from
  4049. the current directory, processes it, and downloads and installs all the
  4050. libraries and dependencies outlined in that file. If the file does not
  4051. exist it will look for composer.json and do the same.
  4052. <info>php composer.phar install</info>
  4053. EOT
  4054. )
  4055. ;
  4056. }
  4057. protected function execute(InputInterface $input, OutputInterface $output)
  4058. {
  4059. $io = $this->getIO();
  4060. if ($args = $input->getArgument('packages')) {
  4061. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  4062. return 1;
  4063. }
  4064. if ($input->getOption('no-custom-installers')) {
  4065. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  4066. $input->setOption('no-plugins', true);
  4067. }
  4068. if ($input->getOption('dev')) {
  4069. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  4070. }
  4071. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4072. $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
  4073. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  4074. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4075. $install = Installer::create($io, $composer);
  4076. $config = $composer->getConfig();
  4077. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  4078. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  4079. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4080. $apcu = $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  4081. $install
  4082. ->setDryRun($input->getOption('dry-run'))
  4083. ->setVerbose($input->getOption('verbose'))
  4084. ->setPreferSource($preferSource)
  4085. ->setPreferDist($preferDist)
  4086. ->setDevMode(!$input->getOption('no-dev'))
  4087. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  4088. ->setRunScripts(!$input->getOption('no-scripts'))
  4089. ->setSkipSuggest($input->getOption('no-suggest'))
  4090. ->setOptimizeAutoloader($optimize)
  4091. ->setClassMapAuthoritative($authoritative)
  4092. ->setApcuAutoloader($apcu)
  4093. ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
  4094. ;
  4095. if ($input->getOption('no-plugins')) {
  4096. $install->disablePlugins();
  4097. }
  4098. return $install->run();
  4099. }
  4100. }
  4101. <?php
  4102. namespace Composer\Command;
  4103. use Composer\Json\JsonFile;
  4104. use Composer\Plugin\CommandEvent;
  4105. use Composer\Plugin\PluginEvents;
  4106. use Composer\Package\PackageInterface;
  4107. use Composer\Repository\RepositoryInterface;
  4108. use Symfony\Component\Console\Helper\Table;
  4109. use Symfony\Component\Console\Input\InputInterface;
  4110. use Symfony\Component\Console\Input\InputOption;
  4111. use Symfony\Component\Console\Output\OutputInterface;
  4112. class LicensesCommand extends BaseCommand
  4113. {
  4114. protected function configure()
  4115. {
  4116. $this
  4117. ->setName('licenses')
  4118. ->setDescription('Shows information about licenses of dependencies.')
  4119. ->setDefinition(array(
  4120. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4121. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4122. ))
  4123. ->setHelp(
  4124. <<<EOT
  4125. The license command displays detailed information about the licenses of
  4126. the installed dependencies.
  4127. EOT
  4128. )
  4129. ;
  4130. }
  4131. protected function execute(InputInterface $input, OutputInterface $output)
  4132. {
  4133. $composer = $this->getComposer();
  4134. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  4135. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4136. $root = $composer->getPackage();
  4137. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4138. if ($input->getOption('no-dev')) {
  4139. $packages = $this->filterRequiredPackages($repo, $root);
  4140. } else {
  4141. $packages = $this->appendPackages($repo->getPackages(), array());
  4142. }
  4143. ksort($packages);
  4144. $io = $this->getIO();
  4145. switch ($format = $input->getOption('format')) {
  4146. case 'text':
  4147. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  4148. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  4149. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  4150. $io->write('Dependencies:');
  4151. $io->write('');
  4152. $table = new Table($output);
  4153. $table->setStyle('compact');
  4154. $tableStyle = $table->getStyle();
  4155. $tableStyle->setVerticalBorderChar('');
  4156. $tableStyle->setCellRowContentFormat('%s ');
  4157. $table->setHeaders(array('Name', 'Version', 'License'));
  4158. foreach ($packages as $package) {
  4159. $table->addRow(array(
  4160. $package->getPrettyName(),
  4161. $package->getFullPrettyVersion(),
  4162. implode(', ', $package->getLicense()) ?: 'none',
  4163. ));
  4164. }
  4165. $table->render();
  4166. break;
  4167. case 'json':
  4168. $dependencies = array();
  4169. foreach ($packages as $package) {
  4170. $dependencies[$package->getPrettyName()] = array(
  4171. 'version' => $package->getFullPrettyVersion(),
  4172. 'license' => $package->getLicense(),
  4173. );
  4174. }
  4175. $io->write(JsonFile::encode(array(
  4176. 'name' => $root->getPrettyName(),
  4177. 'version' => $root->getFullPrettyVersion(),
  4178. 'license' => $root->getLicense(),
  4179. 'dependencies' => $dependencies,
  4180. )));
  4181. break;
  4182. default:
  4183. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4184. }
  4185. }
  4186. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  4187. {
  4188. $requires = array_keys($package->getRequires());
  4189. $packageListNames = array_keys($bucket);
  4190. $packages = array_filter(
  4191. $repo->getPackages(),
  4192. function ($package) use ($requires, $packageListNames) {
  4193. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  4194. }
  4195. );
  4196. $bucket = $this->appendPackages($packages, $bucket);
  4197. foreach ($packages as $package) {
  4198. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  4199. }
  4200. return $bucket;
  4201. }
  4202. public function appendPackages(array $packages, array $bucket)
  4203. {
  4204. foreach ($packages as $package) {
  4205. $bucket[$package->getName()] = $package;
  4206. }
  4207. return $bucket;
  4208. }
  4209. }
  4210. <?php
  4211. namespace Composer\Command;
  4212. use Symfony\Component\Console\Input\InputInterface;
  4213. use Symfony\Component\Console\Input\InputArgument;
  4214. use Symfony\Component\Console\Input\ArrayInput;
  4215. use Symfony\Component\Console\Input\InputOption;
  4216. use Symfony\Component\Console\Output\OutputInterface;
  4217. class OutdatedCommand extends ShowCommand
  4218. {
  4219. protected function configure()
  4220. {
  4221. $this
  4222. ->setName('outdated')
  4223. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  4224. ->setDefinition(array(
  4225. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  4226. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  4227. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  4228. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  4229. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  4230. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  4231. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4232. 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.'),
  4233. ))
  4234. ->setHelp(
  4235. <<<EOT
  4236. The outdated command is just a proxy for `composer show -l`
  4237. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  4238. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  4239. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  4240. compatibility breaks according to semver, so upgrade when you can but it
  4241. may involve work.
  4242. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  4243. EOT
  4244. )
  4245. ;
  4246. }
  4247. protected function execute(InputInterface $input, OutputInterface $output)
  4248. {
  4249. $args = array(
  4250. 'show',
  4251. '--latest' => true,
  4252. );
  4253. if (!$input->getOption('all')) {
  4254. $args['--outdated'] = true;
  4255. }
  4256. if ($input->getOption('direct')) {
  4257. $args['--direct'] = true;
  4258. }
  4259. if ($input->getArgument('package')) {
  4260. $args['package'] = $input->getArgument('package');
  4261. }
  4262. if ($input->getOption('strict')) {
  4263. $args['--strict'] = true;
  4264. }
  4265. if ($input->getOption('minor-only')) {
  4266. $args['--minor-only'] = true;
  4267. }
  4268. $args['--format'] = $input->getOption('format');
  4269. $args['--ignore'] = $input->getOption('ignore');
  4270. $input = new ArrayInput($args);
  4271. return $this->getApplication()->run($input, $output);
  4272. }
  4273. public function isProxyCommand()
  4274. {
  4275. return true;
  4276. }
  4277. }
  4278. <?php
  4279. namespace Composer\Command;
  4280. use Symfony\Component\Console\Input\InputInterface;
  4281. use Symfony\Component\Console\Output\OutputInterface;
  4282. class ProhibitsCommand extends BaseDependencyCommand
  4283. {
  4284. protected function configure()
  4285. {
  4286. parent::configure();
  4287. $this
  4288. ->setName('prohibits')
  4289. ->setAliases(array('why-not'))
  4290. ->setDescription('Shows which packages prevent the given package from being installed.')
  4291. ->setHelp(
  4292. <<<EOT
  4293. Displays detailed information about why a package cannot be installed.
  4294. <info>php composer.phar prohibits composer/composer</info>
  4295. EOT
  4296. )
  4297. ;
  4298. }
  4299. protected function execute(InputInterface $input, OutputInterface $output)
  4300. {
  4301. return parent::doExecute($input, $output, true);
  4302. }
  4303. }
  4304. <?php
  4305. namespace Composer\Command;
  4306. use Composer\Config\JsonConfigSource;
  4307. use Composer\Installer;
  4308. use Composer\Plugin\CommandEvent;
  4309. use Composer\Plugin\PluginEvents;
  4310. use Composer\Json\JsonFile;
  4311. use Composer\Factory;
  4312. use Symfony\Component\Console\Input\InputInterface;
  4313. use Symfony\Component\Console\Input\InputOption;
  4314. use Symfony\Component\Console\Input\InputArgument;
  4315. use Symfony\Component\Console\Output\OutputInterface;
  4316. use Composer\Package\BasePackage;
  4317. class RemoveCommand extends BaseCommand
  4318. {
  4319. protected function configure()
  4320. {
  4321. $this
  4322. ->setName('remove')
  4323. ->setDescription('Removes a package from the require or require-dev.')
  4324. ->setDefinition(array(
  4325. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  4326. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  4327. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4328. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.'),
  4329. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4330. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  4331. new InputOption('update-with-dependencies', null, InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  4332. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  4333. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'),
  4334. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4335. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4336. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4337. ))
  4338. ->setHelp(
  4339. <<<EOT
  4340. The <info>remove</info> command removes a package from the current
  4341. list of installed packages
  4342. <info>php composer.phar remove</info>
  4343. EOT
  4344. )
  4345. ;
  4346. }
  4347. protected function execute(InputInterface $input, OutputInterface $output)
  4348. {
  4349. $packages = $input->getArgument('packages');
  4350. $packages = array_map('strtolower', $packages);
  4351. $file = Factory::getComposerFile();
  4352. $jsonFile = new JsonFile($file);
  4353. $composer = $jsonFile->read();
  4354. $composerBackup = file_get_contents($jsonFile->getPath());
  4355. $json = new JsonConfigSource($jsonFile);
  4356. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  4357. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  4358. $io = $this->getIO();
  4359. if ($input->getOption('update-with-dependencies')) {
  4360. $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>');
  4361. }
  4362. foreach (array('require', 'require-dev') as $linkType) {
  4363. if (isset($composer[$linkType])) {
  4364. foreach ($composer[$linkType] as $name => $version) {
  4365. $composer[$linkType][strtolower($name)] = $name;
  4366. }
  4367. }
  4368. }
  4369. foreach ($packages as $package) {
  4370. if (isset($composer[$type][$package])) {
  4371. $json->removeLink($type, $composer[$type][$package]);
  4372. } elseif (isset($composer[$altType][$package])) {
  4373. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  4374. if ($io->isInteractive()) {
  4375. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ', true)) {
  4376. $json->removeLink($altType, $composer[$altType][$package]);
  4377. }
  4378. }
  4379. } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  4380. foreach ($matches as $matchedPackage) {
  4381. $json->removeLink($type, $matchedPackage);
  4382. }
  4383. } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  4384. foreach ($matches as $matchedPackage) {
  4385. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  4386. if ($io->isInteractive()) {
  4387. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ', true)) {
  4388. $json->removeLink($altType, $matchedPackage);
  4389. }
  4390. }
  4391. }
  4392. } else {
  4393. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  4394. }
  4395. }
  4396. if ($input->getOption('no-update')) {
  4397. return 0;
  4398. }
  4399. $this->resetComposer();
  4400. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4401. $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
  4402. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  4403. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4404. $install = Installer::create($io, $composer);
  4405. $updateDevMode = !$input->getOption('update-no-dev');
  4406. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  4407. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  4408. $apcu = $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  4409. $install
  4410. ->setVerbose($input->getOption('verbose'))
  4411. ->setDevMode($updateDevMode)
  4412. ->setOptimizeAutoloader($optimize)
  4413. ->setClassMapAuthoritative($authoritative)
  4414. ->setApcuAutoloader($apcu)
  4415. ->setUpdate(true)
  4416. ->setUpdateWhitelist($packages)
  4417. ->setWhitelistTransitiveDependencies(!$input->getOption('no-update-with-dependencies'))
  4418. ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
  4419. ->setRunScripts(!$input->getOption('no-scripts'))
  4420. ;
  4421. $status = $install->run();
  4422. if ($status !== 0) {
  4423. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  4424. file_put_contents($jsonFile->getPath(), $composerBackup);
  4425. }
  4426. return $status;
  4427. }
  4428. }
  4429. <?php
  4430. namespace Composer\Command;
  4431. use Symfony\Component\Console\Input\InputInterface;
  4432. use Symfony\Component\Console\Input\InputArgument;
  4433. use Symfony\Component\Console\Input\InputOption;
  4434. use Symfony\Component\Console\Output\OutputInterface;
  4435. use Composer\Factory;
  4436. use Composer\Installer;
  4437. use Composer\Json\JsonFile;
  4438. use Composer\Json\JsonManipulator;
  4439. use Composer\Package\Version\VersionParser;
  4440. use Composer\Plugin\CommandEvent;
  4441. use Composer\Plugin\PluginEvents;
  4442. use Composer\Repository\CompositeRepository;
  4443. use Composer\Repository\PlatformRepository;
  4444. class RequireCommand extends InitCommand
  4445. {
  4446. private $newlyCreated;
  4447. private $json;
  4448. private $file;
  4449. private $composerBackup;
  4450. protected function configure()
  4451. {
  4452. $this
  4453. ->setName('require')
  4454. ->setDescription('Adds required packages to your composer.json and installs them.')
  4455. ->setDefinition(array(
  4456. 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"'),
  4457. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  4458. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4459. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  4460. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4461. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'Do not show package suggestions.'),
  4462. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies.'),
  4463. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4464. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  4465. new InputOption('update-with-dependencies', null, InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  4466. new InputOption('update-with-all-dependencies', null, InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  4467. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'),
  4468. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  4469. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  4470. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  4471. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4472. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4473. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4474. ))
  4475. ->setHelp(
  4476. <<<EOT
  4477. The require command adds required packages to your composer.json and installs them.
  4478. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  4479. matches to require.
  4480. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  4481. If you do not want to install the new dependencies immediately you can call it with --no-update
  4482. EOT
  4483. )
  4484. ;
  4485. }
  4486. protected function execute(InputInterface $input, OutputInterface $output)
  4487. {
  4488. if (function_exists('pcntl_async_signals')) {
  4489. pcntl_async_signals(true);
  4490. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  4491. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  4492. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  4493. }
  4494. $this->file = Factory::getComposerFile();
  4495. $io = $this->getIO();
  4496. $this->newlyCreated = !file_exists($this->file);
  4497. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  4498. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  4499. return 1;
  4500. }
  4501. if (!is_readable($this->file)) {
  4502. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  4503. return 1;
  4504. }
  4505. if (!is_writable($this->file)) {
  4506. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  4507. return 1;
  4508. }
  4509. if (filesize($this->file) === 0) {
  4510. file_put_contents($this->file, "{\n}\n");
  4511. }
  4512. $this->json = new JsonFile($this->file);
  4513. $this->composerBackup = file_get_contents($this->json->getPath());
  4514. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4515. $repos = $composer->getRepositoryManager()->getRepositories();
  4516. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  4517. $this->repos = new CompositeRepository(array_merge(
  4518. array(new PlatformRepository(array(), $platformOverrides)),
  4519. $repos
  4520. ));
  4521. if ($composer->getPackage()->getPreferStable()) {
  4522. $preferredStability = 'stable';
  4523. } else {
  4524. $preferredStability = $composer->getPackage()->getMinimumStability();
  4525. }
  4526. $phpVersion = $this->repos->findPackage('php', '*')->getPrettyVersion();
  4527. $requirements = $this->determineRequirements($input, $output, $input->getArgument('packages'), $phpVersion, $preferredStability, !$input->getOption('no-update'));
  4528. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  4529. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  4530. $requirements = $this->formatRequirements($requirements);
  4531. $versionParser = new VersionParser();
  4532. foreach ($requirements as $constraint) {
  4533. $versionParser->parseConstraints($constraint);
  4534. }
  4535. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  4536. if (!$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  4537. $composerDefinition = $this->json->read();
  4538. foreach ($requirements as $package => $version) {
  4539. $composerDefinition[$requireKey][$package] = $version;
  4540. unset($composerDefinition[$removeKey][$package]);
  4541. }
  4542. $this->json->write($composerDefinition);
  4543. }
  4544. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  4545. if ($input->getOption('no-update')) {
  4546. return 0;
  4547. }
  4548. $updateDevMode = !$input->getOption('update-no-dev');
  4549. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  4550. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  4551. $apcu = $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  4552. $this->resetComposer();
  4553. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4554. $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
  4555. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  4556. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4557. $install = Installer::create($io, $composer);
  4558. $install
  4559. ->setVerbose($input->getOption('verbose'))
  4560. ->setPreferSource($input->getOption('prefer-source'))
  4561. ->setPreferDist($input->getOption('prefer-dist'))
  4562. ->setDevMode($updateDevMode)
  4563. ->setRunScripts(!$input->getOption('no-scripts'))
  4564. ->setSkipSuggest($input->getOption('no-suggest'))
  4565. ->setOptimizeAutoloader($optimize)
  4566. ->setClassMapAuthoritative($authoritative)
  4567. ->setApcuAutoloader($apcu)
  4568. ->setUpdate(true)
  4569. ->setUpdateWhitelist(array_keys($requirements))
  4570. ->setWhitelistTransitiveDependencies($input->getOption('update-with-dependencies'))
  4571. ->setWhitelistAllDependencies($input->getOption('update-with-all-dependencies'))
  4572. ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
  4573. ->setPreferStable($input->getOption('prefer-stable'))
  4574. ->setPreferLowest($input->getOption('prefer-lowest'))
  4575. ;
  4576. $status = $install->run();
  4577. if ($status !== 0) {
  4578. $this->revertComposerFile();
  4579. }
  4580. return $status;
  4581. }
  4582. private function updateFileCleanly($json, array $new, $requireKey, $removeKey, $sortPackages)
  4583. {
  4584. $contents = file_get_contents($json->getPath());
  4585. $manipulator = new JsonManipulator($contents);
  4586. foreach ($new as $package => $constraint) {
  4587. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  4588. return false;
  4589. }
  4590. if (!$manipulator->removeSubNode($removeKey, $package)) {
  4591. return false;
  4592. }
  4593. }
  4594. file_put_contents($json->getPath(), $manipulator->getContents());
  4595. return true;
  4596. }
  4597. protected function interact(InputInterface $input, OutputInterface $output)
  4598. {
  4599. return;
  4600. }
  4601. public function revertComposerFile()
  4602. {
  4603. $io = $this->getIO();
  4604. if ($this->newlyCreated) {
  4605. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  4606. unlink($this->json->getPath());
  4607. } else {
  4608. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.' to its original content.</error>');
  4609. file_put_contents($this->json->getPath(), $this->composerBackup);
  4610. }
  4611. exit(1);
  4612. }
  4613. }
  4614. <?php
  4615. namespace Composer\Command;
  4616. use Composer\Script\Event as ScriptEvent;
  4617. use Composer\Script\ScriptEvents;
  4618. use Composer\Util\ProcessExecutor;
  4619. use Symfony\Component\Console\Input\InputInterface;
  4620. use Symfony\Component\Console\Input\InputOption;
  4621. use Symfony\Component\Console\Input\InputArgument;
  4622. use Symfony\Component\Console\Output\OutputInterface;
  4623. use Symfony\Component\Console\Helper\Table;
  4624. class RunScriptCommand extends BaseCommand
  4625. {
  4626. protected $scriptEvents = array(
  4627. ScriptEvents::PRE_INSTALL_CMD,
  4628. ScriptEvents::POST_INSTALL_CMD,
  4629. ScriptEvents::PRE_UPDATE_CMD,
  4630. ScriptEvents::POST_UPDATE_CMD,
  4631. ScriptEvents::PRE_STATUS_CMD,
  4632. ScriptEvents::POST_STATUS_CMD,
  4633. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  4634. ScriptEvents::POST_CREATE_PROJECT_CMD,
  4635. ScriptEvents::PRE_ARCHIVE_CMD,
  4636. ScriptEvents::POST_ARCHIVE_CMD,
  4637. ScriptEvents::PRE_AUTOLOAD_DUMP,
  4638. ScriptEvents::POST_AUTOLOAD_DUMP,
  4639. );
  4640. protected function configure()
  4641. {
  4642. $this
  4643. ->setName('run-script')
  4644. ->setDescription('Runs the scripts defined in composer.json.')
  4645. ->setDefinition(array(
  4646. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  4647. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  4648. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  4649. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  4650. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  4651. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  4652. ))
  4653. ->setHelp(
  4654. <<<EOT
  4655. The <info>run-script</info> command runs scripts defined in composer.json:
  4656. <info>php composer.phar run-script post-update-cmd</info>
  4657. EOT
  4658. )
  4659. ;
  4660. }
  4661. protected function execute(InputInterface $input, OutputInterface $output)
  4662. {
  4663. if ($input->getOption('list')) {
  4664. return $this->listScripts($output);
  4665. } elseif (!$input->getArgument('script')) {
  4666. throw new \RuntimeException('Missing required argument "script"');
  4667. }
  4668. $script = $input->getArgument('script');
  4669. if (!in_array($script, $this->scriptEvents)) {
  4670. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  4671. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  4672. }
  4673. }
  4674. $composer = $this->getComposer();
  4675. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  4676. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  4677. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  4678. if (!$hasListeners) {
  4679. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  4680. }
  4681. $args = $input->getArgument('args');
  4682. if (null !== $timeout = $input->getOption('timeout')) {
  4683. if (!ctype_digit($timeout)) {
  4684. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  4685. }
  4686. ProcessExecutor::setTimeout((int) $timeout);
  4687. }
  4688. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  4689. }
  4690. protected function listScripts(OutputInterface $output)
  4691. {
  4692. $scripts = $this->getComposer()->getPackage()->getScripts();
  4693. if (!count($scripts)) {
  4694. return 0;
  4695. }
  4696. $io = $this->getIO();
  4697. $io->writeError('<info>scripts:</info>');
  4698. $table = array();
  4699. foreach ($scripts as $name => $script) {
  4700. $description = '';
  4701. try {
  4702. $cmd = $this->getApplication()->find($name);
  4703. if ($cmd instanceof ScriptAliasCommand) {
  4704. $description = $cmd->getDescription();
  4705. }
  4706. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  4707. }
  4708. $table[] = array(' '.$name, $description);
  4709. }
  4710. $renderer = new Table($output);
  4711. $renderer->setStyle('compact');
  4712. $rendererStyle = $renderer->getStyle();
  4713. $rendererStyle->setVerticalBorderChar('');
  4714. $rendererStyle->setCellRowContentFormat('%s ');
  4715. $renderer->setRows($table)->render();
  4716. return 0;
  4717. }
  4718. }
  4719. <?php
  4720. namespace Composer\Command;
  4721. use Symfony\Component\Console\Input\InputInterface;
  4722. use Symfony\Component\Console\Input\InputOption;
  4723. use Symfony\Component\Console\Input\InputArgument;
  4724. use Symfony\Component\Console\Output\OutputInterface;
  4725. class ScriptAliasCommand extends BaseCommand
  4726. {
  4727. private $script;
  4728. private $description;
  4729. public function __construct($script, $description)
  4730. {
  4731. $this->script = $script;
  4732. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  4733. parent::__construct();
  4734. }
  4735. protected function configure()
  4736. {
  4737. $this
  4738. ->setName($this->script)
  4739. ->setDescription($this->description)
  4740. ->setDefinition(array(
  4741. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  4742. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  4743. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  4744. ))
  4745. ->setHelp(
  4746. <<<EOT
  4747. The <info>run-script</info> command runs scripts defined in composer.json:
  4748. <info>php composer.phar run-script post-update-cmd</info>
  4749. EOT
  4750. )
  4751. ;
  4752. }
  4753. protected function execute(InputInterface $input, OutputInterface $output)
  4754. {
  4755. $composer = $this->getComposer();
  4756. $args = $input->getArguments();
  4757. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  4758. }
  4759. }
  4760. <?php
  4761. namespace Composer\Command;
  4762. use Composer\Factory;
  4763. use Symfony\Component\Console\Input\InputInterface;
  4764. use Symfony\Component\Console\Input\InputArgument;
  4765. use Symfony\Component\Console\Input\InputOption;
  4766. use Symfony\Component\Console\Output\OutputInterface;
  4767. use Composer\Repository\CompositeRepository;
  4768. use Composer\Repository\PlatformRepository;
  4769. use Composer\Repository\RepositoryInterface;
  4770. use Composer\Plugin\CommandEvent;
  4771. use Composer\Plugin\PluginEvents;
  4772. class SearchCommand extends BaseCommand
  4773. {
  4774. protected $matches;
  4775. protected $lowMatches = array();
  4776. protected $tokens;
  4777. protected $output;
  4778. protected $onlyName;
  4779. protected function configure()
  4780. {
  4781. $this
  4782. ->setName('search')
  4783. ->setDescription('Searches for packages.')
  4784. ->setDefinition(array(
  4785. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in name'),
  4786. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  4787. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  4788. ))
  4789. ->setHelp(
  4790. <<<EOT
  4791. The search command searches for packages by its name
  4792. <info>php composer.phar search symfony composer</info>
  4793. EOT
  4794. )
  4795. ;
  4796. }
  4797. protected function execute(InputInterface $input, OutputInterface $output)
  4798. {
  4799. $platformRepo = new PlatformRepository;
  4800. $io = $this->getIO();
  4801. if (!($composer = $this->getComposer(false))) {
  4802. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  4803. }
  4804. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  4805. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  4806. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  4807. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  4808. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4809. $onlyName = $input->getOption('only-name');
  4810. $type = $input->getOption('type') ?: null;
  4811. $flags = $onlyName ? RepositoryInterface::SEARCH_NAME : RepositoryInterface::SEARCH_FULLTEXT;
  4812. $results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags, $type);
  4813. foreach ($results as $result) {
  4814. $io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
  4815. }
  4816. }
  4817. }
  4818. <?php
  4819. namespace Composer\Command;
  4820. use Composer\Composer;
  4821. use Composer\Factory;
  4822. use Composer\Config;
  4823. use Composer\Util\Filesystem;
  4824. use Composer\SelfUpdate\Keys;
  4825. use Composer\SelfUpdate\Versions;
  4826. use Composer\IO\IOInterface;
  4827. use Composer\Downloader\FilesystemException;
  4828. use Symfony\Component\Console\Input\InputInterface;
  4829. use Symfony\Component\Console\Input\InputOption;
  4830. use Symfony\Component\Console\Input\InputArgument;
  4831. use Symfony\Component\Console\Output\OutputInterface;
  4832. use Symfony\Component\Finder\Finder;
  4833. class SelfUpdateCommand extends BaseCommand
  4834. {
  4835. const HOMEPAGE = 'getcomposer.org';
  4836. const OLD_INSTALL_EXT = '-old.phar';
  4837. protected function configure()
  4838. {
  4839. $this
  4840. ->setName('self-update')
  4841. ->setAliases(array('selfupdate'))
  4842. ->setDescription('Updates composer.phar to the latest version.')
  4843. ->setDefinition(array(
  4844. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  4845. 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'),
  4846. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  4847. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4848. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  4849. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  4850. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  4851. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  4852. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  4853. ))
  4854. ->setHelp(
  4855. <<<EOT
  4856. The <info>self-update</info> command checks getcomposer.org for newer
  4857. versions of composer and if found, installs the latest.
  4858. <info>php composer.phar self-update</info>
  4859. EOT
  4860. )
  4861. ;
  4862. }
  4863. protected function execute(InputInterface $input, OutputInterface $output)
  4864. {
  4865. $config = Factory::createConfig();
  4866. if ($config->get('disable-tls') === true) {
  4867. $baseUrl = 'http://' . self::HOMEPAGE;
  4868. } else {
  4869. $baseUrl = 'https://' . self::HOMEPAGE;
  4870. }
  4871. $io = $this->getIO();
  4872. $remoteFilesystem = Factory::createRemoteFilesystem($io, $config);
  4873. $versionsUtil = new Versions($config, $remoteFilesystem);
  4874. foreach (array('stable', 'preview', 'snapshot') as $channel) {
  4875. if ($input->getOption($channel)) {
  4876. $versionsUtil->setChannel($channel);
  4877. }
  4878. }
  4879. if ($input->getOption('set-channel-only')) {
  4880. return 0;
  4881. }
  4882. $cacheDir = $config->get('cache-dir');
  4883. $rollbackDir = $config->get('data-dir');
  4884. $home = $config->get('home');
  4885. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  4886. if ($input->getOption('update-keys')) {
  4887. return $this->fetchKeys($io, $config);
  4888. }
  4889. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  4890. if (!is_writable($tmpDir)) {
  4891. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  4892. }
  4893. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  4894. $composeUser = posix_getpwuid(posix_geteuid());
  4895. $homeOwner = posix_getpwuid(fileowner($home));
  4896. if (isset($composeUser['name']) && isset($homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  4897. $io->writeError('<warning>You are running composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  4898. }
  4899. }
  4900. if ($input->getOption('rollback')) {
  4901. return $this->rollback($output, $rollbackDir, $localFilename);
  4902. }
  4903. $latest = $versionsUtil->getLatest();
  4904. $latestVersion = $latest['version'];
  4905. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  4906. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  4907. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  4908. return 1;
  4909. }
  4910. if (Composer::VERSION === $updateVersion) {
  4911. $io->writeError(sprintf('<info>You are already using composer version %s (%s channel).</info>', $updateVersion, $versionsUtil->getChannel()));
  4912. if ($input->getOption('clean-backups')) {
  4913. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  4914. }
  4915. return 0;
  4916. }
  4917. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp.phar';
  4918. $backupFile = sprintf(
  4919. '%s/%s-%s%s',
  4920. $rollbackDir,
  4921. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  4922. preg_replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  4923. self::OLD_INSTALL_EXT
  4924. );
  4925. $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion);
  4926. $io->write(sprintf("Updating to version <info>%s</info> (%s channel).", $updateVersion, $versionsUtil->getChannel()));
  4927. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  4928. $signature = $remoteFilesystem->getContents(self::HOMEPAGE, $remoteFilename.'.sig', false);
  4929. $io->writeError(' ', false);
  4930. $remoteFilesystem->copy(self::HOMEPAGE, $remoteFilename, $tempFilename, !$input->getOption('no-progress'));
  4931. $io->writeError('');
  4932. if (!file_exists($tempFilename) || !$signature) {
  4933. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  4934. return 1;
  4935. }
  4936. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  4937. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  4938. } else {
  4939. if (!extension_loaded('openssl')) {
  4940. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  4941. . '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.');
  4942. }
  4943. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  4944. if (!file_exists($sigFile)) {
  4945. file_put_contents(
  4946. $home.'/keys.dev.pub',
  4947. <<<DEVPUBKEY
  4948. -----BEGIN PUBLIC KEY-----
  4949. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  4950. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  4951. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  4952. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  4953. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  4954. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  4955. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  4956. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  4957. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  4958. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  4959. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  4960. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  4961. -----END PUBLIC KEY-----
  4962. DEVPUBKEY
  4963. );
  4964. file_put_contents(
  4965. $home.'/keys.tags.pub',
  4966. <<<TAGSPUBKEY
  4967. -----BEGIN PUBLIC KEY-----
  4968. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  4969. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  4970. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  4971. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  4972. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  4973. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  4974. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  4975. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  4976. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  4977. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  4978. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  4979. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  4980. -----END PUBLIC KEY-----
  4981. TAGSPUBKEY
  4982. );
  4983. }
  4984. $pubkeyid = openssl_pkey_get_public($sigFile);
  4985. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  4986. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  4987. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  4988. }
  4989. $signature = json_decode($signature, true);
  4990. $signature = base64_decode($signature['sha384']);
  4991. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  4992. openssl_free_key($pubkeyid);
  4993. if (!$verified) {
  4994. 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');
  4995. }
  4996. }
  4997. if ($input->getOption('clean-backups')) {
  4998. $this->cleanBackups($rollbackDir);
  4999. }
  5000. if ($err = $this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  5001. @unlink($tempFilename);
  5002. $io->writeError('<error>The file is corrupted ('.$err->getMessage().').</error>');
  5003. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  5004. return 1;
  5005. }
  5006. if (file_exists($backupFile)) {
  5007. $io->writeError(sprintf(
  5008. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  5009. Composer::VERSION
  5010. ));
  5011. } else {
  5012. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  5013. }
  5014. }
  5015. protected function fetchKeys(IOInterface $io, Config $config)
  5016. {
  5017. if (!$io->isInteractive()) {
  5018. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  5019. }
  5020. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  5021. $validator = function ($value) {
  5022. if (!preg_match('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  5023. throw new \UnexpectedValueException('Invalid input');
  5024. }
  5025. return trim($value)."\n";
  5026. };
  5027. $devKey = '';
  5028. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  5029. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  5030. while ($line = $io->ask('')) {
  5031. $devKey .= trim($line)."\n";
  5032. if (trim($line) === '-----END PUBLIC KEY-----') {
  5033. break;
  5034. }
  5035. }
  5036. }
  5037. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  5038. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5039. $tagsKey = '';
  5040. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  5041. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  5042. while ($line = $io->ask('')) {
  5043. $tagsKey .= trim($line)."\n";
  5044. if (trim($line) === '-----END PUBLIC KEY-----') {
  5045. break;
  5046. }
  5047. }
  5048. }
  5049. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  5050. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5051. $io->write('Public keys stored in '.$config->get('home'));
  5052. }
  5053. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  5054. {
  5055. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  5056. if (!$rollbackVersion) {
  5057. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  5058. }
  5059. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  5060. if (!is_file($oldFile)) {
  5061. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  5062. }
  5063. if (!is_readable($oldFile)) {
  5064. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  5065. }
  5066. $io = $this->getIO();
  5067. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  5068. if ($err = $this->setLocalPhar($localFilename, $oldFile)) {
  5069. $io->writeError('<error>The backup file was corrupted ('.$err->getMessage().').</error>');
  5070. return 1;
  5071. }
  5072. return 0;
  5073. }
  5074. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  5075. {
  5076. try {
  5077. @chmod($newFilename, fileperms($localFilename));
  5078. if (!ini_get('phar.readonly')) {
  5079. $phar = new \Phar($newFilename);
  5080. unset($phar);
  5081. }
  5082. if ($backupTarget && file_exists($localFilename)) {
  5083. @copy($localFilename, $backupTarget);
  5084. }
  5085. rename($newFilename, $localFilename);
  5086. return null;
  5087. } catch (\Exception $e) {
  5088. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  5089. throw $e;
  5090. }
  5091. return $e;
  5092. }
  5093. }
  5094. protected function cleanBackups($rollbackDir, $except = null)
  5095. {
  5096. $finder = $this->getOldInstallationFinder($rollbackDir);
  5097. $io = $this->getIO();
  5098. $fs = new Filesystem;
  5099. foreach ($finder as $file) {
  5100. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  5101. continue;
  5102. }
  5103. $file = (string) $file;
  5104. $io->writeError('<info>Removing: '.$file.'</info>');
  5105. $fs->remove($file);
  5106. }
  5107. }
  5108. protected function getLastBackupVersion($rollbackDir)
  5109. {
  5110. $finder = $this->getOldInstallationFinder($rollbackDir);
  5111. $finder->sortByName();
  5112. $files = iterator_to_array($finder);
  5113. if (count($files)) {
  5114. return basename(end($files), self::OLD_INSTALL_EXT);
  5115. }
  5116. return false;
  5117. }
  5118. protected function getOldInstallationFinder($rollbackDir)
  5119. {
  5120. $finder = Finder::create()
  5121. ->depth(0)
  5122. ->files()
  5123. ->name('*' . self::OLD_INSTALL_EXT)
  5124. ->in($rollbackDir);
  5125. return $finder;
  5126. }
  5127. }
  5128. <?php
  5129. namespace Composer\Command;
  5130. use Composer\Composer;
  5131. use Composer\DependencyResolver\DefaultPolicy;
  5132. use Composer\DependencyResolver\Pool;
  5133. use Composer\Json\JsonFile;
  5134. use Composer\Package\BasePackage;
  5135. use Composer\Package\CompletePackageInterface;
  5136. use Composer\Package\PackageInterface;
  5137. use Composer\Package\Version\VersionParser;
  5138. use Composer\Package\Version\VersionSelector;
  5139. use Composer\Plugin\CommandEvent;
  5140. use Composer\Plugin\PluginEvents;
  5141. use Composer\Repository\ArrayRepository;
  5142. use Composer\Repository\ComposerRepository;
  5143. use Composer\Repository\CompositeRepository;
  5144. use Composer\Repository\PlatformRepository;
  5145. use Composer\Repository\RepositoryFactory;
  5146. use Composer\Repository\RepositoryInterface;
  5147. use Composer\Semver\Constraint\ConstraintInterface;
  5148. use Composer\Semver\Semver;
  5149. use Composer\Spdx\SpdxLicenses;
  5150. use Composer\Util\Platform;
  5151. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  5152. use Symfony\Component\Console\Input\InputArgument;
  5153. use Symfony\Component\Console\Input\InputInterface;
  5154. use Symfony\Component\Console\Input\InputOption;
  5155. use Symfony\Component\Console\Output\OutputInterface;
  5156. use Symfony\Component\Console\Terminal;
  5157. class ShowCommand extends BaseCommand
  5158. {
  5159. protected $versionParser;
  5160. protected $colors;
  5161. private $pool;
  5162. protected function configure()
  5163. {
  5164. $this
  5165. ->setName('show')
  5166. ->setAliases(array('info'))
  5167. ->setDescription('Shows information about packages.')
  5168. ->setDefinition(array(
  5169. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  5170. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  5171. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  5172. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  5173. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  5174. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  5175. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  5176. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  5177. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  5178. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  5179. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  5180. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  5181. 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.'),
  5182. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  5183. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  5184. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  5185. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  5186. ))
  5187. ->setHelp(
  5188. <<<EOT
  5189. The show command displays detailed information about a package, or
  5190. lists all packages available.
  5191. EOT
  5192. )
  5193. ;
  5194. }
  5195. protected function execute(InputInterface $input, OutputInterface $output)
  5196. {
  5197. $this->versionParser = new VersionParser;
  5198. if ($input->getOption('tree')) {
  5199. $this->initStyles($output);
  5200. }
  5201. $composer = $this->getComposer(false);
  5202. $io = $this->getIO();
  5203. if ($input->getOption('installed')) {
  5204. $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>');
  5205. }
  5206. if ($input->getOption('outdated')) {
  5207. $input->setOption('latest', true);
  5208. } elseif ($input->getOption('ignore')) {
  5209. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  5210. }
  5211. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  5212. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  5213. return 1;
  5214. }
  5215. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  5216. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  5217. return 1;
  5218. }
  5219. if ($input->getOption('tree') && $input->getOption('latest')) {
  5220. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  5221. return 1;
  5222. }
  5223. $format = $input->getOption('format');
  5224. if (!in_array($format, array('text', 'json'))) {
  5225. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  5226. return 1;
  5227. }
  5228. $platformOverrides = array();
  5229. if ($composer) {
  5230. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5231. }
  5232. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  5233. $phpVersion = $platformRepo->findPackage('php', '*')->getVersion();
  5234. if ($input->getOption('self')) {
  5235. $package = $this->getComposer()->getPackage();
  5236. $repos = $installedRepo = new ArrayRepository(array($package));
  5237. } elseif ($input->getOption('platform')) {
  5238. $repos = $installedRepo = $platformRepo;
  5239. } elseif ($input->getOption('available')) {
  5240. $installedRepo = $platformRepo;
  5241. if ($composer) {
  5242. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  5243. } else {
  5244. $defaultRepos = RepositoryFactory::defaultRepos($io);
  5245. $repos = new CompositeRepository($defaultRepos);
  5246. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  5247. }
  5248. } elseif ($input->getOption('all') && $composer) {
  5249. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5250. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  5251. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  5252. } elseif ($input->getOption('all')) {
  5253. $defaultRepos = RepositoryFactory::defaultRepos($io);
  5254. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  5255. $installedRepo = $platformRepo;
  5256. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  5257. } else {
  5258. $repos = $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
  5259. $rootPkg = $this->getComposer()->getPackage();
  5260. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  5261. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  5262. }
  5263. }
  5264. if ($composer) {
  5265. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  5266. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5267. }
  5268. if ($input->getOption('latest') && null === $composer) {
  5269. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  5270. $input->setOption('latest', false);
  5271. }
  5272. $packageFilter = $input->getArgument('package');
  5273. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  5274. if (empty($package)) {
  5275. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  5276. if (empty($package)) {
  5277. $options = $input->getOptions();
  5278. if (!isset($options['working-dir']) || !file_exists('composer.json')) {
  5279. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
  5280. }
  5281. $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
  5282. return 1;
  5283. }
  5284. } else {
  5285. $versions = array($package->getPrettyVersion() => $package->getVersion());
  5286. }
  5287. $exitCode = 0;
  5288. if ($input->getOption('tree')) {
  5289. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  5290. if ('json' === $format) {
  5291. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  5292. } else {
  5293. $this->displayPackageTree(array($arrayTree));
  5294. }
  5295. } else {
  5296. $latestPackage = null;
  5297. if ($input->getOption('latest')) {
  5298. $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion);
  5299. }
  5300. if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) {
  5301. $exitCode = 1;
  5302. }
  5303. if ($input->getOption('path')) {
  5304. $io->write($package->getName(), false);
  5305. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  5306. return $exitCode;
  5307. }
  5308. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  5309. $this->printLinks($package, 'requires');
  5310. $this->printLinks($package, 'devRequires', 'requires (dev)');
  5311. if ($package->getSuggests()) {
  5312. $io->write("\n<info>suggests</info>");
  5313. foreach ($package->getSuggests() as $suggested => $reason) {
  5314. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  5315. }
  5316. }
  5317. $this->printLinks($package, 'provides');
  5318. $this->printLinks($package, 'conflicts');
  5319. $this->printLinks($package, 'replaces');
  5320. }
  5321. return $exitCode;
  5322. }
  5323. if ($input->getOption('tree')) {
  5324. $rootRequires = $this->getRootRequires();
  5325. $packages = $installedRepo->getPackages();
  5326. usort($packages, 'strcmp');
  5327. $arrayTree = array();
  5328. foreach ($packages as $package) {
  5329. if (in_array($package->getName(), $rootRequires, true)) {
  5330. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  5331. }
  5332. }
  5333. if ('json' === $format) {
  5334. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  5335. } else {
  5336. $this->displayPackageTree($arrayTree);
  5337. }
  5338. return 0;
  5339. }
  5340. if ($repos instanceof CompositeRepository) {
  5341. $repos = $repos->getRepositories();
  5342. } elseif (!is_array($repos)) {
  5343. $repos = array($repos);
  5344. }
  5345. $packages = array();
  5346. if (null !== $packageFilter) {
  5347. $packageFilter = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  5348. }
  5349. $packageListFilter = array();
  5350. if ($input->getOption('direct')) {
  5351. $packageListFilter = $this->getRootRequires();
  5352. }
  5353. if (class_exists('Symfony\Component\Console\Terminal')) {
  5354. $terminal = new Terminal();
  5355. $width = $terminal->getWidth();
  5356. } else {
  5357. list($width) = $this->getApplication()->getTerminalDimensions();
  5358. }
  5359. if (null === $width) {
  5360. $width = PHP_INT_MAX;
  5361. }
  5362. if (Platform::isWindows()) {
  5363. $width--;
  5364. } else {
  5365. $width = max(80, $width);
  5366. }
  5367. if ($input->getOption('path') && null === $composer) {
  5368. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  5369. $input->setOption('path', false);
  5370. }
  5371. foreach ($repos as $repo) {
  5372. if ($repo === $platformRepo) {
  5373. $type = 'platform';
  5374. } elseif (
  5375. $repo === $installedRepo
  5376. || ($installedRepo instanceof CompositeRepository && in_array($repo, $installedRepo->getRepositories(), true))
  5377. ) {
  5378. $type = 'installed';
  5379. } else {
  5380. $type = 'available';
  5381. }
  5382. if ($repo instanceof ComposerRepository && $repo->hasProviders()) {
  5383. foreach ($repo->getProviderNames() as $name) {
  5384. if (!$packageFilter || preg_match($packageFilter, $name)) {
  5385. $packages[$type][$name] = $name;
  5386. }
  5387. }
  5388. } else {
  5389. foreach ($repo->getPackages() as $package) {
  5390. if (!isset($packages[$type][$package->getName()])
  5391. || !is_object($packages[$type][$package->getName()])
  5392. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  5393. ) {
  5394. if (!$packageFilter || preg_match($packageFilter, $package->getName())) {
  5395. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  5396. $packages[$type][$package->getName()] = $package;
  5397. }
  5398. }
  5399. }
  5400. }
  5401. }
  5402. }
  5403. $showAllTypes = $input->getOption('all');
  5404. $showLatest = $input->getOption('latest');
  5405. $showMinorOnly = $input->getOption('minor-only');
  5406. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  5407. $indent = $showAllTypes ? ' ' : '';
  5408. $latestPackages = array();
  5409. $exitCode = 0;
  5410. $viewData = array();
  5411. $viewMetaData = array();
  5412. foreach (array('platform' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  5413. if (isset($packages[$type])) {
  5414. ksort($packages[$type]);
  5415. $nameLength = $versionLength = $latestLength = 0;
  5416. if ($showLatest && $showVersion) {
  5417. foreach ($packages[$type] as $package) {
  5418. if (is_object($package)) {
  5419. $latestPackage = $this->findLatestPackage($package, $composer, $phpVersion, $showMinorOnly);
  5420. if ($latestPackage === false) {
  5421. continue;
  5422. }
  5423. $latestPackages[$package->getPrettyName()] = $latestPackage;
  5424. }
  5425. }
  5426. }
  5427. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  5428. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  5429. $writeLatest = $writeVersion && $showLatest;
  5430. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  5431. $hasOutdatedPackages = false;
  5432. $viewData[$type] = array();
  5433. foreach ($packages[$type] as $package) {
  5434. $packageViewData = array();
  5435. if (is_object($package)) {
  5436. $latestPackage = null;
  5437. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  5438. $latestPackage = $latestPackages[$package->getPrettyName()];
  5439. }
  5440. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackage->isAbandoned();
  5441. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  5442. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  5443. continue;
  5444. } elseif ($input->getOption('outdated') || $input->getOption('strict')) {
  5445. $hasOutdatedPackages = true;
  5446. }
  5447. $packageViewData['name'] = $package->getPrettyName();
  5448. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  5449. if ($writeVersion) {
  5450. $packageViewData['version'] = $package->getFullPrettyVersion();
  5451. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  5452. }
  5453. if ($writeLatest && $latestPackage) {
  5454. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  5455. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  5456. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  5457. }
  5458. if ($writeDescription) {
  5459. $packageViewData['description'] = $package->getDescription();
  5460. }
  5461. if ($writePath) {
  5462. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  5463. }
  5464. if ($latestPackage && $latestPackage->isAbandoned()) {
  5465. $replacement = is_string($latestPackage->getReplacementPackage())
  5466. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  5467. : 'No replacement was suggested';
  5468. $packageWarning = sprintf(
  5469. 'Package %s is abandoned, you should avoid using it. %s.',
  5470. $package->getPrettyName(),
  5471. $replacement
  5472. );
  5473. $packageViewData['warning'] = $packageWarning;
  5474. }
  5475. } else {
  5476. $packageViewData['name'] = $package;
  5477. $nameLength = max($nameLength, strlen($package));
  5478. }
  5479. $viewData[$type][] = $packageViewData;
  5480. }
  5481. $viewMetaData[$type] = array(
  5482. 'nameLength' => $nameLength,
  5483. 'versionLength' => $versionLength,
  5484. 'latestLength' => $latestLength,
  5485. );
  5486. if ($input->getOption('strict') && $hasOutdatedPackages) {
  5487. $exitCode = 1;
  5488. break;
  5489. }
  5490. }
  5491. }
  5492. if ('json' === $format) {
  5493. $io->write(JsonFile::encode($viewData));
  5494. } else {
  5495. foreach ($viewData as $type => $packages) {
  5496. $nameLength = $viewMetaData[$type]['nameLength'];
  5497. $versionLength = $viewMetaData[$type]['versionLength'];
  5498. $latestLength = $viewMetaData[$type]['latestLength'];
  5499. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  5500. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  5501. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  5502. if ($writeLatest && !$io->isDecorated()) {
  5503. $latestLength += 2;
  5504. }
  5505. if ($showAllTypes) {
  5506. if ('available' === $type) {
  5507. $io->write('<comment>' . $type . '</comment>:');
  5508. } else {
  5509. $io->write('<info>' . $type . '</info>:');
  5510. }
  5511. }
  5512. foreach ($packages as $package) {
  5513. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  5514. if (isset($package['version']) && $writeVersion) {
  5515. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  5516. }
  5517. if (isset($package['latest']) && $writeLatest) {
  5518. $latestVersion = $package['latest'];
  5519. $updateStatus = $package['latest-status'];
  5520. $style = $this->updateStatusToVersionStyle($updateStatus);
  5521. if (!$io->isDecorated()) {
  5522. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  5523. }
  5524. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  5525. }
  5526. if (isset($package['description']) && $writeDescription) {
  5527. $description = strtok($package['description'], "\r\n");
  5528. $remaining = $width - $nameLength - $versionLength - 4;
  5529. if ($writeLatest) {
  5530. $remaining -= $latestLength;
  5531. }
  5532. if (strlen($description) > $remaining) {
  5533. $description = substr($description, 0, $remaining - 3) . '...';
  5534. }
  5535. $io->write(' ' . $description, false);
  5536. }
  5537. if (isset($package['path'])) {
  5538. $io->write(' ' . $package['path'], false);
  5539. }
  5540. $io->write('');
  5541. if (isset($package['warning'])) {
  5542. $io->writeError('<warning>' . $package['warning'] . '</warning>');
  5543. }
  5544. }
  5545. if ($showAllTypes) {
  5546. $io->write('');
  5547. }
  5548. }
  5549. }
  5550. return $exitCode;
  5551. }
  5552. protected function getRootRequires()
  5553. {
  5554. $rootPackage = $this->getComposer()->getPackage();
  5555. return array_map(
  5556. 'strtolower',
  5557. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  5558. );
  5559. }
  5560. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  5561. {
  5562. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  5563. }
  5564. protected function getPackage(RepositoryInterface $installedRepo, RepositoryInterface $repos, $name, $version = null)
  5565. {
  5566. $name = strtolower($name);
  5567. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  5568. $policy = new DefaultPolicy();
  5569. $pool = new Pool('dev');
  5570. $pool->addRepository($repos);
  5571. $matchedPackage = null;
  5572. $versions = array();
  5573. $matches = $pool->whatProvides($name, $constraint);
  5574. foreach ($matches as $index => $package) {
  5575. if ($package->getName() !== $name) {
  5576. unset($matches[$index]);
  5577. continue;
  5578. }
  5579. if (null === $version && $installedRepo->hasPackage($package)) {
  5580. $matchedPackage = $package;
  5581. }
  5582. $versions[$package->getPrettyVersion()] = $package->getVersion();
  5583. $matches[$index] = $package->getId();
  5584. }
  5585. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, array(), $matches)) {
  5586. $matchedPackage = $pool->literalToPackage($preferred[0]);
  5587. }
  5588. return array($matchedPackage, $versions);
  5589. }
  5590. protected function printMeta(CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo, PackageInterface $latestPackage = null)
  5591. {
  5592. $io = $this->getIO();
  5593. $io->write('<info>name</info> : ' . $package->getPrettyName());
  5594. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  5595. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  5596. $this->printVersions($package, $versions, $installedRepo);
  5597. if ($latestPackage) {
  5598. $style = $this->getVersionStyle($latestPackage, $package);
  5599. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  5600. } else {
  5601. $latestPackage = $package;
  5602. }
  5603. $io->write('<info>type</info> : ' . $package->getType());
  5604. $this->printLicenses($package);
  5605. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  5606. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  5607. if ($installedRepo->hasPackage($package)) {
  5608. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  5609. }
  5610. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  5611. if ($latestPackage->isAbandoned()) {
  5612. $replacement = ($latestPackage->getReplacementPackage() !== null)
  5613. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  5614. : null;
  5615. $io->writeError(
  5616. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  5617. );
  5618. }
  5619. if ($package->getSupport()) {
  5620. $io->write("\n<info>support</info>");
  5621. foreach ($package->getSupport() as $type => $value) {
  5622. $io->write('<comment>' . $type . '</comment> : '.$value);
  5623. }
  5624. }
  5625. if ($package->getAutoload()) {
  5626. $io->write("\n<info>autoload</info>");
  5627. foreach ($package->getAutoload() as $type => $autoloads) {
  5628. $io->write('<comment>' . $type . '</comment>');
  5629. if ($type === 'psr-0') {
  5630. foreach ($autoloads as $name => $path) {
  5631. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  5632. }
  5633. } elseif ($type === 'psr-4') {
  5634. foreach ($autoloads as $name => $path) {
  5635. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  5636. }
  5637. } elseif ($type === 'classmap') {
  5638. $io->write(implode(', ', $autoloads));
  5639. }
  5640. }
  5641. if ($package->getIncludePaths()) {
  5642. $io->write('<comment>include-path</comment>');
  5643. $io->write(implode(', ', $package->getIncludePaths()));
  5644. }
  5645. }
  5646. }
  5647. protected function printVersions(CompletePackageInterface $package, array $versions, RepositoryInterface $installedRepo)
  5648. {
  5649. uasort($versions, 'version_compare');
  5650. $versions = array_keys(array_reverse($versions));
  5651. if ($installedRepo->hasPackage($package)) {
  5652. $installedVersion = $package->getPrettyVersion();
  5653. $key = array_search($installedVersion, $versions);
  5654. if (false !== $key) {
  5655. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  5656. }
  5657. }
  5658. $versions = implode(', ', $versions);
  5659. $this->getIO()->write('<info>versions</info> : ' . $versions);
  5660. }
  5661. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  5662. {
  5663. $title = $title ?: $linkType;
  5664. $io = $this->getIO();
  5665. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  5666. $io->write("\n<info>" . $title . "</info>");
  5667. foreach ($links as $link) {
  5668. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  5669. }
  5670. }
  5671. }
  5672. protected function printLicenses(CompletePackageInterface $package)
  5673. {
  5674. $spdxLicenses = new SpdxLicenses();
  5675. $licenses = $package->getLicense();
  5676. $io = $this->getIO();
  5677. foreach ($licenses as $licenseId) {
  5678. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  5679. if (!$license) {
  5680. $out = $licenseId;
  5681. } else {
  5682. if ($license[1] === true) {
  5683. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  5684. } else {
  5685. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  5686. }
  5687. }
  5688. $io->write('<info>license</info> : ' . $out);
  5689. }
  5690. }
  5691. protected function initStyles(OutputInterface $output)
  5692. {
  5693. $this->colors = array(
  5694. 'green',
  5695. 'yellow',
  5696. 'cyan',
  5697. 'magenta',
  5698. 'blue',
  5699. );
  5700. foreach ($this->colors as $color) {
  5701. $style = new OutputFormatterStyle($color);
  5702. $output->getFormatter()->setStyle($color, $style);
  5703. }
  5704. }
  5705. protected function displayPackageTree(array $arrayTree)
  5706. {
  5707. $io = $this->getIO();
  5708. foreach ($arrayTree as $package) {
  5709. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  5710. $io->write(' ' . $package['version'], false);
  5711. $io->write(' ' . strtok($package['description'], "\r\n"));
  5712. if (isset($package['requires'])) {
  5713. $requires = $package['requires'];
  5714. $treeBar = '├';
  5715. $j = 0;
  5716. $total = count($requires);
  5717. foreach ($requires as $require) {
  5718. $requireName = $require['name'];
  5719. $j++;
  5720. if ($j === $total) {
  5721. $treeBar = 'â””';
  5722. }
  5723. $level = 1;
  5724. $color = $this->colors[$level];
  5725. $info = sprintf(
  5726. '%s──<%s>%s</%s> %s',
  5727. $treeBar,
  5728. $color,
  5729. $requireName,
  5730. $color,
  5731. $require['version']
  5732. );
  5733. $this->writeTreeLine($info);
  5734. $treeBar = str_replace('â””', ' ', $treeBar);
  5735. $packagesInTree = array($package['name'], $requireName);
  5736. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  5737. }
  5738. }
  5739. }
  5740. }
  5741. protected function generatePackageTree(
  5742. PackageInterface $package,
  5743. RepositoryInterface $installedRepo,
  5744. RepositoryInterface $distantRepos
  5745. ) {
  5746. $requires = $package->getRequires();
  5747. ksort($requires);
  5748. $children = array();
  5749. foreach ($requires as $requireName => $require) {
  5750. $packagesInTree = array($package->getName(), $requireName);
  5751. $treeChildDesc = array(
  5752. 'name' => $requireName,
  5753. 'version' => $require->getPrettyConstraint(),
  5754. );
  5755. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $distantRepos, $packagesInTree);
  5756. if ($deepChildren) {
  5757. $treeChildDesc['requires'] = $deepChildren;
  5758. }
  5759. $children[] = $treeChildDesc;
  5760. }
  5761. $tree = array(
  5762. 'name' => $package->getPrettyName(),
  5763. 'version' => $package->getPrettyVersion(),
  5764. 'description' => $package->getDescription(),
  5765. );
  5766. if ($children) {
  5767. $tree['requires'] = $children;
  5768. }
  5769. return $tree;
  5770. }
  5771. protected function displayTree(
  5772. $package,
  5773. array $packagesInTree,
  5774. $previousTreeBar = '├',
  5775. $level = 1
  5776. ) {
  5777. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  5778. if (isset($package['requires'])) {
  5779. $requires = $package['requires'];
  5780. $treeBar = $previousTreeBar . ' ├';
  5781. $i = 0;
  5782. $total = count($requires);
  5783. foreach ($requires as $require) {
  5784. $currentTree = $packagesInTree;
  5785. $i++;
  5786. if ($i === $total) {
  5787. $treeBar = $previousTreeBar . ' â””';
  5788. }
  5789. $colorIdent = $level % count($this->colors);
  5790. $color = $this->colors[$colorIdent];
  5791. $circularWarn = in_array(
  5792. $require['name'],
  5793. $currentTree,
  5794. true
  5795. ) ? '(circular dependency aborted here)' : '';
  5796. $info = rtrim(sprintf(
  5797. '%s──<%s>%s</%s> %s %s',
  5798. $treeBar,
  5799. $color,
  5800. $require['name'],
  5801. $color,
  5802. $require['version'],
  5803. $circularWarn
  5804. ));
  5805. $this->writeTreeLine($info);
  5806. $treeBar = str_replace('â””', ' ', $treeBar);
  5807. $currentTree[] = $require['name'];
  5808. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  5809. }
  5810. }
  5811. }
  5812. protected function addTree(
  5813. $name,
  5814. $package,
  5815. RepositoryInterface $installedRepo,
  5816. RepositoryInterface $distantRepos,
  5817. array $packagesInTree
  5818. ) {
  5819. $children = array();
  5820. list($package, $versions) = $this->getPackage(
  5821. $installedRepo,
  5822. $distantRepos,
  5823. $name,
  5824. $package->getPrettyConstraint() === 'self.version' ? $package->getConstraint() : $package->getPrettyConstraint()
  5825. );
  5826. if (is_object($package)) {
  5827. $requires = $package->getRequires();
  5828. ksort($requires);
  5829. foreach ($requires as $requireName => $require) {
  5830. $currentTree = $packagesInTree;
  5831. $treeChildDesc = array(
  5832. 'name' => $requireName,
  5833. 'version' => $require->getPrettyConstraint(),
  5834. );
  5835. if (!in_array($requireName, $currentTree, true)) {
  5836. $currentTree[] = $requireName;
  5837. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $distantRepos, $currentTree);
  5838. if ($deepChildren) {
  5839. $treeChildDesc['requires'] = $deepChildren;
  5840. }
  5841. }
  5842. $children[] = $treeChildDesc;
  5843. }
  5844. }
  5845. return $children;
  5846. }
  5847. private function updateStatusToVersionStyle($updateStatus)
  5848. {
  5849. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  5850. }
  5851. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  5852. {
  5853. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  5854. return 'up-to-date';
  5855. }
  5856. $constraint = $package->getVersion();
  5857. if (0 !== strpos($constraint, 'dev-')) {
  5858. $constraint = '^'.$constraint;
  5859. }
  5860. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  5861. return 'semver-safe-update';
  5862. }
  5863. return 'update-possible';
  5864. }
  5865. private function writeTreeLine($line)
  5866. {
  5867. $io = $this->getIO();
  5868. if (!$io->isDecorated()) {
  5869. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  5870. }
  5871. $io->write($line);
  5872. }
  5873. private function findLatestPackage(PackageInterface $package, Composer $composer, $phpVersion, $minorOnly = false)
  5874. {
  5875. $name = $package->getName();
  5876. $versionSelector = new VersionSelector($this->getPool($composer));
  5877. $stability = $composer->getPackage()->getMinimumStability();
  5878. $flags = $composer->getPackage()->getStabilityFlags();
  5879. if (isset($flags[$name])) {
  5880. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  5881. }
  5882. $bestStability = $stability;
  5883. if ($composer->getPackage()->getPreferStable()) {
  5884. $bestStability = $package->getStability();
  5885. }
  5886. $targetVersion = null;
  5887. if (0 === strpos($package->getVersion(), 'dev-')) {
  5888. $targetVersion = $package->getVersion();
  5889. }
  5890. if ($targetVersion === null && $minorOnly) {
  5891. $targetVersion = '^' . $package->getVersion();
  5892. }
  5893. return $versionSelector->findBestCandidate($name, $targetVersion, $phpVersion, $bestStability);
  5894. }
  5895. private function getPool(Composer $composer)
  5896. {
  5897. if (!$this->pool) {
  5898. $this->pool = new Pool($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  5899. $this->pool->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  5900. }
  5901. return $this->pool;
  5902. }
  5903. }
  5904. <?php
  5905. namespace Composer\Command;
  5906. use Symfony\Component\Console\Input\InputInterface;
  5907. use Symfony\Component\Console\Input\InputOption;
  5908. use Symfony\Component\Console\Output\OutputInterface;
  5909. use Composer\Downloader\ChangeReportInterface;
  5910. use Composer\Downloader\DvcsDownloaderInterface;
  5911. use Composer\Downloader\VcsCapableDownloaderInterface;
  5912. use Composer\Package\Dumper\ArrayDumper;
  5913. use Composer\Package\Version\VersionGuesser;
  5914. use Composer\Package\Version\VersionParser;
  5915. use Composer\Plugin\CommandEvent;
  5916. use Composer\Plugin\PluginEvents;
  5917. use Composer\Script\ScriptEvents;
  5918. use Composer\Util\ProcessExecutor;
  5919. class StatusCommand extends BaseCommand
  5920. {
  5921. const EXIT_CODE_ERRORS = 1;
  5922. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  5923. const EXIT_CODE_VERSION_CHANGES = 4;
  5924. protected function configure()
  5925. {
  5926. $this
  5927. ->setName('status')
  5928. ->setDescription('Shows a list of locally modified packages, for packages installed from source.')
  5929. ->setDefinition(array(
  5930. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  5931. ))
  5932. ->setHelp(
  5933. <<<EOT
  5934. The status command displays a list of dependencies that have
  5935. been modified locally.
  5936. EOT
  5937. )
  5938. ;
  5939. }
  5940. protected function execute(InputInterface $input, OutputInterface $output)
  5941. {
  5942. $composer = $this->getComposer();
  5943. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  5944. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5945. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  5946. $dm = $composer->getDownloadManager();
  5947. $im = $composer->getInstallationManager();
  5948. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  5949. $errors = array();
  5950. $io = $this->getIO();
  5951. $unpushedChanges = array();
  5952. $vcsVersionChanges = array();
  5953. $parser = new VersionParser;
  5954. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  5955. $dumper = new ArrayDumper;
  5956. foreach ($installedRepo->getCanonicalPackages() as $package) {
  5957. $downloader = $dm->getDownloaderForInstalledPackage($package);
  5958. $targetDir = $im->getInstallPath($package);
  5959. if ($downloader instanceof ChangeReportInterface) {
  5960. if (is_link($targetDir)) {
  5961. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  5962. }
  5963. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  5964. $errors[$targetDir] = $changes;
  5965. }
  5966. }
  5967. if ($downloader instanceof VcsCapableDownloaderInterface) {
  5968. if ($currentRef = $downloader->getVcsReference($package, $targetDir)) {
  5969. switch ($package->getInstallationSource()) {
  5970. case 'source':
  5971. $previousRef = $package->getSourceReference();
  5972. break;
  5973. case 'dist':
  5974. $previousRef = $package->getDistReference();
  5975. break;
  5976. default:
  5977. $previousRef = null;
  5978. }
  5979. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  5980. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  5981. $vcsVersionChanges[$targetDir] = array(
  5982. 'previous' => array(
  5983. 'version' => $package->getPrettyVersion(),
  5984. 'ref' => $previousRef,
  5985. ),
  5986. 'current' => array(
  5987. 'version' => $currentVersion['pretty_version'],
  5988. 'ref' => $currentVersion['commit'],
  5989. ),
  5990. );
  5991. }
  5992. }
  5993. }
  5994. if ($downloader instanceof DvcsDownloaderInterface) {
  5995. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  5996. $unpushedChanges[$targetDir] = $unpushed;
  5997. }
  5998. }
  5999. }
  6000. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  6001. $io->writeError('<info>No local changes</info>');
  6002. return 0;
  6003. }
  6004. if ($errors) {
  6005. $io->writeError('<error>You have changes in the following dependencies:</error>');
  6006. foreach ($errors as $path => $changes) {
  6007. if ($input->getOption('verbose')) {
  6008. $indentedChanges = implode("\n", array_map(function ($line) {
  6009. return ' ' . ltrim($line);
  6010. }, explode("\n", $changes)));
  6011. $io->write('<info>'.$path.'</info>:');
  6012. $io->write($indentedChanges);
  6013. } else {
  6014. $io->write($path);
  6015. }
  6016. }
  6017. }
  6018. if ($unpushedChanges) {
  6019. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  6020. foreach ($unpushedChanges as $path => $changes) {
  6021. if ($input->getOption('verbose')) {
  6022. $indentedChanges = implode("\n", array_map(function ($line) {
  6023. return ' ' . ltrim($line);
  6024. }, explode("\n", $changes)));
  6025. $io->write('<info>'.$path.'</info>:');
  6026. $io->write($indentedChanges);
  6027. } else {
  6028. $io->write($path);
  6029. }
  6030. }
  6031. }
  6032. if ($vcsVersionChanges) {
  6033. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  6034. foreach ($vcsVersionChanges as $path => $changes) {
  6035. if ($input->getOption('verbose')) {
  6036. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  6037. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  6038. if ($io->isVeryVerbose()) {
  6039. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  6040. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  6041. }
  6042. $io->write('<info>'.$path.'</info>:');
  6043. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  6044. } else {
  6045. $io->write($path);
  6046. }
  6047. }
  6048. }
  6049. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  6050. $io->writeError('Use --verbose (-v) to see a list of files');
  6051. }
  6052. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  6053. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  6054. }
  6055. }
  6056. <?php
  6057. namespace Composer\Command;
  6058. use Composer\Repository\PlatformRepository;
  6059. use Symfony\Component\Console\Input\InputArgument;
  6060. use Symfony\Component\Console\Input\InputInterface;
  6061. use Symfony\Component\Console\Input\InputOption;
  6062. use Symfony\Component\Console\Output\OutputInterface;
  6063. class SuggestsCommand extends BaseCommand
  6064. {
  6065. protected function configure()
  6066. {
  6067. $this
  6068. ->setName('suggests')
  6069. ->setDescription('Shows package suggestions.')
  6070. ->setDefinition(array(
  6071. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package'),
  6072. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  6073. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  6074. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  6075. ))
  6076. ->setHelp(
  6077. <<<EOT
  6078. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  6079. Enabling <info>-v</info> implies <info>--by-package --by-suggestion</info>, showing both lists.
  6080. EOT
  6081. )
  6082. ;
  6083. }
  6084. protected function execute(InputInterface $input, OutputInterface $output)
  6085. {
  6086. $lock = $this->getComposer()->getLocker()->getLockData();
  6087. if (empty($lock)) {
  6088. throw new \RuntimeException('Lockfile seems to be empty?');
  6089. }
  6090. $packages = $lock['packages'];
  6091. if (!$input->getOption('no-dev')) {
  6092. $packages += $lock['packages-dev'];
  6093. }
  6094. $filter = $input->getArgument('packages');
  6095. $installed = array();
  6096. foreach ($packages as $package) {
  6097. $installed[] = $package['name'];
  6098. if (!empty($package['provide'])) {
  6099. $installed = array_merge($installed, array_keys($package['provide']));
  6100. }
  6101. if (!empty($package['replace'])) {
  6102. $installed = array_merge($installed, array_keys($package['replace']));
  6103. }
  6104. }
  6105. $installed = array_flip($installed);
  6106. ksort($installed);
  6107. $platform = new PlatformRepository(array(), $this->getComposer()->getConfig()->get('platform') ?: array());
  6108. $suggesters = array();
  6109. $suggested = array();
  6110. foreach ($packages as $package) {
  6111. $packageName = $package['name'];
  6112. if ((!empty($filter) && !in_array($packageName, $filter)) || empty($package['suggest'])) {
  6113. continue;
  6114. }
  6115. foreach ($package['suggest'] as $suggestion => $reason) {
  6116. if (false === strpos('/', $suggestion) && null !== $platform->findPackage($suggestion, '*')) {
  6117. continue;
  6118. }
  6119. if (!isset($installed[$suggestion])) {
  6120. $suggesters[$packageName][$suggestion] = $reason;
  6121. $suggested[$suggestion][$packageName] = $reason;
  6122. }
  6123. }
  6124. }
  6125. ksort($suggesters);
  6126. ksort($suggested);
  6127. $mode = 0;
  6128. $io = $this->getIO();
  6129. if ($input->getOption('by-package') || $io->isVerbose()) {
  6130. $mode |= 1;
  6131. }
  6132. if ($input->getOption('by-suggestion')) {
  6133. $mode |= 2;
  6134. }
  6135. if ($mode === 0) {
  6136. foreach (array_keys($suggested) as $suggestion) {
  6137. $io->write(sprintf('<info>%s</info>', $suggestion));
  6138. }
  6139. return;
  6140. }
  6141. if ($mode & 1) {
  6142. foreach ($suggesters as $suggester => $suggestions) {
  6143. $io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  6144. foreach ($suggestions as $suggestion => $reason) {
  6145. $io->write(sprintf(' - <info>%s</info>: %s', $suggestion, $reason ?: '*'));
  6146. }
  6147. $io->write('');
  6148. }
  6149. }
  6150. if ($mode & 2) {
  6151. if ($mode & 1) {
  6152. $io->write(str_repeat('-', 78));
  6153. }
  6154. foreach ($suggested as $suggestion => $suggesters) {
  6155. $io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  6156. foreach ($suggesters as $suggester => $reason) {
  6157. $io->write(sprintf(' - <info>%s</info>: %s', $suggester, $reason ?: '*'));
  6158. }
  6159. $io->write('');
  6160. }
  6161. }
  6162. }
  6163. }
  6164. <?php
  6165. namespace Composer\Command;
  6166. use Composer\Composer;
  6167. use Composer\Installer;
  6168. use Composer\IO\IOInterface;
  6169. use Composer\Plugin\CommandEvent;
  6170. use Composer\Plugin\PluginEvents;
  6171. use Symfony\Component\Console\Helper\Table;
  6172. use Symfony\Component\Console\Input\InputInterface;
  6173. use Symfony\Component\Console\Input\InputOption;
  6174. use Symfony\Component\Console\Input\InputArgument;
  6175. use Symfony\Component\Console\Output\OutputInterface;
  6176. use Symfony\Component\Console\Question\Question;
  6177. class UpdateCommand extends BaseCommand
  6178. {
  6179. protected function configure()
  6180. {
  6181. $this
  6182. ->setName('update')
  6183. ->setAliases(array('u', 'upgrade'))
  6184. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  6185. ->setDefinition(array(
  6186. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  6187. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  6188. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  6189. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  6190. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  6191. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  6192. new InputOption('lock', null, InputOption::VALUE_NONE, 'Only updates the lock file hash to suppress warning about the lock file being out of date.'),
  6193. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  6194. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  6195. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  6196. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  6197. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'Do not show package suggestions.'),
  6198. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Add also dependencies of whitelisted packages to the whitelist, except those defined in root package.'),
  6199. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Add also all dependencies of whitelisted packages to the whitelist, including those defined in root package.'),
  6200. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  6201. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  6202. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  6203. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  6204. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'),
  6205. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  6206. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  6207. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  6208. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  6209. ))
  6210. ->setHelp(
  6211. <<<EOT
  6212. The <info>update</info> command reads the composer.json file from the
  6213. current directory, processes it, and updates, removes or installs all the
  6214. dependencies.
  6215. <info>php composer.phar update</info>
  6216. To limit the update operation to a few packages, you can list the package(s)
  6217. you want to update as such:
  6218. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  6219. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  6220. from a specific vendor:
  6221. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  6222. To select packages names interactively with auto-completion use <info>-i</info>.
  6223. EOT
  6224. )
  6225. ;
  6226. }
  6227. protected function execute(InputInterface $input, OutputInterface $output)
  6228. {
  6229. $io = $this->getIO();
  6230. if ($input->getOption('no-custom-installers')) {
  6231. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  6232. $input->setOption('no-plugins', true);
  6233. }
  6234. if ($input->getOption('dev')) {
  6235. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  6236. }
  6237. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  6238. $packages = $input->getArgument('packages');
  6239. if ($input->getOption('interactive')) {
  6240. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  6241. }
  6242. if ($input->getOption('root-reqs')) {
  6243. $require = array_keys($composer->getPackage()->getRequires());
  6244. if (!$input->getOption('no-dev')) {
  6245. $requireDev = array_keys($composer->getPackage()->getDevRequires());
  6246. $require = array_merge($require, $requireDev);
  6247. }
  6248. if (!empty($packages)) {
  6249. $packages = array_intersect($packages, $require);
  6250. } else {
  6251. $packages = $require;
  6252. }
  6253. }
  6254. $composer->getDownloadManager()->setOutputProgress(!$input->getOption('no-progress'));
  6255. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  6256. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6257. $install = Installer::create($io, $composer);
  6258. $config = $composer->getConfig();
  6259. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  6260. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  6261. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  6262. $apcu = $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  6263. $install
  6264. ->setDryRun($input->getOption('dry-run'))
  6265. ->setVerbose($input->getOption('verbose'))
  6266. ->setPreferSource($preferSource)
  6267. ->setPreferDist($preferDist)
  6268. ->setDevMode(!$input->getOption('no-dev'))
  6269. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  6270. ->setRunScripts(!$input->getOption('no-scripts'))
  6271. ->setSkipSuggest($input->getOption('no-suggest'))
  6272. ->setOptimizeAutoloader($optimize)
  6273. ->setClassMapAuthoritative($authoritative)
  6274. ->setApcuAutoloader($apcu)
  6275. ->setUpdate(true)
  6276. ->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $packages)
  6277. ->setWhitelistTransitiveDependencies($input->getOption('with-dependencies'))
  6278. ->setWhitelistAllDependencies($input->getOption('with-all-dependencies'))
  6279. ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs'))
  6280. ->setPreferStable($input->getOption('prefer-stable'))
  6281. ->setPreferLowest($input->getOption('prefer-lowest'))
  6282. ;
  6283. if ($input->getOption('no-plugins')) {
  6284. $install->disablePlugins();
  6285. }
  6286. return $install->run();
  6287. }
  6288. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  6289. {
  6290. if (!$input->isInteractive()) {
  6291. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  6292. }
  6293. $requires = array_merge(
  6294. $composer->getPackage()->getRequires(),
  6295. $composer->getPackage()->getDevRequires()
  6296. );
  6297. $autocompleterValues = array();
  6298. foreach ($requires as $require) {
  6299. $target = $require->getTarget();
  6300. $autocompleterValues[strtolower($target)] = $target;
  6301. }
  6302. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  6303. foreach ($installedPackages as $package) {
  6304. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  6305. }
  6306. $helper = $this->getHelper('question');
  6307. $question = new Question('<comment>Enter package name: </comment>', null);
  6308. $io->writeError('<info>Press enter without value to end submission</info>');
  6309. do {
  6310. $autocompleterValues = array_diff($autocompleterValues, $packages);
  6311. $question->setAutocompleterValues($autocompleterValues);
  6312. $addedPackage = $helper->ask($input, $output, $question);
  6313. if (!is_string($addedPackage) || empty($addedPackage)) {
  6314. break;
  6315. }
  6316. $addedPackage = strtolower($addedPackage);
  6317. if (!in_array($addedPackage, $packages)) {
  6318. $packages[] = $addedPackage;
  6319. }
  6320. } while (true);
  6321. $packages = array_filter($packages);
  6322. if (!$packages) {
  6323. throw new \InvalidArgumentException('You must enter minimum one package.');
  6324. }
  6325. $table = new Table($output);
  6326. $table->setHeaders(array('Selected packages'));
  6327. foreach ($packages as $package) {
  6328. $table->addRow(array($package));
  6329. }
  6330. $table->render();
  6331. if ($io->askConfirmation(sprintf(
  6332. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  6333. 1 === count($packages) ? '' : 's'
  6334. ), true)) {
  6335. return $packages;
  6336. }
  6337. throw new \RuntimeException('Installation aborted.');
  6338. }
  6339. }
  6340. <?php
  6341. namespace Composer\Command;
  6342. use Composer\Factory;
  6343. use Composer\Package\Loader\ValidatingArrayLoader;
  6344. use Composer\Plugin\CommandEvent;
  6345. use Composer\Plugin\PluginEvents;
  6346. use Composer\Util\ConfigValidator;
  6347. use Symfony\Component\Console\Input\InputArgument;
  6348. use Symfony\Component\Console\Input\InputInterface;
  6349. use Symfony\Component\Console\Input\InputOption;
  6350. use Symfony\Component\Console\Output\OutputInterface;
  6351. class ValidateCommand extends BaseCommand
  6352. {
  6353. protected function configure()
  6354. {
  6355. $this
  6356. ->setName('validate')
  6357. ->setDescription('Validates a composer.json and composer.lock.')
  6358. ->setDefinition(array(
  6359. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not make a complete validation'),
  6360. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  6361. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  6362. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  6363. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  6364. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  6365. ))
  6366. ->setHelp(
  6367. <<<EOT
  6368. The validate command validates a given composer.json and composer.lock
  6369. Exit codes in case of errors are:
  6370. 1 validation warning(s), only when --strict is given
  6371. 2 validation error(s)
  6372. 3 file unreadable or missing
  6373. EOT
  6374. );
  6375. }
  6376. protected function execute(InputInterface $input, OutputInterface $output)
  6377. {
  6378. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  6379. $io = $this->getIO();
  6380. if (!file_exists($file)) {
  6381. $io->writeError('<error>' . $file . ' not found.</error>');
  6382. return 3;
  6383. }
  6384. if (!is_readable($file)) {
  6385. $io->writeError('<error>' . $file . ' is not readable.</error>');
  6386. return 3;
  6387. }
  6388. $validator = new ConfigValidator($io);
  6389. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  6390. $checkPublish = !$input->getOption('no-check-publish');
  6391. $checkLock = !$input->getOption('no-check-lock');
  6392. $isStrict = $input->getOption('strict');
  6393. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
  6394. $lockErrors = array();
  6395. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  6396. $locker = $composer->getLocker();
  6397. if ($locker->isLocked() && !$locker->isFresh()) {
  6398. $lockErrors[] = 'The lock file is not up to date with the latest changes in composer.json, it is recommended that you run `composer update`.';
  6399. }
  6400. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true, $isStrict);
  6401. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  6402. if ($input->getOption('with-dependencies')) {
  6403. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6404. foreach ($localRepo->getPackages() as $package) {
  6405. $path = $composer->getInstallationManager()->getInstallPath($package);
  6406. $file = $path . '/composer.json';
  6407. if (is_dir($path) && file_exists($file)) {
  6408. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll);
  6409. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  6410. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  6411. $exitCode = max($depCode, $exitCode);
  6412. }
  6413. }
  6414. }
  6415. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  6416. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6417. $exitCode = max($eventCode, $exitCode);
  6418. return $exitCode;
  6419. }
  6420. private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false, $isStrict = false)
  6421. {
  6422. if (!$errors && !$publishErrors && !$warnings) {
  6423. $io->write('<info>' . $name . ' is valid</info>');
  6424. } elseif (!$errors && !$publishErrors) {
  6425. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  6426. if ($printSchemaUrl) {
  6427. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  6428. }
  6429. } elseif (!$errors) {
  6430. $io->writeError('<info>' . $name . ' is valid for simple usage with composer but has</info>');
  6431. $io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
  6432. if ($printSchemaUrl) {
  6433. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  6434. }
  6435. } else {
  6436. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  6437. }
  6438. if ($checkPublish) {
  6439. $errors = array_merge($errors, $publishErrors);
  6440. } elseif (!$isStrict) {
  6441. $warnings = array_merge($warnings, $publishErrors);
  6442. }
  6443. if ($checkLock) {
  6444. $errors = array_merge($errors, $lockErrors);
  6445. } elseif (!$isStrict) {
  6446. $warnings = array_merge($warnings, $lockErrors);
  6447. }
  6448. $messages = array(
  6449. 'error' => $errors,
  6450. 'warning' => $warnings,
  6451. );
  6452. foreach ($messages as $style => $msgs) {
  6453. foreach ($msgs as $msg) {
  6454. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  6455. }
  6456. }
  6457. }
  6458. }
  6459. <?php
  6460. namespace Composer;
  6461. use Composer\Package\RootPackageInterface;
  6462. use Composer\Package\Locker;
  6463. use Composer\Repository\RepositoryManager;
  6464. use Composer\Installer\InstallationManager;
  6465. use Composer\Plugin\PluginManager;
  6466. use Composer\Downloader\DownloadManager;
  6467. use Composer\EventDispatcher\EventDispatcher;
  6468. use Composer\Autoload\AutoloadGenerator;
  6469. use Composer\Package\Archiver\ArchiveManager;
  6470. class Composer
  6471. {
  6472. const VERSION = '1.8.0';
  6473. const BRANCH_ALIAS_VERSION = '';
  6474. const RELEASE_DATE = '2018-12-03 10:31:16';
  6475. private $package;
  6476. private $locker;
  6477. private $repositoryManager;
  6478. private $downloadManager;
  6479. private $installationManager;
  6480. private $pluginManager;
  6481. private $config;
  6482. private $eventDispatcher;
  6483. private $autoloadGenerator;
  6484. private $archiveManager;
  6485. public function setPackage(RootPackageInterface $package)
  6486. {
  6487. $this->package = $package;
  6488. }
  6489. public function getPackage()
  6490. {
  6491. return $this->package;
  6492. }
  6493. public function setConfig(Config $config)
  6494. {
  6495. $this->config = $config;
  6496. }
  6497. public function getConfig()
  6498. {
  6499. return $this->config;
  6500. }
  6501. public function setLocker(Locker $locker)
  6502. {
  6503. $this->locker = $locker;
  6504. }
  6505. public function getLocker()
  6506. {
  6507. return $this->locker;
  6508. }
  6509. public function setRepositoryManager(RepositoryManager $manager)
  6510. {
  6511. $this->repositoryManager = $manager;
  6512. }
  6513. public function getRepositoryManager()
  6514. {
  6515. return $this->repositoryManager;
  6516. }
  6517. public function setDownloadManager(DownloadManager $manager)
  6518. {
  6519. $this->downloadManager = $manager;
  6520. }
  6521. public function getDownloadManager()
  6522. {
  6523. return $this->downloadManager;
  6524. }
  6525. public function setArchiveManager(ArchiveManager $manager)
  6526. {
  6527. $this->archiveManager = $manager;
  6528. }
  6529. public function getArchiveManager()
  6530. {
  6531. return $this->archiveManager;
  6532. }
  6533. public function setInstallationManager(InstallationManager $manager)
  6534. {
  6535. $this->installationManager = $manager;
  6536. }
  6537. public function getInstallationManager()
  6538. {
  6539. return $this->installationManager;
  6540. }
  6541. public function setPluginManager(PluginManager $manager)
  6542. {
  6543. $this->pluginManager = $manager;
  6544. }
  6545. public function getPluginManager()
  6546. {
  6547. return $this->pluginManager;
  6548. }
  6549. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  6550. {
  6551. $this->eventDispatcher = $eventDispatcher;
  6552. }
  6553. public function getEventDispatcher()
  6554. {
  6555. return $this->eventDispatcher;
  6556. }
  6557. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  6558. {
  6559. $this->autoloadGenerator = $autoloadGenerator;
  6560. }
  6561. public function getAutoloadGenerator()
  6562. {
  6563. return $this->autoloadGenerator;
  6564. }
  6565. }
  6566. <?php
  6567. namespace Composer;
  6568. use Composer\Config\ConfigSourceInterface;
  6569. use Composer\Downloader\TransportException;
  6570. use Composer\IO\IOInterface;
  6571. use Composer\Util\Platform;
  6572. class Config
  6573. {
  6574. const RELATIVE_PATHS = 1;
  6575. public static $defaultConfig = array(
  6576. 'process-timeout' => 300,
  6577. 'use-include-path' => false,
  6578. 'preferred-install' => 'auto',
  6579. 'notify-on-install' => true,
  6580. 'github-protocols' => array('https', 'ssh', 'git'),
  6581. 'vendor-dir' => 'vendor',
  6582. 'bin-dir' => '{$vendor-dir}/bin',
  6583. 'cache-dir' => '{$home}/cache',
  6584. 'data-dir' => '{$home}',
  6585. 'cache-files-dir' => '{$cache-dir}/files',
  6586. 'cache-repo-dir' => '{$cache-dir}/repo',
  6587. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  6588. 'cache-ttl' => 15552000,
  6589. 'cache-files-ttl' => null,
  6590. 'cache-files-maxsize' => '300MiB',
  6591. 'bin-compat' => 'auto',
  6592. 'discard-changes' => false,
  6593. 'autoloader-suffix' => null,
  6594. 'sort-packages' => false,
  6595. 'optimize-autoloader' => false,
  6596. 'classmap-authoritative' => false,
  6597. 'apcu-autoloader' => false,
  6598. 'prepend-autoloader' => true,
  6599. 'github-domains' => array('github.com'),
  6600. 'bitbucket-expose-hostname' => true,
  6601. 'disable-tls' => false,
  6602. 'secure-http' => true,
  6603. 'cafile' => null,
  6604. 'capath' => null,
  6605. 'github-expose-hostname' => true,
  6606. 'gitlab-domains' => array('gitlab.com'),
  6607. 'store-auths' => 'prompt',
  6608. 'platform' => array(),
  6609. 'archive-format' => 'tar',
  6610. 'archive-dir' => '.',
  6611. 'htaccess-protect' => true,
  6612. );
  6613. public static $defaultRepositories = array(
  6614. 'packagist.org' => array(
  6615. 'type' => 'composer',
  6616. 'url' => 'https?://repo.packagist.org',
  6617. 'allow_ssl_downgrade' => true,
  6618. ),
  6619. );
  6620. private $config;
  6621. private $baseDir;
  6622. private $repositories;
  6623. private $configSource;
  6624. private $authConfigSource;
  6625. private $useEnvironment;
  6626. private $warnedHosts = array();
  6627. public function __construct($useEnvironment = true, $baseDir = null)
  6628. {
  6629. $this->config = static::$defaultConfig;
  6630. $this->repositories = static::$defaultRepositories;
  6631. $this->useEnvironment = (bool) $useEnvironment;
  6632. $this->baseDir = $baseDir;
  6633. }
  6634. public function setConfigSource(ConfigSourceInterface $source)
  6635. {
  6636. $this->configSource = $source;
  6637. }
  6638. public function getConfigSource()
  6639. {
  6640. return $this->configSource;
  6641. }
  6642. public function setAuthConfigSource(ConfigSourceInterface $source)
  6643. {
  6644. $this->authConfigSource = $source;
  6645. }
  6646. public function getAuthConfigSource()
  6647. {
  6648. return $this->authConfigSource;
  6649. }
  6650. public function merge($config)
  6651. {
  6652. if (!empty($config['config']) && is_array($config['config'])) {
  6653. foreach ($config['config'] as $key => $val) {
  6654. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic')) && isset($this->config[$key])) {
  6655. $this->config[$key] = array_merge($this->config[$key], $val);
  6656. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  6657. if (is_array($val) || is_array($this->config[$key])) {
  6658. if (is_string($val)) {
  6659. $val = array('*' => $val);
  6660. }
  6661. if (is_string($this->config[$key])) {
  6662. $this->config[$key] = array('*' => $this->config[$key]);
  6663. }
  6664. $this->config[$key] = array_merge($this->config[$key], $val);
  6665. if (isset($this->config[$key]['*'])) {
  6666. $wildcard = $this->config[$key]['*'];
  6667. unset($this->config[$key]['*']);
  6668. $this->config[$key]['*'] = $wildcard;
  6669. }
  6670. } else {
  6671. $this->config[$key] = $val;
  6672. }
  6673. } else {
  6674. $this->config[$key] = $val;
  6675. }
  6676. }
  6677. }
  6678. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  6679. $this->repositories = array_reverse($this->repositories, true);
  6680. $newRepos = array_reverse($config['repositories'], true);
  6681. foreach ($newRepos as $name => $repository) {
  6682. if (false === $repository) {
  6683. $this->disableRepoByName($name);
  6684. continue;
  6685. }
  6686. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  6687. $this->disableRepoByName(key($repository));
  6688. continue;
  6689. }
  6690. if (is_int($name)) {
  6691. $this->repositories[] = $repository;
  6692. } else {
  6693. if ($name === 'packagist') {
  6694. $this->repositories[$name . '.org'] = $repository;
  6695. } else {
  6696. $this->repositories[$name] = $repository;
  6697. }
  6698. }
  6699. }
  6700. $this->repositories = array_reverse($this->repositories, true);
  6701. }
  6702. }
  6703. public function getRepositories()
  6704. {
  6705. return $this->repositories;
  6706. }
  6707. public function get($key, $flags = 0)
  6708. {
  6709. switch ($key) {
  6710. case 'vendor-dir':
  6711. case 'bin-dir':
  6712. case 'process-timeout':
  6713. case 'data-dir':
  6714. case 'cache-dir':
  6715. case 'cache-files-dir':
  6716. case 'cache-repo-dir':
  6717. case 'cache-vcs-dir':
  6718. case 'cafile':
  6719. case 'capath':
  6720. case 'htaccess-protect':
  6721. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  6722. $val = $this->getComposerEnv($env);
  6723. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  6724. $val = Platform::expandPath($val);
  6725. if (substr($key, -4) !== '-dir') {
  6726. return $val;
  6727. }
  6728. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  6729. case 'cache-ttl':
  6730. return (int) $this->config[$key];
  6731. case 'cache-files-maxsize':
  6732. if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  6733. throw new \RuntimeException(
  6734. "Could not parse the value of 'cache-files-maxsize': {$this->config[$key]}"
  6735. );
  6736. }
  6737. $size = $matches[1];
  6738. if (isset($matches[2])) {
  6739. switch (strtolower($matches[2])) {
  6740. case 'g':
  6741. $size *= 1024;
  6742. case 'm':
  6743. $size *= 1024;
  6744. case 'k':
  6745. $size *= 1024;
  6746. break;
  6747. }
  6748. }
  6749. return $size;
  6750. case 'cache-files-ttl':
  6751. if (isset($this->config[$key])) {
  6752. return (int) $this->config[$key];
  6753. }
  6754. return (int) $this->config['cache-ttl'];
  6755. case 'home':
  6756. $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  6757. return rtrim($this->process($val, $flags), '/\\');
  6758. case 'bin-compat':
  6759. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  6760. if (!in_array($value, array('auto', 'full'))) {
  6761. throw new \RuntimeException(
  6762. "Invalid value for 'bin-compat': {$value}. Expected auto, full"
  6763. );
  6764. }
  6765. return $value;
  6766. case 'discard-changes':
  6767. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  6768. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  6769. throw new \RuntimeException(
  6770. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  6771. );
  6772. }
  6773. if ('stash' === $env) {
  6774. return 'stash';
  6775. }
  6776. return $env !== 'false' && (bool) $env;
  6777. }
  6778. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  6779. throw new \RuntimeException(
  6780. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  6781. );
  6782. }
  6783. return $this->config[$key];
  6784. case 'github-protocols':
  6785. $protos = $this->config['github-protocols'];
  6786. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  6787. unset($protos[$index]);
  6788. }
  6789. if (reset($protos) === 'http') {
  6790. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  6791. }
  6792. return $protos;
  6793. case 'disable-tls':
  6794. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  6795. case 'secure-http':
  6796. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  6797. default:
  6798. if (!isset($this->config[$key])) {
  6799. return null;
  6800. }
  6801. return $this->process($this->config[$key], $flags);
  6802. }
  6803. }
  6804. public function all($flags = 0)
  6805. {
  6806. $all = array(
  6807. 'repositories' => $this->getRepositories(),
  6808. );
  6809. foreach (array_keys($this->config) as $key) {
  6810. $all['config'][$key] = $this->get($key, $flags);
  6811. }
  6812. return $all;
  6813. }
  6814. public function raw()
  6815. {
  6816. return array(
  6817. 'repositories' => $this->getRepositories(),
  6818. 'config' => $this->config,
  6819. );
  6820. }
  6821. public function has($key)
  6822. {
  6823. return array_key_exists($key, $this->config);
  6824. }
  6825. private function process($value, $flags)
  6826. {
  6827. $config = $this;
  6828. if (!is_string($value)) {
  6829. return $value;
  6830. }
  6831. return preg_replace_callback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  6832. return $config->get($match[1], $flags);
  6833. }, $value);
  6834. }
  6835. private function realpath($path)
  6836. {
  6837. if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  6838. return $path;
  6839. }
  6840. return $this->baseDir . '/' . $path;
  6841. }
  6842. private function getComposerEnv($var)
  6843. {
  6844. if ($this->useEnvironment) {
  6845. return getenv($var);
  6846. }
  6847. return false;
  6848. }
  6849. private function disableRepoByName($name)
  6850. {
  6851. if (isset($this->repositories[$name])) {
  6852. unset($this->repositories[$name]);
  6853. } elseif ($name === 'packagist') {
  6854. unset($this->repositories['packagist.org']);
  6855. }
  6856. }
  6857. public function prohibitUrlByConfig($url, IOInterface $io = null)
  6858. {
  6859. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  6860. return;
  6861. }
  6862. $scheme = parse_url($url, PHP_URL_SCHEME);
  6863. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  6864. if ($this->get('secure-http')) {
  6865. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  6866. } elseif ($io) {
  6867. $host = parse_url($url, PHP_URL_HOST);
  6868. if (!isset($this->warnedHosts[$host])) {
  6869. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  6870. }
  6871. $this->warnedHosts[$host] = true;
  6872. }
  6873. }
  6874. }
  6875. }
  6876. <?php
  6877. namespace Composer\Config;
  6878. interface ConfigSourceInterface
  6879. {
  6880. public function addRepository($name, $config);
  6881. public function removeRepository($name);
  6882. public function addConfigSetting($name, $value);
  6883. public function removeConfigSetting($name);
  6884. public function addProperty($name, $value);
  6885. public function removeProperty($name);
  6886. public function addLink($type, $name, $value);
  6887. public function removeLink($type, $name);
  6888. public function getName();
  6889. }
  6890. <?php
  6891. namespace Composer\Config;
  6892. use Composer\Json\JsonFile;
  6893. use Composer\Json\JsonManipulator;
  6894. use Composer\Util\Silencer;
  6895. class JsonConfigSource implements ConfigSourceInterface
  6896. {
  6897. private $file;
  6898. private $authConfig;
  6899. public function __construct(JsonFile $file, $authConfig = false)
  6900. {
  6901. $this->file = $file;
  6902. $this->authConfig = $authConfig;
  6903. }
  6904. public function getName()
  6905. {
  6906. return $this->file->getPath();
  6907. }
  6908. public function addRepository($name, $config)
  6909. {
  6910. $this->manipulateJson('addRepository', $name, $config, function (&$config, $repo, $repoConfig) {
  6911. if (isset($config['repositories'])) {
  6912. foreach ($config['repositories'] as $index => $val) {
  6913. if ($index === $repo) {
  6914. continue;
  6915. }
  6916. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  6917. unset($config['repositories'][$index]);
  6918. $config['repositories']['packagist.org'] = false;
  6919. break;
  6920. }
  6921. }
  6922. }
  6923. $config['repositories'][$repo] = $repoConfig;
  6924. });
  6925. }
  6926. public function removeRepository($name)
  6927. {
  6928. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  6929. unset($config['repositories'][$repo]);
  6930. });
  6931. }
  6932. public function addConfigSetting($name, $value)
  6933. {
  6934. $authConfig = $this->authConfig;
  6935. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  6936. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|platform)\.}', $key)) {
  6937. list($key, $host) = explode('.', $key, 2);
  6938. if ($authConfig) {
  6939. $config[$key][$host] = $val;
  6940. } else {
  6941. $config['config'][$key][$host] = $val;
  6942. }
  6943. } else {
  6944. $config['config'][$key] = $val;
  6945. }
  6946. });
  6947. }
  6948. public function removeConfigSetting($name)
  6949. {
  6950. $authConfig = $this->authConfig;
  6951. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  6952. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|platform)\.}', $key)) {
  6953. list($key, $host) = explode('.', $key, 2);
  6954. if ($authConfig) {
  6955. unset($config[$key][$host]);
  6956. } else {
  6957. unset($config['config'][$key][$host]);
  6958. }
  6959. } else {
  6960. unset($config['config'][$key]);
  6961. }
  6962. });
  6963. }
  6964. public function addProperty($name, $value)
  6965. {
  6966. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  6967. if (substr($key, 0, 6) === 'extra.' || substr($key, 0, 8) === 'scripts.') {
  6968. $bits = explode('.', $key);
  6969. $last = array_pop($bits);
  6970. $arr = &$config[reset($bits)];
  6971. foreach ($bits as $bit) {
  6972. if (!isset($arr[$bit])) {
  6973. $arr[$bit] = array();
  6974. }
  6975. $arr = &$arr[$bit];
  6976. }
  6977. $arr[$last] = $val;
  6978. } else {
  6979. $config[$key] = $val;
  6980. }
  6981. });
  6982. }
  6983. public function removeProperty($name)
  6984. {
  6985. $authConfig = $this->authConfig;
  6986. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  6987. if (substr($key, 0, 6) === 'extra.' || substr($key, 0, 8) === 'scripts.') {
  6988. $bits = explode('.', $key);
  6989. $last = array_pop($bits);
  6990. $arr = &$config[reset($bits)];
  6991. foreach ($bits as $bit) {
  6992. if (!isset($arr[$bit])) {
  6993. return;
  6994. }
  6995. $arr = &$arr[$bit];
  6996. }
  6997. unset($arr[$last]);
  6998. } else {
  6999. unset($config[$key]);
  7000. }
  7001. });
  7002. }
  7003. public function addLink($type, $name, $value)
  7004. {
  7005. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  7006. $config[$type][$name] = $value;
  7007. });
  7008. }
  7009. public function removeLink($type, $name)
  7010. {
  7011. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  7012. unset($config[$type][$name]);
  7013. });
  7014. }
  7015. protected function manipulateJson($method, $args, $fallback)
  7016. {
  7017. $args = func_get_args();
  7018. array_shift($args);
  7019. $fallback = array_pop($args);
  7020. if ($this->file->exists()) {
  7021. if (!is_writable($this->file->getPath())) {
  7022. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  7023. }
  7024. if (!is_readable($this->file->getPath())) {
  7025. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  7026. }
  7027. $contents = file_get_contents($this->file->getPath());
  7028. } elseif ($this->authConfig) {
  7029. $contents = "{\n}\n";
  7030. } else {
  7031. $contents = "{\n \"config\": {\n }\n}\n";
  7032. }
  7033. $manipulator = new JsonManipulator($contents);
  7034. $newFile = !$this->file->exists();
  7035. if ($this->authConfig && $method === 'addConfigSetting') {
  7036. $method = 'addSubNode';
  7037. list($mainNode, $name) = explode('.', $args[0], 2);
  7038. $args = array($mainNode, $name, $args[1]);
  7039. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  7040. $method = 'removeSubNode';
  7041. list($mainNode, $name) = explode('.', $args[0], 2);
  7042. $args = array($mainNode, $name);
  7043. }
  7044. if (call_user_func_array(array($manipulator, $method), $args)) {
  7045. file_put_contents($this->file->getPath(), $manipulator->getContents());
  7046. } else {
  7047. $config = $this->file->read();
  7048. $this->arrayUnshiftRef($args, $config);
  7049. call_user_func_array($fallback, $args);
  7050. $this->file->write($config);
  7051. }
  7052. if ($newFile) {
  7053. Silencer::call('chmod', $this->file->getPath(), 0600);
  7054. }
  7055. }
  7056. private function arrayUnshiftRef(&$array, &$value)
  7057. {
  7058. $return = array_unshift($array, '');
  7059. $array[0] = &$value;
  7060. return $return;
  7061. }
  7062. }
  7063. <?php
  7064. namespace Composer\Console;
  7065. use Composer\IO\NullIO;
  7066. use Composer\Util\Platform;
  7067. use Composer\Util\Silencer;
  7068. use Symfony\Component\Console\Application as BaseApplication;
  7069. use Symfony\Component\Console\Exception\CommandNotFoundException;
  7070. use Symfony\Component\Console\Input\InputInterface;
  7071. use Symfony\Component\Console\Input\InputOption;
  7072. use Symfony\Component\Console\Output\OutputInterface;
  7073. use Composer\Command;
  7074. use Composer\Composer;
  7075. use Composer\Factory;
  7076. use Composer\IO\IOInterface;
  7077. use Composer\IO\ConsoleIO;
  7078. use Composer\Json\JsonValidationException;
  7079. use Composer\Util\ErrorHandler;
  7080. use Composer\EventDispatcher\ScriptExecutionException;
  7081. use Composer\Exception\NoSslException;
  7082. class Application extends BaseApplication
  7083. {
  7084. protected $composer;
  7085. protected $io;
  7086. private static $logo = ' ______
  7087. / ____/___ ____ ___ ____ ____ ________ _____
  7088. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  7089. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  7090. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  7091. /_/
  7092. ';
  7093. private $hasPluginCommands = false;
  7094. private $disablePluginsByDefault = false;
  7095. public function __construct()
  7096. {
  7097. static $shutdownRegistered = false;
  7098. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  7099. ini_set('xdebug.show_exception_trace', false);
  7100. ini_set('xdebug.scream', false);
  7101. }
  7102. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  7103. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  7104. }
  7105. if (!$shutdownRegistered) {
  7106. $shutdownRegistered = true;
  7107. register_shutdown_function(function () {
  7108. $lastError = error_get_last();
  7109. if ($lastError && $lastError['message'] &&
  7110. (strpos($lastError['message'], 'Allowed memory') !== false ||
  7111. strpos($lastError['message'], 'exceeded memory') !== false )) {
  7112. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  7113. }
  7114. });
  7115. }
  7116. $this->io = new NullIO();
  7117. parent::__construct('Composer', Composer::VERSION);
  7118. }
  7119. public function run(InputInterface $input = null, OutputInterface $output = null)
  7120. {
  7121. if (null === $output) {
  7122. $output = Factory::createOutput();
  7123. }
  7124. return parent::run($input, $output);
  7125. }
  7126. public function doRun(InputInterface $input, OutputInterface $output)
  7127. {
  7128. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  7129. $io = $this->io = new ConsoleIO($input, $output, $this->getHelperSet());
  7130. ErrorHandler::register($io);
  7131. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  7132. $oldWorkingDir = getcwd();
  7133. chdir($newWorkDir);
  7134. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  7135. }
  7136. $commandName = '';
  7137. if ($name = $this->getCommandName($input)) {
  7138. try {
  7139. $commandName = $this->find($name)->getName();
  7140. } catch (CommandNotFoundException $e) {
  7141. $commandName = false;
  7142. } catch (\InvalidArgumentException $e) {
  7143. }
  7144. }
  7145. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project'), true) && !file_exists(Factory::getComposerFile())) {
  7146. $dir = dirname(getcwd());
  7147. $home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
  7148. while (dirname($dir) !== $dir && $dir !== $home) {
  7149. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  7150. if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ', true)) {
  7151. $oldWorkingDir = getcwd();
  7152. chdir($dir);
  7153. }
  7154. break;
  7155. }
  7156. $dir = dirname($dir);
  7157. }
  7158. }
  7159. if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) {
  7160. try {
  7161. foreach ($this->getPluginCommands() as $command) {
  7162. if ($this->has($command->getName())) {
  7163. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  7164. } else {
  7165. $this->add($command);
  7166. }
  7167. }
  7168. } catch (NoSslException $e) {
  7169. }
  7170. $this->hasPluginCommands = true;
  7171. }
  7172. $isProxyCommand = false;
  7173. if ($name = $this->getCommandName($input)) {
  7174. try {
  7175. $command = $this->find($name);
  7176. $commandName = $command->getName();
  7177. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  7178. } catch (\InvalidArgumentException $e) {
  7179. }
  7180. }
  7181. if (!$isProxyCommand) {
  7182. $io->writeError(sprintf(
  7183. 'Running %s (%s) with %s on %s',
  7184. Composer::VERSION,
  7185. Composer::RELEASE_DATE,
  7186. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  7187. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  7188. ), true, IOInterface::DEBUG);
  7189. if (PHP_VERSION_ID < 50302) {
  7190. $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>');
  7191. }
  7192. if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  7193. $io->writeError('<warning>You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug</warning>');
  7194. }
  7195. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  7196. $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']));
  7197. }
  7198. if (getenv('COMPOSER_NO_INTERACTION')) {
  7199. $input->setInteractive(false);
  7200. }
  7201. if (!Platform::isWindows() && function_exists('exec') && !getenv('COMPOSER_ALLOW_SUPERUSER')) {
  7202. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  7203. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  7204. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  7205. }
  7206. if ($uid = (int) getenv('SUDO_UID')) {
  7207. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  7208. }
  7209. }
  7210. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  7211. }
  7212. Silencer::call(function () use ($io) {
  7213. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  7214. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  7215. $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()));
  7216. }
  7217. });
  7218. $file = Factory::getComposerFile();
  7219. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  7220. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  7221. foreach ($composer['scripts'] as $script => $dummy) {
  7222. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  7223. if ($this->has($script)) {
  7224. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  7225. } else {
  7226. $description = null;
  7227. if (isset($composer['scripts-descriptions'][$script])) {
  7228. $description = $composer['scripts-descriptions'][$script];
  7229. }
  7230. $this->add(new Command\ScriptAliasCommand($script, $description));
  7231. }
  7232. }
  7233. }
  7234. }
  7235. }
  7236. }
  7237. try {
  7238. if ($input->hasParameterOption('--profile')) {
  7239. $startTime = microtime(true);
  7240. $this->io->enableDebugging($startTime);
  7241. }
  7242. $result = parent::doRun($input, $output);
  7243. if (isset($oldWorkingDir)) {
  7244. chdir($oldWorkingDir);
  7245. }
  7246. if (isset($startTime)) {
  7247. $io->writeError('<info>Memory usage: '.round(memory_get_usage() / 1024 / 1024, 2).'MB (peak: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'MB), time: '.round(microtime(true) - $startTime, 2).'s');
  7248. }
  7249. restore_error_handler();
  7250. return $result;
  7251. } catch (ScriptExecutionException $e) {
  7252. return $e->getCode();
  7253. } catch (\Exception $e) {
  7254. $this->hintCommonErrors($e);
  7255. restore_error_handler();
  7256. throw $e;
  7257. }
  7258. }
  7259. private function getNewWorkingDir(InputInterface $input)
  7260. {
  7261. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  7262. if (false !== $workingDir && !is_dir($workingDir)) {
  7263. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  7264. }
  7265. return $workingDir;
  7266. }
  7267. private function hintCommonErrors($exception)
  7268. {
  7269. $io = $this->getIO();
  7270. Silencer::suppress();
  7271. try {
  7272. $composer = $this->getComposer(false, true);
  7273. if ($composer) {
  7274. $config = $composer->getConfig();
  7275. $minSpaceFree = 1024 * 1024;
  7276. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  7277. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  7278. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  7279. ) {
  7280. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  7281. }
  7282. }
  7283. } catch (\Exception $e) {
  7284. }
  7285. Silencer::restore();
  7286. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  7287. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  7288. $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);
  7289. }
  7290. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  7291. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  7292. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  7293. }
  7294. }
  7295. public function getComposer($required = true, $disablePlugins = null)
  7296. {
  7297. if (null === $disablePlugins) {
  7298. $disablePlugins = $this->disablePluginsByDefault;
  7299. }
  7300. if (null === $this->composer) {
  7301. try {
  7302. $this->composer = Factory::create($this->io, null, $disablePlugins);
  7303. } catch (\InvalidArgumentException $e) {
  7304. if ($required) {
  7305. $this->io->writeError($e->getMessage());
  7306. exit(1);
  7307. }
  7308. } catch (JsonValidationException $e) {
  7309. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  7310. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  7311. throw new JsonValidationException($message);
  7312. }
  7313. }
  7314. return $this->composer;
  7315. }
  7316. public function resetComposer()
  7317. {
  7318. $this->composer = null;
  7319. }
  7320. public function getIO()
  7321. {
  7322. return $this->io;
  7323. }
  7324. public function getHelp()
  7325. {
  7326. return self::$logo . parent::getHelp();
  7327. }
  7328. protected function getDefaultCommands()
  7329. {
  7330. $commands = array_merge(parent::getDefaultCommands(), array(
  7331. new Command\AboutCommand(),
  7332. new Command\ConfigCommand(),
  7333. new Command\DependsCommand(),
  7334. new Command\ProhibitsCommand(),
  7335. new Command\InitCommand(),
  7336. new Command\InstallCommand(),
  7337. new Command\CreateProjectCommand(),
  7338. new Command\UpdateCommand(),
  7339. new Command\SearchCommand(),
  7340. new Command\ValidateCommand(),
  7341. new Command\ShowCommand(),
  7342. new Command\SuggestsCommand(),
  7343. new Command\RequireCommand(),
  7344. new Command\DumpAutoloadCommand(),
  7345. new Command\StatusCommand(),
  7346. new Command\ArchiveCommand(),
  7347. new Command\DiagnoseCommand(),
  7348. new Command\RunScriptCommand(),
  7349. new Command\LicensesCommand(),
  7350. new Command\GlobalCommand(),
  7351. new Command\ClearCacheCommand(),
  7352. new Command\RemoveCommand(),
  7353. new Command\HomeCommand(),
  7354. new Command\ExecCommand(),
  7355. new Command\OutdatedCommand(),
  7356. new Command\CheckPlatformReqsCommand(),
  7357. ));
  7358. if ('phar:' === substr(__FILE__, 0, 5)) {
  7359. $commands[] = new Command\SelfUpdateCommand();
  7360. }
  7361. return $commands;
  7362. }
  7363. public function getLongVersion()
  7364. {
  7365. if (Composer::BRANCH_ALIAS_VERSION) {
  7366. return sprintf(
  7367. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  7368. $this->getName(),
  7369. Composer::BRANCH_ALIAS_VERSION,
  7370. $this->getVersion(),
  7371. Composer::RELEASE_DATE
  7372. );
  7373. }
  7374. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  7375. }
  7376. protected function getDefaultInputDefinition()
  7377. {
  7378. $definition = parent::getDefaultInputDefinition();
  7379. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  7380. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  7381. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  7382. return $definition;
  7383. }
  7384. private function getPluginCommands()
  7385. {
  7386. $commands = array();
  7387. $composer = $this->getComposer(false, false);
  7388. if (null === $composer) {
  7389. $composer = Factory::createGlobal($this->io, false);
  7390. }
  7391. if (null !== $composer) {
  7392. $pm = $composer->getPluginManager();
  7393. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  7394. $newCommands = $capability->getCommands();
  7395. if (!is_array($newCommands)) {
  7396. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  7397. }
  7398. foreach ($newCommands as $command) {
  7399. if (!$command instanceof Command\BaseCommand) {
  7400. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  7401. }
  7402. }
  7403. $commands = array_merge($commands, $newCommands);
  7404. }
  7405. }
  7406. return $commands;
  7407. }
  7408. }
  7409. <?php
  7410. namespace Composer\Console;
  7411. use Symfony\Component\Console\Formatter\OutputFormatter;
  7412. class HtmlOutputFormatter extends OutputFormatter
  7413. {
  7414. private static $availableForegroundColors = array(
  7415. 30 => 'black',
  7416. 31 => 'red',
  7417. 32 => 'green',
  7418. 33 => 'yellow',
  7419. 34 => 'blue',
  7420. 35 => 'magenta',
  7421. 36 => 'cyan',
  7422. 37 => 'white',
  7423. );
  7424. private static $availableBackgroundColors = array(
  7425. 40 => 'black',
  7426. 41 => 'red',
  7427. 42 => 'green',
  7428. 43 => 'yellow',
  7429. 44 => 'blue',
  7430. 45 => 'magenta',
  7431. 46 => 'cyan',
  7432. 47 => 'white',
  7433. );
  7434. private static $availableOptions = array(
  7435. 1 => 'bold',
  7436. 4 => 'underscore',
  7437. );
  7438. public function __construct(array $styles = array())
  7439. {
  7440. parent::__construct(true, $styles);
  7441. }
  7442. public function format($message)
  7443. {
  7444. $formatted = parent::format($message);
  7445. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  7446. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  7447. }
  7448. private function formatHtml($matches)
  7449. {
  7450. $out = '<span style="';
  7451. foreach (explode(';', $matches[1]) as $code) {
  7452. if (isset(self::$availableForegroundColors[$code])) {
  7453. $out .= 'color:'.self::$availableForegroundColors[$code].';';
  7454. } elseif (isset(self::$availableBackgroundColors[$code])) {
  7455. $out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
  7456. } elseif (isset(self::$availableOptions[$code])) {
  7457. switch (self::$availableOptions[$code]) {
  7458. case 'bold':
  7459. $out .= 'font-weight:bold;';
  7460. break;
  7461. case 'underscore':
  7462. $out .= 'text-decoration:underline;';
  7463. break;
  7464. }
  7465. }
  7466. }
  7467. return $out.'">'.$matches[2].'</span>';
  7468. }
  7469. }
  7470. <?php
  7471. namespace Composer\DependencyResolver;
  7472. class Decisions implements \Iterator, \Countable
  7473. {
  7474. const DECISION_LITERAL = 0;
  7475. const DECISION_REASON = 1;
  7476. protected $pool;
  7477. protected $decisionMap;
  7478. protected $decisionQueue = array();
  7479. public function __construct($pool)
  7480. {
  7481. $this->pool = $pool;
  7482. $this->decisionMap = array();
  7483. }
  7484. public function decide($literal, $level, $why)
  7485. {
  7486. $this->addDecision($literal, $level);
  7487. $this->decisionQueue[] = array(
  7488. self::DECISION_LITERAL => $literal,
  7489. self::DECISION_REASON => $why,
  7490. );
  7491. }
  7492. public function satisfy($literal)
  7493. {
  7494. $packageId = abs($literal);
  7495. return (
  7496. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  7497. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  7498. );
  7499. }
  7500. public function conflict($literal)
  7501. {
  7502. $packageId = abs($literal);
  7503. return (
  7504. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  7505. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  7506. );
  7507. }
  7508. public function decided($literalOrPackageId)
  7509. {
  7510. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  7511. }
  7512. public function undecided($literalOrPackageId)
  7513. {
  7514. return empty($this->decisionMap[abs($literalOrPackageId)]);
  7515. }
  7516. public function decidedInstall($literalOrPackageId)
  7517. {
  7518. $packageId = abs($literalOrPackageId);
  7519. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  7520. }
  7521. public function decisionLevel($literalOrPackageId)
  7522. {
  7523. $packageId = abs($literalOrPackageId);
  7524. if (isset($this->decisionMap[$packageId])) {
  7525. return abs($this->decisionMap[$packageId]);
  7526. }
  7527. return 0;
  7528. }
  7529. public function decisionRule($literalOrPackageId)
  7530. {
  7531. $packageId = abs($literalOrPackageId);
  7532. foreach ($this->decisionQueue as $i => $decision) {
  7533. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  7534. return $decision[self::DECISION_REASON];
  7535. }
  7536. }
  7537. return null;
  7538. }
  7539. public function atOffset($queueOffset)
  7540. {
  7541. return $this->decisionQueue[$queueOffset];
  7542. }
  7543. public function validOffset($queueOffset)
  7544. {
  7545. return $queueOffset >= 0 && $queueOffset < count($this->decisionQueue);
  7546. }
  7547. public function lastReason()
  7548. {
  7549. return $this->decisionQueue[count($this->decisionQueue) - 1][self::DECISION_REASON];
  7550. }
  7551. public function lastLiteral()
  7552. {
  7553. return $this->decisionQueue[count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  7554. }
  7555. public function reset()
  7556. {
  7557. while ($decision = array_pop($this->decisionQueue)) {
  7558. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  7559. }
  7560. }
  7561. public function resetToOffset($offset)
  7562. {
  7563. while (count($this->decisionQueue) > $offset + 1) {
  7564. $decision = array_pop($this->decisionQueue);
  7565. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  7566. }
  7567. }
  7568. public function revertLast()
  7569. {
  7570. $this->decisionMap[abs($this->lastLiteral())] = 0;
  7571. array_pop($this->decisionQueue);
  7572. }
  7573. public function count()
  7574. {
  7575. return count($this->decisionQueue);
  7576. }
  7577. public function rewind()
  7578. {
  7579. end($this->decisionQueue);
  7580. }
  7581. public function current()
  7582. {
  7583. return current($this->decisionQueue);
  7584. }
  7585. public function key()
  7586. {
  7587. return key($this->decisionQueue);
  7588. }
  7589. public function next()
  7590. {
  7591. return prev($this->decisionQueue);
  7592. }
  7593. public function valid()
  7594. {
  7595. return false !== current($this->decisionQueue);
  7596. }
  7597. public function isEmpty()
  7598. {
  7599. return count($this->decisionQueue) === 0;
  7600. }
  7601. protected function addDecision($literal, $level)
  7602. {
  7603. $packageId = abs($literal);
  7604. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  7605. if ($previousDecision != 0) {
  7606. $literalString = $this->pool->literalToString($literal);
  7607. $package = $this->pool->literalToPackage($literal);
  7608. throw new SolverBugException(
  7609. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  7610. );
  7611. }
  7612. if ($literal > 0) {
  7613. $this->decisionMap[$packageId] = $level;
  7614. } else {
  7615. $this->decisionMap[$packageId] = -$level;
  7616. }
  7617. }
  7618. }
  7619. <?php
  7620. namespace Composer\DependencyResolver;
  7621. use Composer\Package\PackageInterface;
  7622. use Composer\Package\AliasPackage;
  7623. use Composer\Package\BasePackage;
  7624. use Composer\Semver\Constraint\Constraint;
  7625. class DefaultPolicy implements PolicyInterface
  7626. {
  7627. private $preferStable;
  7628. private $preferLowest;
  7629. public function __construct($preferStable = false, $preferLowest = false)
  7630. {
  7631. $this->preferStable = $preferStable;
  7632. $this->preferLowest = $preferLowest;
  7633. }
  7634. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  7635. {
  7636. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  7637. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  7638. }
  7639. $constraint = new Constraint($operator, $b->getVersion());
  7640. $version = new Constraint('==', $a->getVersion());
  7641. return $constraint->matchSpecific($version, true);
  7642. }
  7643. public function findUpdatePackages(Pool $pool, array $installedMap, PackageInterface $package, $mustMatchName = false)
  7644. {
  7645. $packages = array();
  7646. foreach ($pool->whatProvides($package->getName(), null, $mustMatchName) as $candidate) {
  7647. if ($candidate !== $package) {
  7648. $packages[] = $candidate;
  7649. }
  7650. }
  7651. return $packages;
  7652. }
  7653. public function getPriority(Pool $pool, PackageInterface $package)
  7654. {
  7655. return $pool->getPriority($package->getRepository());
  7656. }
  7657. public function selectPreferredPackages(Pool $pool, array $installedMap, array $literals, $requiredPackage = null)
  7658. {
  7659. $packages = $this->groupLiteralsByNamePreferInstalled($pool, $installedMap, $literals);
  7660. foreach ($packages as &$literals) {
  7661. $policy = $this;
  7662. usort($literals, function ($a, $b) use ($policy, $pool, $installedMap, $requiredPackage) {
  7663. return $policy->compareByPriorityPreferInstalled($pool, $installedMap, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  7664. });
  7665. }
  7666. foreach ($packages as &$literals) {
  7667. $literals = $this->pruneToHighestPriorityOrInstalled($pool, $installedMap, $literals);
  7668. $literals = $this->pruneToBestVersion($pool, $literals);
  7669. $literals = $this->pruneRemoteAliases($pool, $literals);
  7670. }
  7671. $selected = call_user_func_array('array_merge', $packages);
  7672. usort($selected, function ($a, $b) use ($policy, $pool, $installedMap, $requiredPackage) {
  7673. return $policy->compareByPriorityPreferInstalled($pool, $installedMap, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  7674. });
  7675. return $selected;
  7676. }
  7677. protected function groupLiteralsByNamePreferInstalled(Pool $pool, array $installedMap, $literals)
  7678. {
  7679. $packages = array();
  7680. foreach ($literals as $literal) {
  7681. $packageName = $pool->literalToPackage($literal)->getName();
  7682. if (!isset($packages[$packageName])) {
  7683. $packages[$packageName] = array();
  7684. }
  7685. if (isset($installedMap[abs($literal)])) {
  7686. array_unshift($packages[$packageName], $literal);
  7687. } else {
  7688. $packages[$packageName][] = $literal;
  7689. }
  7690. }
  7691. return $packages;
  7692. }
  7693. public function compareByPriorityPreferInstalled(Pool $pool, array $installedMap, PackageInterface $a, PackageInterface $b, $requiredPackage = null, $ignoreReplace = false)
  7694. {
  7695. if ($a->getRepository() === $b->getRepository()) {
  7696. if ($a->getName() === $b->getName()) {
  7697. $aAliased = $a instanceof AliasPackage;
  7698. $bAliased = $b instanceof AliasPackage;
  7699. if ($aAliased && !$bAliased) {
  7700. return -1;
  7701. }
  7702. if (!$aAliased && $bAliased) {
  7703. return 1;
  7704. }
  7705. }
  7706. if (!$ignoreReplace) {
  7707. if ($this->replaces($a, $b)) {
  7708. return 1;
  7709. }
  7710. if ($this->replaces($b, $a)) {
  7711. return -1;
  7712. }
  7713. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  7714. $requiredVendor = substr($requiredPackage, 0, $pos);
  7715. $aIsSameVendor = substr($a->getName(), 0, $pos) === $requiredVendor;
  7716. $bIsSameVendor = substr($b->getName(), 0, $pos) === $requiredVendor;
  7717. if ($bIsSameVendor !== $aIsSameVendor) {
  7718. return $aIsSameVendor ? -1 : 1;
  7719. }
  7720. }
  7721. }
  7722. if ($a->id === $b->id) {
  7723. return 0;
  7724. }
  7725. return ($a->id < $b->id) ? -1 : 1;
  7726. }
  7727. if (isset($installedMap[$a->id])) {
  7728. return -1;
  7729. }
  7730. if (isset($installedMap[$b->id])) {
  7731. return 1;
  7732. }
  7733. return ($this->getPriority($pool, $a) > $this->getPriority($pool, $b)) ? -1 : 1;
  7734. }
  7735. protected function replaces(PackageInterface $source, PackageInterface $target)
  7736. {
  7737. foreach ($source->getReplaces() as $link) {
  7738. if ($link->getTarget() === $target->getName()
  7739. ) {
  7740. return true;
  7741. }
  7742. }
  7743. return false;
  7744. }
  7745. protected function pruneToBestVersion(Pool $pool, $literals)
  7746. {
  7747. $operator = $this->preferLowest ? '<' : '>';
  7748. $bestLiterals = array($literals[0]);
  7749. $bestPackage = $pool->literalToPackage($literals[0]);
  7750. foreach ($literals as $i => $literal) {
  7751. if (0 === $i) {
  7752. continue;
  7753. }
  7754. $package = $pool->literalToPackage($literal);
  7755. if ($this->versionCompare($package, $bestPackage, $operator)) {
  7756. $bestPackage = $package;
  7757. $bestLiterals = array($literal);
  7758. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  7759. $bestLiterals[] = $literal;
  7760. }
  7761. }
  7762. return $bestLiterals;
  7763. }
  7764. protected function pruneToHighestPriorityOrInstalled(Pool $pool, array $installedMap, array $literals)
  7765. {
  7766. $selected = array();
  7767. $priority = null;
  7768. foreach ($literals as $literal) {
  7769. $package = $pool->literalToPackage($literal);
  7770. if (isset($installedMap[$package->id])) {
  7771. $selected[] = $literal;
  7772. continue;
  7773. }
  7774. if (null === $priority) {
  7775. $priority = $this->getPriority($pool, $package);
  7776. }
  7777. if ($this->getPriority($pool, $package) != $priority) {
  7778. break;
  7779. }
  7780. $selected[] = $literal;
  7781. }
  7782. return $selected;
  7783. }
  7784. protected function pruneRemoteAliases(Pool $pool, array $literals)
  7785. {
  7786. $hasLocalAlias = false;
  7787. foreach ($literals as $literal) {
  7788. $package = $pool->literalToPackage($literal);
  7789. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  7790. $hasLocalAlias = true;
  7791. break;
  7792. }
  7793. }
  7794. if (!$hasLocalAlias) {
  7795. return $literals;
  7796. }
  7797. $selected = array();
  7798. foreach ($literals as $literal) {
  7799. $package = $pool->literalToPackage($literal);
  7800. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  7801. $selected[] = $literal;
  7802. }
  7803. }
  7804. return $selected;
  7805. }
  7806. }
  7807. <?php
  7808. namespace Composer\DependencyResolver;
  7809. use Composer\Package\PackageInterface;
  7810. use Composer\Package\Link;
  7811. class GenericRule extends Rule
  7812. {
  7813. protected $literals;
  7814. public function __construct(array $literals, $reason, $reasonData, $job = null)
  7815. {
  7816. parent::__construct($reason, $reasonData, $job);
  7817. sort($literals);
  7818. $this->literals = $literals;
  7819. }
  7820. public function getLiterals()
  7821. {
  7822. return $this->literals;
  7823. }
  7824. public function getHash()
  7825. {
  7826. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  7827. return $data['hash'];
  7828. }
  7829. public function equals(Rule $rule)
  7830. {
  7831. return $this->literals === $rule->getLiterals();
  7832. }
  7833. public function isAssertion()
  7834. {
  7835. return 1 === count($this->literals);
  7836. }
  7837. public function __toString()
  7838. {
  7839. $result = $this->isDisabled() ? 'disabled(' : '(';
  7840. foreach ($this->literals as $i => $literal) {
  7841. if ($i != 0) {
  7842. $result .= '|';
  7843. }
  7844. $result .= $literal;
  7845. }
  7846. $result .= ')';
  7847. return $result;
  7848. }
  7849. }
  7850. <?php
  7851. namespace Composer\DependencyResolver\Operation;
  7852. use Composer\Package\PackageInterface;
  7853. class InstallOperation extends SolverOperation
  7854. {
  7855. protected $package;
  7856. public function __construct(PackageInterface $package, $reason = null)
  7857. {
  7858. parent::__construct($reason);
  7859. $this->package = $package;
  7860. }
  7861. public function getPackage()
  7862. {
  7863. return $this->package;
  7864. }
  7865. public function getJobType()
  7866. {
  7867. return 'install';
  7868. }
  7869. public function __toString()
  7870. {
  7871. return 'Installing '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
  7872. }
  7873. }
  7874. <?php
  7875. namespace Composer\DependencyResolver\Operation;
  7876. use Composer\Package\AliasPackage;
  7877. use Composer\Package\PackageInterface;
  7878. class MarkAliasInstalledOperation extends SolverOperation
  7879. {
  7880. protected $package;
  7881. public function __construct(AliasPackage $package, $reason = null)
  7882. {
  7883. parent::__construct($reason);
  7884. $this->package = $package;
  7885. }
  7886. public function getPackage()
  7887. {
  7888. return $this->package;
  7889. }
  7890. public function getJobType()
  7891. {
  7892. return 'markAliasInstalled';
  7893. }
  7894. public function __toString()
  7895. {
  7896. return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as installed, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
  7897. }
  7898. }
  7899. <?php
  7900. namespace Composer\DependencyResolver\Operation;
  7901. use Composer\Package\AliasPackage;
  7902. use Composer\Package\PackageInterface;
  7903. class MarkAliasUninstalledOperation extends SolverOperation
  7904. {
  7905. protected $package;
  7906. public function __construct(AliasPackage $package, $reason = null)
  7907. {
  7908. parent::__construct($reason);
  7909. $this->package = $package;
  7910. }
  7911. public function getPackage()
  7912. {
  7913. return $this->package;
  7914. }
  7915. public function getJobType()
  7916. {
  7917. return 'markAliasUninstalled';
  7918. }
  7919. public function __toString()
  7920. {
  7921. return 'Marking '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).') as uninstalled, alias of '.$this->package->getAliasOf()->getPrettyName().' ('.$this->formatVersion($this->package->getAliasOf()).')';
  7922. }
  7923. }
  7924. <?php
  7925. namespace Composer\DependencyResolver\Operation;
  7926. interface OperationInterface
  7927. {
  7928. public function getJobType();
  7929. public function getReason();
  7930. public function __toString();
  7931. }
  7932. <?php
  7933. namespace Composer\DependencyResolver\Operation;
  7934. use Composer\Package\PackageInterface;
  7935. abstract class SolverOperation implements OperationInterface
  7936. {
  7937. protected $reason;
  7938. public function __construct($reason = null)
  7939. {
  7940. $this->reason = $reason;
  7941. }
  7942. public function getReason()
  7943. {
  7944. return $this->reason;
  7945. }
  7946. protected function formatVersion(PackageInterface $package)
  7947. {
  7948. return $package->getFullPrettyVersion();
  7949. }
  7950. }
  7951. <?php
  7952. namespace Composer\DependencyResolver\Operation;
  7953. use Composer\Package\PackageInterface;
  7954. class UninstallOperation extends SolverOperation
  7955. {
  7956. protected $package;
  7957. public function __construct(PackageInterface $package, $reason = null)
  7958. {
  7959. parent::__construct($reason);
  7960. $this->package = $package;
  7961. }
  7962. public function getPackage()
  7963. {
  7964. return $this->package;
  7965. }
  7966. public function getJobType()
  7967. {
  7968. return 'uninstall';
  7969. }
  7970. public function __toString()
  7971. {
  7972. return 'Uninstalling '.$this->package->getPrettyName().' ('.$this->formatVersion($this->package).')';
  7973. }
  7974. }
  7975. <?php
  7976. namespace Composer\DependencyResolver\Operation;
  7977. use Composer\Package\PackageInterface;
  7978. class UpdateOperation extends SolverOperation
  7979. {
  7980. protected $initialPackage;
  7981. protected $targetPackage;
  7982. public function __construct(PackageInterface $initial, PackageInterface $target, $reason = null)
  7983. {
  7984. parent::__construct($reason);
  7985. $this->initialPackage = $initial;
  7986. $this->targetPackage = $target;
  7987. }
  7988. public function getInitialPackage()
  7989. {
  7990. return $this->initialPackage;
  7991. }
  7992. public function getTargetPackage()
  7993. {
  7994. return $this->targetPackage;
  7995. }
  7996. public function getJobType()
  7997. {
  7998. return 'update';
  7999. }
  8000. public function __toString()
  8001. {
  8002. return 'Updating '.$this->initialPackage->getPrettyName().' ('.$this->formatVersion($this->initialPackage).') to '.
  8003. $this->targetPackage->getPrettyName(). ' ('.$this->formatVersion($this->targetPackage).')';
  8004. }
  8005. }
  8006. <?php
  8007. namespace Composer\DependencyResolver;
  8008. use Composer\Package\PackageInterface;
  8009. interface PolicyInterface
  8010. {
  8011. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  8012. public function findUpdatePackages(Pool $pool, array $installedMap, PackageInterface $package);
  8013. public function selectPreferredPackages(Pool $pool, array $installedMap, array $literals, $requiredPackage = null);
  8014. }
  8015. <?php
  8016. namespace Composer\DependencyResolver;
  8017. use Composer\Package\BasePackage;
  8018. use Composer\Package\AliasPackage;
  8019. use Composer\Package\Version\VersionParser;
  8020. use Composer\Semver\Constraint\ConstraintInterface;
  8021. use Composer\Semver\Constraint\Constraint;
  8022. use Composer\Semver\Constraint\EmptyConstraint;
  8023. use Composer\Repository\RepositoryInterface;
  8024. use Composer\Repository\CompositeRepository;
  8025. use Composer\Repository\ComposerRepository;
  8026. use Composer\Repository\InstalledRepositoryInterface;
  8027. use Composer\Repository\PlatformRepository;
  8028. use Composer\Package\PackageInterface;
  8029. class Pool implements \Countable
  8030. {
  8031. const MATCH_NAME = -1;
  8032. const MATCH_NONE = 0;
  8033. const MATCH = 1;
  8034. const MATCH_PROVIDE = 2;
  8035. const MATCH_REPLACE = 3;
  8036. const MATCH_FILTERED = 4;
  8037. protected $repositories = array();
  8038. protected $providerRepos = array();
  8039. protected $packages = array();
  8040. protected $packageByName = array();
  8041. protected $packageByExactName = array();
  8042. protected $acceptableStabilities;
  8043. protected $stabilityFlags;
  8044. protected $versionParser;
  8045. protected $providerCache = array();
  8046. protected $filterRequires;
  8047. protected $whitelist = null;
  8048. protected $id = 1;
  8049. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $filterRequires = array())
  8050. {
  8051. $this->versionParser = new VersionParser;
  8052. $this->acceptableStabilities = array();
  8053. foreach (BasePackage::$stabilities as $stability => $value) {
  8054. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  8055. $this->acceptableStabilities[$stability] = $value;
  8056. }
  8057. }
  8058. $this->stabilityFlags = $stabilityFlags;
  8059. $this->filterRequires = $filterRequires;
  8060. foreach ($filterRequires as $name => $constraint) {
  8061. if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) {
  8062. unset($this->filterRequires[$name]);
  8063. }
  8064. }
  8065. }
  8066. public function setWhitelist($whitelist)
  8067. {
  8068. $this->whitelist = $whitelist;
  8069. $this->providerCache = array();
  8070. }
  8071. public function addRepository(RepositoryInterface $repo, $rootAliases = array())
  8072. {
  8073. if ($repo instanceof CompositeRepository) {
  8074. $repos = $repo->getRepositories();
  8075. } else {
  8076. $repos = array($repo);
  8077. }
  8078. foreach ($repos as $repo) {
  8079. $this->repositories[] = $repo;
  8080. $exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
  8081. if ($repo instanceof ComposerRepository && $repo->hasProviders()) {
  8082. $this->providerRepos[] = $repo;
  8083. $repo->setRootAliases($rootAliases);
  8084. $repo->resetPackageIds();
  8085. } else {
  8086. foreach ($repo->getPackages() as $package) {
  8087. $names = $package->getNames();
  8088. $stability = $package->getStability();
  8089. if ($exempt || $this->isPackageAcceptable($names, $stability)) {
  8090. $package->setId($this->id++);
  8091. $this->packages[] = $package;
  8092. $this->packageByExactName[$package->getName()][$package->id] = $package;
  8093. foreach ($names as $provided) {
  8094. $this->packageByName[$provided][] = $package;
  8095. }
  8096. $name = $package->getName();
  8097. if (isset($rootAliases[$name][$package->getVersion()])) {
  8098. $alias = $rootAliases[$name][$package->getVersion()];
  8099. if ($package instanceof AliasPackage) {
  8100. $package = $package->getAliasOf();
  8101. }
  8102. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  8103. $aliasPackage->setRootPackageAlias(true);
  8104. $aliasPackage->setId($this->id++);
  8105. $package->getRepository()->addPackage($aliasPackage);
  8106. $this->packages[] = $aliasPackage;
  8107. $this->packageByExactName[$aliasPackage->getName()][$aliasPackage->id] = $aliasPackage;
  8108. foreach ($aliasPackage->getNames() as $name) {
  8109. $this->packageByName[$name][] = $aliasPackage;
  8110. }
  8111. }
  8112. }
  8113. }
  8114. }
  8115. }
  8116. }
  8117. public function getPriority(RepositoryInterface $repo)
  8118. {
  8119. $priority = array_search($repo, $this->repositories, true);
  8120. if (false === $priority) {
  8121. throw new \RuntimeException("Could not determine repository priority. The repository was not registered in the pool.");
  8122. }
  8123. return -$priority;
  8124. }
  8125. public function packageById($id)
  8126. {
  8127. return $this->packages[$id - 1];
  8128. }
  8129. public function count()
  8130. {
  8131. return count($this->packages);
  8132. }
  8133. public function whatProvides($name, ConstraintInterface $constraint = null, $mustMatchName = false, $bypassFilters = false)
  8134. {
  8135. if ($bypassFilters) {
  8136. return $this->computeWhatProvides($name, $constraint, $mustMatchName, true);
  8137. }
  8138. $key = ((int) $mustMatchName).$constraint;
  8139. if (isset($this->providerCache[$name][$key])) {
  8140. return $this->providerCache[$name][$key];
  8141. }
  8142. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName, $bypassFilters);
  8143. }
  8144. private function computeWhatProvides($name, $constraint, $mustMatchName = false, $bypassFilters = false)
  8145. {
  8146. $candidates = array();
  8147. foreach ($this->providerRepos as $repo) {
  8148. foreach ($repo->whatProvides($this, $name, $bypassFilters) as $candidate) {
  8149. $candidates[] = $candidate;
  8150. if ($candidate->id < 1) {
  8151. $candidate->setId($this->id++);
  8152. $this->packages[$this->id - 2] = $candidate;
  8153. }
  8154. }
  8155. }
  8156. if ($mustMatchName) {
  8157. $candidates = array_filter($candidates, function ($candidate) use ($name) {
  8158. return $candidate->getName() == $name;
  8159. });
  8160. if (isset($this->packageByExactName[$name])) {
  8161. $candidates = array_merge($candidates, $this->packageByExactName[$name]);
  8162. }
  8163. } elseif (isset($this->packageByName[$name])) {
  8164. $candidates = array_merge($candidates, $this->packageByName[$name]);
  8165. }
  8166. $matches = $provideMatches = array();
  8167. $nameMatch = false;
  8168. foreach ($candidates as $candidate) {
  8169. $aliasOfCandidate = null;
  8170. if ($candidate instanceof AliasPackage) {
  8171. $aliasOfCandidate = $candidate->getAliasOf();
  8172. }
  8173. if ($this->whitelist !== null && !$bypassFilters && (
  8174. (!($candidate instanceof AliasPackage) && !isset($this->whitelist[$candidate->id])) ||
  8175. ($candidate instanceof AliasPackage && !isset($this->whitelist[$aliasOfCandidate->id]))
  8176. )) {
  8177. continue;
  8178. }
  8179. switch ($this->match($candidate, $name, $constraint, $bypassFilters)) {
  8180. case self::MATCH_NONE:
  8181. break;
  8182. case self::MATCH_NAME:
  8183. $nameMatch = true;
  8184. break;
  8185. case self::MATCH:
  8186. $nameMatch = true;
  8187. $matches[] = $candidate;
  8188. break;
  8189. case self::MATCH_PROVIDE:
  8190. $provideMatches[] = $candidate;
  8191. break;
  8192. case self::MATCH_REPLACE:
  8193. $matches[] = $candidate;
  8194. break;
  8195. case self::MATCH_FILTERED:
  8196. break;
  8197. default:
  8198. throw new \UnexpectedValueException('Unexpected match type');
  8199. }
  8200. }
  8201. if ($nameMatch) {
  8202. return $matches;
  8203. }
  8204. return array_merge($matches, $provideMatches);
  8205. }
  8206. public function literalToPackage($literal)
  8207. {
  8208. $packageId = abs($literal);
  8209. return $this->packageById($packageId);
  8210. }
  8211. public function literalToPrettyString($literal, $installedMap)
  8212. {
  8213. $package = $this->literalToPackage($literal);
  8214. if (isset($installedMap[$package->id])) {
  8215. $prefix = ($literal > 0 ? 'keep' : 'remove');
  8216. } else {
  8217. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  8218. }
  8219. return $prefix.' '.$package->getPrettyString();
  8220. }
  8221. public function isPackageAcceptable($name, $stability)
  8222. {
  8223. foreach ((array) $name as $n) {
  8224. if (!isset($this->stabilityFlags[$n]) && isset($this->acceptableStabilities[$stability])) {
  8225. return true;
  8226. }
  8227. if (isset($this->stabilityFlags[$n]) && BasePackage::$stabilities[$stability] <= $this->stabilityFlags[$n]) {
  8228. return true;
  8229. }
  8230. }
  8231. return false;
  8232. }
  8233. public function match($candidate, $name, ConstraintInterface $constraint = null, $bypassFilters)
  8234. {
  8235. $candidateName = $candidate->getName();
  8236. $candidateVersion = $candidate->getVersion();
  8237. $isDev = $candidate->getStability() === 'dev';
  8238. $isAlias = $candidate instanceof AliasPackage;
  8239. if (!$bypassFilters && !$isDev && !$isAlias && isset($this->filterRequires[$name])) {
  8240. $requireFilter = $this->filterRequires[$name];
  8241. } else {
  8242. $requireFilter = new EmptyConstraint;
  8243. }
  8244. if ($candidateName === $name) {
  8245. $pkgConstraint = new Constraint('==', $candidateVersion);
  8246. if ($constraint === null || $constraint->matches($pkgConstraint)) {
  8247. return $requireFilter->matches($pkgConstraint) ? self::MATCH : self::MATCH_FILTERED;
  8248. }
  8249. return self::MATCH_NAME;
  8250. }
  8251. $provides = $candidate->getProvides();
  8252. $replaces = $candidate->getReplaces();
  8253. if (isset($replaces[0]) || isset($provides[0])) {
  8254. foreach ($provides as $link) {
  8255. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  8256. return $requireFilter->matches($link->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED;
  8257. }
  8258. }
  8259. foreach ($replaces as $link) {
  8260. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  8261. return $requireFilter->matches($link->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED;
  8262. }
  8263. }
  8264. return self::MATCH_NONE;
  8265. }
  8266. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  8267. return $requireFilter->matches($provides[$name]->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED;
  8268. }
  8269. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  8270. return $requireFilter->matches($replaces[$name]->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED;
  8271. }
  8272. return self::MATCH_NONE;
  8273. }
  8274. }
  8275. <?php
  8276. namespace Composer\DependencyResolver;
  8277. use Composer\Package\CompletePackageInterface;
  8278. class Problem
  8279. {
  8280. protected $reasonSeen;
  8281. protected $reasons = array();
  8282. protected $section = 0;
  8283. protected $pool;
  8284. public function __construct(Pool $pool)
  8285. {
  8286. $this->pool = $pool;
  8287. }
  8288. public function addRule(Rule $rule)
  8289. {
  8290. $this->addReason(spl_object_hash($rule), array(
  8291. 'rule' => $rule,
  8292. 'job' => $rule->getJob(),
  8293. ));
  8294. }
  8295. public function getReasons()
  8296. {
  8297. return $this->reasons;
  8298. }
  8299. public function getPrettyString(array $installedMap = array())
  8300. {
  8301. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  8302. if (count($reasons) === 1) {
  8303. reset($reasons);
  8304. $reason = current($reasons);
  8305. $rule = $reason['rule'];
  8306. $job = $reason['job'];
  8307. if (isset($job['constraint'])) {
  8308. $packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
  8309. } else {
  8310. $packages = array();
  8311. }
  8312. if ($job && $job['cmd'] === 'install' && empty($packages)) {
  8313. if ($job['packageName'] === 'php' || $job['packageName'] === 'php-64bit' || $job['packageName'] === 'hhvm') {
  8314. $version = phpversion();
  8315. $available = $this->pool->whatProvides($job['packageName']);
  8316. if (count($available)) {
  8317. $firstAvailable = reset($available);
  8318. $version = $firstAvailable->getPrettyVersion();
  8319. $extra = $firstAvailable->getExtra();
  8320. if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  8321. $version .= '; ' . $firstAvailable->getDescription();
  8322. }
  8323. }
  8324. $msg = "\n - This package requires ".$job['packageName'].$this->constraintToText($job['constraint']).' but ';
  8325. if (defined('HHVM_VERSION')) {
  8326. return $msg . 'your HHVM version does not satisfy that requirement.';
  8327. }
  8328. if ($job['packageName'] === 'hhvm') {
  8329. return $msg . 'you are running this with PHP and not HHVM.';
  8330. }
  8331. return $msg . 'your PHP version ('. $version .') does not satisfy that requirement.';
  8332. }
  8333. if (0 === stripos($job['packageName'], 'ext-')) {
  8334. if (false !== strpos($job['packageName'], ' ')) {
  8335. return "\n - The requested PHP extension ".$job['packageName'].' should be required as '.str_replace(' ', '-', $job['packageName']).'.';
  8336. }
  8337. $ext = substr($job['packageName'], 4);
  8338. $error = extension_loaded($ext) ? 'has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'is missing from your system';
  8339. return "\n - The requested PHP extension ".$job['packageName'].$this->constraintToText($job['constraint']).' '.$error.'. Install or enable PHP\'s '.$ext.' extension.';
  8340. }
  8341. if (0 === stripos($job['packageName'], 'lib-')) {
  8342. if (strtolower($job['packageName']) === 'lib-icu') {
  8343. $error = extension_loaded('intl') ? 'has the wrong version installed, try upgrading the intl extension.' : 'is missing from your system, make sure the intl extension is loaded.';
  8344. return "\n - The requested linked library ".$job['packageName'].$this->constraintToText($job['constraint']).' '.$error;
  8345. }
  8346. return "\n - The requested linked library ".$job['packageName'].$this->constraintToText($job['constraint']).' has the wrong version installed or is missing from your system, make sure to load the extension providing it.';
  8347. }
  8348. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $job['packageName'])) {
  8349. $illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $job['packageName']);
  8350. return "\n - The requested package ".$job['packageName'].' could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.';
  8351. }
  8352. if ($providers = $this->pool->whatProvides($job['packageName'], $job['constraint'], true, true)) {
  8353. return "\n - The requested package ".$job['packageName'].$this->constraintToText($job['constraint']).' is satisfiable by '.$this->getPackageList($providers).' but these conflict with your requirements or minimum-stability.';
  8354. }
  8355. if ($providers = $this->pool->whatProvides($job['packageName'], null, true, true)) {
  8356. return "\n - The requested package ".$job['packageName'].$this->constraintToText($job['constraint']).' exists as '.$this->getPackageList($providers).' but these are rejected by your constraint.';
  8357. }
  8358. return "\n - The requested package ".$job['packageName'].' could not be found in any version, there may be a typo in the package name.';
  8359. }
  8360. }
  8361. $messages = array();
  8362. foreach ($reasons as $reason) {
  8363. $rule = $reason['rule'];
  8364. $job = $reason['job'];
  8365. if ($job) {
  8366. $messages[] = $this->jobToText($job);
  8367. } elseif ($rule) {
  8368. if ($rule instanceof Rule) {
  8369. $messages[] = $rule->getPrettyString($this->pool, $installedMap);
  8370. }
  8371. }
  8372. }
  8373. return "\n - ".implode("\n - ", $messages);
  8374. }
  8375. protected function addReason($id, $reason)
  8376. {
  8377. if (!isset($this->reasonSeen[$id])) {
  8378. $this->reasonSeen[$id] = true;
  8379. $this->reasons[$this->section][] = $reason;
  8380. }
  8381. }
  8382. public function nextSection()
  8383. {
  8384. $this->section++;
  8385. }
  8386. protected function jobToText($job)
  8387. {
  8388. switch ($job['cmd']) {
  8389. case 'install':
  8390. $packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
  8391. if (!$packages) {
  8392. return 'No package found to satisfy install request for '.$job['packageName'].$this->constraintToText($job['constraint']);
  8393. }
  8394. return 'Installation request for '.$job['packageName'].$this->constraintToText($job['constraint']).' -> satisfiable by '.$this->getPackageList($packages).'.';
  8395. case 'update':
  8396. return 'Update request for '.$job['packageName'].$this->constraintToText($job['constraint']).'.';
  8397. case 'remove':
  8398. return 'Removal request for '.$job['packageName'].$this->constraintToText($job['constraint']).'';
  8399. }
  8400. if (isset($job['constraint'])) {
  8401. $packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
  8402. } else {
  8403. $packages = array();
  8404. }
  8405. return 'Job(cmd='.$job['cmd'].', target='.$job['packageName'].', packages=['.$this->getPackageList($packages).'])';
  8406. }
  8407. protected function getPackageList($packages)
  8408. {
  8409. $prepared = array();
  8410. foreach ($packages as $package) {
  8411. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  8412. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion();
  8413. }
  8414. foreach ($prepared as $name => $package) {
  8415. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  8416. }
  8417. return implode(', ', $prepared);
  8418. }
  8419. protected function constraintToText($constraint)
  8420. {
  8421. return $constraint ? ' '.$constraint->getPrettyString() : '';
  8422. }
  8423. }
  8424. <?php
  8425. namespace Composer\DependencyResolver;
  8426. use Composer\Semver\Constraint\ConstraintInterface;
  8427. class Request
  8428. {
  8429. protected $jobs;
  8430. public function __construct()
  8431. {
  8432. $this->jobs = array();
  8433. }
  8434. public function install($packageName, ConstraintInterface $constraint = null)
  8435. {
  8436. $this->addJob($packageName, 'install', $constraint);
  8437. }
  8438. public function update($packageName, ConstraintInterface $constraint = null)
  8439. {
  8440. $this->addJob($packageName, 'update', $constraint);
  8441. }
  8442. public function remove($packageName, ConstraintInterface $constraint = null)
  8443. {
  8444. $this->addJob($packageName, 'remove', $constraint);
  8445. }
  8446. public function fix($packageName, ConstraintInterface $constraint = null)
  8447. {
  8448. $this->addJob($packageName, 'install', $constraint, true);
  8449. }
  8450. protected function addJob($packageName, $cmd, ConstraintInterface $constraint = null, $fixed = false)
  8451. {
  8452. $packageName = strtolower($packageName);
  8453. $this->jobs[] = array(
  8454. 'cmd' => $cmd,
  8455. 'packageName' => $packageName,
  8456. 'constraint' => $constraint,
  8457. 'fixed' => $fixed,
  8458. );
  8459. }
  8460. public function updateAll()
  8461. {
  8462. $this->jobs[] = array('cmd' => 'update-all');
  8463. }
  8464. public function getJobs()
  8465. {
  8466. return $this->jobs;
  8467. }
  8468. }
  8469. <?php
  8470. namespace Composer\DependencyResolver;
  8471. use Composer\Package\CompletePackage;
  8472. use Composer\Package\Link;
  8473. use Composer\Package\PackageInterface;
  8474. abstract class Rule
  8475. {
  8476. const RULE_INTERNAL_ALLOW_UPDATE = 1;
  8477. const RULE_JOB_INSTALL = 2;
  8478. const RULE_JOB_REMOVE = 3;
  8479. const RULE_PACKAGE_CONFLICT = 6;
  8480. const RULE_PACKAGE_REQUIRES = 7;
  8481. const RULE_PACKAGE_OBSOLETES = 8;
  8482. const RULE_INSTALLED_PACKAGE_OBSOLETES = 9;
  8483. const RULE_PACKAGE_SAME_NAME = 10;
  8484. const RULE_PACKAGE_IMPLICIT_OBSOLETES = 11;
  8485. const RULE_LEARNED = 12;
  8486. const RULE_PACKAGE_ALIAS = 13;
  8487. const BITFIELD_TYPE = 0;
  8488. const BITFIELD_REASON = 8;
  8489. const BITFIELD_DISABLED = 16;
  8490. protected $bitfield;
  8491. protected $job;
  8492. protected $reasonData;
  8493. public function __construct($reason, $reasonData, $job = null)
  8494. {
  8495. $this->reasonData = $reasonData;
  8496. if ($job) {
  8497. $this->job = $job;
  8498. }
  8499. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  8500. ($reason << self::BITFIELD_REASON) |
  8501. (255 << self::BITFIELD_TYPE);
  8502. }
  8503. abstract public function getLiterals();
  8504. abstract public function getHash();
  8505. public function getJob()
  8506. {
  8507. return $this->job;
  8508. }
  8509. abstract public function equals(Rule $rule);
  8510. public function getReason()
  8511. {
  8512. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  8513. }
  8514. public function getReasonData()
  8515. {
  8516. return $this->reasonData;
  8517. }
  8518. public function getRequiredPackage()
  8519. {
  8520. if ($this->getReason() === self::RULE_JOB_INSTALL) {
  8521. return $this->reasonData;
  8522. }
  8523. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  8524. return $this->reasonData->getTarget();
  8525. }
  8526. }
  8527. public function setType($type)
  8528. {
  8529. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  8530. }
  8531. public function getType()
  8532. {
  8533. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  8534. }
  8535. public function disable()
  8536. {
  8537. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  8538. }
  8539. public function enable()
  8540. {
  8541. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  8542. }
  8543. public function isDisabled()
  8544. {
  8545. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  8546. }
  8547. public function isEnabled()
  8548. {
  8549. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  8550. }
  8551. abstract public function isAssertion();
  8552. public function getPrettyString(Pool $pool, array $installedMap = array())
  8553. {
  8554. $literals = $this->getLiterals();
  8555. $ruleText = '';
  8556. foreach ($literals as $i => $literal) {
  8557. if ($i != 0) {
  8558. $ruleText .= '|';
  8559. }
  8560. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  8561. }
  8562. switch ($this->getReason()) {
  8563. case self::RULE_INTERNAL_ALLOW_UPDATE:
  8564. return $ruleText;
  8565. case self::RULE_JOB_INSTALL:
  8566. return "Install command rule ($ruleText)";
  8567. case self::RULE_JOB_REMOVE:
  8568. return "Remove command rule ($ruleText)";
  8569. case self::RULE_PACKAGE_CONFLICT:
  8570. $package1 = $pool->literalToPackage($literals[0]);
  8571. $package2 = $pool->literalToPackage($literals[1]);
  8572. return $package1->getPrettyString().' conflicts with '.$this->formatPackagesUnique($pool, array($package2)).'.';
  8573. case self::RULE_PACKAGE_REQUIRES:
  8574. $sourceLiteral = array_shift($literals);
  8575. $sourcePackage = $pool->literalToPackage($sourceLiteral);
  8576. $requires = array();
  8577. foreach ($literals as $literal) {
  8578. $requires[] = $pool->literalToPackage($literal);
  8579. }
  8580. $text = $this->reasonData->getPrettyString($sourcePackage);
  8581. if ($requires) {
  8582. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires) . '.';
  8583. } else {
  8584. $targetName = $this->reasonData->getTarget();
  8585. if ($targetName === 'php' || $targetName === 'php-64bit' || $targetName === 'hhvm') {
  8586. if (defined('HHVM_VERSION')) {
  8587. return $text . ' -> your HHVM version does not satisfy that requirement.';
  8588. }
  8589. if ($targetName === 'hhvm') {
  8590. return $text . ' -> you are running this with PHP and not HHVM.';
  8591. }
  8592. $packages = $pool->whatProvides($targetName);
  8593. $package = count($packages) ? current($packages) : phpversion();
  8594. if (!($package instanceof CompletePackage)) {
  8595. return $text . ' -> your PHP version ('.phpversion().') does not satisfy that requirement.';
  8596. }
  8597. $extra = $package->getExtra();
  8598. if (!empty($extra['config.platform'])) {
  8599. $text .= ' -> your PHP version ('.phpversion().') overridden by "config.platform.php" version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
  8600. } else {
  8601. $text .= ' -> your PHP version ('.$package->getPrettyVersion().') does not satisfy that requirement.';
  8602. }
  8603. return $text;
  8604. }
  8605. if (0 === strpos($targetName, 'ext-')) {
  8606. $ext = substr($targetName, 4);
  8607. $error = extension_loaded($ext) ? 'has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'is missing from your system';
  8608. return $text . ' -> the requested PHP extension '.$ext.' '.$error.'.';
  8609. }
  8610. if (0 === strpos($targetName, 'lib-')) {
  8611. $lib = substr($targetName, 4);
  8612. return $text . ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.';
  8613. }
  8614. if ($providers = $pool->whatProvides($targetName, $this->reasonData->getConstraint(), true, true)) {
  8615. return $text . ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $providers) .' but these conflict with your requirements or minimum-stability.';
  8616. }
  8617. return $text . ' -> no matching package found.';
  8618. }
  8619. return $text;
  8620. case self::RULE_PACKAGE_OBSOLETES:
  8621. return $ruleText;
  8622. case self::RULE_INSTALLED_PACKAGE_OBSOLETES:
  8623. return $ruleText;
  8624. case self::RULE_PACKAGE_SAME_NAME:
  8625. return 'Can only install one of: ' . $this->formatPackagesUnique($pool, $literals) . '.';
  8626. case self::RULE_PACKAGE_IMPLICIT_OBSOLETES:
  8627. return $ruleText;
  8628. case self::RULE_LEARNED:
  8629. return 'Conclusion: '.$ruleText;
  8630. case self::RULE_PACKAGE_ALIAS:
  8631. return $ruleText;
  8632. default:
  8633. return '('.$ruleText.')';
  8634. }
  8635. }
  8636. protected function formatPackagesUnique($pool, array $packages)
  8637. {
  8638. $prepared = array();
  8639. foreach ($packages as $package) {
  8640. if (!is_object($package)) {
  8641. $package = $pool->literalToPackage($package);
  8642. }
  8643. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  8644. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion();
  8645. }
  8646. foreach ($prepared as $name => $package) {
  8647. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  8648. }
  8649. return implode(', ', $prepared);
  8650. }
  8651. }
  8652. <?php
  8653. namespace Composer\DependencyResolver;
  8654. use Composer\Package\PackageInterface;
  8655. use Composer\Package\Link;
  8656. class Rule2Literals extends Rule
  8657. {
  8658. protected $literal1;
  8659. protected $literal2;
  8660. public function __construct($literal1, $literal2, $reason, $reasonData, $job = null)
  8661. {
  8662. parent::__construct($reason, $reasonData, $job);
  8663. if ($literal1 < $literal2) {
  8664. $this->literal1 = $literal1;
  8665. $this->literal2 = $literal2;
  8666. } else {
  8667. $this->literal1 = $literal2;
  8668. $this->literal2 = $literal1;
  8669. }
  8670. }
  8671. public function getLiterals()
  8672. {
  8673. return array($this->literal1, $this->literal2);
  8674. }
  8675. public function getHash()
  8676. {
  8677. return $this->literal1.','.$this->literal2;
  8678. }
  8679. public function equals(Rule $rule)
  8680. {
  8681. if ($rule instanceof self) {
  8682. if ($this->literal1 !== $rule->literal1) {
  8683. return false;
  8684. }
  8685. if ($this->literal2 !== $rule->literal2) {
  8686. return false;
  8687. }
  8688. return true;
  8689. }
  8690. $literals = $rule->getLiterals();
  8691. if (2 != count($literals)) {
  8692. return false;
  8693. }
  8694. if ($this->literal1 !== $literals[0]) {
  8695. return false;
  8696. }
  8697. if ($this->literal2 !== $literals[1]) {
  8698. return false;
  8699. }
  8700. return true;
  8701. }
  8702. public function isAssertion()
  8703. {
  8704. return false;
  8705. }
  8706. public function __toString()
  8707. {
  8708. $result = $this->isDisabled() ? 'disabled(' : '(';
  8709. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  8710. return $result;
  8711. }
  8712. }
  8713. <?php
  8714. namespace Composer\DependencyResolver;
  8715. class RuleSet implements \IteratorAggregate, \Countable
  8716. {
  8717. const TYPE_PACKAGE = 0;
  8718. const TYPE_JOB = 1;
  8719. const TYPE_LEARNED = 4;
  8720. public $ruleById;
  8721. protected static $types = array(
  8722. 255 => 'UNKNOWN',
  8723. self::TYPE_PACKAGE => 'PACKAGE',
  8724. self::TYPE_JOB => 'JOB',
  8725. self::TYPE_LEARNED => 'LEARNED',
  8726. );
  8727. protected $rules;
  8728. protected $nextRuleId;
  8729. protected $rulesByHash;
  8730. public function __construct()
  8731. {
  8732. $this->nextRuleId = 0;
  8733. foreach ($this->getTypes() as $type) {
  8734. $this->rules[$type] = array();
  8735. }
  8736. $this->rulesByHash = array();
  8737. }
  8738. public function add(Rule $rule, $type)
  8739. {
  8740. if (!isset(self::$types[$type])) {
  8741. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  8742. }
  8743. $hash = $rule->getHash();
  8744. if (isset($this->rulesByHash[$hash])) {
  8745. $potentialDuplicates = $this->rulesByHash[$hash];
  8746. if (is_array($potentialDuplicates)) {
  8747. foreach ($potentialDuplicates as $potentialDuplicate) {
  8748. if ($rule->equals($potentialDuplicate)) {
  8749. return;
  8750. }
  8751. }
  8752. } else {
  8753. if ($rule->equals($potentialDuplicates)) {
  8754. return;
  8755. }
  8756. }
  8757. }
  8758. if (!isset($this->rules[$type])) {
  8759. $this->rules[$type] = array();
  8760. }
  8761. $this->rules[$type][] = $rule;
  8762. $this->ruleById[$this->nextRuleId] = $rule;
  8763. $rule->setType($type);
  8764. $this->nextRuleId++;
  8765. if (!isset($this->rulesByHash[$hash])) {
  8766. $this->rulesByHash[$hash] = $rule;
  8767. } elseif (is_array($this->rulesByHash[$hash])) {
  8768. $this->rulesByHash[$hash][] = $rule;
  8769. } else {
  8770. $originalRule = $this->rulesByHash[$hash];
  8771. $this->rulesByHash[$hash] = array($originalRule, $rule);
  8772. }
  8773. }
  8774. public function count()
  8775. {
  8776. return $this->nextRuleId;
  8777. }
  8778. public function ruleById($id)
  8779. {
  8780. return $this->ruleById[$id];
  8781. }
  8782. public function getRules()
  8783. {
  8784. return $this->rules;
  8785. }
  8786. public function getIterator()
  8787. {
  8788. return new RuleSetIterator($this->getRules());
  8789. }
  8790. public function getIteratorFor($types)
  8791. {
  8792. if (!is_array($types)) {
  8793. $types = array($types);
  8794. }
  8795. $allRules = $this->getRules();
  8796. $rules = array();
  8797. foreach ($types as $type) {
  8798. $rules[$type] = $allRules[$type];
  8799. }
  8800. return new RuleSetIterator($rules);
  8801. }
  8802. public function getIteratorWithout($types)
  8803. {
  8804. if (!is_array($types)) {
  8805. $types = array($types);
  8806. }
  8807. $rules = $this->getRules();
  8808. foreach ($types as $type) {
  8809. unset($rules[$type]);
  8810. }
  8811. return new RuleSetIterator($rules);
  8812. }
  8813. public function getTypes()
  8814. {
  8815. $types = self::$types;
  8816. unset($types[255]);
  8817. return array_keys($types);
  8818. }
  8819. public function getPrettyString(Pool $pool = null)
  8820. {
  8821. $string = "\n";
  8822. foreach ($this->rules as $type => $rules) {
  8823. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  8824. foreach ($rules as $rule) {
  8825. $string .= ($pool ? $rule->getPrettyString($pool) : $rule)."\n";
  8826. }
  8827. $string .= "\n\n";
  8828. }
  8829. return $string;
  8830. }
  8831. public function __toString()
  8832. {
  8833. return $this->getPrettyString(null);
  8834. }
  8835. }
  8836. <?php
  8837. namespace Composer\DependencyResolver;
  8838. use Composer\Package\PackageInterface;
  8839. use Composer\Package\AliasPackage;
  8840. use Composer\Repository\PlatformRepository;
  8841. class RuleSetGenerator
  8842. {
  8843. protected $policy;
  8844. protected $pool;
  8845. protected $rules;
  8846. protected $jobs;
  8847. protected $installedMap;
  8848. protected $whitelistedMap;
  8849. protected $addedMap;
  8850. protected $conflictAddedMap;
  8851. protected $addedPackages;
  8852. protected $addedPackagesByNames;
  8853. public function __construct(PolicyInterface $policy, Pool $pool)
  8854. {
  8855. $this->policy = $policy;
  8856. $this->pool = $pool;
  8857. }
  8858. protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
  8859. {
  8860. $literals = array(-$package->id);
  8861. foreach ($providers as $provider) {
  8862. if ($provider === $package) {
  8863. return null;
  8864. }
  8865. $literals[] = $provider->id;
  8866. }
  8867. return new GenericRule($literals, $reason, $reasonData);
  8868. }
  8869. protected function createInstallOneOfRule(array $packages, $reason, $job)
  8870. {
  8871. $literals = array();
  8872. foreach ($packages as $package) {
  8873. $literals[] = $package->id;
  8874. }
  8875. return new GenericRule($literals, $reason, $job['packageName'], $job);
  8876. }
  8877. protected function createRemoveRule(PackageInterface $package, $reason, $job)
  8878. {
  8879. return new GenericRule(array(-$package->id), $reason, $job['packageName'], $job);
  8880. }
  8881. protected function createRule2Literals(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
  8882. {
  8883. if ($issuer === $provider) {
  8884. return null;
  8885. }
  8886. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  8887. }
  8888. private function addRule($type, Rule $newRule = null)
  8889. {
  8890. if (!$newRule) {
  8891. return;
  8892. }
  8893. $this->rules->add($newRule, $type);
  8894. }
  8895. protected function whitelistFromPackage(PackageInterface $package)
  8896. {
  8897. $workQueue = new \SplQueue;
  8898. $workQueue->enqueue($package);
  8899. while (!$workQueue->isEmpty()) {
  8900. $package = $workQueue->dequeue();
  8901. if (isset($this->whitelistedMap[$package->id])) {
  8902. continue;
  8903. }
  8904. $this->whitelistedMap[$package->id] = true;
  8905. foreach ($package->getRequires() as $link) {
  8906. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint(), true);
  8907. foreach ($possibleRequires as $require) {
  8908. $workQueue->enqueue($require);
  8909. }
  8910. }
  8911. $obsoleteProviders = $this->pool->whatProvides($package->getName(), null, true);
  8912. foreach ($obsoleteProviders as $provider) {
  8913. if ($provider === $package) {
  8914. continue;
  8915. }
  8916. if (($package instanceof AliasPackage) && $package->getAliasOf() === $provider) {
  8917. $workQueue->enqueue($provider);
  8918. }
  8919. }
  8920. }
  8921. }
  8922. protected function addRulesForPackage(PackageInterface $package, $ignorePlatformReqs)
  8923. {
  8924. $workQueue = new \SplQueue;
  8925. $workQueue->enqueue($package);
  8926. while (!$workQueue->isEmpty()) {
  8927. $package = $workQueue->dequeue();
  8928. if (isset($this->addedMap[$package->id])) {
  8929. continue;
  8930. }
  8931. $this->addedMap[$package->id] = true;
  8932. $this->addedPackages[] = $package;
  8933. foreach ($package->getNames() as $name) {
  8934. $this->addedPackagesByNames[$name][] = $package;
  8935. }
  8936. foreach ($package->getRequires() as $link) {
  8937. if ($ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
  8938. continue;
  8939. }
  8940. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  8941. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  8942. foreach ($possibleRequires as $require) {
  8943. $workQueue->enqueue($require);
  8944. }
  8945. }
  8946. $packageName = $package->getName();
  8947. $obsoleteProviders = $this->pool->whatProvides($packageName, null);
  8948. foreach ($obsoleteProviders as $provider) {
  8949. if ($provider === $package) {
  8950. continue;
  8951. }
  8952. if (($package instanceof AliasPackage) && $package->getAliasOf() === $provider) {
  8953. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($provider), Rule::RULE_PACKAGE_ALIAS, $package));
  8954. } elseif (!$this->obsoleteImpossibleForAlias($package, $provider)) {
  8955. $reason = ($packageName == $provider->getName()) ? Rule::RULE_PACKAGE_SAME_NAME : Rule::RULE_PACKAGE_IMPLICIT_OBSOLETES;
  8956. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $provider, $reason, $package));
  8957. }
  8958. }
  8959. }
  8960. }
  8961. protected function addConflictRules()
  8962. {
  8963. foreach ($this->addedPackages as $package) {
  8964. foreach ($package->getConflicts() as $link) {
  8965. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  8966. continue;
  8967. }
  8968. foreach ($this->addedPackagesByNames[$link->getTarget()] as $possibleConflict) {
  8969. $conflictMatch = $this->pool->match($possibleConflict, $link->getTarget(), $link->getConstraint(), true);
  8970. if ($conflictMatch === Pool::MATCH || $conflictMatch === Pool::MATCH_REPLACE) {
  8971. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $possibleConflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  8972. }
  8973. }
  8974. }
  8975. $isInstalled = isset($this->installedMap[$package->id]);
  8976. foreach ($package->getReplaces() as $link) {
  8977. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  8978. continue;
  8979. }
  8980. foreach ($this->addedPackagesByNames[$link->getTarget()] as $provider) {
  8981. if ($provider === $package) {
  8982. continue;
  8983. }
  8984. if (!$this->obsoleteImpossibleForAlias($package, $provider)) {
  8985. $reason = $isInstalled ? Rule::RULE_INSTALLED_PACKAGE_OBSOLETES : Rule::RULE_PACKAGE_OBSOLETES;
  8986. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $provider, $reason, $link));
  8987. }
  8988. }
  8989. }
  8990. }
  8991. }
  8992. protected function obsoleteImpossibleForAlias($package, $provider)
  8993. {
  8994. $packageIsAlias = $package instanceof AliasPackage;
  8995. $providerIsAlias = $provider instanceof AliasPackage;
  8996. $impossible = (
  8997. ($packageIsAlias && $package->getAliasOf() === $provider) ||
  8998. ($providerIsAlias && $provider->getAliasOf() === $package) ||
  8999. ($packageIsAlias && $providerIsAlias && $provider->getAliasOf() === $package->getAliasOf())
  9000. );
  9001. return $impossible;
  9002. }
  9003. protected function whitelistFromJobs()
  9004. {
  9005. foreach ($this->jobs as $job) {
  9006. switch ($job['cmd']) {
  9007. case 'install':
  9008. $packages = $this->pool->whatProvides($job['packageName'], $job['constraint'], true);
  9009. foreach ($packages as $package) {
  9010. $this->whitelistFromPackage($package);
  9011. }
  9012. break;
  9013. }
  9014. }
  9015. }
  9016. protected function addRulesForJobs($ignorePlatformReqs)
  9017. {
  9018. foreach ($this->jobs as $job) {
  9019. switch ($job['cmd']) {
  9020. case 'install':
  9021. if (!$job['fixed'] && $ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $job['packageName'])) {
  9022. break;
  9023. }
  9024. $packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
  9025. if ($packages) {
  9026. foreach ($packages as $package) {
  9027. if (!isset($this->installedMap[$package->id])) {
  9028. $this->addRulesForPackage($package, $ignorePlatformReqs);
  9029. }
  9030. }
  9031. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_JOB_INSTALL, $job);
  9032. $this->addRule(RuleSet::TYPE_JOB, $rule);
  9033. }
  9034. break;
  9035. case 'remove':
  9036. $packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
  9037. foreach ($packages as $package) {
  9038. $rule = $this->createRemoveRule($package, Rule::RULE_JOB_REMOVE, $job);
  9039. $this->addRule(RuleSet::TYPE_JOB, $rule);
  9040. }
  9041. break;
  9042. }
  9043. }
  9044. }
  9045. public function getRulesFor($jobs, $installedMap, $ignorePlatformReqs = false)
  9046. {
  9047. $this->jobs = $jobs;
  9048. $this->rules = new RuleSet;
  9049. $this->installedMap = $installedMap;
  9050. $this->whitelistedMap = array();
  9051. foreach ($this->installedMap as $package) {
  9052. $this->whitelistFromPackage($package);
  9053. }
  9054. $this->whitelistFromJobs();
  9055. $this->pool->setWhitelist($this->whitelistedMap);
  9056. $this->addedMap = array();
  9057. $this->conflictAddedMap = array();
  9058. $this->addedPackages = array();
  9059. $this->addedPackagesByNames = array();
  9060. foreach ($this->installedMap as $package) {
  9061. $this->addRulesForPackage($package, $ignorePlatformReqs);
  9062. }
  9063. $this->addRulesForJobs($ignorePlatformReqs);
  9064. $this->addConflictRules();
  9065. $this->addedPackages = $this->addedPackagesByNames = null;
  9066. return $this->rules;
  9067. }
  9068. }
  9069. <?php
  9070. namespace Composer\DependencyResolver;
  9071. class RuleSetIterator implements \Iterator
  9072. {
  9073. protected $rules;
  9074. protected $types;
  9075. protected $currentOffset;
  9076. protected $currentType;
  9077. protected $currentTypeOffset;
  9078. public function __construct(array $rules)
  9079. {
  9080. $this->rules = $rules;
  9081. $this->types = array_keys($rules);
  9082. sort($this->types);
  9083. $this->rewind();
  9084. }
  9085. public function current()
  9086. {
  9087. return $this->rules[$this->currentType][$this->currentOffset];
  9088. }
  9089. public function key()
  9090. {
  9091. return $this->currentType;
  9092. }
  9093. public function next()
  9094. {
  9095. $this->currentOffset++;
  9096. if (!isset($this->rules[$this->currentType])) {
  9097. return;
  9098. }
  9099. if ($this->currentOffset >= count($this->rules[$this->currentType])) {
  9100. $this->currentOffset = 0;
  9101. do {
  9102. $this->currentTypeOffset++;
  9103. if (!isset($this->types[$this->currentTypeOffset])) {
  9104. $this->currentType = -1;
  9105. break;
  9106. }
  9107. $this->currentType = $this->types[$this->currentTypeOffset];
  9108. } while (isset($this->types[$this->currentTypeOffset]) && !count($this->rules[$this->currentType]));
  9109. }
  9110. }
  9111. public function rewind()
  9112. {
  9113. $this->currentOffset = 0;
  9114. $this->currentTypeOffset = -1;
  9115. $this->currentType = -1;
  9116. do {
  9117. $this->currentTypeOffset++;
  9118. if (!isset($this->types[$this->currentTypeOffset])) {
  9119. $this->currentType = -1;
  9120. break;
  9121. }
  9122. $this->currentType = $this->types[$this->currentTypeOffset];
  9123. } while (isset($this->types[$this->currentTypeOffset]) && !count($this->rules[$this->currentType]));
  9124. }
  9125. public function valid()
  9126. {
  9127. return isset($this->rules[$this->currentType])
  9128. && isset($this->rules[$this->currentType][$this->currentOffset]);
  9129. }
  9130. }
  9131. <?php
  9132. namespace Composer\DependencyResolver;
  9133. class RuleWatchChain extends \SplDoublyLinkedList
  9134. {
  9135. protected $offset = 0;
  9136. public function seek($offset)
  9137. {
  9138. $this->rewind();
  9139. for ($i = 0; $i < $offset; $i++, $this->next());
  9140. }
  9141. public function remove()
  9142. {
  9143. $offset = $this->key();
  9144. $this->offsetUnset($offset);
  9145. $this->seek($offset);
  9146. }
  9147. }
  9148. <?php
  9149. namespace Composer\DependencyResolver;
  9150. class RuleWatchGraph
  9151. {
  9152. protected $watchChains = array();
  9153. public function insert(RuleWatchNode $node)
  9154. {
  9155. if ($node->getRule()->isAssertion()) {
  9156. return;
  9157. }
  9158. foreach (array($node->watch1, $node->watch2) as $literal) {
  9159. if (!isset($this->watchChains[$literal])) {
  9160. $this->watchChains[$literal] = new RuleWatchChain;
  9161. }
  9162. $this->watchChains[$literal]->unshift($node);
  9163. }
  9164. }
  9165. public function propagateLiteral($decidedLiteral, $level, $decisions)
  9166. {
  9167. $literal = -$decidedLiteral;
  9168. if (!isset($this->watchChains[$literal])) {
  9169. return null;
  9170. }
  9171. $chain = $this->watchChains[$literal];
  9172. $chain->rewind();
  9173. while ($chain->valid()) {
  9174. $node = $chain->current();
  9175. $otherWatch = $node->getOtherWatch($literal);
  9176. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  9177. $ruleLiterals = $node->getRule()->getLiterals();
  9178. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  9179. return $literal !== $ruleLiteral &&
  9180. $otherWatch !== $ruleLiteral &&
  9181. !$decisions->conflict($ruleLiteral);
  9182. });
  9183. if ($alternativeLiterals) {
  9184. reset($alternativeLiterals);
  9185. $this->moveWatch($literal, current($alternativeLiterals), $node);
  9186. continue;
  9187. }
  9188. if ($decisions->conflict($otherWatch)) {
  9189. return $node->getRule();
  9190. }
  9191. $decisions->decide($otherWatch, $level, $node->getRule());
  9192. }
  9193. $chain->next();
  9194. }
  9195. return null;
  9196. }
  9197. protected function moveWatch($fromLiteral, $toLiteral, $node)
  9198. {
  9199. if (!isset($this->watchChains[$toLiteral])) {
  9200. $this->watchChains[$toLiteral] = new RuleWatchChain;
  9201. }
  9202. $node->moveWatch($fromLiteral, $toLiteral);
  9203. $this->watchChains[$fromLiteral]->remove();
  9204. $this->watchChains[$toLiteral]->unshift($node);
  9205. }
  9206. }
  9207. <?php
  9208. namespace Composer\DependencyResolver;
  9209. class RuleWatchNode
  9210. {
  9211. public $watch1;
  9212. public $watch2;
  9213. protected $rule;
  9214. public function __construct($rule)
  9215. {
  9216. $this->rule = $rule;
  9217. $literals = $rule->getLiterals();
  9218. $literalCount = count($literals);
  9219. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  9220. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  9221. }
  9222. public function watch2OnHighest(Decisions $decisions)
  9223. {
  9224. $literals = $this->rule->getLiterals();
  9225. if (count($literals) < 3) {
  9226. return;
  9227. }
  9228. $watchLevel = 0;
  9229. foreach ($literals as $literal) {
  9230. $level = $decisions->decisionLevel($literal);
  9231. if ($level > $watchLevel) {
  9232. $this->watch2 = $literal;
  9233. $watchLevel = $level;
  9234. }
  9235. }
  9236. }
  9237. public function getRule()
  9238. {
  9239. return $this->rule;
  9240. }
  9241. public function getOtherWatch($literal)
  9242. {
  9243. if ($this->watch1 == $literal) {
  9244. return $this->watch2;
  9245. }
  9246. return $this->watch1;
  9247. }
  9248. public function moveWatch($from, $to)
  9249. {
  9250. if ($this->watch1 == $from) {
  9251. $this->watch1 = $to;
  9252. } else {
  9253. $this->watch2 = $to;
  9254. }
  9255. }
  9256. }
  9257. <?php
  9258. namespace Composer\DependencyResolver;
  9259. use Composer\IO\IOInterface;
  9260. use Composer\Repository\RepositoryInterface;
  9261. use Composer\Repository\PlatformRepository;
  9262. class Solver
  9263. {
  9264. const BRANCH_LITERALS = 0;
  9265. const BRANCH_LEVEL = 1;
  9266. protected $policy;
  9267. protected $pool;
  9268. protected $installed;
  9269. protected $rules;
  9270. protected $ruleSetGenerator;
  9271. protected $jobs;
  9272. protected $updateMap = array();
  9273. protected $watchGraph;
  9274. protected $decisions;
  9275. protected $installedMap;
  9276. protected $propagateIndex;
  9277. protected $branches = array();
  9278. protected $problems = array();
  9279. protected $learnedPool = array();
  9280. protected $learnedWhy = array();
  9281. protected $io;
  9282. public function __construct(PolicyInterface $policy, Pool $pool, RepositoryInterface $installed, IOInterface $io)
  9283. {
  9284. $this->io = $io;
  9285. $this->policy = $policy;
  9286. $this->pool = $pool;
  9287. $this->installed = $installed;
  9288. $this->ruleSetGenerator = new RuleSetGenerator($policy, $pool);
  9289. }
  9290. public function getRuleSetSize()
  9291. {
  9292. return count($this->rules);
  9293. }
  9294. private function makeAssertionRuleDecisions()
  9295. {
  9296. $decisionStart = count($this->decisions) - 1;
  9297. $rulesCount = count($this->rules);
  9298. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  9299. $rule = $this->rules->ruleById[$ruleIndex];
  9300. if (!$rule->isAssertion() || $rule->isDisabled()) {
  9301. continue;
  9302. }
  9303. $literals = $rule->getLiterals();
  9304. $literal = $literals[0];
  9305. if (!$this->decisions->decided($literal)) {
  9306. $this->decisions->decide($literal, 1, $rule);
  9307. continue;
  9308. }
  9309. if ($this->decisions->satisfy($literal)) {
  9310. continue;
  9311. }
  9312. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  9313. $rule->disable();
  9314. continue;
  9315. }
  9316. $conflict = $this->decisions->decisionRule($literal);
  9317. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  9318. $problem = new Problem($this->pool);
  9319. $problem->addRule($rule);
  9320. $problem->addRule($conflict);
  9321. $this->disableProblem($rule);
  9322. $this->problems[] = $problem;
  9323. continue;
  9324. }
  9325. $problem = new Problem($this->pool);
  9326. $problem->addRule($rule);
  9327. $problem->addRule($conflict);
  9328. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_JOB) as $assertRule) {
  9329. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  9330. continue;
  9331. }
  9332. $assertRuleLiterals = $assertRule->getLiterals();
  9333. $assertRuleLiteral = $assertRuleLiterals[0];
  9334. if (abs($literal) !== abs($assertRuleLiteral)) {
  9335. continue;
  9336. }
  9337. $problem->addRule($assertRule);
  9338. $this->disableProblem($assertRule);
  9339. }
  9340. $this->problems[] = $problem;
  9341. $this->decisions->resetToOffset($decisionStart);
  9342. $ruleIndex = -1;
  9343. }
  9344. }
  9345. protected function setupInstalledMap()
  9346. {
  9347. $this->installedMap = array();
  9348. foreach ($this->installed->getPackages() as $package) {
  9349. $this->installedMap[$package->id] = $package;
  9350. }
  9351. }
  9352. protected function checkForRootRequireProblems($ignorePlatformReqs)
  9353. {
  9354. foreach ($this->jobs as $job) {
  9355. switch ($job['cmd']) {
  9356. case 'update':
  9357. $packages = $this->pool->whatProvides($job['packageName'], $job['constraint']);
  9358. foreach ($packages as $package) {
  9359. if (isset($this->installedMap[$package->id])) {
  9360. $this->updateMap[$package->id] = true;
  9361. }
  9362. }
  9363. break;
  9364. case 'update-all':
  9365. foreach ($this->installedMap as $package) {
  9366. $this->updateMap[$package->id] = true;
  9367. }
  9368. break;
  9369. case 'install':
  9370. if ($ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $job['packageName'])) {
  9371. break;
  9372. }
  9373. if (!$this->pool->whatProvides($job['packageName'], $job['constraint'])) {
  9374. $problem = new Problem($this->pool);
  9375. $problem->addRule(new GenericRule(array(), null, null, $job));
  9376. $this->problems[] = $problem;
  9377. }
  9378. break;
  9379. }
  9380. }
  9381. }
  9382. public function solve(Request $request, $ignorePlatformReqs = false)
  9383. {
  9384. $this->jobs = $request->getJobs();
  9385. $this->setupInstalledMap();
  9386. $this->rules = $this->ruleSetGenerator->getRulesFor($this->jobs, $this->installedMap, $ignorePlatformReqs);
  9387. $this->checkForRootRequireProblems($ignorePlatformReqs);
  9388. $this->decisions = new Decisions($this->pool);
  9389. $this->watchGraph = new RuleWatchGraph;
  9390. foreach ($this->rules as $rule) {
  9391. $this->watchGraph->insert(new RuleWatchNode($rule));
  9392. }
  9393. $this->makeAssertionRuleDecisions();
  9394. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  9395. $before = microtime(true);
  9396. $this->runSat(true);
  9397. $this->io->writeError('', true, IOInterface::DEBUG);
  9398. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  9399. foreach ($this->installedMap as $packageId => $void) {
  9400. if ($this->decisions->undecided($packageId)) {
  9401. $this->decisions->decide(-$packageId, 1, null);
  9402. }
  9403. }
  9404. if ($this->problems) {
  9405. throw new SolverProblemsException($this->problems, $this->installedMap);
  9406. }
  9407. $transaction = new Transaction($this->policy, $this->pool, $this->installedMap, $this->decisions);
  9408. return $transaction->getOperations();
  9409. }
  9410. protected function propagate($level)
  9411. {
  9412. while ($this->decisions->validOffset($this->propagateIndex)) {
  9413. $decision = $this->decisions->atOffset($this->propagateIndex);
  9414. $conflict = $this->watchGraph->propagateLiteral(
  9415. $decision[Decisions::DECISION_LITERAL],
  9416. $level,
  9417. $this->decisions
  9418. );
  9419. $this->propagateIndex++;
  9420. if ($conflict) {
  9421. return $conflict;
  9422. }
  9423. }
  9424. return null;
  9425. }
  9426. private function revert($level)
  9427. {
  9428. while (!$this->decisions->isEmpty()) {
  9429. $literal = $this->decisions->lastLiteral();
  9430. if ($this->decisions->undecided($literal)) {
  9431. break;
  9432. }
  9433. $decisionLevel = $this->decisions->decisionLevel($literal);
  9434. if ($decisionLevel <= $level) {
  9435. break;
  9436. }
  9437. $this->decisions->revertLast();
  9438. $this->propagateIndex = count($this->decisions);
  9439. }
  9440. while (!empty($this->branches) && $this->branches[count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  9441. array_pop($this->branches);
  9442. }
  9443. }
  9444. private function setPropagateLearn($level, $literal, $disableRules, Rule $rule)
  9445. {
  9446. $level++;
  9447. $this->decisions->decide($literal, $level, $rule);
  9448. while (true) {
  9449. $rule = $this->propagate($level);
  9450. if (!$rule) {
  9451. break;
  9452. }
  9453. if ($level == 1) {
  9454. return $this->analyzeUnsolvable($rule, $disableRules);
  9455. }
  9456. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  9457. if ($newLevel <= 0 || $newLevel >= $level) {
  9458. throw new SolverBugException(
  9459. "Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
  9460. );
  9461. } elseif (!$newRule) {
  9462. throw new SolverBugException(
  9463. "No rule was learned from analyzing $rule at level $level."
  9464. );
  9465. }
  9466. $level = $newLevel;
  9467. $this->revert($level);
  9468. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  9469. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  9470. $ruleNode = new RuleWatchNode($newRule);
  9471. $ruleNode->watch2OnHighest($this->decisions);
  9472. $this->watchGraph->insert($ruleNode);
  9473. $this->decisions->decide($learnLiteral, $level, $newRule);
  9474. }
  9475. return $level;
  9476. }
  9477. private function selectAndInstall($level, array $decisionQueue, $disableRules, Rule $rule)
  9478. {
  9479. $literals = $this->policy->selectPreferredPackages($this->pool, $this->installedMap, $decisionQueue, $rule->getRequiredPackage());
  9480. $selectedLiteral = array_shift($literals);
  9481. if (count($literals)) {
  9482. $this->branches[] = array($literals, $level);
  9483. }
  9484. return $this->setPropagateLearn($level, $selectedLiteral, $disableRules, $rule);
  9485. }
  9486. protected function analyze($level, Rule $rule)
  9487. {
  9488. $analyzedRule = $rule;
  9489. $ruleLevel = 1;
  9490. $num = 0;
  9491. $l1num = 0;
  9492. $seen = array();
  9493. $learnedLiterals = array(null);
  9494. $decisionId = count($this->decisions);
  9495. $this->learnedPool[] = array();
  9496. while (true) {
  9497. $this->learnedPool[count($this->learnedPool) - 1][] = $rule;
  9498. foreach ($rule->getLiterals() as $literal) {
  9499. if ($this->decisions->satisfy($literal)) {
  9500. continue;
  9501. }
  9502. if (isset($seen[abs($literal)])) {
  9503. continue;
  9504. }
  9505. $seen[abs($literal)] = true;
  9506. $l = $this->decisions->decisionLevel($literal);
  9507. if (1 === $l) {
  9508. $l1num++;
  9509. } elseif ($level === $l) {
  9510. $num++;
  9511. } else {
  9512. $learnedLiterals[] = $literal;
  9513. if ($l > $ruleLevel) {
  9514. $ruleLevel = $l;
  9515. }
  9516. }
  9517. }
  9518. $l1retry = true;
  9519. while ($l1retry) {
  9520. $l1retry = false;
  9521. if (!$num && !--$l1num) {
  9522. break 2;
  9523. }
  9524. while (true) {
  9525. if ($decisionId <= 0) {
  9526. throw new SolverBugException(
  9527. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  9528. );
  9529. }
  9530. $decisionId--;
  9531. $decision = $this->decisions->atOffset($decisionId);
  9532. $literal = $decision[Decisions::DECISION_LITERAL];
  9533. if (isset($seen[abs($literal)])) {
  9534. break;
  9535. }
  9536. }
  9537. unset($seen[abs($literal)]);
  9538. if ($num && 0 === --$num) {
  9539. $learnedLiterals[0] = -abs($literal);
  9540. if (!$l1num) {
  9541. break 2;
  9542. }
  9543. foreach ($learnedLiterals as $i => $learnedLiteral) {
  9544. if ($i !== 0) {
  9545. unset($seen[abs($learnedLiteral)]);
  9546. }
  9547. }
  9548. $l1num++;
  9549. $l1retry = true;
  9550. }
  9551. }
  9552. $decision = $this->decisions->atOffset($decisionId);
  9553. $rule = $decision[Decisions::DECISION_REASON];
  9554. }
  9555. $why = count($this->learnedPool) - 1;
  9556. if (!$learnedLiterals[0]) {
  9557. throw new SolverBugException(
  9558. "Did not find a learnable literal in analyzed rule $analyzedRule."
  9559. );
  9560. }
  9561. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  9562. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  9563. }
  9564. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule)
  9565. {
  9566. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  9567. $why = spl_object_hash($conflictRule);
  9568. $learnedWhy = $this->learnedWhy[$why];
  9569. $problemRules = $this->learnedPool[$learnedWhy];
  9570. foreach ($problemRules as $problemRule) {
  9571. $this->analyzeUnsolvableRule($problem, $problemRule);
  9572. }
  9573. return;
  9574. }
  9575. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  9576. return;
  9577. }
  9578. $problem->nextSection();
  9579. $problem->addRule($conflictRule);
  9580. }
  9581. private function analyzeUnsolvable(Rule $conflictRule, $disableRules)
  9582. {
  9583. $problem = new Problem($this->pool);
  9584. $problem->addRule($conflictRule);
  9585. $this->analyzeUnsolvableRule($problem, $conflictRule);
  9586. $this->problems[] = $problem;
  9587. $seen = array();
  9588. $literals = $conflictRule->getLiterals();
  9589. foreach ($literals as $literal) {
  9590. if ($this->decisions->satisfy($literal)) {
  9591. continue;
  9592. }
  9593. $seen[abs($literal)] = true;
  9594. }
  9595. foreach ($this->decisions as $decision) {
  9596. $literal = $decision[Decisions::DECISION_LITERAL];
  9597. if (!isset($seen[abs($literal)])) {
  9598. continue;
  9599. }
  9600. $why = $decision[Decisions::DECISION_REASON];
  9601. $problem->addRule($why);
  9602. $this->analyzeUnsolvableRule($problem, $why);
  9603. $literals = $why->getLiterals();
  9604. foreach ($literals as $literal) {
  9605. if ($this->decisions->satisfy($literal)) {
  9606. continue;
  9607. }
  9608. $seen[abs($literal)] = true;
  9609. }
  9610. }
  9611. if ($disableRules) {
  9612. foreach ($this->problems[count($this->problems) - 1] as $reason) {
  9613. $this->disableProblem($reason['rule']);
  9614. }
  9615. $this->resetSolver();
  9616. return 1;
  9617. }
  9618. return 0;
  9619. }
  9620. private function disableProblem(Rule $why)
  9621. {
  9622. $job = $why->getJob();
  9623. if (!$job) {
  9624. $why->disable();
  9625. return;
  9626. }
  9627. foreach ($this->rules as $rule) {
  9628. if ($job === $rule->getJob()) {
  9629. $rule->disable();
  9630. }
  9631. }
  9632. }
  9633. private function resetSolver()
  9634. {
  9635. $this->decisions->reset();
  9636. $this->propagateIndex = 0;
  9637. $this->branches = array();
  9638. $this->enableDisableLearnedRules();
  9639. $this->makeAssertionRuleDecisions();
  9640. }
  9641. private function enableDisableLearnedRules()
  9642. {
  9643. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  9644. $why = $this->learnedWhy[spl_object_hash($rule)];
  9645. $problemRules = $this->learnedPool[$why];
  9646. $foundDisabled = false;
  9647. foreach ($problemRules as $problemRule) {
  9648. if ($problemRule->isDisabled()) {
  9649. $foundDisabled = true;
  9650. break;
  9651. }
  9652. }
  9653. if ($foundDisabled && $rule->isEnabled()) {
  9654. $rule->disable();
  9655. } elseif (!$foundDisabled && $rule->isDisabled()) {
  9656. $rule->enable();
  9657. }
  9658. }
  9659. }
  9660. private function runSat($disableRules = true)
  9661. {
  9662. $this->propagateIndex = 0;
  9663. $decisionQueue = array();
  9664. $decisionSupplementQueue = array();
  9665. $disableRules = array();
  9666. $level = 1;
  9667. $systemLevel = $level + 1;
  9668. $installedPos = 0;
  9669. while (true) {
  9670. if (1 === $level) {
  9671. $conflictRule = $this->propagate($level);
  9672. if (null !== $conflictRule) {
  9673. if ($this->analyzeUnsolvable($conflictRule, $disableRules)) {
  9674. continue;
  9675. }
  9676. return;
  9677. }
  9678. }
  9679. if ($level < $systemLevel) {
  9680. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_JOB);
  9681. foreach ($iterator as $rule) {
  9682. if ($rule->isEnabled()) {
  9683. $decisionQueue = array();
  9684. $noneSatisfied = true;
  9685. foreach ($rule->getLiterals() as $literal) {
  9686. if ($this->decisions->satisfy($literal)) {
  9687. $noneSatisfied = false;
  9688. break;
  9689. }
  9690. if ($literal > 0 && $this->decisions->undecided($literal)) {
  9691. $decisionQueue[] = $literal;
  9692. }
  9693. }
  9694. if ($noneSatisfied && count($decisionQueue)) {
  9695. if (count($this->installed) != count($this->updateMap)) {
  9696. $prunedQueue = array();
  9697. foreach ($decisionQueue as $literal) {
  9698. if (isset($this->installedMap[abs($literal)])) {
  9699. $prunedQueue[] = $literal;
  9700. if (isset($this->updateMap[abs($literal)])) {
  9701. $prunedQueue = $decisionQueue;
  9702. break;
  9703. }
  9704. }
  9705. }
  9706. $decisionQueue = $prunedQueue;
  9707. }
  9708. }
  9709. if ($noneSatisfied && count($decisionQueue)) {
  9710. $oLevel = $level;
  9711. $level = $this->selectAndInstall($level, $decisionQueue, $disableRules, $rule);
  9712. if (0 === $level) {
  9713. return;
  9714. }
  9715. if ($level <= $oLevel) {
  9716. break;
  9717. }
  9718. }
  9719. }
  9720. }
  9721. $systemLevel = $level + 1;
  9722. $iterator->next();
  9723. if ($iterator->valid()) {
  9724. continue;
  9725. }
  9726. }
  9727. if ($level < $systemLevel) {
  9728. $systemLevel = $level;
  9729. }
  9730. $rulesCount = count($this->rules);
  9731. $pass = 1;
  9732. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  9733. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  9734. if ($i == $rulesCount) {
  9735. if (1 === $pass) {
  9736. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  9737. } else {
  9738. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  9739. }
  9740. $i = 0;
  9741. $pass++;
  9742. }
  9743. $rule = $this->rules->ruleById[$i];
  9744. $literals = $rule->getLiterals();
  9745. if ($rule->isDisabled()) {
  9746. continue;
  9747. }
  9748. $decisionQueue = array();
  9749. foreach ($literals as $literal) {
  9750. if ($literal <= 0) {
  9751. if (!$this->decisions->decidedInstall($literal)) {
  9752. continue 2;
  9753. }
  9754. } else {
  9755. if ($this->decisions->decidedInstall($literal)) {
  9756. continue 2;
  9757. }
  9758. if ($this->decisions->undecided($literal)) {
  9759. $decisionQueue[] = $literal;
  9760. }
  9761. }
  9762. }
  9763. if (count($decisionQueue) < 2) {
  9764. continue;
  9765. }
  9766. $level = $this->selectAndInstall($level, $decisionQueue, $disableRules, $rule);
  9767. if (0 === $level) {
  9768. return;
  9769. }
  9770. $rulesCount = count($this->rules);
  9771. $n = -1;
  9772. }
  9773. if ($level < $systemLevel) {
  9774. continue;
  9775. }
  9776. if (count($this->branches)) {
  9777. $lastLiteral = null;
  9778. $lastLevel = null;
  9779. $lastBranchIndex = 0;
  9780. $lastBranchOffset = 0;
  9781. for ($i = count($this->branches) - 1; $i >= 0; $i--) {
  9782. list($literals, $l) = $this->branches[$i];
  9783. foreach ($literals as $offset => $literal) {
  9784. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  9785. $lastLiteral = $literal;
  9786. $lastBranchIndex = $i;
  9787. $lastBranchOffset = $offset;
  9788. $lastLevel = $l;
  9789. }
  9790. }
  9791. }
  9792. if ($lastLiteral) {
  9793. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  9794. $level = $lastLevel;
  9795. $this->revert($level);
  9796. $why = $this->decisions->lastReason();
  9797. $level = $this->setPropagateLearn($level, $lastLiteral, $disableRules, $why);
  9798. if ($level == 0) {
  9799. return;
  9800. }
  9801. continue;
  9802. }
  9803. }
  9804. break;
  9805. }
  9806. }
  9807. }
  9808. <?php
  9809. namespace Composer\DependencyResolver;
  9810. class SolverBugException extends \RuntimeException
  9811. {
  9812. public function __construct($message)
  9813. {
  9814. parent::__construct(
  9815. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  9816. "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"
  9817. );
  9818. }
  9819. }
  9820. <?php
  9821. namespace Composer\DependencyResolver;
  9822. use Composer\Util\IniHelper;
  9823. class SolverProblemsException extends \RuntimeException
  9824. {
  9825. protected $problems;
  9826. protected $installedMap;
  9827. public function __construct(array $problems, array $installedMap)
  9828. {
  9829. $this->problems = $problems;
  9830. $this->installedMap = $installedMap;
  9831. parent::__construct($this->createMessage(), 2);
  9832. }
  9833. protected function createMessage()
  9834. {
  9835. $text = "\n";
  9836. $hasExtensionProblems = false;
  9837. foreach ($this->problems as $i => $problem) {
  9838. $text .= " Problem ".($i + 1).$problem->getPrettyString($this->installedMap)."\n";
  9839. if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
  9840. $hasExtensionProblems = true;
  9841. }
  9842. }
  9843. if (strpos($text, 'could not be found') || strpos($text, 'no matching package found')) {
  9844. $text .= "\nPotential 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.";
  9845. }
  9846. if ($hasExtensionProblems) {
  9847. $text .= $this->createExtensionHint();
  9848. }
  9849. return $text;
  9850. }
  9851. public function getProblems()
  9852. {
  9853. return $this->problems;
  9854. }
  9855. private function createExtensionHint()
  9856. {
  9857. $paths = IniHelper::getAll();
  9858. if (count($paths) === 1 && empty($paths[0])) {
  9859. return '';
  9860. }
  9861. $text = "\n To enable extensions, verify that they are enabled in your .ini files:\n - ";
  9862. $text .= implode("\n - ", $paths);
  9863. $text .= "\n You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
  9864. return $text;
  9865. }
  9866. private function hasExtensionProblems(array $reasonSets)
  9867. {
  9868. foreach ($reasonSets as $reasonSet) {
  9869. foreach ($reasonSet as $reason) {
  9870. if (isset($reason["rule"]) && 0 === strpos($reason["rule"]->getRequiredPackage(), 'ext-')) {
  9871. return true;
  9872. }
  9873. }
  9874. }
  9875. return false;
  9876. }
  9877. }
  9878. <?php
  9879. namespace Composer\DependencyResolver;
  9880. use Composer\Package\AliasPackage;
  9881. class Transaction
  9882. {
  9883. protected $policy;
  9884. protected $pool;
  9885. protected $installedMap;
  9886. protected $decisions;
  9887. protected $transaction;
  9888. public function __construct($policy, $pool, $installedMap, $decisions)
  9889. {
  9890. $this->policy = $policy;
  9891. $this->pool = $pool;
  9892. $this->installedMap = $installedMap;
  9893. $this->decisions = $decisions;
  9894. $this->transaction = array();
  9895. }
  9896. public function getOperations()
  9897. {
  9898. $installMeansUpdateMap = $this->findUpdates();
  9899. $updateMap = array();
  9900. $installMap = array();
  9901. $uninstallMap = array();
  9902. foreach ($this->decisions as $i => $decision) {
  9903. $literal = $decision[Decisions::DECISION_LITERAL];
  9904. $reason = $decision[Decisions::DECISION_REASON];
  9905. $package = $this->pool->literalToPackage($literal);
  9906. if (($literal > 0) == isset($this->installedMap[$package->id])) {
  9907. continue;
  9908. }
  9909. if ($literal > 0) {
  9910. if (isset($installMeansUpdateMap[abs($literal)]) && !$package instanceof AliasPackage) {
  9911. $source = $installMeansUpdateMap[abs($literal)];
  9912. $updateMap[$package->id] = array(
  9913. 'package' => $package,
  9914. 'source' => $source,
  9915. 'reason' => $reason,
  9916. );
  9917. unset($installMeansUpdateMap[abs($literal)]);
  9918. $ignoreRemove[$source->id] = true;
  9919. } else {
  9920. $installMap[$package->id] = array(
  9921. 'package' => $package,
  9922. 'reason' => $reason,
  9923. );
  9924. }
  9925. }
  9926. }
  9927. foreach ($this->decisions as $i => $decision) {
  9928. $literal = $decision[Decisions::DECISION_LITERAL];
  9929. $reason = $decision[Decisions::DECISION_REASON];
  9930. $package = $this->pool->literalToPackage($literal);
  9931. if ($literal <= 0 &&
  9932. isset($this->installedMap[$package->id]) &&
  9933. !isset($ignoreRemove[$package->id])) {
  9934. $uninstallMap[$package->id] = array(
  9935. 'package' => $package,
  9936. 'reason' => $reason,
  9937. );
  9938. }
  9939. }
  9940. $this->transactionFromMaps($installMap, $updateMap, $uninstallMap);
  9941. return $this->transaction;
  9942. }
  9943. protected function transactionFromMaps($installMap, $updateMap, $uninstallMap)
  9944. {
  9945. $queue = array_map(
  9946. function ($operation) {
  9947. return $operation['package'];
  9948. },
  9949. $this->findRootPackages($installMap, $updateMap)
  9950. );
  9951. $visited = array();
  9952. while (!empty($queue)) {
  9953. $package = array_pop($queue);
  9954. $packageId = $package->id;
  9955. if (!isset($visited[$packageId])) {
  9956. $queue[] = $package;
  9957. if ($package instanceof AliasPackage) {
  9958. $queue[] = $package->getAliasOf();
  9959. } else {
  9960. foreach ($package->getRequires() as $link) {
  9961. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  9962. foreach ($possibleRequires as $require) {
  9963. $queue[] = $require;
  9964. }
  9965. }
  9966. }
  9967. $visited[$package->id] = true;
  9968. } else {
  9969. if (isset($installMap[$packageId])) {
  9970. $this->install(
  9971. $installMap[$packageId]['package'],
  9972. $installMap[$packageId]['reason']
  9973. );
  9974. unset($installMap[$packageId]);
  9975. }
  9976. if (isset($updateMap[$packageId])) {
  9977. $this->update(
  9978. $updateMap[$packageId]['source'],
  9979. $updateMap[$packageId]['package'],
  9980. $updateMap[$packageId]['reason']
  9981. );
  9982. unset($updateMap[$packageId]);
  9983. }
  9984. }
  9985. }
  9986. foreach ($uninstallMap as $uninstall) {
  9987. $this->uninstall($uninstall['package'], $uninstall['reason']);
  9988. }
  9989. }
  9990. protected function findRootPackages($installMap, $updateMap)
  9991. {
  9992. $packages = $installMap + $updateMap;
  9993. $roots = $packages;
  9994. foreach ($packages as $packageId => $operation) {
  9995. $package = $operation['package'];
  9996. if (!isset($roots[$packageId])) {
  9997. continue;
  9998. }
  9999. foreach ($package->getRequires() as $link) {
  10000. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10001. foreach ($possibleRequires as $require) {
  10002. if ($require !== $package) {
  10003. unset($roots[$require->id]);
  10004. }
  10005. }
  10006. }
  10007. }
  10008. return $roots;
  10009. }
  10010. protected function findUpdates()
  10011. {
  10012. $installMeansUpdateMap = array();
  10013. foreach ($this->decisions as $i => $decision) {
  10014. $literal = $decision[Decisions::DECISION_LITERAL];
  10015. $package = $this->pool->literalToPackage($literal);
  10016. if ($package instanceof AliasPackage) {
  10017. continue;
  10018. }
  10019. if ($literal <= 0 && isset($this->installedMap[$package->id])) {
  10020. $updates = $this->policy->findUpdatePackages($this->pool, $this->installedMap, $package);
  10021. $literals = array($package->id);
  10022. foreach ($updates as $update) {
  10023. $literals[] = $update->id;
  10024. }
  10025. foreach ($literals as $updateLiteral) {
  10026. if ($updateLiteral !== $literal) {
  10027. $installMeansUpdateMap[abs($updateLiteral)] = $package;
  10028. }
  10029. }
  10030. }
  10031. }
  10032. return $installMeansUpdateMap;
  10033. }
  10034. protected function install($package, $reason)
  10035. {
  10036. if ($package instanceof AliasPackage) {
  10037. return $this->markAliasInstalled($package, $reason);
  10038. }
  10039. $this->transaction[] = new Operation\InstallOperation($package, $reason);
  10040. }
  10041. protected function update($from, $to, $reason)
  10042. {
  10043. $this->transaction[] = new Operation\UpdateOperation($from, $to, $reason);
  10044. }
  10045. protected function uninstall($package, $reason)
  10046. {
  10047. if ($package instanceof AliasPackage) {
  10048. return $this->markAliasUninstalled($package, $reason);
  10049. }
  10050. $this->transaction[] = new Operation\UninstallOperation($package, $reason);
  10051. }
  10052. protected function markAliasInstalled($package, $reason)
  10053. {
  10054. $this->transaction[] = new Operation\MarkAliasInstalledOperation($package, $reason);
  10055. }
  10056. protected function markAliasUninstalled($package, $reason)
  10057. {
  10058. $this->transaction[] = new Operation\MarkAliasUninstalledOperation($package, $reason);
  10059. }
  10060. }
  10061. <?php
  10062. namespace Composer\Downloader;
  10063. use Composer\Package\PackageInterface;
  10064. use Symfony\Component\Finder\Finder;
  10065. use Composer\IO\IOInterface;
  10066. abstract class ArchiveDownloader extends FileDownloader
  10067. {
  10068. public function download(PackageInterface $package, $path, $output = true)
  10069. {
  10070. $temporaryDir = $this->config->get('vendor-dir').'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  10071. $retries = 3;
  10072. while ($retries--) {
  10073. $fileName = parent::download($package, $path, $output);
  10074. if ($output) {
  10075. $this->io->writeError(' Extracting archive', false, IOInterface::VERBOSE);
  10076. }
  10077. try {
  10078. $this->filesystem->ensureDirectoryExists($temporaryDir);
  10079. try {
  10080. $this->extract($fileName, $temporaryDir);
  10081. } catch (\Exception $e) {
  10082. parent::clearLastCacheWrite($package);
  10083. throw $e;
  10084. }
  10085. $this->filesystem->unlink($fileName);
  10086. $contentDir = $this->getFolderContent($temporaryDir);
  10087. if (1 === count($contentDir) && is_dir(reset($contentDir))) {
  10088. $contentDir = $this->getFolderContent((string) reset($contentDir));
  10089. }
  10090. foreach ($contentDir as $file) {
  10091. $file = (string) $file;
  10092. $this->filesystem->rename($file, $path . '/' . basename($file));
  10093. }
  10094. $this->filesystem->removeDirectory($temporaryDir);
  10095. if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir').'/composer/')) {
  10096. $this->filesystem->removeDirectory($this->config->get('vendor-dir').'/composer/');
  10097. }
  10098. if ($this->filesystem->isDirEmpty($this->config->get('vendor-dir'))) {
  10099. $this->filesystem->removeDirectory($this->config->get('vendor-dir'));
  10100. }
  10101. } catch (\Exception $e) {
  10102. $this->filesystem->removeDirectory($path);
  10103. $this->filesystem->removeDirectory($temporaryDir);
  10104. if ($retries && $e instanceof \UnexpectedValueException && class_exists('ZipArchive') && $e->getCode() === \ZipArchive::ER_NOZIP) {
  10105. $this->io->writeError('');
  10106. if ($this->io->isDebug()) {
  10107. $this->io->writeError(' Invalid zip file ('.$e->getMessage().'), retrying...');
  10108. } else {
  10109. $this->io->writeError(' Invalid zip file, retrying...');
  10110. }
  10111. usleep(500000);
  10112. continue;
  10113. }
  10114. throw $e;
  10115. }
  10116. break;
  10117. }
  10118. }
  10119. protected function getFileName(PackageInterface $package, $path)
  10120. {
  10121. return rtrim($path.'/'.md5($path.spl_object_hash($package)).'.'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_EXTENSION), '.');
  10122. }
  10123. abstract protected function extract($file, $path);
  10124. private function getFolderContent($dir)
  10125. {
  10126. $finder = Finder::create()
  10127. ->ignoreVCS(false)
  10128. ->ignoreDotFiles(false)
  10129. ->notName('.DS_Store')
  10130. ->depth(0)
  10131. ->in($dir);
  10132. return iterator_to_array($finder);
  10133. }
  10134. }
  10135. <?php
  10136. namespace Composer\Downloader;
  10137. use Composer\Package\PackageInterface;
  10138. interface ChangeReportInterface
  10139. {
  10140. public function getLocalChanges(PackageInterface $package, $path);
  10141. }
  10142. <?php
  10143. namespace Composer\Downloader;
  10144. use Composer\Package\PackageInterface;
  10145. use Composer\IO\IOInterface;
  10146. use Composer\Util\Filesystem;
  10147. class DownloadManager
  10148. {
  10149. private $io;
  10150. private $preferDist = false;
  10151. private $preferSource = false;
  10152. private $packagePreferences = array();
  10153. private $filesystem;
  10154. private $downloaders = array();
  10155. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  10156. {
  10157. $this->io = $io;
  10158. $this->preferSource = $preferSource;
  10159. $this->filesystem = $filesystem ?: new Filesystem();
  10160. }
  10161. public function setPreferSource($preferSource)
  10162. {
  10163. $this->preferSource = $preferSource;
  10164. return $this;
  10165. }
  10166. public function setPreferDist($preferDist)
  10167. {
  10168. $this->preferDist = $preferDist;
  10169. return $this;
  10170. }
  10171. public function setPreferences(array $preferences)
  10172. {
  10173. $this->packagePreferences = $preferences;
  10174. return $this;
  10175. }
  10176. public function setOutputProgress($outputProgress)
  10177. {
  10178. foreach ($this->downloaders as $downloader) {
  10179. $downloader->setOutputProgress($outputProgress);
  10180. }
  10181. return $this;
  10182. }
  10183. public function setDownloader($type, DownloaderInterface $downloader)
  10184. {
  10185. $type = strtolower($type);
  10186. $this->downloaders[$type] = $downloader;
  10187. return $this;
  10188. }
  10189. public function getDownloader($type)
  10190. {
  10191. $type = strtolower($type);
  10192. if (!isset($this->downloaders[$type])) {
  10193. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  10194. }
  10195. return $this->downloaders[$type];
  10196. }
  10197. public function getDownloaderForInstalledPackage(PackageInterface $package)
  10198. {
  10199. $installationSource = $package->getInstallationSource();
  10200. if ('metapackage' === $package->getType()) {
  10201. return;
  10202. }
  10203. if ('dist' === $installationSource) {
  10204. $downloader = $this->getDownloader($package->getDistType());
  10205. } elseif ('source' === $installationSource) {
  10206. $downloader = $this->getDownloader($package->getSourceType());
  10207. } else {
  10208. throw new \InvalidArgumentException(
  10209. 'Package '.$package.' seems not been installed properly'
  10210. );
  10211. }
  10212. if ($installationSource !== $downloader->getInstallationSource()) {
  10213. throw new \LogicException(sprintf(
  10214. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  10215. get_class($downloader),
  10216. $downloader->getInstallationSource(),
  10217. $installationSource,
  10218. $package
  10219. ));
  10220. }
  10221. return $downloader;
  10222. }
  10223. public function download(PackageInterface $package, $targetDir, $preferSource = null)
  10224. {
  10225. $preferSource = null !== $preferSource ? $preferSource : $this->preferSource;
  10226. $sourceType = $package->getSourceType();
  10227. $distType = $package->getDistType();
  10228. $sources = array();
  10229. if ($sourceType) {
  10230. $sources[] = 'source';
  10231. }
  10232. if ($distType) {
  10233. $sources[] = 'dist';
  10234. }
  10235. if (empty($sources)) {
  10236. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  10237. }
  10238. if (!$preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  10239. $sources = array_reverse($sources);
  10240. }
  10241. $this->filesystem->ensureDirectoryExists($targetDir);
  10242. foreach ($sources as $i => $source) {
  10243. if (isset($e)) {
  10244. $this->io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  10245. }
  10246. $package->setInstallationSource($source);
  10247. try {
  10248. $downloader = $this->getDownloaderForInstalledPackage($package);
  10249. if ($downloader) {
  10250. $downloader->download($package, $targetDir);
  10251. }
  10252. break;
  10253. } catch (\RuntimeException $e) {
  10254. if ($i === count($sources) - 1) {
  10255. throw $e;
  10256. }
  10257. $this->io->writeError(
  10258. ' <warning>Failed to download '.
  10259. $package->getPrettyName().
  10260. ' from ' . $source . ': '.
  10261. $e->getMessage().'</warning>'
  10262. );
  10263. }
  10264. }
  10265. }
  10266. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  10267. {
  10268. $downloader = $this->getDownloaderForInstalledPackage($initial);
  10269. if (!$downloader) {
  10270. return;
  10271. }
  10272. $installationSource = $initial->getInstallationSource();
  10273. if ('dist' === $installationSource) {
  10274. $initialType = $initial->getDistType();
  10275. $targetType = $target->getDistType();
  10276. } else {
  10277. $initialType = $initial->getSourceType();
  10278. $targetType = $target->getSourceType();
  10279. }
  10280. if ($target->isDev() && 'dist' === $installationSource) {
  10281. $downloader->remove($initial, $targetDir);
  10282. $this->download($target, $targetDir);
  10283. return;
  10284. }
  10285. if ($initialType === $targetType) {
  10286. $target->setInstallationSource($installationSource);
  10287. try {
  10288. $downloader->update($initial, $target, $targetDir);
  10289. return;
  10290. } catch (\RuntimeException $e) {
  10291. if (!$this->io->isInteractive()) {
  10292. throw $e;
  10293. }
  10294. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  10295. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ', true)) {
  10296. throw $e;
  10297. }
  10298. }
  10299. }
  10300. $downloader->remove($initial, $targetDir);
  10301. $this->download($target, $targetDir, 'source' === $installationSource);
  10302. }
  10303. public function remove(PackageInterface $package, $targetDir)
  10304. {
  10305. $downloader = $this->getDownloaderForInstalledPackage($package);
  10306. if ($downloader) {
  10307. $downloader->remove($package, $targetDir);
  10308. }
  10309. }
  10310. protected function resolvePackageInstallPreference(PackageInterface $package)
  10311. {
  10312. foreach ($this->packagePreferences as $pattern => $preference) {
  10313. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  10314. if (preg_match($pattern, $package->getName())) {
  10315. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  10316. return 'dist';
  10317. }
  10318. return 'source';
  10319. }
  10320. }
  10321. return $package->isDev() ? 'source' : 'dist';
  10322. }
  10323. }
  10324. <?php
  10325. namespace Composer\Downloader;
  10326. use Composer\Package\PackageInterface;
  10327. interface DownloaderInterface
  10328. {
  10329. public function getInstallationSource();
  10330. public function download(PackageInterface $package, $path);
  10331. public function update(PackageInterface $initial, PackageInterface $target, $path);
  10332. public function remove(PackageInterface $package, $path);
  10333. public function setOutputProgress($outputProgress);
  10334. }
  10335. <?php
  10336. namespace Composer\Downloader;
  10337. use Composer\Package\PackageInterface;
  10338. interface DvcsDownloaderInterface
  10339. {
  10340. public function getUnpushedChanges(PackageInterface $package, $path);
  10341. }
  10342. <?php
  10343. namespace Composer\Downloader;
  10344. use Composer\Config;
  10345. use Composer\Cache;
  10346. use Composer\Factory;
  10347. use Composer\IO\IOInterface;
  10348. use Composer\IO\NullIO;
  10349. use Composer\Package\Comparer\Comparer;
  10350. use Composer\Package\PackageInterface;
  10351. use Composer\Package\Version\VersionParser;
  10352. use Composer\Plugin\PluginEvents;
  10353. use Composer\Plugin\PreFileDownloadEvent;
  10354. use Composer\EventDispatcher\EventDispatcher;
  10355. use Composer\Util\Filesystem;
  10356. use Composer\Util\RemoteFilesystem;
  10357. use Composer\Util\Url as UrlUtil;
  10358. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  10359. {
  10360. protected $io;
  10361. protected $config;
  10362. protected $rfs;
  10363. protected $filesystem;
  10364. protected $cache;
  10365. protected $outputProgress = true;
  10366. private $lastCacheWrites = array();
  10367. private $eventDispatcher;
  10368. public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, RemoteFilesystem $rfs = null, Filesystem $filesystem = null)
  10369. {
  10370. $this->io = $io;
  10371. $this->config = $config;
  10372. $this->eventDispatcher = $eventDispatcher;
  10373. $this->rfs = $rfs ?: Factory::createRemoteFilesystem($this->io, $config);
  10374. $this->filesystem = $filesystem ?: new Filesystem();
  10375. $this->cache = $cache;
  10376. if ($this->cache && $this->cache->gcIsNecessary()) {
  10377. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  10378. }
  10379. }
  10380. public function getInstallationSource()
  10381. {
  10382. return 'dist';
  10383. }
  10384. public function download(PackageInterface $package, $path, $output = true)
  10385. {
  10386. if (!$package->getDistUrl()) {
  10387. throw new \InvalidArgumentException('The given package is missing url information');
  10388. }
  10389. if ($output) {
  10390. $this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>): ", false);
  10391. }
  10392. $urls = $package->getDistUrls();
  10393. while ($url = array_shift($urls)) {
  10394. try {
  10395. $fileName = $this->doDownload($package, $path, $url);
  10396. break;
  10397. } catch (\Exception $e) {
  10398. if ($this->io->isDebug()) {
  10399. $this->io->writeError('');
  10400. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  10401. } elseif (count($urls)) {
  10402. $this->io->writeError('');
  10403. $this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')', false);
  10404. }
  10405. if (!count($urls)) {
  10406. throw $e;
  10407. }
  10408. }
  10409. }
  10410. if ($output) {
  10411. $this->io->writeError('');
  10412. }
  10413. return $fileName;
  10414. }
  10415. protected function doDownload(PackageInterface $package, $path, $url)
  10416. {
  10417. $this->filesystem->emptyDirectory($path);
  10418. $fileName = $this->getFileName($package, $path);
  10419. $processedUrl = $this->processUrl($package, $url);
  10420. $hostname = parse_url($processedUrl, PHP_URL_HOST);
  10421. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->rfs, $processedUrl);
  10422. if ($this->eventDispatcher) {
  10423. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  10424. }
  10425. $rfs = $preFileDownloadEvent->getRemoteFilesystem();
  10426. try {
  10427. $checksum = $package->getDistSha1Checksum();
  10428. $cacheKey = $this->getCacheKey($package, $processedUrl);
  10429. if ($this->cache && (!$checksum || $checksum === $this->cache->sha1($cacheKey)) && $this->cache->copyTo($cacheKey, $fileName)) {
  10430. $this->io->writeError('Loading from cache', false);
  10431. } else {
  10432. if (!$this->outputProgress) {
  10433. $this->io->writeError('Downloading', false);
  10434. }
  10435. $retries = 3;
  10436. while ($retries--) {
  10437. try {
  10438. $rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress, $package->getTransportOptions());
  10439. break;
  10440. } catch (TransportException $e) {
  10441. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  10442. throw $e;
  10443. }
  10444. $this->io->writeError('');
  10445. $this->io->writeError(' Download failed, retrying...', true, IOInterface::VERBOSE);
  10446. usleep(500000);
  10447. }
  10448. }
  10449. if (!$this->outputProgress) {
  10450. $this->io->writeError(' (<comment>100%</comment>)', false);
  10451. }
  10452. if ($this->cache) {
  10453. $this->lastCacheWrites[$package->getName()] = $cacheKey;
  10454. $this->cache->copyFrom($cacheKey, $fileName);
  10455. }
  10456. }
  10457. if (!file_exists($fileName)) {
  10458. throw new \UnexpectedValueException($url.' could not be saved to '.$fileName.', make sure the'
  10459. .' directory is writable and you have internet connectivity');
  10460. }
  10461. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  10462. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url.')');
  10463. }
  10464. } catch (\Exception $e) {
  10465. $this->filesystem->removeDirectory($path);
  10466. $this->clearLastCacheWrite($package);
  10467. throw $e;
  10468. }
  10469. return $fileName;
  10470. }
  10471. public function setOutputProgress($outputProgress)
  10472. {
  10473. $this->outputProgress = $outputProgress;
  10474. return $this;
  10475. }
  10476. protected function clearLastCacheWrite(PackageInterface $package)
  10477. {
  10478. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  10479. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  10480. unset($this->lastCacheWrites[$package->getName()]);
  10481. }
  10482. }
  10483. public function update(PackageInterface $initial, PackageInterface $target, $path)
  10484. {
  10485. $name = $target->getName();
  10486. $from = $initial->getPrettyVersion();
  10487. $to = $target->getPrettyVersion();
  10488. $actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Updating' : 'Downgrading';
  10489. $this->io->writeError(" - " . $actionName . " <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>): ", false);
  10490. $this->remove($initial, $path, false);
  10491. $this->download($target, $path, false);
  10492. $this->io->writeError('');
  10493. }
  10494. public function remove(PackageInterface $package, $path, $output = true)
  10495. {
  10496. if ($output) {
  10497. $this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  10498. }
  10499. if (!$this->filesystem->removeDirectory($path)) {
  10500. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  10501. }
  10502. }
  10503. protected function getFileName(PackageInterface $package, $path)
  10504. {
  10505. return $path.'/'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME);
  10506. }
  10507. protected function processUrl(PackageInterface $package, $url)
  10508. {
  10509. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  10510. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  10511. }
  10512. if ($package->getDistReference()) {
  10513. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  10514. }
  10515. return $url;
  10516. }
  10517. private function getCacheKey(PackageInterface $package, $processedUrl)
  10518. {
  10519. $cacheKey = sha1($processedUrl);
  10520. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  10521. }
  10522. public function getLocalChanges(PackageInterface $package, $targetDir)
  10523. {
  10524. $prevIO = $this->io;
  10525. $prevProgress = $this->outputProgress;
  10526. $this->io = new NullIO;
  10527. $this->io->loadConfiguration($this->config);
  10528. $this->outputProgress = false;
  10529. $e = null;
  10530. try {
  10531. $this->download($package, $targetDir.'_compare', false);
  10532. $comparer = new Comparer();
  10533. $comparer->setSource($targetDir.'_compare');
  10534. $comparer->setUpdate($targetDir);
  10535. $comparer->doCompare();
  10536. $output = $comparer->getChanged(true, true);
  10537. $this->filesystem->removeDirectory($targetDir.'_compare');
  10538. } catch (\Exception $e) {
  10539. }
  10540. $this->io = $prevIO;
  10541. $this->outputProgress = $prevProgress;
  10542. if ($e) {
  10543. throw $e;
  10544. }
  10545. return trim($output);
  10546. }
  10547. }
  10548. <?php
  10549. namespace Composer\Downloader;
  10550. class FilesystemException extends \Exception
  10551. {
  10552. public function __construct($message = '', $code = 0, \Exception $previous = null)
  10553. {
  10554. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  10555. }
  10556. }
  10557. <?php
  10558. namespace Composer\Downloader;
  10559. use Composer\Package\PackageInterface;
  10560. use Composer\Util\ProcessExecutor;
  10561. class FossilDownloader extends VcsDownloader
  10562. {
  10563. public function doDownload(PackageInterface $package, $path, $url)
  10564. {
  10565. $this->config->prohibitUrlByConfig($url, $this->io);
  10566. $url = ProcessExecutor::escape($url);
  10567. $ref = ProcessExecutor::escape($package->getSourceReference());
  10568. $repoFile = $path . '.fossil';
  10569. $this->io->writeError("Cloning ".$package->getSourceReference());
  10570. $command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape($repoFile));
  10571. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  10572. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10573. }
  10574. $command = sprintf('fossil open %s --nested', ProcessExecutor::escape($repoFile));
  10575. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  10576. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10577. }
  10578. $command = sprintf('fossil update %s', $ref);
  10579. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  10580. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10581. }
  10582. }
  10583. public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  10584. {
  10585. $this->config->prohibitUrlByConfig($url, $this->io);
  10586. $url = ProcessExecutor::escape($url);
  10587. $ref = ProcessExecutor::escape($target->getSourceReference());
  10588. $this->io->writeError(" Updating to ".$target->getSourceReference());
  10589. if (!$this->hasMetadataRepository($path)) {
  10590. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  10591. }
  10592. $command = sprintf('fossil pull && fossil up %s', $ref);
  10593. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  10594. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10595. }
  10596. }
  10597. public function getLocalChanges(PackageInterface $package, $path)
  10598. {
  10599. if (!$this->hasMetadataRepository($path)) {
  10600. return null;
  10601. }
  10602. $this->process->execute('fossil changes', $output, realpath($path));
  10603. return trim($output) ?: null;
  10604. }
  10605. protected function getCommitLogs($fromReference, $toReference, $path)
  10606. {
  10607. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  10608. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  10609. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10610. }
  10611. $log = '';
  10612. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  10613. foreach ($this->process->splitLines($output) as $line) {
  10614. if (preg_match($match, $line)) {
  10615. break;
  10616. }
  10617. $log .= $line;
  10618. }
  10619. return $log;
  10620. }
  10621. protected function hasMetadataRepository($path)
  10622. {
  10623. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  10624. }
  10625. }
  10626. <?php
  10627. namespace Composer\Downloader;
  10628. use Composer\Config;
  10629. use Composer\IO\IOInterface;
  10630. use Composer\Package\PackageInterface;
  10631. use Composer\Util\Filesystem;
  10632. use Composer\Util\Git as GitUtil;
  10633. use Composer\Util\Platform;
  10634. use Composer\Util\ProcessExecutor;
  10635. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  10636. {
  10637. private $hasStashedChanges = false;
  10638. private $hasDiscardedChanges = false;
  10639. private $gitUtil;
  10640. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  10641. {
  10642. parent::__construct($io, $config, $process, $fs);
  10643. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  10644. }
  10645. public function doDownload(PackageInterface $package, $path, $url)
  10646. {
  10647. GitUtil::cleanEnv();
  10648. $path = $this->normalizePath($path);
  10649. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  10650. $ref = $package->getSourceReference();
  10651. $flag = Platform::isWindows() ? '/D ' : '';
  10652. $gitVersion = $this->gitUtil->getVersion();
  10653. $msg = "Cloning ".$this->getShortHash($ref);
  10654. $command = 'git clone --no-checkout %url% %path% && cd '.$flag.'%path% && git remote add composer %url% && git fetch composer';
  10655. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=')) {
  10656. $this->io->writeError('', true, IOInterface::DEBUG);
  10657. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  10658. try {
  10659. $this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref);
  10660. if (is_dir($cachePath)) {
  10661. $command =
  10662. 'git clone --no-checkout %cachePath% %path% --dissociate --reference %cachePath% '
  10663. . '&& cd '.$flag.'%path% '
  10664. . '&& git remote set-url origin %url% && git remote add composer %url%';
  10665. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  10666. }
  10667. } catch (\RuntimeException $e) {
  10668. }
  10669. }
  10670. $this->io->writeError($msg);
  10671. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  10672. return str_replace(
  10673. array('%url%', '%path%', '%cachePath%'),
  10674. array(
  10675. ProcessExecutor::escape($url),
  10676. ProcessExecutor::escape($path),
  10677. ProcessExecutor::escape($cachePath),
  10678. ),
  10679. $command
  10680. );
  10681. };
  10682. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  10683. if ($url !== $package->getSourceUrl()) {
  10684. $this->updateOriginUrl($path, $package->getSourceUrl());
  10685. } else {
  10686. $this->setPushUrl($path, $url);
  10687. }
  10688. if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
  10689. if ($package->getDistReference() === $package->getSourceReference()) {
  10690. $package->setDistReference($newRef);
  10691. }
  10692. $package->setSourceReference($newRef);
  10693. }
  10694. }
  10695. public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  10696. {
  10697. GitUtil::cleanEnv();
  10698. if (!$this->hasMetadataRepository($path)) {
  10699. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  10700. }
  10701. $updateOriginUrl = false;
  10702. if (
  10703. 0 === $this->process->execute('git remote -v', $output, $path)
  10704. && preg_match('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  10705. && preg_match('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  10706. ) {
  10707. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  10708. $updateOriginUrl = true;
  10709. }
  10710. }
  10711. $ref = $target->getSourceReference();
  10712. $this->io->writeError(" Checking out ".$this->getShortHash($ref));
  10713. $command = 'git remote set-url composer %s && git rev-parse --quiet --verify %s || (git fetch composer && git fetch --tags composer)';
  10714. $commandCallable = function ($url) use ($command, $ref) {
  10715. return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($ref.'^{commit}'));
  10716. };
  10717. $this->gitUtil->runCommand($commandCallable, $url, $path);
  10718. if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
  10719. if ($target->getDistReference() === $target->getSourceReference()) {
  10720. $target->setDistReference($newRef);
  10721. }
  10722. $target->setSourceReference($newRef);
  10723. }
  10724. if ($updateOriginUrl) {
  10725. $this->updateOriginUrl($path, $target->getSourceUrl());
  10726. }
  10727. }
  10728. public function getLocalChanges(PackageInterface $package, $path)
  10729. {
  10730. GitUtil::cleanEnv();
  10731. if (!$this->hasMetadataRepository($path)) {
  10732. return;
  10733. }
  10734. $command = 'git status --porcelain --untracked-files=no';
  10735. if (0 !== $this->process->execute($command, $output, $path)) {
  10736. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10737. }
  10738. return trim($output) ?: null;
  10739. }
  10740. public function getUnpushedChanges(PackageInterface $package, $path)
  10741. {
  10742. GitUtil::cleanEnv();
  10743. $path = $this->normalizePath($path);
  10744. if (!$this->hasMetadataRepository($path)) {
  10745. return;
  10746. }
  10747. $command = 'git show-ref --head -d';
  10748. if (0 !== $this->process->execute($command, $output, $path)) {
  10749. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10750. }
  10751. $refs = trim($output);
  10752. if (!preg_match('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  10753. return;
  10754. }
  10755. $headRef = $match[1];
  10756. if (!preg_match_all('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  10757. return;
  10758. }
  10759. $branch = $matches[1][0];
  10760. $unpushedChanges = null;
  10761. for ($i = 0; $i <= 1; $i++) {
  10762. foreach ($matches[1] as $candidate) {
  10763. if (preg_match('{^[a-f0-9]+ refs/remotes/((?:composer|origin)/'.preg_quote($candidate).')$}mi', $refs, $match)) {
  10764. $branch = $candidate;
  10765. $remoteBranch = $match[1];
  10766. break;
  10767. }
  10768. }
  10769. if (!isset($remoteBranch)) {
  10770. $unpushedChanges = 'Branch ' . $branch . ' could not be found on the origin remote and appears to be unpushed';
  10771. } else {
  10772. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  10773. if (0 !== $this->process->execute($command, $output, $path)) {
  10774. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10775. }
  10776. $unpushedChanges = trim($output) ?: null;
  10777. }
  10778. if ($unpushedChanges && $i === 0) {
  10779. $this->process->execute('git fetch composer && git fetch origin', $output, $path);
  10780. }
  10781. if (!$unpushedChanges) {
  10782. break;
  10783. }
  10784. }
  10785. return $unpushedChanges;
  10786. }
  10787. protected function cleanChanges(PackageInterface $package, $path, $update)
  10788. {
  10789. GitUtil::cleanEnv();
  10790. $path = $this->normalizePath($path);
  10791. $unpushed = $this->getUnpushedChanges($package, $path);
  10792. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  10793. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  10794. }
  10795. if (!$changes = $this->getLocalChanges($package, $path)) {
  10796. return;
  10797. }
  10798. if (!$this->io->isInteractive()) {
  10799. $discardChanges = $this->config->get('discard-changes');
  10800. if (true === $discardChanges) {
  10801. return $this->discardChanges($path);
  10802. }
  10803. if ('stash' === $discardChanges) {
  10804. if (!$update) {
  10805. return parent::cleanChanges($package, $path, $update);
  10806. }
  10807. return $this->stashChanges($path);
  10808. }
  10809. return parent::cleanChanges($package, $path, $update);
  10810. }
  10811. $changes = array_map(function ($elem) {
  10812. return ' '.$elem;
  10813. }, preg_split('{\s*\r?\n\s*}', $changes));
  10814. $this->io->writeError(' <error>The package has modified files:</error>');
  10815. $this->io->writeError(array_slice($changes, 0, 10));
  10816. if (count($changes) > 10) {
  10817. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  10818. }
  10819. while (true) {
  10820. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  10821. case 'y':
  10822. $this->discardChanges($path);
  10823. break 2;
  10824. case 's':
  10825. if (!$update) {
  10826. goto help;
  10827. }
  10828. $this->stashChanges($path);
  10829. break 2;
  10830. case 'n':
  10831. throw new \RuntimeException('Update aborted');
  10832. case 'v':
  10833. $this->io->writeError($changes);
  10834. break;
  10835. case 'd':
  10836. $this->viewDiff($path);
  10837. break;
  10838. case '?':
  10839. default:
  10840. help:
  10841. $this->io->writeError(array(
  10842. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  10843. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  10844. ' v - view modified files',
  10845. ' d - view local modifications (diff)',
  10846. ));
  10847. if ($update) {
  10848. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  10849. }
  10850. $this->io->writeError(' ? - print help');
  10851. break;
  10852. }
  10853. }
  10854. }
  10855. protected function reapplyChanges($path)
  10856. {
  10857. $path = $this->normalizePath($path);
  10858. if ($this->hasStashedChanges) {
  10859. $this->hasStashedChanges = false;
  10860. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  10861. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  10862. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  10863. }
  10864. }
  10865. $this->hasDiscardedChanges = false;
  10866. }
  10867. protected function updateToCommit($path, $reference, $branch, $date)
  10868. {
  10869. $force = $this->hasDiscardedChanges || $this->hasStashedChanges ? '-f ' : '';
  10870. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  10871. $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
  10872. $branches = null;
  10873. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  10874. $branches = $output;
  10875. }
  10876. $gitRef = $reference;
  10877. if (!preg_match('{^[a-f0-9]{40}$}', $reference)
  10878. && $branches
  10879. && preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  10880. ) {
  10881. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  10882. if (0 === $this->process->execute($command, $output, $path)) {
  10883. return;
  10884. }
  10885. }
  10886. if (preg_match('{^[a-f0-9]{40}$}', $reference)) {
  10887. if (!preg_match('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && preg_match('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  10888. $branch = 'v' . $branch;
  10889. }
  10890. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  10891. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  10892. if (0 === $this->process->execute($command, $output, $path)
  10893. || 0 === $this->process->execute($fallbackCommand, $output, $path)
  10894. ) {
  10895. $command = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  10896. if (0 === $this->process->execute($command, $output, $path)) {
  10897. return;
  10898. }
  10899. }
  10900. }
  10901. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  10902. if (0 === $this->process->execute($command, $output, $path)) {
  10903. return;
  10904. }
  10905. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  10906. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  10907. }
  10908. throw new \RuntimeException(GitUtil::sanitizeUrl('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
  10909. }
  10910. protected function updateOriginUrl($path, $url)
  10911. {
  10912. $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
  10913. $this->setPushUrl($path, $url);
  10914. }
  10915. protected function setPushUrl($path, $url)
  10916. {
  10917. if (preg_match('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  10918. $protocols = $this->config->get('github-protocols');
  10919. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  10920. if (!in_array('ssh', $protocols, true)) {
  10921. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  10922. }
  10923. $cmd = sprintf('git remote set-url --push origin %s', ProcessExecutor::escape($pushUrl));
  10924. $this->process->execute($cmd, $ignoredOutput, $path);
  10925. }
  10926. }
  10927. protected function getCommitLogs($fromReference, $toReference, $path)
  10928. {
  10929. $path = $this->normalizePath($path);
  10930. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  10931. if (0 !== $this->process->execute($command, $output, $path)) {
  10932. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  10933. }
  10934. return $output;
  10935. }
  10936. protected function discardChanges($path)
  10937. {
  10938. $path = $this->normalizePath($path);
  10939. if (0 !== $this->process->execute('git reset --hard', $output, $path)) {
  10940. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  10941. }
  10942. $this->hasDiscardedChanges = true;
  10943. }
  10944. protected function stashChanges($path)
  10945. {
  10946. $path = $this->normalizePath($path);
  10947. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  10948. throw new \RuntimeException("Could not stash changes\n\n:".$this->process->getErrorOutput());
  10949. }
  10950. $this->hasStashedChanges = true;
  10951. }
  10952. protected function viewDiff($path)
  10953. {
  10954. $path = $this->normalizePath($path);
  10955. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  10956. throw new \RuntimeException("Could not view diff\n\n:".$this->process->getErrorOutput());
  10957. }
  10958. $this->io->writeError($output);
  10959. }
  10960. protected function normalizePath($path)
  10961. {
  10962. if (Platform::isWindows() && strlen($path) > 0) {
  10963. $basePath = $path;
  10964. $removed = array();
  10965. while (!is_dir($basePath) && $basePath !== '\\') {
  10966. array_unshift($removed, basename($basePath));
  10967. $basePath = dirname($basePath);
  10968. }
  10969. if ($basePath === '\\') {
  10970. return $path;
  10971. }
  10972. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  10973. }
  10974. return $path;
  10975. }
  10976. protected function hasMetadataRepository($path)
  10977. {
  10978. $path = $this->normalizePath($path);
  10979. return is_dir($path.'/.git');
  10980. }
  10981. protected function getShortHash($reference)
  10982. {
  10983. if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {
  10984. return substr($reference, 0, 10);
  10985. }
  10986. return $reference;
  10987. }
  10988. }
  10989. <?php
  10990. namespace Composer\Downloader;
  10991. use Composer\Config;
  10992. use Composer\Cache;
  10993. use Composer\EventDispatcher\EventDispatcher;
  10994. use Composer\Package\PackageInterface;
  10995. use Composer\Util\Platform;
  10996. use Composer\Util\ProcessExecutor;
  10997. use Composer\Util\RemoteFilesystem;
  10998. use Composer\IO\IOInterface;
  10999. class GzipDownloader extends ArchiveDownloader
  11000. {
  11001. protected $process;
  11002. public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, ProcessExecutor $process = null, RemoteFilesystem $rfs = null)
  11003. {
  11004. $this->process = $process ?: new ProcessExecutor($io);
  11005. parent::__construct($io, $config, $eventDispatcher, $cache, $rfs);
  11006. }
  11007. protected function extract($file, $path)
  11008. {
  11009. $targetFilepath = $path . DIRECTORY_SEPARATOR . basename(substr($file, 0, -3));
  11010. if (!Platform::isWindows()) {
  11011. $command = 'gzip -cd ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  11012. if (0 === $this->process->execute($command, $ignoredOutput)) {
  11013. return;
  11014. }
  11015. if (extension_loaded('zlib')) {
  11016. $this->extractUsingExt($file, $targetFilepath);
  11017. return;
  11018. }
  11019. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  11020. throw new \RuntimeException($processError);
  11021. }
  11022. $this->extractUsingExt($file, $targetFilepath);
  11023. }
  11024. protected function getFileName(PackageInterface $package, $path)
  11025. {
  11026. return $path.'/'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME);
  11027. }
  11028. private function extractUsingExt($file, $targetFilepath)
  11029. {
  11030. $archiveFile = gzopen($file, 'rb');
  11031. $targetFile = fopen($targetFilepath, 'wb');
  11032. while ($string = gzread($archiveFile, 4096)) {
  11033. fwrite($targetFile, $string, Platform::strlen($string));
  11034. }
  11035. gzclose($archiveFile);
  11036. fclose($targetFile);
  11037. }
  11038. }
  11039. <?php
  11040. namespace Composer\Downloader;
  11041. use Composer\Package\PackageInterface;
  11042. use Composer\Util\ProcessExecutor;
  11043. use Composer\Util\Hg as HgUtils;
  11044. class HgDownloader extends VcsDownloader
  11045. {
  11046. public function doDownload(PackageInterface $package, $path, $url)
  11047. {
  11048. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  11049. $cloneCommand = function ($url) use ($path) {
  11050. return sprintf('hg clone %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  11051. };
  11052. $hgUtils->runCommand($cloneCommand, $url, $path);
  11053. $ref = ProcessExecutor::escape($package->getSourceReference());
  11054. $command = sprintf('hg up %s', $ref);
  11055. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  11056. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  11057. }
  11058. }
  11059. public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  11060. {
  11061. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  11062. $ref = $target->getSourceReference();
  11063. $this->io->writeError(" Updating to ".$target->getSourceReference());
  11064. if (!$this->hasMetadataRepository($path)) {
  11065. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  11066. }
  11067. $command = function ($url) use ($ref) {
  11068. return sprintf('hg pull %s && hg up %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  11069. };
  11070. $hgUtils->runCommand($command, $url, $path);
  11071. }
  11072. public function getLocalChanges(PackageInterface $package, $path)
  11073. {
  11074. if (!is_dir($path.'/.hg')) {
  11075. return null;
  11076. }
  11077. $this->process->execute('hg st', $output, realpath($path));
  11078. return trim($output) ?: null;
  11079. }
  11080. protected function getCommitLogs($fromReference, $toReference, $path)
  11081. {
  11082. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  11083. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  11084. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  11085. }
  11086. return $output;
  11087. }
  11088. protected function hasMetadataRepository($path)
  11089. {
  11090. return is_dir($path . '/.hg');
  11091. }
  11092. }
  11093. <?php
  11094. namespace Composer\Downloader;
  11095. use Composer\Package\Archiver\ArchivableFilesFinder;
  11096. use Composer\Package\Dumper\ArrayDumper;
  11097. use Composer\Package\PackageInterface;
  11098. use Composer\Package\Version\VersionGuesser;
  11099. use Composer\Package\Version\VersionParser;
  11100. use Composer\Util\Platform;
  11101. use Composer\Util\ProcessExecutor;
  11102. use Composer\Util\Filesystem as ComposerFilesystem;
  11103. use Symfony\Component\Filesystem\Exception\IOException;
  11104. use Symfony\Component\Filesystem\Filesystem;
  11105. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  11106. {
  11107. const STRATEGY_SYMLINK = 10;
  11108. const STRATEGY_MIRROR = 20;
  11109. public function download(PackageInterface $package, $path, $output = true)
  11110. {
  11111. $url = $package->getDistUrl();
  11112. $realUrl = realpath($url);
  11113. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  11114. throw new \RuntimeException(sprintf(
  11115. 'Source path "%s" is not found for package %s',
  11116. $url,
  11117. $package->getName()
  11118. ));
  11119. }
  11120. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  11121. throw new \RuntimeException(sprintf(
  11122. 'Package %s cannot install to "%s" inside its source at "%s"',
  11123. $package->getName(),
  11124. realpath($path),
  11125. $realUrl
  11126. ));
  11127. }
  11128. $transportOptions = $package->getTransportOptions() + array('symlink' => null);
  11129. $currentStrategy = self::STRATEGY_SYMLINK;
  11130. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  11131. $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS');
  11132. if ($mirrorPathRepos) {
  11133. $currentStrategy = self::STRATEGY_MIRROR;
  11134. }
  11135. if (true === $transportOptions['symlink']) {
  11136. $currentStrategy = self::STRATEGY_SYMLINK;
  11137. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  11138. } elseif (false === $transportOptions['symlink']) {
  11139. $currentStrategy = self::STRATEGY_MIRROR;
  11140. $allowedStrategies = array(self::STRATEGY_MIRROR);
  11141. }
  11142. $fileSystem = new Filesystem();
  11143. $this->filesystem->removeDirectory($path);
  11144. if ($output) {
  11145. $this->io->writeError(sprintf(
  11146. ' - Installing <info>%s</info> (<comment>%s</comment>): ',
  11147. $package->getName(),
  11148. $package->getFullPrettyVersion()
  11149. ), false);
  11150. }
  11151. $isFallback = false;
  11152. if (self::STRATEGY_SYMLINK == $currentStrategy) {
  11153. try {
  11154. if (Platform::isWindows()) {
  11155. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  11156. $this->filesystem->junction($realUrl, $path);
  11157. } else {
  11158. $absolutePath = $path;
  11159. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  11160. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  11161. }
  11162. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  11163. $path = rtrim($path, "/");
  11164. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  11165. $fileSystem->symlink($shortestPath, $path);
  11166. }
  11167. } catch (IOException $e) {
  11168. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
  11169. $this->io->writeError('');
  11170. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  11171. $currentStrategy = self::STRATEGY_MIRROR;
  11172. $isFallback = true;
  11173. } else {
  11174. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  11175. }
  11176. }
  11177. }
  11178. if (self::STRATEGY_MIRROR == $currentStrategy) {
  11179. $fs = new ComposerFilesystem();
  11180. $realUrl = $fs->normalizePath($realUrl);
  11181. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  11182. $iterator = new ArchivableFilesFinder($realUrl, array());
  11183. $fileSystem->mirror($realUrl, $path, $iterator);
  11184. }
  11185. $this->io->writeError('');
  11186. }
  11187. public function remove(PackageInterface $package, $path, $output = true)
  11188. {
  11189. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  11190. if ($output) {
  11191. $this->io->writeError(" - Removing junction for <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  11192. }
  11193. if (!$this->filesystem->removeJunction($path)) {
  11194. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  11195. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  11196. }
  11197. } else {
  11198. parent::remove($package, $path, $output);
  11199. }
  11200. }
  11201. public function getVcsReference(PackageInterface $package, $path)
  11202. {
  11203. $parser = new VersionParser;
  11204. $guesser = new VersionGuesser($this->config, new ProcessExecutor($this->io), $parser);
  11205. $dumper = new ArrayDumper;
  11206. $packageConfig = $dumper->dump($package);
  11207. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  11208. return $packageVersion['commit'];
  11209. }
  11210. }
  11211. }
  11212. <?php
  11213. namespace Composer\Downloader;
  11214. use Composer\Util\Filesystem;
  11215. class PearPackageExtractor
  11216. {
  11217. private static $rolesWithoutPackageNamePrefix = array('php', 'script', 'www');
  11218. private $filesystem;
  11219. private $file;
  11220. public function __construct($file)
  11221. {
  11222. if (!is_file($file)) {
  11223. throw new \UnexpectedValueException('PEAR package file is not found at '.$file);
  11224. }
  11225. $this->filesystem = new Filesystem();
  11226. $this->file = $file;
  11227. }
  11228. public function extractTo($target, array $roles = array('php' => '/', 'script' => '/bin'), $vars = array())
  11229. {
  11230. $extractionPath = $target.'/tarball';
  11231. try {
  11232. $archive = new \PharData($this->file);
  11233. $archive->extractTo($extractionPath, null, true);
  11234. if (!is_file($this->combine($extractionPath, '/package.xml'))) {
  11235. throw new \RuntimeException('Invalid PEAR package. It must contain package.xml file.');
  11236. }
  11237. $fileCopyActions = $this->buildCopyActions($extractionPath, $roles, $vars);
  11238. $this->copyFiles($fileCopyActions, $extractionPath, $target, $roles, $vars);
  11239. $this->filesystem->removeDirectory($extractionPath);
  11240. } catch (\Exception $exception) {
  11241. throw new \UnexpectedValueException(sprintf('Failed to extract PEAR package %s to %s. Reason: %s', $this->file, $target, $exception->getMessage()), 0, $exception);
  11242. }
  11243. }
  11244. private function copyFiles($files, $source, $target, $roles, $vars)
  11245. {
  11246. foreach ($files as $file) {
  11247. $from = $this->combine($source, $file['from']);
  11248. $to = $this->combine($target, $roles[$file['role']]);
  11249. $to = $this->combine($to, $file['to']);
  11250. $tasks = $file['tasks'];
  11251. $this->copyFile($from, $to, $tasks, $vars);
  11252. }
  11253. }
  11254. private function copyFile($from, $to, $tasks, $vars)
  11255. {
  11256. if (!is_file($from)) {
  11257. throw new \RuntimeException('Invalid PEAR package. package.xml defines file that is not located inside tarball.');
  11258. }
  11259. $this->filesystem->ensureDirectoryExists(dirname($to));
  11260. if (0 == count($tasks)) {
  11261. $copied = copy($from, $to);
  11262. } else {
  11263. $content = file_get_contents($from);
  11264. $replacements = array();
  11265. foreach ($tasks as $task) {
  11266. $pattern = $task['from'];
  11267. $varName = $task['to'];
  11268. if (isset($vars[$varName])) {
  11269. if ($varName === 'php_bin' && false === strpos($to, '.bat')) {
  11270. $replacements[$pattern] = preg_replace('{\.bat$}', '', $vars[$varName]);
  11271. } else {
  11272. $replacements[$pattern] = $vars[$varName];
  11273. }
  11274. }
  11275. }
  11276. $content = strtr($content, $replacements);
  11277. $copied = file_put_contents($to, $content);
  11278. }
  11279. if (false === $copied) {
  11280. throw new \RuntimeException(sprintf('Failed to copy %s to %s', $from, $to));
  11281. }
  11282. }
  11283. private function buildCopyActions($source, array $roles, $vars)
  11284. {
  11285. $package = simplexml_load_string(file_get_contents($this->combine($source, 'package.xml')));
  11286. if (false === $package) {
  11287. throw new \RuntimeException('Package definition file is not valid.');
  11288. }
  11289. $packageSchemaVersion = $package['version'];
  11290. if ('1.0' == $packageSchemaVersion) {
  11291. $children = $package->release->filelist->children();
  11292. $packageName = (string) $package->name;
  11293. $packageVersion = (string) $package->release->version;
  11294. $sourceDir = $packageName . '-' . $packageVersion;
  11295. $result = $this->buildSourceList10($children, $roles, $sourceDir, '', null, $packageName);
  11296. } elseif ('2.0' == $packageSchemaVersion || '2.1' == $packageSchemaVersion) {
  11297. $children = $package->contents->children();
  11298. $packageName = (string) $package->name;
  11299. $packageVersion = (string) $package->version->release;
  11300. $sourceDir = $packageName . '-' . $packageVersion;
  11301. $result = $this->buildSourceList20($children, $roles, $sourceDir, '', null, $packageName);
  11302. $namespaces = $package->getNamespaces();
  11303. $package->registerXPathNamespace('ns', $namespaces['']);
  11304. $releaseNodes = $package->xpath('ns:phprelease');
  11305. $this->applyRelease($result, $releaseNodes, $vars);
  11306. } else {
  11307. throw new \RuntimeException('Unsupported schema version of package definition file.');
  11308. }
  11309. return $result;
  11310. }
  11311. private function applyRelease(&$actions, $releaseNodes, $vars)
  11312. {
  11313. foreach ($releaseNodes as $releaseNode) {
  11314. $requiredOs = $releaseNode->installconditions && $releaseNode->installconditions->os && $releaseNode->installconditions->os->name ? (string) $releaseNode->installconditions->os->name : '';
  11315. if ($requiredOs && $vars['os'] != $requiredOs) {
  11316. continue;
  11317. }
  11318. if ($releaseNode->filelist) {
  11319. foreach ($releaseNode->filelist->children() as $action) {
  11320. if ('install' == $action->getName()) {
  11321. $name = (string) $action['name'];
  11322. $as = (string) $action['as'];
  11323. if (isset($actions[$name])) {
  11324. $actions[$name]['to'] = $as;
  11325. }
  11326. } elseif ('ignore' == $action->getName()) {
  11327. $name = (string) $action['name'];
  11328. unset($actions[$name]);
  11329. } else {
  11330. }
  11331. }
  11332. }
  11333. break;
  11334. }
  11335. }
  11336. private function buildSourceList10($children, $targetRoles, $source, $target, $role, $packageName)
  11337. {
  11338. $result = array();
  11339. foreach ($children as $child) {
  11340. if ($child->getName() == 'dir') {
  11341. $dirSource = $this->combine($source, (string) $child['name']);
  11342. $dirTarget = $child['baseinstalldir'] ?: $target;
  11343. $dirRole = $child['role'] ?: $role;
  11344. $dirFiles = $this->buildSourceList10($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName);
  11345. $result = array_merge($result, $dirFiles);
  11346. } elseif ($child->getName() == 'file') {
  11347. $fileRole = (string) $child['role'] ?: $role;
  11348. if (isset($targetRoles[$fileRole])) {
  11349. $fileName = (string) ($child['name'] ?: $child[0]);
  11350. $fileSource = $this->combine($source, $fileName);
  11351. $fileTarget = $this->combine((string) $child['baseinstalldir'] ?: $target, $fileName);
  11352. if (!in_array($fileRole, self::$rolesWithoutPackageNamePrefix)) {
  11353. $fileTarget = $packageName . '/' . $fileTarget;
  11354. }
  11355. $result[(string) $child['name']] = array('from' => $fileSource, 'to' => $fileTarget, 'role' => $fileRole, 'tasks' => array());
  11356. }
  11357. }
  11358. }
  11359. return $result;
  11360. }
  11361. private function buildSourceList20($children, $targetRoles, $source, $target, $role, $packageName)
  11362. {
  11363. $result = array();
  11364. foreach ($children as $child) {
  11365. if ('dir' == $child->getName()) {
  11366. $dirSource = $this->combine($source, $child['name']);
  11367. $dirTarget = $child['baseinstalldir'] ?: $target;
  11368. $dirRole = $child['role'] ?: $role;
  11369. $dirFiles = $this->buildSourceList20($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName);
  11370. $result = array_merge($result, $dirFiles);
  11371. } elseif ('file' == $child->getName()) {
  11372. $fileRole = (string) $child['role'] ?: $role;
  11373. if (isset($targetRoles[$fileRole])) {
  11374. $fileSource = $this->combine($source, (string) $child['name']);
  11375. $fileTarget = $this->combine((string) ($child['baseinstalldir'] ?: $target), (string) $child['name']);
  11376. $fileTasks = array();
  11377. foreach ($child->children('http://pear.php.net/dtd/tasks-1.0') as $taskNode) {
  11378. if ('replace' == $taskNode->getName()) {
  11379. $fileTasks[] = array('from' => (string) $taskNode->attributes()->from, 'to' => (string) $taskNode->attributes()->to);
  11380. }
  11381. }
  11382. if (!in_array($fileRole, self::$rolesWithoutPackageNamePrefix)) {
  11383. $fileTarget = $packageName . '/' . $fileTarget;
  11384. }
  11385. $result[(string) $child['name']] = array('from' => $fileSource, 'to' => $fileTarget, 'role' => $fileRole, 'tasks' => $fileTasks);
  11386. }
  11387. }
  11388. }
  11389. return $result;
  11390. }
  11391. private function combine($left, $right)
  11392. {
  11393. return rtrim($left, '/') . '/' . ltrim($right, '/');
  11394. }
  11395. }
  11396. <?php
  11397. namespace Composer\Downloader;
  11398. use Composer\Package\PackageInterface;
  11399. use Composer\Repository\VcsRepository;
  11400. use Composer\Util\Perforce;
  11401. class PerforceDownloader extends VcsDownloader
  11402. {
  11403. protected $perforce;
  11404. public function doDownload(PackageInterface $package, $path, $url)
  11405. {
  11406. $ref = $package->getSourceReference();
  11407. $label = $this->getLabelFromSourceReference($ref);
  11408. $this->io->writeError('Cloning ' . $ref);
  11409. $this->initPerforce($package, $path, $url);
  11410. $this->perforce->setStream($ref);
  11411. $this->perforce->p4Login();
  11412. $this->perforce->writeP4ClientSpec();
  11413. $this->perforce->connectClient();
  11414. $this->perforce->syncCodeBase($label);
  11415. $this->perforce->cleanupClientSpec();
  11416. }
  11417. private function getLabelFromSourceReference($ref)
  11418. {
  11419. $pos = strpos($ref, '@');
  11420. if (false !== $pos) {
  11421. return substr($ref, $pos + 1);
  11422. }
  11423. return null;
  11424. }
  11425. public function initPerforce(PackageInterface $package, $path, $url)
  11426. {
  11427. if (!empty($this->perforce)) {
  11428. $this->perforce->initializePath($path);
  11429. return;
  11430. }
  11431. $repository = $package->getRepository();
  11432. $repoConfig = null;
  11433. if ($repository instanceof VcsRepository) {
  11434. $repoConfig = $this->getRepoConfig($repository);
  11435. }
  11436. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  11437. }
  11438. private function getRepoConfig(VcsRepository $repository)
  11439. {
  11440. return $repository->getRepoConfig();
  11441. }
  11442. public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  11443. {
  11444. $this->doDownload($target, $path, $url);
  11445. }
  11446. public function getLocalChanges(PackageInterface $package, $path)
  11447. {
  11448. $this->io->writeError('Perforce driver does not check for local changes before overriding', true);
  11449. return;
  11450. }
  11451. protected function getCommitLogs($fromReference, $toReference, $path)
  11452. {
  11453. return $this->perforce->getCommitLogs($fromReference, $toReference);
  11454. }
  11455. public function setPerforce($perforce)
  11456. {
  11457. $this->perforce = $perforce;
  11458. }
  11459. protected function hasMetadataRepository($path)
  11460. {
  11461. return true;
  11462. }
  11463. }
  11464. <?php
  11465. namespace Composer\Downloader;
  11466. class PharDownloader extends ArchiveDownloader
  11467. {
  11468. protected function extract($file, $path)
  11469. {
  11470. $archive = new \Phar($file);
  11471. $archive->extractTo($path, null, true);
  11472. }
  11473. }
  11474. <?php
  11475. namespace Composer\Downloader;
  11476. use Composer\Config;
  11477. use Composer\Cache;
  11478. use Composer\EventDispatcher\EventDispatcher;
  11479. use Composer\Util\IniHelper;
  11480. use Composer\Util\Platform;
  11481. use Composer\Util\ProcessExecutor;
  11482. use Composer\Util\RemoteFilesystem;
  11483. use Composer\IO\IOInterface;
  11484. use RarArchive;
  11485. class RarDownloader extends ArchiveDownloader
  11486. {
  11487. protected $process;
  11488. public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, ProcessExecutor $process = null, RemoteFilesystem $rfs = null)
  11489. {
  11490. $this->process = $process ?: new ProcessExecutor($io);
  11491. parent::__construct($io, $config, $eventDispatcher, $cache, $rfs);
  11492. }
  11493. protected function extract($file, $path)
  11494. {
  11495. $processError = null;
  11496. if (!Platform::isWindows()) {
  11497. $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  11498. if (0 === $this->process->execute($command, $ignoredOutput)) {
  11499. return;
  11500. }
  11501. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  11502. }
  11503. if (!class_exists('RarArchive')) {
  11504. $iniMessage = IniHelper::getMessage();
  11505. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  11506. . $iniMessage . "\n" . $processError;
  11507. if (!Platform::isWindows()) {
  11508. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  11509. }
  11510. throw new \RuntimeException($error);
  11511. }
  11512. $rarArchive = RarArchive::open($file);
  11513. if (false === $rarArchive) {
  11514. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  11515. }
  11516. $entries = $rarArchive->getEntries();
  11517. if (false === $entries) {
  11518. throw new \RuntimeException('Could not retrieve RAR archive entries');
  11519. }
  11520. foreach ($entries as $entry) {
  11521. if (false === $entry->extract($path)) {
  11522. throw new \RuntimeException('Could not extract entry');
  11523. }
  11524. }
  11525. $rarArchive->close();
  11526. }
  11527. }
  11528. <?php
  11529. namespace Composer\Downloader;
  11530. use Composer\Package\PackageInterface;
  11531. use Composer\Util\Svn as SvnUtil;
  11532. use Composer\Repository\VcsRepository;
  11533. use Composer\Util\ProcessExecutor;
  11534. class SvnDownloader extends VcsDownloader
  11535. {
  11536. protected $cacheCredentials = true;
  11537. public function doDownload(PackageInterface $package, $path, $url)
  11538. {
  11539. SvnUtil::cleanEnv();
  11540. $ref = $package->getSourceReference();
  11541. $repo = $package->getRepository();
  11542. if ($repo instanceof VcsRepository) {
  11543. $repoConfig = $repo->getRepoConfig();
  11544. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  11545. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  11546. }
  11547. }
  11548. $this->io->writeError(" Checking out ".$package->getSourceReference());
  11549. $this->execute($url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  11550. }
  11551. public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  11552. {
  11553. SvnUtil::cleanEnv();
  11554. $ref = $target->getSourceReference();
  11555. if (!$this->hasMetadataRepository($path)) {
  11556. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  11557. }
  11558. $util = new SvnUtil($url, $this->io, $this->config);
  11559. $flags = "";
  11560. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  11561. $flags .= ' --ignore-ancestry';
  11562. }
  11563. $this->io->writeError(" Checking out " . $ref);
  11564. $this->execute($url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  11565. }
  11566. public function getLocalChanges(PackageInterface $package, $path)
  11567. {
  11568. if (!$this->hasMetadataRepository($path)) {
  11569. return null;
  11570. }
  11571. $this->process->execute('svn status --ignore-externals', $output, $path);
  11572. return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
  11573. }
  11574. protected function execute($baseUrl, $command, $url, $cwd = null, $path = null)
  11575. {
  11576. $util = new SvnUtil($baseUrl, $this->io, $this->config);
  11577. $util->setCacheCredentials($this->cacheCredentials);
  11578. try {
  11579. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  11580. } catch (\RuntimeException $e) {
  11581. throw new \RuntimeException(
  11582. 'Package could not be downloaded, '.$e->getMessage()
  11583. );
  11584. }
  11585. }
  11586. protected function cleanChanges(PackageInterface $package, $path, $update)
  11587. {
  11588. if (!$changes = $this->getLocalChanges($package, $path)) {
  11589. return;
  11590. }
  11591. if (!$this->io->isInteractive()) {
  11592. if (true === $this->config->get('discard-changes')) {
  11593. return $this->discardChanges($path);
  11594. }
  11595. return parent::cleanChanges($package, $path, $update);
  11596. }
  11597. $changes = array_map(function ($elem) {
  11598. return ' '.$elem;
  11599. }, preg_split('{\s*\r?\n\s*}', $changes));
  11600. $countChanges = count($changes);
  11601. $this->io->writeError(sprintf(' <error>The package has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  11602. $this->io->writeError(array_slice($changes, 0, 10));
  11603. if ($countChanges > 10) {
  11604. $remaingChanges = $countChanges - 10;
  11605. $this->io->writeError(
  11606. sprintf(
  11607. ' <info>'.$remaingChanges.' more file%s modified, choose "v" to view the full list</info>',
  11608. $remaingChanges === 1 ? '' : 's'
  11609. )
  11610. );
  11611. }
  11612. while (true) {
  11613. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  11614. case 'y':
  11615. $this->discardChanges($path);
  11616. break 2;
  11617. case 'n':
  11618. throw new \RuntimeException('Update aborted');
  11619. case 'v':
  11620. $this->io->writeError($changes);
  11621. break;
  11622. case '?':
  11623. default:
  11624. $this->io->writeError(array(
  11625. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  11626. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  11627. ' v - view modified files',
  11628. ' ? - print help',
  11629. ));
  11630. break;
  11631. }
  11632. }
  11633. }
  11634. protected function getCommitLogs($fromReference, $toReference, $path)
  11635. {
  11636. if (preg_match('{.*@(\d+)$}', $fromReference) && preg_match('{.*@(\d+)$}', $toReference)) {
  11637. $command = sprintf('svn info --non-interactive --xml %s', ProcessExecutor::escape($path));
  11638. if (0 !== $this->process->execute($command, $output, $path)) {
  11639. throw new \RuntimeException(
  11640. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  11641. );
  11642. }
  11643. $urlPattern = '#<url>(.*)</url>#';
  11644. if (preg_match($urlPattern, $output, $matches)) {
  11645. $baseUrl = $matches[1];
  11646. } else {
  11647. throw new \RuntimeException(
  11648. 'Unable to determine svn url for path '. $path
  11649. );
  11650. }
  11651. $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
  11652. $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
  11653. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  11654. $util = new SvnUtil($baseUrl, $this->io, $this->config);
  11655. $util->setCacheCredentials($this->cacheCredentials);
  11656. try {
  11657. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  11658. } catch (\RuntimeException $e) {
  11659. throw new \RuntimeException(
  11660. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  11661. );
  11662. }
  11663. }
  11664. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  11665. }
  11666. protected function discardChanges($path)
  11667. {
  11668. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  11669. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  11670. }
  11671. }
  11672. protected function hasMetadataRepository($path)
  11673. {
  11674. return is_dir($path.'/.svn');
  11675. }
  11676. }
  11677. <?php
  11678. namespace Composer\Downloader;
  11679. class TarDownloader extends ArchiveDownloader
  11680. {
  11681. protected function extract($file, $path)
  11682. {
  11683. $archive = new \PharData($file);
  11684. $archive->extractTo($path, null, true);
  11685. }
  11686. }
  11687. <?php
  11688. namespace Composer\Downloader;
  11689. class TransportException extends \RuntimeException
  11690. {
  11691. protected $headers;
  11692. protected $response;
  11693. protected $statusCode;
  11694. public function setHeaders($headers)
  11695. {
  11696. $this->headers = $headers;
  11697. }
  11698. public function getHeaders()
  11699. {
  11700. return $this->headers;
  11701. }
  11702. public function setResponse($response)
  11703. {
  11704. $this->response = $response;
  11705. }
  11706. public function getResponse()
  11707. {
  11708. return $this->response;
  11709. }
  11710. public function setStatusCode($statusCode)
  11711. {
  11712. $this->statusCode = $statusCode;
  11713. }
  11714. public function getStatusCode()
  11715. {
  11716. return $this->statusCode;
  11717. }
  11718. }
  11719. <?php
  11720. namespace Composer\Downloader;
  11721. use Composer\Package\PackageInterface;
  11722. interface VcsCapableDownloaderInterface
  11723. {
  11724. public function getVcsReference(PackageInterface $package, $path);
  11725. }
  11726. <?php
  11727. namespace Composer\Downloader;
  11728. use Composer\Config;
  11729. use Composer\Package\Dumper\ArrayDumper;
  11730. use Composer\Package\PackageInterface;
  11731. use Composer\Package\Version\VersionGuesser;
  11732. use Composer\Package\Version\VersionParser;
  11733. use Composer\Util\ProcessExecutor;
  11734. use Composer\IO\IOInterface;
  11735. use Composer\Util\Filesystem;
  11736. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  11737. {
  11738. protected $io;
  11739. protected $config;
  11740. protected $process;
  11741. protected $filesystem;
  11742. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  11743. {
  11744. $this->io = $io;
  11745. $this->config = $config;
  11746. $this->process = $process ?: new ProcessExecutor($io);
  11747. $this->filesystem = $fs ?: new Filesystem($this->process);
  11748. }
  11749. public function getInstallationSource()
  11750. {
  11751. return 'source';
  11752. }
  11753. public function download(PackageInterface $package, $path)
  11754. {
  11755. if (!$package->getSourceReference()) {
  11756. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  11757. }
  11758. $this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>): ", false);
  11759. $this->filesystem->emptyDirectory($path);
  11760. $urls = $package->getSourceUrls();
  11761. while ($url = array_shift($urls)) {
  11762. try {
  11763. if (Filesystem::isLocalPath($url)) {
  11764. $needle = 'file://';
  11765. $isFileProtocol = false;
  11766. if (0 === strpos($url, $needle)) {
  11767. $url = substr($url, strlen($needle));
  11768. $isFileProtocol = true;
  11769. }
  11770. if (false !== strpos($url, '%')) {
  11771. $url = rawurldecode($url);
  11772. }
  11773. $url = realpath($url);
  11774. if ($isFileProtocol) {
  11775. $url = $needle . $url;
  11776. }
  11777. }
  11778. $this->doDownload($package, $path, $url);
  11779. break;
  11780. } catch (\Exception $e) {
  11781. if ($e instanceof \PHPUnit_Framework_Exception) {
  11782. throw $e;
  11783. }
  11784. if ($this->io->isDebug()) {
  11785. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  11786. } elseif (count($urls)) {
  11787. $this->io->writeError(' Failed, trying the next URL');
  11788. }
  11789. if (!count($urls)) {
  11790. throw $e;
  11791. }
  11792. }
  11793. }
  11794. }
  11795. public function update(PackageInterface $initial, PackageInterface $target, $path)
  11796. {
  11797. if (!$target->getSourceReference()) {
  11798. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  11799. }
  11800. $name = $target->getName();
  11801. if ($initial->getPrettyVersion() == $target->getPrettyVersion()) {
  11802. if ($target->getSourceType() === 'svn') {
  11803. $from = $initial->getSourceReference();
  11804. $to = $target->getSourceReference();
  11805. } else {
  11806. $from = substr($initial->getSourceReference(), 0, 7);
  11807. $to = substr($target->getSourceReference(), 0, 7);
  11808. }
  11809. $name .= ' '.$initial->getPrettyVersion();
  11810. } else {
  11811. $from = $initial->getFullPrettyVersion();
  11812. $to = $target->getFullPrettyVersion();
  11813. }
  11814. $actionName = VersionParser::isUpgrade($initial->getVersion(), $target->getVersion()) ? 'Updating' : 'Downgrading';
  11815. $this->io->writeError(" - " . $actionName . " <info>" . $name . "</info> (<comment>" . $from . "</comment> => <comment>" . $to . "</comment>): ", false);
  11816. $this->cleanChanges($initial, $path, true);
  11817. $urls = $target->getSourceUrls();
  11818. $exception = null;
  11819. while ($url = array_shift($urls)) {
  11820. try {
  11821. if (Filesystem::isLocalPath($url)) {
  11822. $url = realpath($url);
  11823. }
  11824. $this->doUpdate($initial, $target, $path, $url);
  11825. $exception = null;
  11826. break;
  11827. } catch (\Exception $exception) {
  11828. if ($exception instanceof \PHPUnit_Framework_Exception) {
  11829. throw $exception;
  11830. }
  11831. if ($this->io->isDebug()) {
  11832. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  11833. } elseif (count($urls)) {
  11834. $this->io->writeError(' Failed, trying the next URL');
  11835. }
  11836. }
  11837. }
  11838. $this->reapplyChanges($path);
  11839. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  11840. $message = 'Pulling in changes:';
  11841. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  11842. if (!trim($logs)) {
  11843. $message = 'Rolling back changes:';
  11844. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  11845. }
  11846. if (trim($logs)) {
  11847. $logs = implode("\n", array_map(function ($line) {
  11848. return ' ' . $line;
  11849. }, explode("\n", $logs)));
  11850. $logs = str_replace('<', '\<', $logs);
  11851. $this->io->writeError(' '.$message);
  11852. $this->io->writeError($logs);
  11853. }
  11854. }
  11855. if (!$urls && $exception) {
  11856. throw $exception;
  11857. }
  11858. }
  11859. public function remove(PackageInterface $package, $path)
  11860. {
  11861. $this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . $package->getPrettyVersion() . "</comment>)");
  11862. $this->cleanChanges($package, $path, false);
  11863. if (!$this->filesystem->removeDirectory($path)) {
  11864. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  11865. }
  11866. }
  11867. public function setOutputProgress($outputProgress)
  11868. {
  11869. return $this;
  11870. }
  11871. public function getVcsReference(PackageInterface $package, $path)
  11872. {
  11873. $parser = new VersionParser;
  11874. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  11875. $dumper = new ArrayDumper;
  11876. $packageConfig = $dumper->dump($package);
  11877. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  11878. return $packageVersion['commit'];
  11879. }
  11880. }
  11881. protected function cleanChanges(PackageInterface $package, $path, $update)
  11882. {
  11883. if (null !== $this->getLocalChanges($package, $path)) {
  11884. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  11885. }
  11886. }
  11887. protected function reapplyChanges($path)
  11888. {
  11889. }
  11890. abstract protected function doDownload(PackageInterface $package, $path, $url);
  11891. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  11892. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  11893. abstract protected function hasMetadataRepository($path);
  11894. }
  11895. <?php
  11896. namespace Composer\Downloader;
  11897. use Composer\Config;
  11898. use Composer\Cache;
  11899. use Composer\EventDispatcher\EventDispatcher;
  11900. use Composer\Package\PackageInterface;
  11901. use Composer\Util\ProcessExecutor;
  11902. use Composer\Util\RemoteFilesystem;
  11903. use Composer\IO\IOInterface;
  11904. class XzDownloader extends ArchiveDownloader
  11905. {
  11906. protected $process;
  11907. public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, ProcessExecutor $process = null, RemoteFilesystem $rfs = null)
  11908. {
  11909. $this->process = $process ?: new ProcessExecutor($io);
  11910. parent::__construct($io, $config, $eventDispatcher, $cache, $rfs);
  11911. }
  11912. protected function extract($file, $path)
  11913. {
  11914. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  11915. if (0 === $this->process->execute($command, $ignoredOutput)) {
  11916. return;
  11917. }
  11918. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  11919. throw new \RuntimeException($processError);
  11920. }
  11921. protected function getFileName(PackageInterface $package, $path)
  11922. {
  11923. return $path.'/'.pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME);
  11924. }
  11925. }
  11926. <?php
  11927. namespace Composer\Downloader;
  11928. use Composer\Config;
  11929. use Composer\Cache;
  11930. use Composer\EventDispatcher\EventDispatcher;
  11931. use Composer\Package\PackageInterface;
  11932. use Composer\Util\IniHelper;
  11933. use Composer\Util\Platform;
  11934. use Composer\Util\ProcessExecutor;
  11935. use Composer\Util\RemoteFilesystem;
  11936. use Composer\IO\IOInterface;
  11937. use Symfony\Component\Process\ExecutableFinder;
  11938. use ZipArchive;
  11939. class ZipDownloader extends ArchiveDownloader
  11940. {
  11941. protected static $hasSystemUnzip;
  11942. private static $hasZipArchive;
  11943. private static $isWindows;
  11944. protected $process;
  11945. private $zipArchiveObject;
  11946. public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, ProcessExecutor $process = null, RemoteFilesystem $rfs = null)
  11947. {
  11948. $this->process = $process ?: new ProcessExecutor($io);
  11949. parent::__construct($io, $config, $eventDispatcher, $cache, $rfs);
  11950. }
  11951. public function download(PackageInterface $package, $path, $output = true)
  11952. {
  11953. if (null === self::$hasSystemUnzip) {
  11954. $finder = new ExecutableFinder;
  11955. self::$hasSystemUnzip = (bool) $finder->find('unzip');
  11956. }
  11957. if (null === self::$hasZipArchive) {
  11958. self::$hasZipArchive = class_exists('ZipArchive');
  11959. }
  11960. if (!self::$hasZipArchive && !self::$hasSystemUnzip) {
  11961. $iniMessage = IniHelper::getMessage();
  11962. $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
  11963. throw new \RuntimeException($error);
  11964. }
  11965. if (null === self::$isWindows) {
  11966. self::$isWindows = Platform::isWindows();
  11967. if (!self::$isWindows && !self::$hasSystemUnzip) {
  11968. $this->io->writeError("<warning>As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  11969. $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>");
  11970. $this->io->writeError("<warning>Installing 'unzip' may remediate them.</warning>");
  11971. }
  11972. }
  11973. return parent::download($package, $path, $output);
  11974. }
  11975. protected function extractWithSystemUnzip($file, $path, $isLastChance)
  11976. {
  11977. if (!self::$hasZipArchive) {
  11978. $isLastChance = true;
  11979. }
  11980. if (!self::$hasSystemUnzip && !$isLastChance) {
  11981. return $this->extractWithZipArchive($file, $path, true);
  11982. }
  11983. $processError = null;
  11984. $overwrite = $isLastChance ? '-o' : '';
  11985. $command = 'unzip -qq '.$overwrite.' '.ProcessExecutor::escape($file).' -d '.ProcessExecutor::escape($path);
  11986. try {
  11987. if (0 === $this->process->execute($command, $ignoredOutput)) {
  11988. return true;
  11989. }
  11990. $processError = new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  11991. } catch (\Exception $e) {
  11992. $processError = $e;
  11993. }
  11994. if ($isLastChance) {
  11995. throw $processError;
  11996. }
  11997. $this->io->writeError(' '.$processError->getMessage());
  11998. $this->io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  11999. $this->io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  12000. return $this->extractWithZipArchive($file, $path, true);
  12001. }
  12002. protected function extractWithZipArchive($file, $path, $isLastChance)
  12003. {
  12004. if (!self::$hasSystemUnzip) {
  12005. $isLastChance = true;
  12006. }
  12007. if (!self::$hasZipArchive && !$isLastChance) {
  12008. return $this->extractWithSystemUnzip($file, $path, true);
  12009. }
  12010. $processError = null;
  12011. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  12012. try {
  12013. if (true === ($retval = $zipArchive->open($file))) {
  12014. $extractResult = $zipArchive->extractTo($path);
  12015. if (true === $extractResult) {
  12016. $zipArchive->close();
  12017. return true;
  12018. }
  12019. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  12020. } else {
  12021. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  12022. }
  12023. } catch (\ErrorException $e) {
  12024. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  12025. } catch (\Exception $e) {
  12026. $processError = $e;
  12027. }
  12028. if ($isLastChance) {
  12029. throw $processError;
  12030. }
  12031. $this->io->writeError(' '.$processError->getMessage());
  12032. $this->io->writeError(' Unzip with ZipArchive class failed, falling back to unzip command');
  12033. return $this->extractWithSystemUnzip($file, $path, true);
  12034. }
  12035. public function extract($file, $path)
  12036. {
  12037. if (self::$isWindows) {
  12038. $this->extractWithZipArchive($file, $path, false);
  12039. } else {
  12040. $this->extractWithSystemUnzip($file, $path, false);
  12041. }
  12042. }
  12043. protected function getErrorMessage($retval, $file)
  12044. {
  12045. switch ($retval) {
  12046. case ZipArchive::ER_EXISTS:
  12047. return sprintf("File '%s' already exists.", $file);
  12048. case ZipArchive::ER_INCONS:
  12049. return sprintf("Zip archive '%s' is inconsistent.", $file);
  12050. case ZipArchive::ER_INVAL:
  12051. return sprintf("Invalid argument (%s)", $file);
  12052. case ZipArchive::ER_MEMORY:
  12053. return sprintf("Malloc failure (%s)", $file);
  12054. case ZipArchive::ER_NOENT:
  12055. return sprintf("No such zip file: '%s'", $file);
  12056. case ZipArchive::ER_NOZIP:
  12057. return sprintf("'%s' is not a zip archive.", $file);
  12058. case ZipArchive::ER_OPEN:
  12059. return sprintf("Can't open zip file: %s", $file);
  12060. case ZipArchive::ER_READ:
  12061. return sprintf("Zip read error (%s)", $file);
  12062. case ZipArchive::ER_SEEK:
  12063. return sprintf("Zip seek error (%s)", $file);
  12064. default:
  12065. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  12066. }
  12067. }
  12068. }
  12069. <?php
  12070. namespace Composer\EventDispatcher;
  12071. class Event
  12072. {
  12073. protected $name;
  12074. protected $args;
  12075. protected $flags;
  12076. private $propagationStopped = false;
  12077. public function __construct($name, array $args = array(), array $flags = array())
  12078. {
  12079. $this->name = $name;
  12080. $this->args = $args;
  12081. $this->flags = $flags;
  12082. }
  12083. public function getName()
  12084. {
  12085. return $this->name;
  12086. }
  12087. public function getArguments()
  12088. {
  12089. return $this->args;
  12090. }
  12091. public function getFlags()
  12092. {
  12093. return $this->flags;
  12094. }
  12095. public function isPropagationStopped()
  12096. {
  12097. return $this->propagationStopped;
  12098. }
  12099. public function stopPropagation()
  12100. {
  12101. $this->propagationStopped = true;
  12102. }
  12103. }
  12104. <?php
  12105. namespace Composer\EventDispatcher;
  12106. use Composer\DependencyResolver\PolicyInterface;
  12107. use Composer\DependencyResolver\Pool;
  12108. use Composer\DependencyResolver\Request;
  12109. use Composer\Installer\InstallerEvent;
  12110. use Composer\IO\IOInterface;
  12111. use Composer\Composer;
  12112. use Composer\DependencyResolver\Operation\OperationInterface;
  12113. use Composer\Repository\CompositeRepository;
  12114. use Composer\Script;
  12115. use Composer\Installer\PackageEvent;
  12116. use Composer\Installer\BinaryInstaller;
  12117. use Composer\Util\ProcessExecutor;
  12118. use Composer\Script\Event as ScriptEvent;
  12119. use Symfony\Component\Process\PhpExecutableFinder;
  12120. class EventDispatcher
  12121. {
  12122. protected $composer;
  12123. protected $io;
  12124. protected $loader;
  12125. protected $process;
  12126. protected $listeners;
  12127. private $eventStack;
  12128. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  12129. {
  12130. $this->composer = $composer;
  12131. $this->io = $io;
  12132. $this->process = $process ?: new ProcessExecutor($io);
  12133. $this->eventStack = array();
  12134. }
  12135. public function dispatch($eventName, Event $event = null)
  12136. {
  12137. if (null === $event) {
  12138. $event = new Event($eventName);
  12139. }
  12140. return $this->doDispatch($event);
  12141. }
  12142. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  12143. {
  12144. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  12145. }
  12146. public function dispatchPackageEvent($eventName, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations, OperationInterface $operation)
  12147. {
  12148. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $policy, $pool, $installedRepo, $request, $operations, $operation));
  12149. }
  12150. public function dispatchInstallerEvent($eventName, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array())
  12151. {
  12152. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $policy, $pool, $installedRepo, $request, $operations));
  12153. }
  12154. protected function doDispatch(Event $event)
  12155. {
  12156. $pathStr = 'PATH';
  12157. if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
  12158. $pathStr = 'Path';
  12159. }
  12160. $binDir = $this->composer->getConfig()->get('bin-dir');
  12161. if (is_dir($binDir)) {
  12162. $binDir = realpath($binDir);
  12163. if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) {
  12164. $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
  12165. putenv($pathStr.'='.$_SERVER[$pathStr]);
  12166. }
  12167. }
  12168. $listeners = $this->getListeners($event);
  12169. $this->pushEvent($event);
  12170. $return = 0;
  12171. foreach ($listeners as $callable) {
  12172. if (!is_string($callable)) {
  12173. if (!is_callable($callable)) {
  12174. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  12175. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  12176. }
  12177. $event = $this->checkListenerExpectedEvent($callable, $event);
  12178. $return = false === call_user_func($callable, $event) ? 1 : 0;
  12179. } elseif ($this->isComposerScript($callable)) {
  12180. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  12181. $script = explode(' ', substr($callable, 1));
  12182. $scriptName = $script[0];
  12183. unset($script[0]);
  12184. $args = array_merge($script, $event->getArguments());
  12185. $flags = $event->getFlags();
  12186. if (substr($callable, 0, 10) === '@composer ') {
  12187. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($callable, 9);
  12188. if (0 !== ($exitCode = $this->process->execute($exec))) {
  12189. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  12190. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  12191. }
  12192. } else {
  12193. if (!$this->getListeners(new Event($scriptName))) {
  12194. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  12195. }
  12196. try {
  12197. $return = $this->dispatch($scriptName, new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags));
  12198. } catch (ScriptExecutionException $e) {
  12199. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  12200. throw $e;
  12201. }
  12202. }
  12203. } elseif ($this->isPhpScript($callable)) {
  12204. $className = substr($callable, 0, strpos($callable, '::'));
  12205. $methodName = substr($callable, strpos($callable, '::') + 2);
  12206. if (!class_exists($className)) {
  12207. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  12208. continue;
  12209. }
  12210. if (!is_callable($callable)) {
  12211. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  12212. continue;
  12213. }
  12214. try {
  12215. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  12216. } catch (\Exception $e) {
  12217. $message = "Script %s handling the %s event terminated with an exception";
  12218. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  12219. throw $e;
  12220. }
  12221. } else {
  12222. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  12223. $exec = $callable . ($args === '' ? '' : ' '.$args);
  12224. if ($this->io->isVerbose()) {
  12225. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  12226. } else {
  12227. $this->io->writeError(sprintf('> %s', $exec));
  12228. }
  12229. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  12230. if ($possibleLocalBinaries) {
  12231. foreach ($possibleLocalBinaries as $localExec) {
  12232. if (preg_match('{\b'.preg_quote($callable).'$}', $localExec)) {
  12233. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  12234. $exec = preg_replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  12235. break;
  12236. }
  12237. }
  12238. }
  12239. if (substr($exec, 0, 5) === '@php ') {
  12240. $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5);
  12241. }
  12242. if (0 !== ($exitCode = $this->process->execute($exec))) {
  12243. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  12244. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  12245. }
  12246. }
  12247. if ($event->isPropagationStopped()) {
  12248. break;
  12249. }
  12250. }
  12251. $this->popEvent();
  12252. return $return;
  12253. }
  12254. protected function getPhpExecCommand()
  12255. {
  12256. $finder = new PhpExecutableFinder();
  12257. $phpPath = $finder->find(false);
  12258. if (!$phpPath) {
  12259. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  12260. }
  12261. $phpArgs = $finder->findArguments();
  12262. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  12263. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  12264. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  12265. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  12266. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  12267. }
  12268. protected function executeEventPhpScript($className, $methodName, Event $event)
  12269. {
  12270. $event = $this->checkListenerExpectedEvent(array($className, $methodName), $event);
  12271. if ($this->io->isVerbose()) {
  12272. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  12273. } else {
  12274. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  12275. }
  12276. return $className::$methodName($event);
  12277. }
  12278. protected function checkListenerExpectedEvent($target, Event $event)
  12279. {
  12280. if (in_array($event->getName(), array(
  12281. 'init',
  12282. 'command',
  12283. 'pre-file-download',
  12284. ), true)) {
  12285. return $event;
  12286. }
  12287. try {
  12288. $reflected = new \ReflectionParameter($target, 0);
  12289. } catch (\Exception $e) {
  12290. return $event;
  12291. }
  12292. $typehint = $reflected->getClass();
  12293. if (!$typehint instanceof \ReflectionClass) {
  12294. return $event;
  12295. }
  12296. $expected = $typehint->getName();
  12297. if (!$event instanceof $expected && $expected === 'Composer\Script\CommandEvent') {
  12298. trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED);
  12299. $event = new \Composer\Script\CommandEvent(
  12300. $event->getName(),
  12301. $event->getComposer(),
  12302. $event->getIO(),
  12303. $event->isDevMode(),
  12304. $event->getArguments()
  12305. );
  12306. }
  12307. if (!$event instanceof $expected && $expected === 'Composer\Script\PackageEvent') {
  12308. trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED);
  12309. $event = new \Composer\Script\PackageEvent(
  12310. $event->getName(),
  12311. $event->getComposer(),
  12312. $event->getIO(),
  12313. $event->isDevMode(),
  12314. $event->getPolicy(),
  12315. $event->getPool(),
  12316. $event->getInstalledRepo(),
  12317. $event->getRequest(),
  12318. $event->getOperations(),
  12319. $event->getOperation()
  12320. );
  12321. }
  12322. if (!$event instanceof $expected && $expected === 'Composer\Script\Event') {
  12323. trigger_error('The callback '.$this->serializeCallback($target).' declared at '.$reflected->getDeclaringFunction()->getFileName().' accepts a '.$expected.' but '.$event->getName().' events use a '.get_class($event).' instance. Please adjust your type hint accordingly, see https://getcomposer.org/doc/articles/scripts.md#event-classes', E_USER_DEPRECATED);
  12324. $event = new \Composer\Script\Event(
  12325. $event->getName(),
  12326. $event->getComposer(),
  12327. $event->getIO(),
  12328. $event->isDevMode(),
  12329. $event->getArguments(),
  12330. $event->getFlags()
  12331. );
  12332. }
  12333. return $event;
  12334. }
  12335. private function serializeCallback($cb)
  12336. {
  12337. if (is_array($cb) && count($cb) === 2) {
  12338. if (is_object($cb[0])) {
  12339. $cb[0] = get_class($cb[0]);
  12340. }
  12341. if (is_string($cb[0]) && is_string($cb[1])) {
  12342. $cb = implode('::', $cb);
  12343. }
  12344. }
  12345. if (is_string($cb)) {
  12346. return $cb;
  12347. }
  12348. return var_export($cb, true);
  12349. }
  12350. public function addListener($eventName, $listener, $priority = 0)
  12351. {
  12352. $this->listeners[$eventName][$priority][] = $listener;
  12353. }
  12354. public function addSubscriber(EventSubscriberInterface $subscriber)
  12355. {
  12356. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  12357. if (is_string($params)) {
  12358. $this->addListener($eventName, array($subscriber, $params));
  12359. } elseif (is_string($params[0])) {
  12360. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  12361. } else {
  12362. foreach ($params as $listener) {
  12363. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  12364. }
  12365. }
  12366. }
  12367. }
  12368. protected function getListeners(Event $event)
  12369. {
  12370. $scriptListeners = $this->getScriptListeners($event);
  12371. if (!isset($this->listeners[$event->getName()][0])) {
  12372. $this->listeners[$event->getName()][0] = array();
  12373. }
  12374. krsort($this->listeners[$event->getName()]);
  12375. $listeners = $this->listeners;
  12376. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  12377. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  12378. }
  12379. public function hasEventListeners(Event $event)
  12380. {
  12381. $listeners = $this->getListeners($event);
  12382. return count($listeners) > 0;
  12383. }
  12384. protected function getScriptListeners(Event $event)
  12385. {
  12386. $package = $this->composer->getPackage();
  12387. $scripts = $package->getScripts();
  12388. if (empty($scripts[$event->getName()])) {
  12389. return array();
  12390. }
  12391. if ($this->loader) {
  12392. $this->loader->unregister();
  12393. }
  12394. $generator = $this->composer->getAutoloadGenerator();
  12395. if ($event instanceof ScriptEvent) {
  12396. $generator->setDevMode($event->isDevMode());
  12397. }
  12398. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  12399. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  12400. $map = $generator->parseAutoloads($packageMap, $package);
  12401. $this->loader = $generator->createLoader($map);
  12402. $this->loader->register();
  12403. return $scripts[$event->getName()];
  12404. }
  12405. protected function isPhpScript($callable)
  12406. {
  12407. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  12408. }
  12409. protected function isComposerScript($callable)
  12410. {
  12411. return '@' === substr($callable, 0, 1) && '@php ' !== substr($callable, 0, 5);
  12412. }
  12413. protected function pushEvent(Event $event)
  12414. {
  12415. $eventName = $event->getName();
  12416. if (in_array($eventName, $this->eventStack)) {
  12417. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  12418. }
  12419. return array_push($this->eventStack, $eventName);
  12420. }
  12421. protected function popEvent()
  12422. {
  12423. return array_pop($this->eventStack);
  12424. }
  12425. }
  12426. <?php
  12427. namespace Composer\EventDispatcher;
  12428. interface EventSubscriberInterface
  12429. {
  12430. public static function getSubscribedEvents();
  12431. }
  12432. <?php
  12433. namespace Composer\EventDispatcher;
  12434. class ScriptExecutionException extends \RuntimeException
  12435. {
  12436. }
  12437. <?php
  12438. namespace Composer\Exception;
  12439. class NoSslException extends \RuntimeException
  12440. {
  12441. }
  12442. <?php
  12443. namespace Composer;
  12444. use Composer\Config\JsonConfigSource;
  12445. use Composer\Json\JsonFile;
  12446. use Composer\IO\IOInterface;
  12447. use Composer\Package\Archiver;
  12448. use Composer\Package\Version\VersionGuesser;
  12449. use Composer\Repository\RepositoryManager;
  12450. use Composer\Repository\RepositoryFactory;
  12451. use Composer\Repository\WritableRepositoryInterface;
  12452. use Composer\Util\Filesystem;
  12453. use Composer\Util\Platform;
  12454. use Composer\Util\ProcessExecutor;
  12455. use Composer\Util\RemoteFilesystem;
  12456. use Composer\Util\Silencer;
  12457. use Composer\Plugin\PluginEvents;
  12458. use Composer\EventDispatcher\Event;
  12459. use Seld\JsonLint\DuplicateKeyException;
  12460. use Symfony\Component\Console\Formatter\OutputFormatter;
  12461. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  12462. use Symfony\Component\Console\Output\ConsoleOutput;
  12463. use Composer\EventDispatcher\EventDispatcher;
  12464. use Composer\Autoload\AutoloadGenerator;
  12465. use Composer\Package\Version\VersionParser;
  12466. use Composer\Downloader\TransportException;
  12467. use Seld\JsonLint\JsonParser;
  12468. class Factory
  12469. {
  12470. protected static function getHomeDir()
  12471. {
  12472. $home = getenv('COMPOSER_HOME');
  12473. if ($home) {
  12474. return $home;
  12475. }
  12476. if (Platform::isWindows()) {
  12477. if (!getenv('APPDATA')) {
  12478. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  12479. }
  12480. return rtrim(strtr(getenv('APPDATA'), '\\', '/'), '/') . '/Composer';
  12481. }
  12482. $userDir = self::getUserDir();
  12483. if (is_dir($userDir . '/.composer')) {
  12484. return $userDir . '/.composer';
  12485. }
  12486. if (self::useXdg()) {
  12487. $xdgConfig = getenv('XDG_CONFIG_HOME') ?: $userDir . '/.config';
  12488. return $xdgConfig . '/composer';
  12489. }
  12490. return $userDir . '/.composer';
  12491. }
  12492. protected static function getCacheDir($home)
  12493. {
  12494. $cacheDir = getenv('COMPOSER_CACHE_DIR');
  12495. if ($cacheDir) {
  12496. return $cacheDir;
  12497. }
  12498. $homeEnv = getenv('COMPOSER_HOME');
  12499. if ($homeEnv) {
  12500. return $homeEnv . '/cache';
  12501. }
  12502. if (Platform::isWindows()) {
  12503. if ($cacheDir = getenv('LOCALAPPDATA')) {
  12504. $cacheDir .= '/Composer';
  12505. } else {
  12506. $cacheDir = $home . '/cache';
  12507. }
  12508. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  12509. }
  12510. $userDir = self::getUserDir();
  12511. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  12512. return $home . '/cache';
  12513. }
  12514. if (self::useXdg()) {
  12515. $xdgCache = getenv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  12516. return $xdgCache . '/composer';
  12517. }
  12518. return $home . '/cache';
  12519. }
  12520. protected static function getDataDir($home)
  12521. {
  12522. $homeEnv = getenv('COMPOSER_HOME');
  12523. if ($homeEnv) {
  12524. return $homeEnv;
  12525. }
  12526. if (Platform::isWindows()) {
  12527. return strtr($home, '\\', '/');
  12528. }
  12529. $userDir = self::getUserDir();
  12530. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  12531. $xdgData = getenv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  12532. return $xdgData . '/composer';
  12533. }
  12534. return $home;
  12535. }
  12536. public static function createConfig(IOInterface $io = null, $cwd = null)
  12537. {
  12538. $cwd = $cwd ?: getcwd();
  12539. $config = new Config(true, $cwd);
  12540. $home = self::getHomeDir();
  12541. $config->merge(array('config' => array(
  12542. 'home' => $home,
  12543. 'cache-dir' => self::getCacheDir($home),
  12544. 'data-dir' => self::getDataDir($home),
  12545. )));
  12546. $htaccessProtect = (bool) $config->get('htaccess-protect');
  12547. if ($htaccessProtect) {
  12548. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  12549. foreach ($dirs as $dir) {
  12550. if (!file_exists($dir . '/.htaccess')) {
  12551. if (!is_dir($dir)) {
  12552. Silencer::call('mkdir', $dir, 0777, true);
  12553. }
  12554. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  12555. }
  12556. }
  12557. }
  12558. $file = new JsonFile($config->get('home').'/config.json');
  12559. if ($file->exists()) {
  12560. if ($io && $io->isDebug()) {
  12561. $io->writeError('Loading config file ' . $file->getPath());
  12562. }
  12563. $config->merge($file->read());
  12564. }
  12565. $config->setConfigSource(new JsonConfigSource($file));
  12566. $file = new JsonFile($config->get('home').'/auth.json');
  12567. if ($file->exists()) {
  12568. if ($io && $io->isDebug()) {
  12569. $io->writeError('Loading config file ' . $file->getPath());
  12570. }
  12571. $config->merge(array('config' => $file->read()));
  12572. }
  12573. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  12574. if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
  12575. $authData = json_decode($composerAuthEnv, true);
  12576. if (null === $authData) {
  12577. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  12578. }
  12579. if ($io && $io->isDebug()) {
  12580. $io->writeError('Loading auth config from COMPOSER_AUTH');
  12581. }
  12582. $config->merge(array('config' => $authData));
  12583. }
  12584. return $config;
  12585. }
  12586. public static function getComposerFile()
  12587. {
  12588. return trim(getenv('COMPOSER')) ?: './composer.json';
  12589. }
  12590. public static function createAdditionalStyles()
  12591. {
  12592. return array(
  12593. 'highlight' => new OutputFormatterStyle('red'),
  12594. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  12595. );
  12596. }
  12597. public static function createOutput()
  12598. {
  12599. $styles = self::createAdditionalStyles();
  12600. $formatter = new OutputFormatter(false, $styles);
  12601. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  12602. }
  12603. public static function createDefaultRepositories(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  12604. {
  12605. return RepositoryFactory::defaultRepos($io, $config, $rm);
  12606. }
  12607. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
  12608. {
  12609. $cwd = $cwd ?: getcwd();
  12610. if (null === $localConfig) {
  12611. $localConfig = static::getComposerFile();
  12612. }
  12613. if (is_string($localConfig)) {
  12614. $composerFile = $localConfig;
  12615. $file = new JsonFile($localConfig, null, $io);
  12616. if (!$file->exists()) {
  12617. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  12618. $message = 'Composer could not find a composer.json file in '.$cwd;
  12619. } else {
  12620. $message = 'Composer could not find the config file: '.$localConfig;
  12621. }
  12622. $instructions = 'To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section';
  12623. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  12624. }
  12625. $file->validateSchema(JsonFile::LAX_SCHEMA);
  12626. $jsonParser = new JsonParser;
  12627. try {
  12628. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  12629. } catch (DuplicateKeyException $e) {
  12630. $details = $e->getDetails();
  12631. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  12632. }
  12633. $localConfig = $file->read();
  12634. }
  12635. $config = static::createConfig($io, $cwd);
  12636. $config->merge($localConfig);
  12637. if (isset($composerFile)) {
  12638. $io->writeError('Loading config file ' . $composerFile, true, IOInterface::DEBUG);
  12639. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  12640. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  12641. if ($localAuthFile->exists()) {
  12642. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  12643. $config->merge(array('config' => $localAuthFile->read()));
  12644. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  12645. }
  12646. }
  12647. $vendorDir = $config->get('vendor-dir');
  12648. $composer = new Composer();
  12649. $composer->setConfig($config);
  12650. if ($fullLoad) {
  12651. $io->loadConfiguration($config);
  12652. }
  12653. $rfs = self::createRemoteFilesystem($io, $config);
  12654. $dispatcher = new EventDispatcher($composer, $io);
  12655. $composer->setEventDispatcher($dispatcher);
  12656. $rm = RepositoryFactory::manager($io, $config, $dispatcher, $rfs);
  12657. $composer->setRepositoryManager($rm);
  12658. $this->addLocalRepository($io, $rm, $vendorDir);
  12659. if (!$fullLoad && !isset($localConfig['version'])) {
  12660. $localConfig['version'] = '1.0.0';
  12661. }
  12662. $parser = new VersionParser;
  12663. $guesser = new VersionGuesser($config, new ProcessExecutor($io), $parser);
  12664. $loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser);
  12665. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  12666. $composer->setPackage($package);
  12667. $im = $this->createInstallationManager();
  12668. $composer->setInstallationManager($im);
  12669. if ($fullLoad) {
  12670. $dm = $this->createDownloadManager($io, $config, $dispatcher, $rfs);
  12671. $composer->setDownloadManager($dm);
  12672. $generator = new AutoloadGenerator($dispatcher, $io);
  12673. $composer->setAutoloadGenerator($generator);
  12674. $am = $this->createArchiveManager($config, $dm);
  12675. $composer->setArchiveManager($am);
  12676. }
  12677. $this->createDefaultInstallers($im, $composer, $io);
  12678. if ($fullLoad) {
  12679. $globalComposer = null;
  12680. if (realpath($config->get('home')) !== $cwd) {
  12681. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
  12682. }
  12683. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  12684. $composer->setPluginManager($pm);
  12685. $pm->loadInstalledPlugins();
  12686. }
  12687. if ($fullLoad && isset($composerFile)) {
  12688. $lockFile = "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  12689. ? substr($composerFile, 0, -4).'lock'
  12690. : $composerFile . '.lock';
  12691. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $rm, $im, file_get_contents($composerFile));
  12692. $composer->setLocker($locker);
  12693. }
  12694. if ($fullLoad) {
  12695. $initEvent = new Event(PluginEvents::INIT);
  12696. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  12697. if ($rm->getLocalRepository()) {
  12698. $this->purgePackages($rm->getLocalRepository(), $im);
  12699. }
  12700. }
  12701. return $composer;
  12702. }
  12703. public static function createGlobal(IOInterface $io, $disablePlugins = false)
  12704. {
  12705. $factory = new static();
  12706. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, true);
  12707. }
  12708. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir)
  12709. {
  12710. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io)));
  12711. }
  12712. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
  12713. {
  12714. $composer = null;
  12715. try {
  12716. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad);
  12717. } catch (\Exception $e) {
  12718. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  12719. }
  12720. return $composer;
  12721. }
  12722. public function createDownloadManager(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null)
  12723. {
  12724. $cache = null;
  12725. if ($config->get('cache-files-ttl') > 0) {
  12726. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  12727. }
  12728. $dm = new Downloader\DownloadManager($io);
  12729. switch ($preferred = $config->get('preferred-install')) {
  12730. case 'dist':
  12731. $dm->setPreferDist(true);
  12732. break;
  12733. case 'source':
  12734. $dm->setPreferSource(true);
  12735. break;
  12736. case 'auto':
  12737. default:
  12738. break;
  12739. }
  12740. if (is_array($preferred)) {
  12741. $dm->setPreferences($preferred);
  12742. }
  12743. $executor = new ProcessExecutor($io);
  12744. $fs = new Filesystem($executor);
  12745. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $executor, $fs));
  12746. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $executor, $fs));
  12747. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $executor, $fs));
  12748. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $executor, $fs));
  12749. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config));
  12750. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
  12751. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
  12752. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $eventDispatcher, $cache, $rfs));
  12753. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
  12754. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $eventDispatcher, $cache, $executor, $rfs));
  12755. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $eventDispatcher, $cache, $rfs));
  12756. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $eventDispatcher, $cache, $rfs));
  12757. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $eventDispatcher, $cache, $rfs));
  12758. return $dm;
  12759. }
  12760. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm = null)
  12761. {
  12762. if (null === $dm) {
  12763. $io = new IO\NullIO();
  12764. $io->loadConfiguration($config);
  12765. $dm = $this->createDownloadManager($io, $config);
  12766. }
  12767. $am = new Archiver\ArchiveManager($dm);
  12768. $am->addArchiver(new Archiver\ZipArchiver);
  12769. $am->addArchiver(new Archiver\PharArchiver);
  12770. return $am;
  12771. }
  12772. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  12773. {
  12774. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  12775. }
  12776. protected function createInstallationManager()
  12777. {
  12778. return new Installer\InstallationManager();
  12779. }
  12780. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io)
  12781. {
  12782. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null));
  12783. $im->addInstaller(new Installer\PearInstaller($io, $composer, 'pear-library'));
  12784. $im->addInstaller(new Installer\PluginInstaller($io, $composer));
  12785. $im->addInstaller(new Installer\MetapackageInstaller());
  12786. }
  12787. protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
  12788. {
  12789. foreach ($repo->getPackages() as $package) {
  12790. if (!$im->isPackageInstalled($repo, $package)) {
  12791. $repo->removePackage($package);
  12792. }
  12793. }
  12794. }
  12795. public static function create(IOInterface $io, $config = null, $disablePlugins = false)
  12796. {
  12797. $factory = new static();
  12798. return $factory->createComposer($io, $config, $disablePlugins);
  12799. }
  12800. public static function createRemoteFilesystem(IOInterface $io, Config $config = null, $options = array())
  12801. {
  12802. static $warned = false;
  12803. $disableTls = false;
  12804. if ($config && $config->get('disable-tls') === true) {
  12805. if (!$warned) {
  12806. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  12807. }
  12808. $warned = true;
  12809. $disableTls = true;
  12810. } elseif (!extension_loaded('openssl')) {
  12811. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  12812. . '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.');
  12813. }
  12814. $remoteFilesystemOptions = array();
  12815. if ($disableTls === false) {
  12816. if ($config && $config->get('cafile')) {
  12817. $remoteFilesystemOptions['ssl']['cafile'] = $config->get('cafile');
  12818. }
  12819. if ($config && $config->get('capath')) {
  12820. $remoteFilesystemOptions['ssl']['capath'] = $config->get('capath');
  12821. }
  12822. $remoteFilesystemOptions = array_replace_recursive($remoteFilesystemOptions, $options);
  12823. }
  12824. try {
  12825. $remoteFilesystem = new RemoteFilesystem($io, $config, $remoteFilesystemOptions, $disableTls);
  12826. } catch (TransportException $e) {
  12827. if (false !== strpos($e->getMessage(), 'cafile')) {
  12828. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  12829. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  12830. if (PHP_VERSION_ID < 50600) {
  12831. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  12832. }
  12833. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  12834. }
  12835. throw $e;
  12836. }
  12837. return $remoteFilesystem;
  12838. }
  12839. private static function useXdg()
  12840. {
  12841. foreach (array_keys($_SERVER) as $key) {
  12842. if (substr($key, 0, 4) === 'XDG_') {
  12843. return true;
  12844. }
  12845. }
  12846. return false;
  12847. }
  12848. private static function getUserDir()
  12849. {
  12850. $home = getenv('HOME');
  12851. if (!$home) {
  12852. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  12853. }
  12854. return rtrim(strtr($home, '\\', '/'), '/');
  12855. }
  12856. }
  12857. <?php
  12858. namespace Composer\IO;
  12859. use Composer\Config;
  12860. use Composer\Util\ProcessExecutor;
  12861. use Psr\Log\LoggerInterface;
  12862. use Psr\Log\LogLevel;
  12863. abstract class BaseIO implements IOInterface, LoggerInterface
  12864. {
  12865. protected $authentications = array();
  12866. public function getAuthentications()
  12867. {
  12868. return $this->authentications;
  12869. }
  12870. public function hasAuthentication($repositoryName)
  12871. {
  12872. return isset($this->authentications[$repositoryName]);
  12873. }
  12874. public function getAuthentication($repositoryName)
  12875. {
  12876. if (isset($this->authentications[$repositoryName])) {
  12877. return $this->authentications[$repositoryName];
  12878. }
  12879. return array('username' => null, 'password' => null);
  12880. }
  12881. public function setAuthentication($repositoryName, $username, $password = null)
  12882. {
  12883. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  12884. }
  12885. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  12886. {
  12887. if ($this->hasAuthentication($repositoryName)) {
  12888. $auth = $this->getAuthentication($repositoryName);
  12889. if ($auth['username'] === $username && $auth['password'] === $password) {
  12890. return;
  12891. }
  12892. $this->writeError(
  12893. sprintf(
  12894. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  12895. $repositoryName
  12896. )
  12897. );
  12898. }
  12899. $this->setAuthentication($repositoryName, $username, $password);
  12900. }
  12901. public function loadConfiguration(Config $config)
  12902. {
  12903. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  12904. $githubOauth = $config->get('github-oauth') ?: array();
  12905. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  12906. $gitlabToken = $config->get('gitlab-token') ?: array();
  12907. $httpBasic = $config->get('http-basic') ?: array();
  12908. foreach ($bitbucketOauth as $domain => $cred) {
  12909. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  12910. }
  12911. foreach ($githubOauth as $domain => $token) {
  12912. if (!preg_match('{^[.a-z0-9]+$}', $token)) {
  12913. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  12914. }
  12915. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  12916. }
  12917. foreach ($gitlabOauth as $domain => $token) {
  12918. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  12919. }
  12920. foreach ($gitlabToken as $domain => $token) {
  12921. $this->checkAndSetAuthentication($domain, $token, 'private-token');
  12922. }
  12923. foreach ($httpBasic as $domain => $cred) {
  12924. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  12925. }
  12926. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  12927. }
  12928. public function emergency($message, array $context = array())
  12929. {
  12930. return $this->log(LogLevel::EMERGENCY, $message, $context);
  12931. }
  12932. public function alert($message, array $context = array())
  12933. {
  12934. return $this->log(LogLevel::ALERT, $message, $context);
  12935. }
  12936. public function critical($message, array $context = array())
  12937. {
  12938. return $this->log(LogLevel::CRITICAL, $message, $context);
  12939. }
  12940. public function error($message, array $context = array())
  12941. {
  12942. return $this->log(LogLevel::ERROR, $message, $context);
  12943. }
  12944. public function warning($message, array $context = array())
  12945. {
  12946. return $this->log(LogLevel::WARNING, $message, $context);
  12947. }
  12948. public function notice($message, array $context = array())
  12949. {
  12950. return $this->log(LogLevel::NOTICE, $message, $context);
  12951. }
  12952. public function info($message, array $context = array())
  12953. {
  12954. return $this->log(LogLevel::INFO, $message, $context);
  12955. }
  12956. public function debug($message, array $context = array())
  12957. {
  12958. return $this->log(LogLevel::DEBUG, $message, $context);
  12959. }
  12960. public function log($level, $message, array $context = array())
  12961. {
  12962. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  12963. $this->writeError('<error>'.$message.'</error>', true, self::NORMAL);
  12964. } elseif ($level === LogLevel::WARNING) {
  12965. $this->writeError('<warning>'.$message.'</warning>', true, self::NORMAL);
  12966. } elseif ($level === LogLevel::NOTICE) {
  12967. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  12968. } elseif ($level === LogLevel::INFO) {
  12969. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  12970. } else {
  12971. $this->writeError($message, true, self::DEBUG);
  12972. }
  12973. }
  12974. }
  12975. <?php
  12976. namespace Composer\IO;
  12977. use Symfony\Component\Console\Output\StreamOutput;
  12978. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  12979. use Symfony\Component\Console\Input\StringInput;
  12980. use Symfony\Component\Console\Helper\HelperSet;
  12981. class BufferIO extends ConsoleIO
  12982. {
  12983. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  12984. {
  12985. $input = new StringInput($input);
  12986. $input->setInteractive(false);
  12987. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  12988. parent::__construct($input, $output, new HelperSet(array()));
  12989. }
  12990. public function getOutput()
  12991. {
  12992. fseek($this->output->getStream(), 0);
  12993. $output = stream_get_contents($this->output->getStream());
  12994. $output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  12995. $pre = strip_tags($matches[1]);
  12996. if (strlen($pre) === strlen($matches[2])) {
  12997. return '';
  12998. }
  12999. return rtrim($matches[1])."\n";
  13000. }, $output);
  13001. return $output;
  13002. }
  13003. }
  13004. <?php
  13005. namespace Composer\IO;
  13006. use Composer\Question\StrictConfirmationQuestion;
  13007. use Symfony\Component\Console\Helper\HelperSet;
  13008. use Symfony\Component\Console\Input\InputInterface;
  13009. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  13010. use Symfony\Component\Console\Output\OutputInterface;
  13011. use Symfony\Component\Console\Question\ChoiceQuestion;
  13012. use Symfony\Component\Console\Question\Question;
  13013. class ConsoleIO extends BaseIO
  13014. {
  13015. protected $input;
  13016. protected $output;
  13017. protected $helperSet;
  13018. protected $lastMessage;
  13019. protected $lastMessageErr;
  13020. private $startTime;
  13021. private $verbosityMap;
  13022. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  13023. {
  13024. $this->input = $input;
  13025. $this->output = $output;
  13026. $this->helperSet = $helperSet;
  13027. $this->verbosityMap = array(
  13028. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  13029. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  13030. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  13031. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  13032. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  13033. );
  13034. }
  13035. public function enableDebugging($startTime)
  13036. {
  13037. $this->startTime = $startTime;
  13038. }
  13039. public function isInteractive()
  13040. {
  13041. return $this->input->isInteractive();
  13042. }
  13043. public function isDecorated()
  13044. {
  13045. return $this->output->isDecorated();
  13046. }
  13047. public function isVerbose()
  13048. {
  13049. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  13050. }
  13051. public function isVeryVerbose()
  13052. {
  13053. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  13054. }
  13055. public function isDebug()
  13056. {
  13057. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  13058. }
  13059. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  13060. {
  13061. $this->doWrite($messages, $newline, false, $verbosity);
  13062. }
  13063. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  13064. {
  13065. $this->doWrite($messages, $newline, true, $verbosity);
  13066. }
  13067. private function doWrite($messages, $newline, $stderr, $verbosity)
  13068. {
  13069. $sfVerbosity = $this->verbosityMap[$verbosity];
  13070. if ($sfVerbosity > $this->output->getVerbosity()) {
  13071. return;
  13072. }
  13073. if (OutputInterface::VERBOSITY_QUIET === 0) {
  13074. $sfVerbosity = OutputInterface::OUTPUT_NORMAL;
  13075. }
  13076. if (null !== $this->startTime) {
  13077. $memoryUsage = memory_get_usage() / 1024 / 1024;
  13078. $timeSpent = microtime(true) - $this->startTime;
  13079. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  13080. return sprintf('[%.1fMB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  13081. }, (array) $messages);
  13082. }
  13083. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  13084. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  13085. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  13086. return;
  13087. }
  13088. $this->output->write($messages, $newline, $sfVerbosity);
  13089. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  13090. }
  13091. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  13092. {
  13093. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  13094. }
  13095. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  13096. {
  13097. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  13098. }
  13099. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  13100. {
  13101. $messages = implode($newline ? "\n" : '', (array) $messages);
  13102. if (!isset($size)) {
  13103. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  13104. }
  13105. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  13106. $this->doWrite($messages, false, $stderr, $verbosity);
  13107. $fill = $size - strlen(strip_tags($messages));
  13108. if ($fill > 0) {
  13109. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  13110. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  13111. }
  13112. if ($newline) {
  13113. $this->doWrite('', true, $stderr, $verbosity);
  13114. }
  13115. if ($stderr) {
  13116. $this->lastMessageErr = $messages;
  13117. } else {
  13118. $this->lastMessage = $messages;
  13119. }
  13120. }
  13121. public function ask($question, $default = null)
  13122. {
  13123. $helper = $this->helperSet->get('question');
  13124. $question = new Question($question, $default);
  13125. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  13126. }
  13127. public function askConfirmation($question, $default = true)
  13128. {
  13129. $helper = $this->helperSet->get('question');
  13130. $question = new StrictConfirmationQuestion($question, $default);
  13131. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  13132. }
  13133. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  13134. {
  13135. $helper = $this->helperSet->get('question');
  13136. $question = new Question($question, $default);
  13137. $question->setValidator($validator);
  13138. $question->setMaxAttempts($attempts);
  13139. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  13140. }
  13141. public function askAndHideAnswer($question)
  13142. {
  13143. $helper = $this->helperSet->get('question');
  13144. $question = new Question($question);
  13145. $question->setHidden(true);
  13146. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  13147. }
  13148. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  13149. {
  13150. $helper = $this->helperSet->get('question');
  13151. $question = new ChoiceQuestion($question, $choices, $default);
  13152. $question->setMaxAttempts($attempts ?: null);
  13153. $question->setErrorMessage($errorMessage);
  13154. $question->setMultiselect($multiselect);
  13155. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  13156. if (!is_array($result)) {
  13157. return (string) array_search($result, $choices, true);
  13158. }
  13159. $results = array();
  13160. foreach ($choices as $index => $choice) {
  13161. if (in_array($choice, $result, true)) {
  13162. $results[] = (string) $index;
  13163. }
  13164. }
  13165. return $results;
  13166. }
  13167. private function getErrorOutput()
  13168. {
  13169. if ($this->output instanceof ConsoleOutputInterface) {
  13170. return $this->output->getErrorOutput();
  13171. }
  13172. return $this->output;
  13173. }
  13174. }
  13175. <?php
  13176. namespace Composer\IO;
  13177. use Composer\Config;
  13178. interface IOInterface
  13179. {
  13180. const QUIET = 1;
  13181. const NORMAL = 2;
  13182. const VERBOSE = 4;
  13183. const VERY_VERBOSE = 8;
  13184. const DEBUG = 16;
  13185. public function isInteractive();
  13186. public function isVerbose();
  13187. public function isVeryVerbose();
  13188. public function isDebug();
  13189. public function isDecorated();
  13190. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  13191. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  13192. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  13193. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  13194. public function ask($question, $default = null);
  13195. public function askConfirmation($question, $default = true);
  13196. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  13197. public function askAndHideAnswer($question);
  13198. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  13199. public function getAuthentications();
  13200. public function hasAuthentication($repositoryName);
  13201. public function getAuthentication($repositoryName);
  13202. public function setAuthentication($repositoryName, $username, $password = null);
  13203. public function loadConfiguration(Config $config);
  13204. }
  13205. <?php
  13206. namespace Composer\IO;
  13207. class NullIO extends BaseIO
  13208. {
  13209. public function isInteractive()
  13210. {
  13211. return false;
  13212. }
  13213. public function isVerbose()
  13214. {
  13215. return false;
  13216. }
  13217. public function isVeryVerbose()
  13218. {
  13219. return false;
  13220. }
  13221. public function isDebug()
  13222. {
  13223. return false;
  13224. }
  13225. public function isDecorated()
  13226. {
  13227. return false;
  13228. }
  13229. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  13230. {
  13231. }
  13232. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  13233. {
  13234. }
  13235. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  13236. {
  13237. }
  13238. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  13239. {
  13240. }
  13241. public function ask($question, $default = null)
  13242. {
  13243. return $default;
  13244. }
  13245. public function askConfirmation($question, $default = true)
  13246. {
  13247. return $default;
  13248. }
  13249. public function askAndValidate($question, $validator, $attempts = false, $default = null)
  13250. {
  13251. return $default;
  13252. }
  13253. public function askAndHideAnswer($question)
  13254. {
  13255. return null;
  13256. }
  13257. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  13258. {
  13259. return $default;
  13260. }
  13261. }
  13262. <?php
  13263. namespace Composer;
  13264. use Composer\Autoload\AutoloadGenerator;
  13265. use Composer\DependencyResolver\DefaultPolicy;
  13266. use Composer\DependencyResolver\Operation\UpdateOperation;
  13267. use Composer\DependencyResolver\Operation\InstallOperation;
  13268. use Composer\DependencyResolver\Operation\UninstallOperation;
  13269. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  13270. use Composer\DependencyResolver\Operation\OperationInterface;
  13271. use Composer\DependencyResolver\PolicyInterface;
  13272. use Composer\DependencyResolver\Pool;
  13273. use Composer\DependencyResolver\Request;
  13274. use Composer\DependencyResolver\Rule;
  13275. use Composer\DependencyResolver\Solver;
  13276. use Composer\DependencyResolver\SolverProblemsException;
  13277. use Composer\Downloader\DownloadManager;
  13278. use Composer\EventDispatcher\EventDispatcher;
  13279. use Composer\Installer\InstallationManager;
  13280. use Composer\Installer\InstallerEvents;
  13281. use Composer\Installer\NoopInstaller;
  13282. use Composer\Installer\SuggestedPackagesReporter;
  13283. use Composer\IO\IOInterface;
  13284. use Composer\Package\AliasPackage;
  13285. use Composer\Package\BasePackage;
  13286. use Composer\Package\CompletePackage;
  13287. use Composer\Package\Link;
  13288. use Composer\Package\Loader\ArrayLoader;
  13289. use Composer\Package\Dumper\ArrayDumper;
  13290. use Composer\Semver\Constraint\Constraint;
  13291. use Composer\Package\Locker;
  13292. use Composer\Package\PackageInterface;
  13293. use Composer\Package\RootPackageInterface;
  13294. use Composer\Repository\CompositeRepository;
  13295. use Composer\Repository\InstalledArrayRepository;
  13296. use Composer\Repository\PlatformRepository;
  13297. use Composer\Repository\RepositoryInterface;
  13298. use Composer\Repository\RepositoryManager;
  13299. use Composer\Repository\WritableRepositoryInterface;
  13300. use Composer\Script\ScriptEvents;
  13301. class Installer
  13302. {
  13303. protected $io;
  13304. protected $config;
  13305. protected $package;
  13306. protected $downloadManager;
  13307. protected $repositoryManager;
  13308. protected $locker;
  13309. protected $installationManager;
  13310. protected $eventDispatcher;
  13311. protected $autoloadGenerator;
  13312. protected $preferSource = false;
  13313. protected $preferDist = false;
  13314. protected $optimizeAutoloader = false;
  13315. protected $classMapAuthoritative = false;
  13316. protected $apcuAutoloader = false;
  13317. protected $devMode = false;
  13318. protected $dryRun = false;
  13319. protected $verbose = false;
  13320. protected $update = false;
  13321. protected $dumpAutoloader = true;
  13322. protected $runScripts = true;
  13323. protected $ignorePlatformReqs = false;
  13324. protected $preferStable = false;
  13325. protected $preferLowest = false;
  13326. protected $skipSuggest = false;
  13327. protected $writeLock = true;
  13328. protected $executeOperations = true;
  13329. protected $updateWhitelist = null;
  13330. protected $whitelistDependencies = false;
  13331. protected $whitelistAllDependencies = false;
  13332. protected $suggestedPackagesReporter;
  13333. protected $additionalInstalledRepository;
  13334. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  13335. {
  13336. $this->io = $io;
  13337. $this->config = $config;
  13338. $this->package = $package;
  13339. $this->downloadManager = $downloadManager;
  13340. $this->repositoryManager = $repositoryManager;
  13341. $this->locker = $locker;
  13342. $this->installationManager = $installationManager;
  13343. $this->eventDispatcher = $eventDispatcher;
  13344. $this->autoloadGenerator = $autoloadGenerator;
  13345. }
  13346. public function run()
  13347. {
  13348. gc_collect_cycles();
  13349. gc_disable();
  13350. if (!$this->update && !$this->locker->isLocked()) {
  13351. $this->update = true;
  13352. }
  13353. if ($this->dryRun) {
  13354. $this->verbose = true;
  13355. $this->runScripts = false;
  13356. $this->executeOperations = false;
  13357. $this->writeLock = false;
  13358. $this->dumpAutoloader = false;
  13359. $this->installationManager->addInstaller(new NoopInstaller);
  13360. $this->mockLocalRepositories($this->repositoryManager);
  13361. }
  13362. if ($this->runScripts) {
  13363. $devMode = (int) $this->devMode;
  13364. putenv("COMPOSER_DEV_MODE=$devMode");
  13365. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  13366. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  13367. }
  13368. $this->downloadManager->setPreferSource($this->preferSource);
  13369. $this->downloadManager->setPreferDist($this->preferDist);
  13370. $localRepo = $this->repositoryManager->getLocalRepository();
  13371. if ($this->update) {
  13372. $platformOverrides = $this->config->get('platform') ?: array();
  13373. } else {
  13374. $platformOverrides = $this->locker->getPlatformOverrides();
  13375. }
  13376. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  13377. $installedRepo = $this->createInstalledRepo($localRepo, $platformRepo);
  13378. $aliases = $this->getRootAliases();
  13379. $this->aliasPlatformPackages($platformRepo, $aliases);
  13380. if (!$this->suggestedPackagesReporter) {
  13381. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  13382. }
  13383. try {
  13384. list($res, $devPackages) = $this->doInstall($localRepo, $installedRepo, $platformRepo, $aliases);
  13385. if ($res !== 0) {
  13386. return $res;
  13387. }
  13388. } catch (\Exception $e) {
  13389. if ($this->executeOperations) {
  13390. $this->installationManager->notifyInstalls($this->io);
  13391. }
  13392. throw $e;
  13393. }
  13394. if ($this->executeOperations) {
  13395. $this->installationManager->notifyInstalls($this->io);
  13396. }
  13397. if ($this->devMode && !$this->skipSuggest) {
  13398. $this->suggestedPackagesReporter->output($installedRepo);
  13399. }
  13400. foreach ($localRepo->getPackages() as $package) {
  13401. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  13402. continue;
  13403. }
  13404. $replacement = is_string($package->getReplacementPackage())
  13405. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  13406. : 'No replacement was suggested';
  13407. $this->io->writeError(
  13408. sprintf(
  13409. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  13410. $package->getPrettyName(),
  13411. $replacement
  13412. )
  13413. );
  13414. }
  13415. if ($this->update && $this->writeLock) {
  13416. $localRepo->reload();
  13417. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  13418. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  13419. $updatedLock = $this->locker->setLockData(
  13420. array_diff($localRepo->getCanonicalPackages(), $devPackages),
  13421. $devPackages,
  13422. $platformReqs,
  13423. $platformDevReqs,
  13424. $aliases,
  13425. $this->package->getMinimumStability(),
  13426. $this->package->getStabilityFlags(),
  13427. $this->preferStable || $this->package->getPreferStable(),
  13428. $this->preferLowest,
  13429. $this->config->get('platform') ?: array()
  13430. );
  13431. if ($updatedLock) {
  13432. $this->io->writeError('<info>Writing lock file</info>');
  13433. }
  13434. }
  13435. if ($this->dumpAutoloader) {
  13436. if ($this->optimizeAutoloader) {
  13437. $this->io->writeError('<info>Generating optimized autoload files</info>');
  13438. } else {
  13439. $this->io->writeError('<info>Generating autoload files</info>');
  13440. }
  13441. $this->autoloadGenerator->setDevMode($this->devMode);
  13442. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  13443. $this->autoloadGenerator->setApcu($this->apcuAutoloader);
  13444. $this->autoloadGenerator->setRunScripts($this->runScripts);
  13445. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  13446. }
  13447. if ($this->executeOperations) {
  13448. foreach ($localRepo->getPackages() as $package) {
  13449. $this->installationManager->ensureBinariesPresence($package);
  13450. }
  13451. $vendorDir = $this->config->get('vendor-dir');
  13452. if (is_dir($vendorDir)) {
  13453. @touch($vendorDir);
  13454. }
  13455. }
  13456. if ($this->runScripts) {
  13457. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  13458. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  13459. }
  13460. if (!defined('HHVM_VERSION')) {
  13461. gc_enable();
  13462. }
  13463. return 0;
  13464. }
  13465. protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases)
  13466. {
  13467. $lockedRepository = null;
  13468. $repositories = null;
  13469. if (!$this->update || (!empty($this->updateWhitelist) && $this->locker->isLocked())) {
  13470. try {
  13471. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  13472. } catch (\RuntimeException $e) {
  13473. if ($this->package->getDevRequires()) {
  13474. throw $e;
  13475. }
  13476. $lockedRepository = $this->locker->getLockedRepository();
  13477. }
  13478. }
  13479. $this->whitelistUpdateDependencies(
  13480. $lockedRepository ?: $localRepo,
  13481. $this->package->getRequires(),
  13482. $this->package->getDevRequires()
  13483. );
  13484. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  13485. $policy = $this->createPolicy();
  13486. $pool = $this->createPool($this->update ? null : $lockedRepository);
  13487. $pool->addRepository($installedRepo, $aliases);
  13488. if ($this->update) {
  13489. $repositories = $this->repositoryManager->getRepositories();
  13490. foreach ($repositories as $repository) {
  13491. $pool->addRepository($repository, $aliases);
  13492. }
  13493. }
  13494. if ($lockedRepository) {
  13495. $pool->addRepository($lockedRepository, $aliases);
  13496. }
  13497. $request = $this->createRequest($this->package, $platformRepo);
  13498. if ($this->update) {
  13499. $removedUnstablePackages = array();
  13500. foreach ($localRepo->getPackages() as $package) {
  13501. if (
  13502. !$pool->isPackageAcceptable($package->getNames(), $package->getStability())
  13503. && $this->installationManager->isPackageInstalled($localRepo, $package)
  13504. ) {
  13505. $removedUnstablePackages[$package->getName()] = true;
  13506. $request->remove($package->getName(), new Constraint('=', $package->getVersion()));
  13507. }
  13508. }
  13509. $this->io->writeError('<info>Updating dependencies'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  13510. $request->updateAll();
  13511. $links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  13512. foreach ($links as $link) {
  13513. $request->install($link->getTarget(), $link->getConstraint());
  13514. }
  13515. if ($this->updateWhitelist) {
  13516. $currentPackages = $this->getCurrentPackages($installedRepo);
  13517. $candidates = array();
  13518. foreach ($links as $link) {
  13519. $candidates[$link->getTarget()] = true;
  13520. $rootRequires[$link->getTarget()] = $link;
  13521. }
  13522. foreach ($currentPackages as $package) {
  13523. $candidates[$package->getName()] = true;
  13524. }
  13525. foreach ($candidates as $candidate => $dummy) {
  13526. foreach ($currentPackages as $curPackage) {
  13527. if ($curPackage->getName() === $candidate) {
  13528. if (!$this->isUpdateable($curPackage) && !isset($removedUnstablePackages[$curPackage->getName()])) {
  13529. $constraint = new Constraint('=', $curPackage->getVersion());
  13530. $description = $this->locker->isLocked() ? '(locked at' : '(installed at';
  13531. $requiredAt = isset($rootRequires[$candidate]) ? ', required as ' . $rootRequires[$candidate]->getPrettyConstraint() : '';
  13532. $constraint->setPrettyString($description . ' ' . $curPackage->getPrettyVersion() . $requiredAt . ')');
  13533. $request->install($curPackage->getName(), $constraint);
  13534. }
  13535. break;
  13536. }
  13537. }
  13538. }
  13539. }
  13540. } else {
  13541. $this->io->writeError('<info>Installing dependencies'.($this->devMode ? ' (including require-dev)' : '').' from lock file</info>');
  13542. if (!$this->locker->isFresh()) {
  13543. $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. Run update to update them.</warning>', true, IOInterface::QUIET);
  13544. }
  13545. foreach ($lockedRepository->getPackages() as $package) {
  13546. $version = $package->getVersion();
  13547. if (isset($aliases[$package->getName()][$version])) {
  13548. $version = $aliases[$package->getName()][$version]['alias_normalized'];
  13549. }
  13550. $constraint = new Constraint('=', $version);
  13551. $constraint->setPrettyString($package->getPrettyVersion());
  13552. $request->install($package->getName(), $constraint);
  13553. }
  13554. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  13555. $request->install($link->getTarget(), $link->getConstraint());
  13556. }
  13557. }
  13558. $this->processDevPackages($localRepo, $pool, $policy, $repositories, $installedRepo, $lockedRepository, 'force-links');
  13559. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request);
  13560. $solver = new Solver($policy, $pool, $installedRepo, $this->io);
  13561. try {
  13562. $operations = $solver->solve($request, $this->ignorePlatformReqs);
  13563. } catch (SolverProblemsException $e) {
  13564. $this->io->writeError('<error>Your requirements could not be resolved to an installable set of packages.</error>', true, IOInterface::QUIET);
  13565. $this->io->writeError($e->getMessage());
  13566. if ($this->update && !$this->devMode) {
  13567. $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);
  13568. }
  13569. return array(max(1, $e->getCode()), array());
  13570. }
  13571. $operations = $this->processDevPackages($localRepo, $pool, $policy, $repositories, $installedRepo, $lockedRepository, 'force-updates', $operations);
  13572. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request, $operations);
  13573. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  13574. $this->io->writeError("Analyzed ".$solver->getRuleSetSize()." rules to resolve dependencies", true, IOInterface::VERBOSE);
  13575. if (!$operations) {
  13576. $this->io->writeError('Nothing to install or update');
  13577. }
  13578. $operations = $this->movePluginsToFront($operations);
  13579. $operations = $this->moveUninstallsToFront($operations);
  13580. if ($this->update) {
  13581. $devPackages = $this->extractDevPackages($operations, $localRepo, $platformRepo, $aliases);
  13582. if (!$this->devMode) {
  13583. $operations = $this->filterDevPackageOperations($devPackages, $operations, $localRepo);
  13584. }
  13585. } else {
  13586. $devPackages = null;
  13587. }
  13588. if ($operations) {
  13589. $installs = $updates = $uninstalls = array();
  13590. foreach ($operations as $operation) {
  13591. if ($operation instanceof InstallOperation) {
  13592. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  13593. } elseif ($operation instanceof UpdateOperation) {
  13594. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  13595. } elseif ($operation instanceof UninstallOperation) {
  13596. $uninstalls[] = $operation->getPackage()->getPrettyName();
  13597. }
  13598. }
  13599. $this->io->writeError(sprintf(
  13600. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  13601. count($installs),
  13602. 1 === count($installs) ? '' : 's',
  13603. count($updates),
  13604. 1 === count($updates) ? '' : 's',
  13605. count($uninstalls),
  13606. 1 === count($uninstalls) ? '' : 's'
  13607. ));
  13608. if ($installs) {
  13609. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  13610. }
  13611. if ($updates) {
  13612. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  13613. }
  13614. if ($uninstalls) {
  13615. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  13616. }
  13617. }
  13618. foreach ($operations as $operation) {
  13619. $jobType = $operation->getJobType();
  13620. if ('install' === $jobType) {
  13621. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  13622. }
  13623. if ($this->update) {
  13624. $package = null;
  13625. if ('update' === $jobType) {
  13626. $package = $operation->getTargetPackage();
  13627. } elseif ('install' === $jobType) {
  13628. $package = $operation->getPackage();
  13629. }
  13630. if ($package && $package->isDev()) {
  13631. $references = $this->package->getReferences();
  13632. if (isset($references[$package->getName()])) {
  13633. $this->updateInstallReferences($package, $references[$package->getName()]);
  13634. }
  13635. }
  13636. if ('update' === $jobType) {
  13637. $targetPackage = $operation->getTargetPackage();
  13638. if ($targetPackage->isDev()) {
  13639. $initialPackage = $operation->getInitialPackage();
  13640. if ($targetPackage->getVersion() === $initialPackage->getVersion()
  13641. && (!$targetPackage->getSourceReference() || $targetPackage->getSourceReference() === $initialPackage->getSourceReference())
  13642. && (!$targetPackage->getDistReference() || $targetPackage->getDistReference() === $initialPackage->getDistReference())
  13643. ) {
  13644. $this->io->writeError(' - Skipping update of ' . $targetPackage->getPrettyName() . ' to the same reference-locked version', true, IOInterface::DEBUG);
  13645. $this->io->writeError('', true, IOInterface::DEBUG);
  13646. continue;
  13647. }
  13648. }
  13649. }
  13650. }
  13651. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($jobType);
  13652. if (defined($event) && $this->runScripts) {
  13653. $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
  13654. }
  13655. if (!$this->executeOperations && false === strpos($operation->getJobType(), 'Alias')) {
  13656. $this->io->writeError(' - ' . $operation);
  13657. } elseif ($this->io->isDebug() && false !== strpos($operation->getJobType(), 'Alias')) {
  13658. $this->io->writeError(' - ' . $operation);
  13659. }
  13660. $this->installationManager->execute($localRepo, $operation);
  13661. if ($this->verbose && $this->io->isVeryVerbose() && in_array($jobType, array('install', 'update'))) {
  13662. $reason = $operation->getReason();
  13663. if ($reason instanceof Rule) {
  13664. switch ($reason->getReason()) {
  13665. case Rule::RULE_JOB_INSTALL:
  13666. $this->io->writeError(' REASON: Required by the root package: '.$reason->getPrettyString($pool));
  13667. $this->io->writeError('');
  13668. break;
  13669. case Rule::RULE_PACKAGE_REQUIRES:
  13670. $this->io->writeError(' REASON: '.$reason->getPrettyString($pool));
  13671. $this->io->writeError('');
  13672. break;
  13673. }
  13674. }
  13675. }
  13676. if ($this->executeOperations || $this->writeLock) {
  13677. $localRepo->write();
  13678. }
  13679. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($jobType);
  13680. if (defined($event) && $this->runScripts) {
  13681. $this->eventDispatcher->dispatchPackageEvent(constant($event), $this->devMode, $policy, $pool, $installedRepo, $request, $operations, $operation);
  13682. }
  13683. }
  13684. if ($this->executeOperations) {
  13685. $this->processPackageUrls($pool, $policy, $localRepo, $repositories);
  13686. $localRepo->write();
  13687. }
  13688. return array(0, $devPackages);
  13689. }
  13690. private function extractDevPackages(array $operations, RepositoryInterface $localRepo, PlatformRepository $platformRepo, array $aliases)
  13691. {
  13692. if (!$this->package->getDevRequires()) {
  13693. return array();
  13694. }
  13695. $tempLocalRepo = clone $localRepo;
  13696. foreach ($operations as $operation) {
  13697. switch ($operation->getJobType()) {
  13698. case 'install':
  13699. case 'markAliasInstalled':
  13700. if (!$tempLocalRepo->hasPackage($operation->getPackage())) {
  13701. $tempLocalRepo->addPackage(clone $operation->getPackage());
  13702. }
  13703. break;
  13704. case 'uninstall':
  13705. case 'markAliasUninstalled':
  13706. $tempLocalRepo->removePackage($operation->getPackage());
  13707. break;
  13708. case 'update':
  13709. $tempLocalRepo->removePackage($operation->getInitialPackage());
  13710. if (!$tempLocalRepo->hasPackage($operation->getTargetPackage())) {
  13711. $tempLocalRepo->addPackage(clone $operation->getTargetPackage());
  13712. }
  13713. break;
  13714. default:
  13715. throw new \LogicException('Unknown type: '.$operation->getJobType());
  13716. }
  13717. }
  13718. $localRepo = new InstalledArrayRepository(array());
  13719. $loader = new ArrayLoader(null, true);
  13720. $dumper = new ArrayDumper();
  13721. foreach ($tempLocalRepo->getCanonicalPackages() as $pkg) {
  13722. $localRepo->addPackage($loader->load($dumper->dump($pkg)));
  13723. }
  13724. unset($tempLocalRepo, $loader, $dumper);
  13725. $policy = $this->createPolicy();
  13726. $pool = $this->createPool();
  13727. $installedRepo = $this->createInstalledRepo($localRepo, $platformRepo);
  13728. $pool->addRepository($installedRepo, $aliases);
  13729. $request = $this->createRequest($this->package, $platformRepo);
  13730. $request->updateAll();
  13731. foreach ($this->package->getRequires() as $link) {
  13732. $request->install($link->getTarget(), $link->getConstraint());
  13733. }
  13734. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request);
  13735. $solver = new Solver($policy, $pool, $installedRepo, $this->io);
  13736. $ops = $solver->solve($request, $this->ignorePlatformReqs);
  13737. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, false, $policy, $pool, $installedRepo, $request, $ops);
  13738. $devPackages = array();
  13739. foreach ($ops as $op) {
  13740. if ($op->getJobType() === 'uninstall') {
  13741. $devPackages[] = $op->getPackage();
  13742. }
  13743. }
  13744. return $devPackages;
  13745. }
  13746. private function filterDevPackageOperations(array $devPackages, array $operations, RepositoryInterface $localRepo)
  13747. {
  13748. $finalOps = array();
  13749. $packagesToSkip = array();
  13750. foreach ($devPackages as $pkg) {
  13751. $packagesToSkip[$pkg->getName()] = true;
  13752. if ($installedDevPkg = $localRepo->findPackage($pkg->getName(), '*')) {
  13753. if ($installedDevPkg instanceof AliasPackage) {
  13754. $finalOps[] = new MarkAliasUninstalledOperation($installedDevPkg, 'non-dev install removing it');
  13755. $installedDevPkg = $installedDevPkg->getAliasOf();
  13756. }
  13757. $finalOps[] = new UninstallOperation($installedDevPkg, 'non-dev install removing it');
  13758. }
  13759. }
  13760. foreach ($operations as $op) {
  13761. $package = $op->getJobType() === 'update' ? $op->getTargetPackage() : $op->getPackage();
  13762. if (isset($packagesToSkip[$package->getName()])) {
  13763. continue;
  13764. }
  13765. $finalOps[] = $op;
  13766. }
  13767. return $finalOps;
  13768. }
  13769. private function movePluginsToFront(array $operations)
  13770. {
  13771. $pluginsNoDeps = array();
  13772. $pluginsWithDeps = array();
  13773. $pluginRequires = array();
  13774. foreach (array_reverse($operations, true) as $idx => $op) {
  13775. if ($op instanceof InstallOperation) {
  13776. $package = $op->getPackage();
  13777. } elseif ($op instanceof UpdateOperation) {
  13778. $package = $op->getTargetPackage();
  13779. } else {
  13780. continue;
  13781. }
  13782. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  13783. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  13784. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  13785. return $req !== 'composer-plugin-api' && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req);
  13786. });
  13787. if ($isPlugin && !count($requires)) {
  13788. array_unshift($pluginsNoDeps, $op);
  13789. } else {
  13790. $pluginRequires = array_merge($pluginRequires, $requires);
  13791. array_unshift($pluginsWithDeps, $op);
  13792. }
  13793. unset($operations[$idx]);
  13794. }
  13795. }
  13796. return array_merge($pluginsNoDeps, $pluginsWithDeps, $operations);
  13797. }
  13798. private function moveUninstallsToFront(array $operations)
  13799. {
  13800. $uninstOps = array();
  13801. foreach ($operations as $idx => $op) {
  13802. if ($op instanceof UninstallOperation) {
  13803. $uninstOps[] = $op;
  13804. unset($operations[$idx]);
  13805. }
  13806. }
  13807. return array_merge($uninstOps, $operations);
  13808. }
  13809. private function createInstalledRepo(RepositoryInterface $localRepo, PlatformRepository $platformRepo)
  13810. {
  13811. $installedRootPackage = clone $this->package;
  13812. $installedRootPackage->setRequires(array());
  13813. $installedRootPackage->setDevRequires(array());
  13814. $repos = array(
  13815. $localRepo,
  13816. new InstalledArrayRepository(array($installedRootPackage)),
  13817. $platformRepo,
  13818. );
  13819. $installedRepo = new CompositeRepository($repos);
  13820. if ($this->additionalInstalledRepository) {
  13821. $installedRepo->addRepository($this->additionalInstalledRepository);
  13822. }
  13823. return $installedRepo;
  13824. }
  13825. private function createPool(RepositoryInterface $lockedRepository = null)
  13826. {
  13827. if ($this->update) {
  13828. $minimumStability = $this->package->getMinimumStability();
  13829. $stabilityFlags = $this->package->getStabilityFlags();
  13830. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  13831. } else {
  13832. $minimumStability = $this->locker->getMinimumStability();
  13833. $stabilityFlags = $this->locker->getStabilityFlags();
  13834. $requires = array();
  13835. foreach ($lockedRepository->getPackages() as $package) {
  13836. $constraint = new Constraint('=', $package->getVersion());
  13837. $constraint->setPrettyString($package->getPrettyVersion());
  13838. $requires[$package->getName()] = $constraint;
  13839. }
  13840. }
  13841. $rootConstraints = array();
  13842. foreach ($requires as $req => $constraint) {
  13843. if ($this->ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) {
  13844. continue;
  13845. }
  13846. if ($constraint instanceof Link) {
  13847. $rootConstraints[$req] = $constraint->getConstraint();
  13848. } else {
  13849. $rootConstraints[$req] = $constraint;
  13850. }
  13851. }
  13852. return new Pool($minimumStability, $stabilityFlags, $rootConstraints);
  13853. }
  13854. private function createPolicy()
  13855. {
  13856. $preferStable = null;
  13857. $preferLowest = null;
  13858. if (!$this->update) {
  13859. $preferStable = $this->locker->getPreferStable();
  13860. $preferLowest = $this->locker->getPreferLowest();
  13861. }
  13862. if (null === $preferStable) {
  13863. $preferStable = $this->preferStable || $this->package->getPreferStable();
  13864. }
  13865. if (null === $preferLowest) {
  13866. $preferLowest = $this->preferLowest;
  13867. }
  13868. return new DefaultPolicy($preferStable, $preferLowest);
  13869. }
  13870. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo)
  13871. {
  13872. $request = new Request();
  13873. $constraint = new Constraint('=', $rootPackage->getVersion());
  13874. $constraint->setPrettyString($rootPackage->getPrettyVersion());
  13875. $request->install($rootPackage->getName(), $constraint);
  13876. $fixedPackages = $platformRepo->getPackages();
  13877. if ($this->additionalInstalledRepository) {
  13878. $additionalFixedPackages = $this->additionalInstalledRepository->getPackages();
  13879. $fixedPackages = array_merge($fixedPackages, $additionalFixedPackages);
  13880. }
  13881. $provided = $rootPackage->getProvides();
  13882. foreach ($fixedPackages as $package) {
  13883. $constraint = new Constraint('=', $package->getVersion());
  13884. $constraint->setPrettyString($package->getPrettyVersion());
  13885. if ($package->getRepository() !== $platformRepo
  13886. || !isset($provided[$package->getName()])
  13887. || !$provided[$package->getName()]->getConstraint()->matches($constraint)
  13888. ) {
  13889. $request->fix($package->getName(), $constraint);
  13890. }
  13891. }
  13892. return $request;
  13893. }
  13894. private function processDevPackages($localRepo, $pool, $policy, $repositories, $installedRepo, $lockedRepository, $task, array $operations = null)
  13895. {
  13896. if ($task === 'force-updates' && null === $operations) {
  13897. throw new \InvalidArgumentException('Missing operations argument');
  13898. }
  13899. if ($task === 'force-links') {
  13900. $operations = array();
  13901. }
  13902. if ($this->update && $this->updateWhitelist) {
  13903. $currentPackages = $this->getCurrentPackages($installedRepo);
  13904. }
  13905. foreach ($localRepo->getCanonicalPackages() as $package) {
  13906. if (!$package->isDev()) {
  13907. continue;
  13908. }
  13909. foreach ($operations as $operation) {
  13910. if (('update' === $operation->getJobType() && $operation->getInitialPackage()->equals($package))
  13911. || ('uninstall' === $operation->getJobType() && $operation->getPackage()->equals($package))
  13912. ) {
  13913. continue 2;
  13914. }
  13915. }
  13916. if ($this->update) {
  13917. if ($this->updateWhitelist && !$this->isUpdateable($package)) {
  13918. foreach ($currentPackages as $curPackage) {
  13919. if ($curPackage->isDev() && $curPackage->getName() === $package->getName() && $curPackage->getVersion() === $package->getVersion()) {
  13920. if ($task === 'force-links') {
  13921. $package->setRequires($curPackage->getRequires());
  13922. $package->setConflicts($curPackage->getConflicts());
  13923. $package->setProvides($curPackage->getProvides());
  13924. $package->setReplaces($curPackage->getReplaces());
  13925. } elseif ($task === 'force-updates') {
  13926. if (($curPackage->getSourceReference() && $curPackage->getSourceReference() !== $package->getSourceReference())
  13927. || ($curPackage->getDistReference() && $curPackage->getDistReference() !== $package->getDistReference())
  13928. ) {
  13929. $operations[] = new UpdateOperation($package, $curPackage);
  13930. }
  13931. }
  13932. break;
  13933. }
  13934. }
  13935. continue;
  13936. }
  13937. $matches = $pool->whatProvides($package->getName(), new Constraint('=', $package->getVersion()));
  13938. foreach ($matches as $index => $match) {
  13939. if (!in_array($match->getRepository(), $repositories, true)) {
  13940. unset($matches[$index]);
  13941. continue;
  13942. }
  13943. if ($match->getName() !== $package->getName()) {
  13944. unset($matches[$index]);
  13945. continue;
  13946. }
  13947. $matches[$index] = $match->getId();
  13948. }
  13949. if ($matches && $matches = $policy->selectPreferredPackages($pool, array(), $matches)) {
  13950. $newPackage = $pool->literalToPackage($matches[0]);
  13951. if ($task === 'force-links' && $newPackage) {
  13952. $package->setRequires($newPackage->getRequires());
  13953. $package->setConflicts($newPackage->getConflicts());
  13954. $package->setProvides($newPackage->getProvides());
  13955. $package->setReplaces($newPackage->getReplaces());
  13956. }
  13957. if (
  13958. $task === 'force-updates'
  13959. && $newPackage
  13960. && (
  13961. ($newPackage->getSourceReference() && $newPackage->getSourceReference() !== $package->getSourceReference())
  13962. || ($newPackage->getDistReference() && $newPackage->getDistReference() !== $package->getDistReference())
  13963. )
  13964. ) {
  13965. $operations[] = new UpdateOperation($package, $newPackage);
  13966. continue;
  13967. }
  13968. }
  13969. if ($task === 'force-updates') {
  13970. $references = $this->package->getReferences();
  13971. if (isset($references[$package->getName()]) && $references[$package->getName()] !== $package->getSourceReference()) {
  13972. $operations[] = new UpdateOperation($package, clone $package);
  13973. }
  13974. }
  13975. } else {
  13976. foreach ($lockedRepository->findPackages($package->getName()) as $lockedPackage) {
  13977. if ($lockedPackage->isDev() && $lockedPackage->getVersion() === $package->getVersion()) {
  13978. if ($task === 'force-links') {
  13979. $package->setRequires($lockedPackage->getRequires());
  13980. $package->setConflicts($lockedPackage->getConflicts());
  13981. $package->setProvides($lockedPackage->getProvides());
  13982. $package->setReplaces($lockedPackage->getReplaces());
  13983. } elseif ($task === 'force-updates') {
  13984. if (($lockedPackage->getSourceReference() && $lockedPackage->getSourceReference() !== $package->getSourceReference())
  13985. || ($lockedPackage->getDistReference() && $lockedPackage->getDistReference() !== $package->getDistReference())
  13986. ) {
  13987. $operations[] = new UpdateOperation($package, $lockedPackage);
  13988. }
  13989. }
  13990. break;
  13991. }
  13992. }
  13993. }
  13994. }
  13995. return $operations;
  13996. }
  13997. private function getCurrentPackages($installedRepo)
  13998. {
  13999. if ($this->locker->isLocked()) {
  14000. try {
  14001. return $this->locker->getLockedRepository(true)->getPackages();
  14002. } catch (\RuntimeException $e) {
  14003. return $this->locker->getLockedRepository()->getPackages();
  14004. }
  14005. }
  14006. return $installedRepo->getPackages();
  14007. }
  14008. private function getRootAliases()
  14009. {
  14010. if ($this->update) {
  14011. $aliases = $this->package->getAliases();
  14012. } else {
  14013. $aliases = $this->locker->getAliases();
  14014. }
  14015. $normalizedAliases = array();
  14016. foreach ($aliases as $alias) {
  14017. $normalizedAliases[$alias['package']][$alias['version']] = array(
  14018. 'alias' => $alias['alias'],
  14019. 'alias_normalized' => $alias['alias_normalized'],
  14020. );
  14021. }
  14022. return $normalizedAliases;
  14023. }
  14024. private function processPackageUrls($pool, $policy, $localRepo, $repositories)
  14025. {
  14026. if (!$this->update) {
  14027. return;
  14028. }
  14029. $rootRefs = $this->package->getReferences();
  14030. foreach ($localRepo->getCanonicalPackages() as $package) {
  14031. $matches = $pool->whatProvides($package->getName(), new Constraint('=', $package->getVersion()));
  14032. foreach ($matches as $index => $match) {
  14033. if (!in_array($match->getRepository(), $repositories, true)) {
  14034. unset($matches[$index]);
  14035. continue;
  14036. }
  14037. if ($match->getName() !== $package->getName()) {
  14038. unset($matches[$index]);
  14039. continue;
  14040. }
  14041. $matches[$index] = $match->getId();
  14042. }
  14043. if ($matches && $matches = $policy->selectPreferredPackages($pool, array(), $matches)) {
  14044. $newPackage = $pool->literalToPackage($matches[0]);
  14045. $sourceUrl = $package->getSourceUrl();
  14046. $newSourceUrl = $newPackage->getSourceUrl();
  14047. $newReference = $newPackage->getSourceReference();
  14048. if ($package->isDev() && isset($rootRefs[$package->getName()]) && $package->getSourceReference() === $rootRefs[$package->getName()]) {
  14049. $newReference = $rootRefs[$package->getName()];
  14050. }
  14051. $this->updatePackageUrl($package, $newSourceUrl, $newPackage->getSourceType(), $newReference, $newPackage->getDistUrl());
  14052. if ($package instanceof CompletePackage && $newPackage instanceof CompletePackage) {
  14053. $package->setAbandoned($newPackage->getReplacementPackage() ?: $newPackage->isAbandoned());
  14054. }
  14055. $package->setDistMirrors($newPackage->getDistMirrors());
  14056. $package->setSourceMirrors($newPackage->getSourceMirrors());
  14057. }
  14058. }
  14059. }
  14060. private function updatePackageUrl(PackageInterface $package, $sourceUrl, $sourceType, $sourceReference, $distUrl)
  14061. {
  14062. $oldSourceRef = $package->getSourceReference();
  14063. if ($package->getSourceUrl() !== $sourceUrl) {
  14064. $package->setSourceType($sourceType);
  14065. $package->setSourceUrl($sourceUrl);
  14066. $package->setSourceReference($sourceReference);
  14067. }
  14068. if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $distUrl)) {
  14069. $package->setDistUrl($distUrl);
  14070. $this->updateInstallReferences($package, $sourceReference);
  14071. }
  14072. if ($this->updateWhitelist && !$this->isUpdateable($package)) {
  14073. $this->updateInstallReferences($package, $oldSourceRef);
  14074. }
  14075. }
  14076. private function updateInstallReferences(PackageInterface $package, $reference)
  14077. {
  14078. if (!$reference) {
  14079. return;
  14080. }
  14081. $package->setSourceReference($reference);
  14082. if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $package->getDistUrl())) {
  14083. $package->setDistReference($reference);
  14084. $package->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $package->getDistUrl()));
  14085. } elseif ($package->getDistReference()) {
  14086. $package->setDistReference($reference);
  14087. }
  14088. }
  14089. private function aliasPlatformPackages(PlatformRepository $platformRepo, $aliases)
  14090. {
  14091. foreach ($aliases as $package => $versions) {
  14092. foreach ($versions as $version => $alias) {
  14093. $packages = $platformRepo->findPackages($package, $version);
  14094. foreach ($packages as $package) {
  14095. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  14096. $aliasPackage->setRootPackageAlias(true);
  14097. $platformRepo->addPackage($aliasPackage);
  14098. }
  14099. }
  14100. }
  14101. }
  14102. private function isUpdateable(PackageInterface $package)
  14103. {
  14104. if (!$this->updateWhitelist) {
  14105. throw new \LogicException('isUpdateable should only be called when a whitelist is present');
  14106. }
  14107. foreach ($this->updateWhitelist as $whiteListedPattern => $void) {
  14108. $patternRegexp = BasePackage::packageNameToRegexp($whiteListedPattern);
  14109. if (preg_match($patternRegexp, $package->getName())) {
  14110. return true;
  14111. }
  14112. }
  14113. return false;
  14114. }
  14115. private function extractPlatformRequirements($links)
  14116. {
  14117. $platformReqs = array();
  14118. foreach ($links as $link) {
  14119. if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
  14120. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  14121. }
  14122. }
  14123. return $platformReqs;
  14124. }
  14125. private function whitelistUpdateDependencies($localOrLockRepo, array $rootRequires, array $rootDevRequires)
  14126. {
  14127. if (!$this->updateWhitelist) {
  14128. return;
  14129. }
  14130. $rootRequires = array_merge($rootRequires, $rootDevRequires);
  14131. $requiredPackageNames = array();
  14132. foreach ($rootRequires as $require) {
  14133. $requiredPackageNames[] = $require->getTarget();
  14134. }
  14135. $skipPackages = array();
  14136. if (!$this->whitelistAllDependencies) {
  14137. foreach ($rootRequires as $require) {
  14138. $skipPackages[$require->getTarget()] = true;
  14139. }
  14140. }
  14141. $pool = new Pool('dev');
  14142. $pool->addRepository($localOrLockRepo);
  14143. $seen = array();
  14144. $rootRequiredPackageNames = array_keys($rootRequires);
  14145. foreach ($this->updateWhitelist as $packageName => $void) {
  14146. $packageQueue = new \SplQueue;
  14147. $depPackages = $pool->whatProvides($packageName);
  14148. $nameMatchesRequiredPackage = in_array($packageName, $requiredPackageNames, true);
  14149. if (!$nameMatchesRequiredPackage) {
  14150. $whitelistPatternRegexp = BasePackage::packageNameToRegexp($packageName);
  14151. foreach ($rootRequiredPackageNames as $rootRequiredPackageName) {
  14152. if (preg_match($whitelistPatternRegexp, $rootRequiredPackageName)) {
  14153. $nameMatchesRequiredPackage = true;
  14154. break;
  14155. }
  14156. }
  14157. }
  14158. if (count($depPackages) == 0 && !$nameMatchesRequiredPackage && !in_array($packageName, array('nothing', 'lock', 'mirrors'))) {
  14159. $this->io->writeError('<warning>Package "' . $packageName . '" listed for update is not installed. Ignoring.</warning>');
  14160. }
  14161. foreach ($depPackages as $depPackage) {
  14162. $packageQueue->enqueue($depPackage);
  14163. }
  14164. while (!$packageQueue->isEmpty()) {
  14165. $package = $packageQueue->dequeue();
  14166. if (isset($seen[$package->getId()])) {
  14167. continue;
  14168. }
  14169. $seen[$package->getId()] = true;
  14170. $this->updateWhitelist[$package->getName()] = true;
  14171. if (!$this->whitelistDependencies && !$this->whitelistAllDependencies) {
  14172. continue;
  14173. }
  14174. $requires = $package->getRequires();
  14175. foreach ($requires as $require) {
  14176. $requirePackages = $pool->whatProvides($require->getTarget());
  14177. foreach ($requirePackages as $requirePackage) {
  14178. if (isset($this->updateWhitelist[$requirePackage->getName()])) {
  14179. continue;
  14180. }
  14181. if (isset($skipPackages[$requirePackage->getName()])) {
  14182. $this->io->writeError('<warning>Dependency "' . $requirePackage->getName() . '" is also a root requirement, but is not explicitly whitelisted. Ignoring.</warning>');
  14183. continue;
  14184. }
  14185. $packageQueue->enqueue($requirePackage);
  14186. }
  14187. }
  14188. }
  14189. }
  14190. }
  14191. private function mockLocalRepositories(RepositoryManager $rm)
  14192. {
  14193. $packages = array();
  14194. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  14195. $packages[(string) $package] = clone $package;
  14196. }
  14197. foreach ($packages as $key => $package) {
  14198. if ($package instanceof AliasPackage) {
  14199. $alias = (string) $package->getAliasOf();
  14200. $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  14201. }
  14202. }
  14203. $rm->setLocalRepository(
  14204. new InstalledArrayRepository($packages)
  14205. );
  14206. }
  14207. public static function create(IOInterface $io, Composer $composer)
  14208. {
  14209. return new static(
  14210. $io,
  14211. $composer->getConfig(),
  14212. $composer->getPackage(),
  14213. $composer->getDownloadManager(),
  14214. $composer->getRepositoryManager(),
  14215. $composer->getLocker(),
  14216. $composer->getInstallationManager(),
  14217. $composer->getEventDispatcher(),
  14218. $composer->getAutoloadGenerator()
  14219. );
  14220. }
  14221. public function setAdditionalInstalledRepository(RepositoryInterface $additionalInstalledRepository)
  14222. {
  14223. $this->additionalInstalledRepository = $additionalInstalledRepository;
  14224. return $this;
  14225. }
  14226. public function setDryRun($dryRun = true)
  14227. {
  14228. $this->dryRun = (bool) $dryRun;
  14229. return $this;
  14230. }
  14231. public function isDryRun()
  14232. {
  14233. return $this->dryRun;
  14234. }
  14235. public function setPreferSource($preferSource = true)
  14236. {
  14237. $this->preferSource = (bool) $preferSource;
  14238. return $this;
  14239. }
  14240. public function setPreferDist($preferDist = true)
  14241. {
  14242. $this->preferDist = (bool) $preferDist;
  14243. return $this;
  14244. }
  14245. public function setOptimizeAutoloader($optimizeAutoloader = false)
  14246. {
  14247. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  14248. if (!$this->optimizeAutoloader) {
  14249. $this->setClassMapAuthoritative(false);
  14250. }
  14251. return $this;
  14252. }
  14253. public function setClassMapAuthoritative($classMapAuthoritative = false)
  14254. {
  14255. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  14256. if ($this->classMapAuthoritative) {
  14257. $this->setOptimizeAutoloader(true);
  14258. }
  14259. return $this;
  14260. }
  14261. public function setApcuAutoloader($apcuAutoloader = false)
  14262. {
  14263. $this->apcuAutoloader = (bool) $apcuAutoloader;
  14264. return $this;
  14265. }
  14266. public function setUpdate($update = true)
  14267. {
  14268. $this->update = (bool) $update;
  14269. return $this;
  14270. }
  14271. public function setDevMode($devMode = true)
  14272. {
  14273. $this->devMode = (bool) $devMode;
  14274. return $this;
  14275. }
  14276. public function setDumpAutoloader($dumpAutoloader = true)
  14277. {
  14278. $this->dumpAutoloader = (bool) $dumpAutoloader;
  14279. return $this;
  14280. }
  14281. public function setRunScripts($runScripts = true)
  14282. {
  14283. $this->runScripts = (bool) $runScripts;
  14284. return $this;
  14285. }
  14286. public function setConfig(Config $config)
  14287. {
  14288. $this->config = $config;
  14289. return $this;
  14290. }
  14291. public function setVerbose($verbose = true)
  14292. {
  14293. $this->verbose = (bool) $verbose;
  14294. return $this;
  14295. }
  14296. public function isVerbose()
  14297. {
  14298. return $this->verbose;
  14299. }
  14300. public function setIgnorePlatformRequirements($ignorePlatformReqs = false)
  14301. {
  14302. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  14303. return $this;
  14304. }
  14305. public function setUpdateWhitelist(array $packages)
  14306. {
  14307. $this->updateWhitelist = array_flip(array_map('strtolower', $packages));
  14308. return $this;
  14309. }
  14310. public function setWhitelistDependencies($updateDependencies = true)
  14311. {
  14312. return $this->setWhitelistTransitiveDependencies($updateDependencies);
  14313. }
  14314. public function setWhitelistTransitiveDependencies($updateTransitiveDependencies = true)
  14315. {
  14316. $this->whitelistDependencies = (bool) $updateTransitiveDependencies;
  14317. return $this;
  14318. }
  14319. public function setWhitelistAllDependencies($updateAllDependencies = true)
  14320. {
  14321. $this->whitelistAllDependencies = (bool) $updateAllDependencies;
  14322. return $this;
  14323. }
  14324. public function setPreferStable($preferStable = true)
  14325. {
  14326. $this->preferStable = (bool) $preferStable;
  14327. return $this;
  14328. }
  14329. public function setPreferLowest($preferLowest = true)
  14330. {
  14331. $this->preferLowest = (bool) $preferLowest;
  14332. return $this;
  14333. }
  14334. public function setWriteLock($writeLock = true)
  14335. {
  14336. $this->writeLock = (bool) $writeLock;
  14337. return $this;
  14338. }
  14339. public function setExecuteOperations($executeOperations = true)
  14340. {
  14341. $this->executeOperations = (bool) $executeOperations;
  14342. return $this;
  14343. }
  14344. public function setSkipSuggest($skipSuggest = true)
  14345. {
  14346. $this->skipSuggest = (bool) $skipSuggest;
  14347. return $this;
  14348. }
  14349. public function disablePlugins()
  14350. {
  14351. $this->installationManager->disablePlugins();
  14352. return $this;
  14353. }
  14354. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  14355. {
  14356. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  14357. return $this;
  14358. }
  14359. }
  14360. <?php
  14361. namespace Composer\Installer;
  14362. use Composer\IO\IOInterface;
  14363. use Composer\Package\PackageInterface;
  14364. use Composer\Util\Filesystem;
  14365. use Composer\Util\Platform;
  14366. use Composer\Util\ProcessExecutor;
  14367. use Composer\Util\Silencer;
  14368. class BinaryInstaller
  14369. {
  14370. protected $binDir;
  14371. protected $binCompat;
  14372. protected $io;
  14373. protected $filesystem;
  14374. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
  14375. {
  14376. $this->binDir = $binDir;
  14377. $this->binCompat = $binCompat;
  14378. $this->io = $io;
  14379. $this->filesystem = $filesystem ?: new Filesystem();
  14380. }
  14381. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  14382. {
  14383. $binaries = $this->getBinaries($package);
  14384. if (!$binaries) {
  14385. return;
  14386. }
  14387. foreach ($binaries as $bin) {
  14388. $binPath = $installPath.'/'.$bin;
  14389. if (!file_exists($binPath)) {
  14390. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  14391. continue;
  14392. }
  14393. $binPath = realpath($binPath);
  14394. $this->initializeBinDir();
  14395. $link = $this->binDir.'/'.basename($bin);
  14396. if (file_exists($link)) {
  14397. if (is_link($link)) {
  14398. Silencer::call('chmod', $link, 0777 & ~umask());
  14399. }
  14400. if ($warnOnOverwrite) {
  14401. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  14402. }
  14403. continue;
  14404. }
  14405. if ($this->binCompat === "auto") {
  14406. if (Platform::isWindows()) {
  14407. $this->installFullBinaries($binPath, $link, $bin, $package);
  14408. } else {
  14409. $this->installSymlinkBinaries($binPath, $link);
  14410. }
  14411. } elseif ($this->binCompat === "full") {
  14412. $this->installFullBinaries($binPath, $link, $bin, $package);
  14413. }
  14414. Silencer::call('chmod', $link, 0777 & ~umask());
  14415. }
  14416. }
  14417. public function removeBinaries(PackageInterface $package)
  14418. {
  14419. $this->initializeBinDir();
  14420. $binaries = $this->getBinaries($package);
  14421. if (!$binaries) {
  14422. return;
  14423. }
  14424. foreach ($binaries as $bin) {
  14425. $link = $this->binDir.'/'.basename($bin);
  14426. if (is_link($link) || file_exists($link)) {
  14427. $this->filesystem->unlink($link);
  14428. }
  14429. if (file_exists($link.'.bat')) {
  14430. $this->filesystem->unlink($link.'.bat');
  14431. }
  14432. }
  14433. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  14434. Silencer::call('rmdir', $this->binDir);
  14435. }
  14436. }
  14437. public static function determineBinaryCaller($bin)
  14438. {
  14439. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  14440. return 'call';
  14441. }
  14442. $handle = fopen($bin, 'r');
  14443. $line = fgets($handle);
  14444. fclose($handle);
  14445. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  14446. return trim($match[1]);
  14447. }
  14448. return 'php';
  14449. }
  14450. protected function getBinaries(PackageInterface $package)
  14451. {
  14452. return $package->getBinaries();
  14453. }
  14454. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  14455. {
  14456. if ('.bat' !== substr($binPath, -4)) {
  14457. $this->installUnixyProxyBinaries($binPath, $link);
  14458. @chmod($link, 0777 & ~umask());
  14459. $link .= '.bat';
  14460. if (file_exists($link)) {
  14461. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  14462. }
  14463. }
  14464. if (!file_exists($link)) {
  14465. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  14466. }
  14467. }
  14468. protected function installSymlinkBinaries($binPath, $link)
  14469. {
  14470. if (!$this->filesystem->relativeSymlink($binPath, $link)) {
  14471. $this->installUnixyProxyBinaries($binPath, $link);
  14472. }
  14473. }
  14474. protected function installUnixyProxyBinaries($binPath, $link)
  14475. {
  14476. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  14477. }
  14478. protected function initializeBinDir()
  14479. {
  14480. $this->filesystem->ensureDirectoryExists($this->binDir);
  14481. $this->binDir = realpath($this->binDir);
  14482. }
  14483. protected function generateWindowsProxyCode($bin, $link)
  14484. {
  14485. $binPath = $this->filesystem->findShortestPath($link, $bin);
  14486. $caller = self::determineBinaryCaller($bin);
  14487. return "@ECHO OFF\r\n".
  14488. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  14489. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  14490. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  14491. }
  14492. protected function generateUnixyProxyCode($bin, $link)
  14493. {
  14494. $binPath = $this->filesystem->findShortestPath($link, $bin);
  14495. $binDir = ProcessExecutor::escape(dirname($binPath));
  14496. $binFile = basename($binPath);
  14497. $proxyCode = <<<PROXY
  14498. #!/usr/bin/env sh
  14499. dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  14500. if [ -d /proc/cygdrive ] && [[ \$(which php) == \$(readlink -n /proc/cygdrive)/* ]]; then
  14501. # We are in Cgywin using Windows php, so the path must be translated
  14502. dir=\$(cygpath -m "\$dir");
  14503. fi
  14504. "\${dir}/$binFile" "\$@"
  14505. PROXY;
  14506. return $proxyCode;
  14507. }
  14508. }
  14509. <?php
  14510. namespace Composer\Installer;
  14511. use Composer\Package\PackageInterface;
  14512. interface BinaryPresenceInterface
  14513. {
  14514. public function ensureBinariesPresence(PackageInterface $package);
  14515. }
  14516. <?php
  14517. namespace Composer\Installer;
  14518. use Composer\IO\IOInterface;
  14519. use Composer\Package\PackageInterface;
  14520. use Composer\Package\AliasPackage;
  14521. use Composer\Repository\RepositoryInterface;
  14522. use Composer\Repository\InstalledRepositoryInterface;
  14523. use Composer\DependencyResolver\Operation\OperationInterface;
  14524. use Composer\DependencyResolver\Operation\InstallOperation;
  14525. use Composer\DependencyResolver\Operation\UpdateOperation;
  14526. use Composer\DependencyResolver\Operation\UninstallOperation;
  14527. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  14528. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  14529. use Composer\Util\StreamContextFactory;
  14530. class InstallationManager
  14531. {
  14532. private $installers = array();
  14533. private $cache = array();
  14534. private $notifiablePackages = array();
  14535. public function reset()
  14536. {
  14537. $this->notifiablePackages = array();
  14538. }
  14539. public function addInstaller(InstallerInterface $installer)
  14540. {
  14541. array_unshift($this->installers, $installer);
  14542. $this->cache = array();
  14543. }
  14544. public function removeInstaller(InstallerInterface $installer)
  14545. {
  14546. if (false !== ($key = array_search($installer, $this->installers, true))) {
  14547. array_splice($this->installers, $key, 1);
  14548. $this->cache = array();
  14549. }
  14550. }
  14551. public function disablePlugins()
  14552. {
  14553. foreach ($this->installers as $i => $installer) {
  14554. if (!$installer instanceof PluginInstaller) {
  14555. continue;
  14556. }
  14557. unset($this->installers[$i]);
  14558. }
  14559. }
  14560. public function getInstaller($type)
  14561. {
  14562. $type = strtolower($type);
  14563. if (isset($this->cache[$type])) {
  14564. return $this->cache[$type];
  14565. }
  14566. foreach ($this->installers as $installer) {
  14567. if ($installer->supports($type)) {
  14568. return $this->cache[$type] = $installer;
  14569. }
  14570. }
  14571. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  14572. }
  14573. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  14574. {
  14575. if ($package instanceof AliasPackage) {
  14576. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  14577. }
  14578. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  14579. }
  14580. public function ensureBinariesPresence(PackageInterface $package)
  14581. {
  14582. try {
  14583. $installer = $this->getInstaller($package->getType());
  14584. } catch (\InvalidArgumentException $e) {
  14585. return;
  14586. }
  14587. if ($installer instanceof BinaryPresenceInterface) {
  14588. $installer->ensureBinariesPresence($package);
  14589. }
  14590. }
  14591. public function execute(RepositoryInterface $repo, OperationInterface $operation)
  14592. {
  14593. $method = $operation->getJobType();
  14594. $this->$method($repo, $operation);
  14595. }
  14596. public function install(RepositoryInterface $repo, InstallOperation $operation)
  14597. {
  14598. $package = $operation->getPackage();
  14599. $installer = $this->getInstaller($package->getType());
  14600. $installer->install($repo, $package);
  14601. $this->markForNotification($package);
  14602. }
  14603. public function update(RepositoryInterface $repo, UpdateOperation $operation)
  14604. {
  14605. $initial = $operation->getInitialPackage();
  14606. $target = $operation->getTargetPackage();
  14607. $initialType = $initial->getType();
  14608. $targetType = $target->getType();
  14609. if ($initialType === $targetType) {
  14610. $installer = $this->getInstaller($initialType);
  14611. $installer->update($repo, $initial, $target);
  14612. $this->markForNotification($target);
  14613. } else {
  14614. $this->getInstaller($initialType)->uninstall($repo, $initial);
  14615. $this->getInstaller($targetType)->install($repo, $target);
  14616. }
  14617. }
  14618. public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
  14619. {
  14620. $package = $operation->getPackage();
  14621. $installer = $this->getInstaller($package->getType());
  14622. $installer->uninstall($repo, $package);
  14623. }
  14624. public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  14625. {
  14626. $package = $operation->getPackage();
  14627. if (!$repo->hasPackage($package)) {
  14628. $repo->addPackage(clone $package);
  14629. }
  14630. }
  14631. public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  14632. {
  14633. $package = $operation->getPackage();
  14634. $repo->removePackage($package);
  14635. }
  14636. public function getInstallPath(PackageInterface $package)
  14637. {
  14638. $installer = $this->getInstaller($package->getType());
  14639. return $installer->getInstallPath($package);
  14640. }
  14641. public function notifyInstalls(IOInterface $io)
  14642. {
  14643. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  14644. $repositoryName = parse_url($repoUrl, PHP_URL_HOST);
  14645. if ($io->hasAuthentication($repositoryName)) {
  14646. $auth = $io->getAuthentication($repositoryName);
  14647. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  14648. $authHeader = 'Authorization: Basic '.$authStr;
  14649. }
  14650. if (strpos($repoUrl, '%package%')) {
  14651. foreach ($packages as $package) {
  14652. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  14653. $params = array(
  14654. 'version' => $package->getPrettyVersion(),
  14655. 'version_normalized' => $package->getVersion(),
  14656. );
  14657. $opts = array('http' =>
  14658. array(
  14659. 'method' => 'POST',
  14660. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  14661. 'content' => http_build_query($params, '', '&'),
  14662. 'timeout' => 3,
  14663. ),
  14664. );
  14665. if (isset($authHeader)) {
  14666. $opts['http']['header'][] = $authHeader;
  14667. }
  14668. $context = StreamContextFactory::getContext($url, $opts);
  14669. @file_get_contents($url, false, $context);
  14670. }
  14671. continue;
  14672. }
  14673. $postData = array('downloads' => array());
  14674. foreach ($packages as $package) {
  14675. $postData['downloads'][] = array(
  14676. 'name' => $package->getPrettyName(),
  14677. 'version' => $package->getVersion(),
  14678. );
  14679. }
  14680. $opts = array('http' =>
  14681. array(
  14682. 'method' => 'POST',
  14683. 'header' => array('Content-Type: application/json'),
  14684. 'content' => json_encode($postData),
  14685. 'timeout' => 6,
  14686. ),
  14687. );
  14688. if (isset($authHeader)) {
  14689. $opts['http']['header'][] = $authHeader;
  14690. }
  14691. $context = StreamContextFactory::getContext($repoUrl, $opts);
  14692. @file_get_contents($repoUrl, false, $context);
  14693. }
  14694. $this->reset();
  14695. }
  14696. private function markForNotification(PackageInterface $package)
  14697. {
  14698. if ($package->getNotificationUrl()) {
  14699. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  14700. }
  14701. }
  14702. }
  14703. <?php
  14704. namespace Composer\Installer;
  14705. use Composer\Composer;
  14706. use Composer\DependencyResolver\PolicyInterface;
  14707. use Composer\DependencyResolver\Operation\OperationInterface;
  14708. use Composer\DependencyResolver\Pool;
  14709. use Composer\DependencyResolver\Request;
  14710. use Composer\EventDispatcher\Event;
  14711. use Composer\IO\IOInterface;
  14712. use Composer\Repository\CompositeRepository;
  14713. class InstallerEvent extends Event
  14714. {
  14715. private $composer;
  14716. private $io;
  14717. private $devMode;
  14718. private $policy;
  14719. private $pool;
  14720. private $installedRepo;
  14721. private $request;
  14722. private $operations;
  14723. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations = array())
  14724. {
  14725. parent::__construct($eventName);
  14726. $this->composer = $composer;
  14727. $this->io = $io;
  14728. $this->devMode = $devMode;
  14729. $this->policy = $policy;
  14730. $this->pool = $pool;
  14731. $this->installedRepo = $installedRepo;
  14732. $this->request = $request;
  14733. $this->operations = $operations;
  14734. }
  14735. public function getComposer()
  14736. {
  14737. return $this->composer;
  14738. }
  14739. public function getIO()
  14740. {
  14741. return $this->io;
  14742. }
  14743. public function isDevMode()
  14744. {
  14745. return $this->devMode;
  14746. }
  14747. public function getPolicy()
  14748. {
  14749. return $this->policy;
  14750. }
  14751. public function getPool()
  14752. {
  14753. return $this->pool;
  14754. }
  14755. public function getInstalledRepo()
  14756. {
  14757. return $this->installedRepo;
  14758. }
  14759. public function getRequest()
  14760. {
  14761. return $this->request;
  14762. }
  14763. public function getOperations()
  14764. {
  14765. return $this->operations;
  14766. }
  14767. }
  14768. <?php
  14769. namespace Composer\Installer;
  14770. class InstallerEvents
  14771. {
  14772. const PRE_DEPENDENCIES_SOLVING = 'pre-dependencies-solving';
  14773. const POST_DEPENDENCIES_SOLVING = 'post-dependencies-solving';
  14774. }
  14775. <?php
  14776. namespace Composer\Installer;
  14777. use Composer\Package\PackageInterface;
  14778. use Composer\Repository\InstalledRepositoryInterface;
  14779. use InvalidArgumentException;
  14780. interface InstallerInterface
  14781. {
  14782. public function supports($packageType);
  14783. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  14784. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  14785. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  14786. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  14787. public function getInstallPath(PackageInterface $package);
  14788. }
  14789. <?php
  14790. namespace Composer\Installer;
  14791. use Composer\Composer;
  14792. use Composer\IO\IOInterface;
  14793. use Composer\Repository\InstalledRepositoryInterface;
  14794. use Composer\Package\PackageInterface;
  14795. use Composer\Util\Filesystem;
  14796. use Composer\Util\Silencer;
  14797. use Composer\Util\Platform;
  14798. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  14799. {
  14800. protected $composer;
  14801. protected $vendorDir;
  14802. protected $binDir;
  14803. protected $downloadManager;
  14804. protected $io;
  14805. protected $type;
  14806. protected $filesystem;
  14807. protected $binCompat;
  14808. protected $binaryInstaller;
  14809. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  14810. {
  14811. $this->composer = $composer;
  14812. $this->downloadManager = $composer->getDownloadManager();
  14813. $this->io = $io;
  14814. $this->type = $type;
  14815. $this->filesystem = $filesystem ?: new Filesystem();
  14816. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  14817. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
  14818. }
  14819. public function supports($packageType)
  14820. {
  14821. return $packageType === $this->type || null === $this->type;
  14822. }
  14823. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  14824. {
  14825. if (!$repo->hasPackage($package)) {
  14826. return false;
  14827. }
  14828. $installPath = $this->getInstallPath($package);
  14829. if (is_readable($installPath)) {
  14830. return true;
  14831. }
  14832. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  14833. }
  14834. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  14835. {
  14836. $this->initializeVendorDir();
  14837. $downloadPath = $this->getInstallPath($package);
  14838. if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
  14839. $this->binaryInstaller->removeBinaries($package);
  14840. }
  14841. $this->installCode($package);
  14842. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package));
  14843. if (!$repo->hasPackage($package)) {
  14844. $repo->addPackage(clone $package);
  14845. }
  14846. }
  14847. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  14848. {
  14849. if (!$repo->hasPackage($initial)) {
  14850. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  14851. }
  14852. $this->initializeVendorDir();
  14853. $this->binaryInstaller->removeBinaries($initial);
  14854. $this->updateCode($initial, $target);
  14855. $this->binaryInstaller->installBinaries($target, $this->getInstallPath($target));
  14856. $repo->removePackage($initial);
  14857. if (!$repo->hasPackage($target)) {
  14858. $repo->addPackage(clone $target);
  14859. }
  14860. }
  14861. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  14862. {
  14863. if (!$repo->hasPackage($package)) {
  14864. throw new \InvalidArgumentException('Package is not installed: '.$package);
  14865. }
  14866. $this->removeCode($package);
  14867. $this->binaryInstaller->removeBinaries($package);
  14868. $repo->removePackage($package);
  14869. $downloadPath = $this->getPackageBasePath($package);
  14870. if (strpos($package->getName(), '/')) {
  14871. $packageVendorDir = dirname($downloadPath);
  14872. if (is_dir($packageVendorDir) && $this->filesystem->isDirEmpty($packageVendorDir)) {
  14873. Silencer::call('rmdir', $packageVendorDir);
  14874. }
  14875. }
  14876. }
  14877. public function getInstallPath(PackageInterface $package)
  14878. {
  14879. $this->initializeVendorDir();
  14880. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  14881. $targetDir = $package->getTargetDir();
  14882. return $basePath . ($targetDir ? '/'.$targetDir : '');
  14883. }
  14884. public function ensureBinariesPresence(PackageInterface $package)
  14885. {
  14886. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  14887. }
  14888. protected function getPackageBasePath(PackageInterface $package)
  14889. {
  14890. $installPath = $this->getInstallPath($package);
  14891. $targetDir = $package->getTargetDir();
  14892. if ($targetDir) {
  14893. return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  14894. }
  14895. return $installPath;
  14896. }
  14897. protected function installCode(PackageInterface $package)
  14898. {
  14899. $downloadPath = $this->getInstallPath($package);
  14900. $this->downloadManager->download($package, $downloadPath);
  14901. }
  14902. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  14903. {
  14904. $initialDownloadPath = $this->getInstallPath($initial);
  14905. $targetDownloadPath = $this->getInstallPath($target);
  14906. if ($targetDownloadPath !== $initialDownloadPath) {
  14907. if (substr($initialDownloadPath, 0, strlen($targetDownloadPath)) === $targetDownloadPath
  14908. || substr($targetDownloadPath, 0, strlen($initialDownloadPath)) === $initialDownloadPath
  14909. ) {
  14910. $this->removeCode($initial);
  14911. $this->installCode($target);
  14912. return;
  14913. }
  14914. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  14915. }
  14916. $this->downloadManager->update($initial, $target, $targetDownloadPath);
  14917. }
  14918. protected function removeCode(PackageInterface $package)
  14919. {
  14920. $downloadPath = $this->getPackageBasePath($package);
  14921. $this->downloadManager->remove($package, $downloadPath);
  14922. }
  14923. protected function initializeVendorDir()
  14924. {
  14925. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  14926. $this->vendorDir = realpath($this->vendorDir);
  14927. }
  14928. }
  14929. <?php
  14930. namespace Composer\Installer;
  14931. use Composer\Repository\InstalledRepositoryInterface;
  14932. use Composer\Package\PackageInterface;
  14933. class MetapackageInstaller implements InstallerInterface
  14934. {
  14935. public function supports($packageType)
  14936. {
  14937. return $packageType === 'metapackage';
  14938. }
  14939. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  14940. {
  14941. return $repo->hasPackage($package);
  14942. }
  14943. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  14944. {
  14945. $repo->addPackage(clone $package);
  14946. }
  14947. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  14948. {
  14949. if (!$repo->hasPackage($initial)) {
  14950. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  14951. }
  14952. $repo->removePackage($initial);
  14953. $repo->addPackage(clone $target);
  14954. }
  14955. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  14956. {
  14957. if (!$repo->hasPackage($package)) {
  14958. throw new \InvalidArgumentException('Package is not installed: '.$package);
  14959. }
  14960. $repo->removePackage($package);
  14961. }
  14962. public function getInstallPath(PackageInterface $package)
  14963. {
  14964. return '';
  14965. }
  14966. }
  14967. <?php
  14968. namespace Composer\Installer;
  14969. use Composer\Repository\InstalledRepositoryInterface;
  14970. use Composer\Package\PackageInterface;
  14971. class NoopInstaller implements InstallerInterface
  14972. {
  14973. public function supports($packageType)
  14974. {
  14975. return true;
  14976. }
  14977. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  14978. {
  14979. return $repo->hasPackage($package);
  14980. }
  14981. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  14982. {
  14983. if (!$repo->hasPackage($package)) {
  14984. $repo->addPackage(clone $package);
  14985. }
  14986. }
  14987. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  14988. {
  14989. if (!$repo->hasPackage($initial)) {
  14990. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  14991. }
  14992. $repo->removePackage($initial);
  14993. if (!$repo->hasPackage($target)) {
  14994. $repo->addPackage(clone $target);
  14995. }
  14996. }
  14997. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  14998. {
  14999. if (!$repo->hasPackage($package)) {
  15000. throw new \InvalidArgumentException('Package is not installed: '.$package);
  15001. }
  15002. $repo->removePackage($package);
  15003. }
  15004. public function getInstallPath(PackageInterface $package)
  15005. {
  15006. $targetDir = $package->getTargetDir();
  15007. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  15008. }
  15009. }
  15010. <?php
  15011. namespace Composer\Installer;
  15012. use Composer\Composer;
  15013. use Composer\IO\IOInterface;
  15014. use Composer\DependencyResolver\Operation\OperationInterface;
  15015. use Composer\DependencyResolver\PolicyInterface;
  15016. use Composer\DependencyResolver\Pool;
  15017. use Composer\DependencyResolver\Request;
  15018. use Composer\Repository\CompositeRepository;
  15019. class PackageEvent extends InstallerEvent
  15020. {
  15021. private $operation;
  15022. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, PolicyInterface $policy, Pool $pool, CompositeRepository $installedRepo, Request $request, array $operations, OperationInterface $operation)
  15023. {
  15024. parent::__construct($eventName, $composer, $io, $devMode, $policy, $pool, $installedRepo, $request, $operations);
  15025. $this->operation = $operation;
  15026. }
  15027. public function getOperation()
  15028. {
  15029. return $this->operation;
  15030. }
  15031. }
  15032. <?php
  15033. namespace Composer\Installer;
  15034. class PackageEvents
  15035. {
  15036. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  15037. const POST_PACKAGE_INSTALL = 'post-package-install';
  15038. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  15039. const POST_PACKAGE_UPDATE = 'post-package-update';
  15040. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  15041. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  15042. }
  15043. <?php
  15044. namespace Composer\Installer;
  15045. use Composer\IO\IOInterface;
  15046. use Composer\Package\PackageInterface;
  15047. use Composer\Util\Filesystem;
  15048. use Composer\Util\ProcessExecutor;
  15049. class PearBinaryInstaller extends BinaryInstaller
  15050. {
  15051. private $installer;
  15052. private $vendorDir;
  15053. public function __construct(IOInterface $io, $binDir, $vendorDir, $binCompat, Filesystem $filesystem, PearInstaller $installer)
  15054. {
  15055. parent::__construct($io, $binDir, $binCompat, $filesystem);
  15056. $this->installer = $installer;
  15057. $this->vendorDir = $vendorDir;
  15058. }
  15059. protected function getBinaries(PackageInterface $package)
  15060. {
  15061. $binariesPath = $this->installer->getInstallPath($package) . '/bin/';
  15062. $binaries = array();
  15063. if (file_exists($binariesPath)) {
  15064. foreach (new \FilesystemIterator($binariesPath, \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::CURRENT_AS_FILEINFO) as $fileName => $value) {
  15065. if (!$value->isDir()) {
  15066. $binaries[] = 'bin/'.$fileName;
  15067. }
  15068. }
  15069. }
  15070. return $binaries;
  15071. }
  15072. protected function initializeBinDir()
  15073. {
  15074. parent::initializeBinDir();
  15075. file_put_contents($this->binDir.'/composer-php', $this->generateUnixyPhpProxyCode());
  15076. @chmod($this->binDir.'/composer-php', 0777 & ~umask());
  15077. file_put_contents($this->binDir.'/composer-php.bat', $this->generateWindowsPhpProxyCode());
  15078. @chmod($this->binDir.'/composer-php.bat', 0777 & ~umask());
  15079. }
  15080. protected function generateWindowsProxyCode($bin, $link)
  15081. {
  15082. $binPath = $this->filesystem->findShortestPath($link, $bin);
  15083. if ('.bat' === substr($bin, -4)) {
  15084. $caller = 'call';
  15085. } else {
  15086. $handle = fopen($bin, 'r');
  15087. $line = fgets($handle);
  15088. fclose($handle);
  15089. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  15090. $caller = trim($match[1]);
  15091. } else {
  15092. $caller = 'php';
  15093. }
  15094. if ($caller === 'php') {
  15095. return "@echo off\r\n".
  15096. "pushd .\r\n".
  15097. "cd %~dp0\r\n".
  15098. "set PHP_PROXY=%CD%\\composer-php.bat\r\n".
  15099. "cd ".ProcessExecutor::escape(dirname($binPath))."\r\n".
  15100. "set BIN_TARGET=%CD%\\".basename($binPath)."\r\n".
  15101. "popd\r\n".
  15102. "%PHP_PROXY% \"%BIN_TARGET%\" %*\r\n";
  15103. }
  15104. }
  15105. return "@echo off\r\n".
  15106. "pushd .\r\n".
  15107. "cd %~dp0\r\n".
  15108. "cd ".ProcessExecutor::escape(dirname($binPath))."\r\n".
  15109. "set BIN_TARGET=%CD%\\".basename($binPath)."\r\n".
  15110. "popd\r\n".
  15111. $caller." \"%BIN_TARGET%\" %*\r\n";
  15112. }
  15113. private function generateWindowsPhpProxyCode()
  15114. {
  15115. $binToVendor = $this->filesystem->findShortestPath($this->binDir, $this->vendorDir, true);
  15116. return
  15117. "@echo off\r\n" .
  15118. "setlocal enabledelayedexpansion\r\n" .
  15119. "set BIN_DIR=%~dp0\r\n" .
  15120. "set VENDOR_DIR=%BIN_DIR%\\".$binToVendor."\r\n" .
  15121. "set DIRS=.\r\n" .
  15122. "FOR /D %%V IN (%VENDOR_DIR%\\*) DO (\r\n" .
  15123. " FOR /D %%P IN (%%V\\*) DO (\r\n" .
  15124. " set DIRS=!DIRS!;%%~fP\r\n" .
  15125. " )\r\n" .
  15126. ")\r\n" .
  15127. "php.exe -d include_path=!DIRS! %*\r\n";
  15128. }
  15129. private function generateUnixyPhpProxyCode()
  15130. {
  15131. $binToVendor = $this->filesystem->findShortestPath($this->binDir, $this->vendorDir, true);
  15132. return
  15133. "#!/usr/bin/env sh\n".
  15134. "SRC_DIR=`pwd`\n".
  15135. "BIN_DIR=`dirname $0`\n".
  15136. "VENDOR_DIR=\$BIN_DIR/".escapeshellarg($binToVendor)."\n".
  15137. "DIRS=\"\"\n".
  15138. "for vendor in \$VENDOR_DIR/*; do\n".
  15139. " if [ -d \"\$vendor\" ]; then\n".
  15140. " for package in \$vendor/*; do\n".
  15141. " if [ -d \"\$package\" ]; then\n".
  15142. " DIRS=\"\${DIRS}:\${package}\"\n".
  15143. " fi\n".
  15144. " done\n".
  15145. " fi\n".
  15146. "done\n".
  15147. "php -d include_path=\".\$DIRS\" $@\n";
  15148. }
  15149. }
  15150. <?php
  15151. namespace Composer\Installer;
  15152. use Composer\IO\IOInterface;
  15153. use Composer\Composer;
  15154. use Composer\Downloader\PearPackageExtractor;
  15155. use Composer\Repository\InstalledRepositoryInterface;
  15156. use Composer\Package\PackageInterface;
  15157. use Composer\Util\Platform;
  15158. use Composer\Util\Filesystem;
  15159. class PearInstaller extends LibraryInstaller
  15160. {
  15161. public function __construct(IOInterface $io, Composer $composer, $type = 'pear-library')
  15162. {
  15163. $filesystem = new Filesystem();
  15164. $binaryInstaller = new PearBinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), rtrim($composer->getConfig()->get('vendor-dir'), '/'), $composer->getConfig()->get('bin-compat'), $filesystem, $this);
  15165. parent::__construct($io, $composer, $type, $filesystem, $binaryInstaller);
  15166. }
  15167. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  15168. {
  15169. $this->uninstall($repo, $initial);
  15170. $this->install($repo, $target);
  15171. }
  15172. protected function installCode(PackageInterface $package)
  15173. {
  15174. parent::installCode($package);
  15175. $isWindows = Platform::isWindows();
  15176. $php_bin = $this->binDir . ($isWindows ? '/composer-php.bat' : '/composer-php');
  15177. if (!$isWindows) {
  15178. $php_bin = '/usr/bin/env ' . $php_bin;
  15179. }
  15180. $installPath = $this->getInstallPath($package);
  15181. $vars = array(
  15182. 'os' => $isWindows ? 'windows' : 'linux',
  15183. 'php_bin' => $php_bin,
  15184. 'pear_php' => $installPath,
  15185. 'php_dir' => $installPath,
  15186. 'bin_dir' => $installPath . '/bin',
  15187. 'data_dir' => $installPath . '/data',
  15188. 'version' => $package->getPrettyVersion(),
  15189. );
  15190. $packageArchive = $this->getInstallPath($package).'/'.pathinfo($package->getDistUrl(), PATHINFO_BASENAME);
  15191. $pearExtractor = new PearPackageExtractor($packageArchive);
  15192. $pearExtractor->extractTo($this->getInstallPath($package), array('php' => '/', 'script' => '/bin', 'data' => '/data'), $vars);
  15193. $this->io->writeError(' Cleaning up', true, IOInterface::VERBOSE);
  15194. $this->filesystem->unlink($packageArchive);
  15195. }
  15196. }
  15197. <?php
  15198. namespace Composer\Installer;
  15199. use Composer\Composer;
  15200. use Composer\IO\IOInterface;
  15201. use Composer\Repository\InstalledRepositoryInterface;
  15202. use Composer\Package\PackageInterface;
  15203. class PluginInstaller extends LibraryInstaller
  15204. {
  15205. private $installationManager;
  15206. public function __construct(IOInterface $io, Composer $composer)
  15207. {
  15208. parent::__construct($io, $composer, 'composer-plugin');
  15209. $this->installationManager = $composer->getInstallationManager();
  15210. }
  15211. public function supports($packageType)
  15212. {
  15213. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  15214. }
  15215. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  15216. {
  15217. $extra = $package->getExtra();
  15218. if (empty($extra['class'])) {
  15219. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  15220. }
  15221. parent::install($repo, $package);
  15222. try {
  15223. $this->composer->getPluginManager()->registerPackage($package, true);
  15224. } catch (\Exception $e) {
  15225. $this->io->writeError('Plugin installation failed, rolling back');
  15226. parent::uninstall($repo, $package);
  15227. throw $e;
  15228. }
  15229. }
  15230. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  15231. {
  15232. $extra = $target->getExtra();
  15233. if (empty($extra['class'])) {
  15234. throw new \UnexpectedValueException('Error while installing '.$target->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  15235. }
  15236. parent::update($repo, $initial, $target);
  15237. $this->composer->getPluginManager()->registerPackage($target, true);
  15238. }
  15239. }
  15240. <?php
  15241. namespace Composer\Installer;
  15242. use Composer\Package\PackageInterface;
  15243. use Composer\Downloader\DownloadManager;
  15244. use Composer\Repository\InstalledRepositoryInterface;
  15245. use Composer\Util\Filesystem;
  15246. class ProjectInstaller implements InstallerInterface
  15247. {
  15248. private $installPath;
  15249. private $downloadManager;
  15250. private $filesystem;
  15251. public function __construct($installPath, DownloadManager $dm)
  15252. {
  15253. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  15254. $this->downloadManager = $dm;
  15255. $this->filesystem = new Filesystem;
  15256. }
  15257. public function supports($packageType)
  15258. {
  15259. return true;
  15260. }
  15261. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  15262. {
  15263. return false;
  15264. }
  15265. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  15266. {
  15267. $installPath = $this->installPath;
  15268. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  15269. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  15270. }
  15271. if (!is_dir($installPath)) {
  15272. mkdir($installPath, 0777, true);
  15273. }
  15274. $this->downloadManager->download($package, $installPath);
  15275. }
  15276. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  15277. {
  15278. throw new \InvalidArgumentException("not supported");
  15279. }
  15280. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  15281. {
  15282. throw new \InvalidArgumentException("not supported");
  15283. }
  15284. public function getInstallPath(PackageInterface $package)
  15285. {
  15286. return $this->installPath;
  15287. }
  15288. }
  15289. <?php
  15290. namespace Composer\Installer;
  15291. use Composer\IO\IOInterface;
  15292. use Composer\Package\PackageInterface;
  15293. use Composer\Repository\RepositoryInterface;
  15294. use Symfony\Component\Console\Formatter\OutputFormatter;
  15295. class SuggestedPackagesReporter
  15296. {
  15297. protected $suggestedPackages = array();
  15298. private $io;
  15299. public function __construct(IOInterface $io)
  15300. {
  15301. $this->io = $io;
  15302. }
  15303. public function getPackages()
  15304. {
  15305. return $this->suggestedPackages;
  15306. }
  15307. public function addPackage($source, $target, $reason)
  15308. {
  15309. $this->suggestedPackages[] = array(
  15310. 'source' => $source,
  15311. 'target' => $target,
  15312. 'reason' => $reason,
  15313. );
  15314. return $this;
  15315. }
  15316. public function addSuggestionsFromPackage(PackageInterface $package)
  15317. {
  15318. $source = $package->getPrettyName();
  15319. foreach ($package->getSuggests() as $target => $reason) {
  15320. $this->addPackage(
  15321. $source,
  15322. $target,
  15323. $reason
  15324. );
  15325. }
  15326. return $this;
  15327. }
  15328. public function output(RepositoryInterface $installedRepo = null)
  15329. {
  15330. $suggestedPackages = $this->getPackages();
  15331. $installedPackages = array();
  15332. if (null !== $installedRepo && ! empty($suggestedPackages)) {
  15333. foreach ($installedRepo->getPackages() as $package) {
  15334. $installedPackages = array_merge(
  15335. $installedPackages,
  15336. $package->getNames()
  15337. );
  15338. }
  15339. }
  15340. foreach ($suggestedPackages as $suggestion) {
  15341. if (in_array($suggestion['target'], $installedPackages)) {
  15342. continue;
  15343. }
  15344. $this->io->writeError(sprintf(
  15345. '%s suggests installing %s%s',
  15346. $suggestion['source'],
  15347. $this->escapeOutput($suggestion['target']),
  15348. $this->escapeOutput('' !== $suggestion['reason'] ? ' ('.$suggestion['reason'].')' : '')
  15349. ));
  15350. }
  15351. return $this;
  15352. }
  15353. private function escapeOutput($string)
  15354. {
  15355. return OutputFormatter::escape(
  15356. $this->removeControlCharacters($string)
  15357. );
  15358. }
  15359. private function removeControlCharacters($string)
  15360. {
  15361. return preg_replace(
  15362. '/[[:cntrl:]]/',
  15363. '',
  15364. str_replace("\n", ' ', $string)
  15365. );
  15366. }
  15367. }
  15368. <?php
  15369. namespace Composer\Json;
  15370. use JsonSchema\Validator;
  15371. use Seld\JsonLint\JsonParser;
  15372. use Seld\JsonLint\ParsingException;
  15373. use Composer\Util\RemoteFilesystem;
  15374. use Composer\IO\IOInterface;
  15375. use Composer\Downloader\TransportException;
  15376. class JsonFile
  15377. {
  15378. const LAX_SCHEMA = 1;
  15379. const STRICT_SCHEMA = 2;
  15380. const JSON_UNESCAPED_SLASHES = 64;
  15381. const JSON_PRETTY_PRINT = 128;
  15382. const JSON_UNESCAPED_UNICODE = 256;
  15383. private $path;
  15384. private $rfs;
  15385. private $io;
  15386. public function __construct($path, RemoteFilesystem $rfs = null, IOInterface $io = null)
  15387. {
  15388. $this->path = $path;
  15389. if (null === $rfs && preg_match('{^https?://}i', $path)) {
  15390. throw new \InvalidArgumentException('http urls require a RemoteFilesystem instance to be passed');
  15391. }
  15392. $this->rfs = $rfs;
  15393. $this->io = $io;
  15394. }
  15395. public function getPath()
  15396. {
  15397. return $this->path;
  15398. }
  15399. public function exists()
  15400. {
  15401. return is_file($this->path);
  15402. }
  15403. public function read()
  15404. {
  15405. try {
  15406. if ($this->rfs) {
  15407. $json = $this->rfs->getContents($this->path, $this->path, false);
  15408. } else {
  15409. if ($this->io && $this->io->isDebug()) {
  15410. $this->io->writeError('Reading ' . $this->path);
  15411. }
  15412. $json = file_get_contents($this->path);
  15413. }
  15414. } catch (TransportException $e) {
  15415. throw new \RuntimeException($e->getMessage(), 0, $e);
  15416. } catch (\Exception $e) {
  15417. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  15418. }
  15419. return static::parseJson($json, $this->path);
  15420. }
  15421. public function write(array $hash, $options = 448)
  15422. {
  15423. $dir = dirname($this->path);
  15424. if (!is_dir($dir)) {
  15425. if (file_exists($dir)) {
  15426. throw new \UnexpectedValueException(
  15427. $dir.' exists and is not a directory.'
  15428. );
  15429. }
  15430. if (!@mkdir($dir, 0777, true)) {
  15431. throw new \UnexpectedValueException(
  15432. $dir.' does not exist and could not be created.'
  15433. );
  15434. }
  15435. }
  15436. $retries = 3;
  15437. while ($retries--) {
  15438. try {
  15439. file_put_contents($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  15440. break;
  15441. } catch (\Exception $e) {
  15442. if ($retries) {
  15443. usleep(500000);
  15444. continue;
  15445. }
  15446. throw $e;
  15447. }
  15448. }
  15449. }
  15450. public function validateSchema($schema = self::STRICT_SCHEMA)
  15451. {
  15452. $content = file_get_contents($this->path);
  15453. $data = json_decode($content);
  15454. if (null === $data && 'null' !== $content) {
  15455. self::validateSyntax($content, $this->path);
  15456. }
  15457. $schemaFile = __DIR__ . '/../../../res/composer-schema.json';
  15458. if (false === strpos($schemaFile, '://')) {
  15459. $schemaFile = 'file://' . $schemaFile;
  15460. }
  15461. $schemaData = (object) array('$ref' => $schemaFile);
  15462. if ($schema === self::LAX_SCHEMA) {
  15463. $schemaData->additionalProperties = true;
  15464. $schemaData->required = array();
  15465. }
  15466. $validator = new Validator();
  15467. $validator->check($data, $schemaData);
  15468. if (!$validator->isValid()) {
  15469. $errors = array();
  15470. foreach ((array) $validator->getErrors() as $error) {
  15471. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  15472. }
  15473. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  15474. }
  15475. return true;
  15476. }
  15477. public static function encode($data, $options = 448)
  15478. {
  15479. if (PHP_VERSION_ID >= 50400) {
  15480. $json = json_encode($data, $options);
  15481. if (false === $json) {
  15482. self::throwEncodeError(json_last_error());
  15483. }
  15484. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  15485. $json = preg_replace('/\[\s+\]/', '[]', $json);
  15486. $json = preg_replace('/\{\s+\}/', '{}', $json);
  15487. }
  15488. return $json;
  15489. }
  15490. $json = json_encode($data);
  15491. if (false === $json) {
  15492. self::throwEncodeError(json_last_error());
  15493. }
  15494. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  15495. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  15496. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  15497. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  15498. return $json;
  15499. }
  15500. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  15501. }
  15502. private static function throwEncodeError($code)
  15503. {
  15504. switch ($code) {
  15505. case JSON_ERROR_DEPTH:
  15506. $msg = 'Maximum stack depth exceeded';
  15507. break;
  15508. case JSON_ERROR_STATE_MISMATCH:
  15509. $msg = 'Underflow or the modes mismatch';
  15510. break;
  15511. case JSON_ERROR_CTRL_CHAR:
  15512. $msg = 'Unexpected control character found';
  15513. break;
  15514. case JSON_ERROR_UTF8:
  15515. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  15516. break;
  15517. default:
  15518. $msg = 'Unknown error';
  15519. }
  15520. throw new \RuntimeException('JSON encoding failed: '.$msg);
  15521. }
  15522. public static function parseJson($json, $file = null)
  15523. {
  15524. if (null === $json) {
  15525. return;
  15526. }
  15527. $data = json_decode($json, true);
  15528. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  15529. self::validateSyntax($json, $file);
  15530. }
  15531. return $data;
  15532. }
  15533. protected static function validateSyntax($json, $file = null)
  15534. {
  15535. $parser = new JsonParser();
  15536. $result = $parser->lint($json);
  15537. if (null === $result) {
  15538. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  15539. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  15540. }
  15541. return true;
  15542. }
  15543. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  15544. }
  15545. }
  15546. <?php
  15547. namespace Composer\Json;
  15548. class JsonFormatter
  15549. {
  15550. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  15551. {
  15552. $result = '';
  15553. $pos = 0;
  15554. $strLen = strlen($json);
  15555. $indentStr = ' ';
  15556. $newLine = "\n";
  15557. $outOfQuotes = true;
  15558. $buffer = '';
  15559. $noescape = true;
  15560. for ($i = 0; $i < $strLen; $i++) {
  15561. $char = substr($json, $i, 1);
  15562. if ('"' === $char && $noescape) {
  15563. $outOfQuotes = !$outOfQuotes;
  15564. }
  15565. if (!$outOfQuotes) {
  15566. $buffer .= $char;
  15567. $noescape = '\\' === $char ? !$noescape : true;
  15568. continue;
  15569. } elseif ('' !== $buffer) {
  15570. if ($unescapeSlashes) {
  15571. $buffer = str_replace('\\/', '/', $buffer);
  15572. }
  15573. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  15574. $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  15575. $l = strlen($match[1]);
  15576. if ($l % 2) {
  15577. $code = hexdec($match[2]);
  15578. if (0xD800 <= $code && 0xDFFF >= $code) {
  15579. return $match[0];
  15580. }
  15581. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  15582. pack('H*', $match[2]),
  15583. 'UTF-8',
  15584. 'UCS-2BE'
  15585. );
  15586. }
  15587. return $match[0];
  15588. }, $buffer);
  15589. }
  15590. $result .= $buffer.$char;
  15591. $buffer = '';
  15592. continue;
  15593. }
  15594. if (':' === $char) {
  15595. $char .= ' ';
  15596. } elseif ('}' === $char || ']' === $char) {
  15597. $pos--;
  15598. $prevChar = substr($json, $i - 1, 1);
  15599. if ('{' !== $prevChar && '[' !== $prevChar) {
  15600. $result .= $newLine;
  15601. for ($j = 0; $j < $pos; $j++) {
  15602. $result .= $indentStr;
  15603. }
  15604. } else {
  15605. $result = rtrim($result);
  15606. }
  15607. }
  15608. $result .= $char;
  15609. if (',' === $char || '{' === $char || '[' === $char) {
  15610. $result .= $newLine;
  15611. if ('{' === $char || '[' === $char) {
  15612. $pos++;
  15613. }
  15614. for ($j = 0; $j < $pos; $j++) {
  15615. $result .= $indentStr;
  15616. }
  15617. }
  15618. }
  15619. return $result;
  15620. }
  15621. }
  15622. <?php
  15623. namespace Composer\Json;
  15624. use Composer\Repository\PlatformRepository;
  15625. class JsonManipulator
  15626. {
  15627. private static $DEFINES = '(?(DEFINE)
  15628. (?<number> -? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)? )
  15629. (?<boolean> true | false | null )
  15630. (?<string> " ([^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9a-f]{4} )* " )
  15631. (?<array> \[ (?: (?&json) \s* (?: , (?&json) \s* )* )? \s* \] )
  15632. (?<pair> \s* (?&string) \s* : (?&json) \s* )
  15633. (?<object> \{ (?: (?&pair) (?: , (?&pair) )* )? \s* \} )
  15634. (?<json> \s* (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  15635. )';
  15636. private $contents;
  15637. private $newline;
  15638. private $indent;
  15639. public function __construct($contents)
  15640. {
  15641. $contents = trim($contents);
  15642. if ($contents === '') {
  15643. $contents = '{}';
  15644. }
  15645. if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
  15646. throw new \InvalidArgumentException('The json file must be an object ({})');
  15647. }
  15648. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  15649. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  15650. $this->detectIndenting();
  15651. }
  15652. public function getContents()
  15653. {
  15654. return $this->contents . $this->newline;
  15655. }
  15656. public function addLink($type, $package, $constraint, $sortPackages = false)
  15657. {
  15658. $decoded = JsonFile::parseJson($this->contents);
  15659. if (!isset($decoded[$type])) {
  15660. return $this->addMainKey($type, array($package => $constraint));
  15661. }
  15662. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  15663. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  15664. if (!$this->pregMatch($regex, $this->contents, $matches)) {
  15665. return false;
  15666. }
  15667. $links = $matches['value'];
  15668. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  15669. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  15670. if ($this->pregMatch($regex, $links, $packageMatches)) {
  15671. $existingPackage = $packageMatches['package'];
  15672. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  15673. $links = preg_replace_callback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  15674. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  15675. }, $links);
  15676. } else {
  15677. if ($this->pregMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  15678. $links = preg_replace(
  15679. '{'.preg_quote($match[1]).'$}',
  15680. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  15681. $links
  15682. );
  15683. } else {
  15684. $links = '{' . $this->newline .
  15685. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  15686. $this->indent . '}';
  15687. }
  15688. }
  15689. if (true === $sortPackages) {
  15690. $requirements = json_decode($links, true);
  15691. $this->sortPackages($requirements);
  15692. $links = $this->format($requirements);
  15693. }
  15694. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  15695. return true;
  15696. }
  15697. private function sortPackages(array &$packages = array())
  15698. {
  15699. $prefix = function ($requirement) {
  15700. if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $requirement)) {
  15701. return preg_replace(
  15702. array(
  15703. '/^php/',
  15704. '/^hhvm/',
  15705. '/^ext/',
  15706. '/^lib/',
  15707. '/^\D/',
  15708. ),
  15709. array(
  15710. '0-$0',
  15711. '1-$0',
  15712. '2-$0',
  15713. '3-$0',
  15714. '4-$0',
  15715. ),
  15716. $requirement
  15717. );
  15718. }
  15719. return '5-'.$requirement;
  15720. };
  15721. uksort($packages, function ($a, $b) use ($prefix) {
  15722. return strnatcmp($prefix($a), $prefix($b));
  15723. });
  15724. }
  15725. public function addRepository($name, $config)
  15726. {
  15727. return $this->addSubNode('repositories', $name, $config);
  15728. }
  15729. public function removeRepository($name)
  15730. {
  15731. return $this->removeSubNode('repositories', $name);
  15732. }
  15733. public function addConfigSetting($name, $value)
  15734. {
  15735. return $this->addSubNode('config', $name, $value);
  15736. }
  15737. public function removeConfigSetting($name)
  15738. {
  15739. return $this->removeSubNode('config', $name);
  15740. }
  15741. public function addProperty($name, $value)
  15742. {
  15743. if (substr($name, 0, 6) === 'extra.') {
  15744. return $this->addSubNode('extra', substr($name, 6), $value);
  15745. }
  15746. if (substr($name, 0, 8) === 'scripts.') {
  15747. return $this->addSubNode('scripts', substr($name, 8), $value);
  15748. }
  15749. return $this->addMainKey($name, $value);
  15750. }
  15751. public function removeProperty($name)
  15752. {
  15753. if (substr($name, 0, 6) === 'extra.') {
  15754. return $this->removeSubNode('extra', substr($name, 6));
  15755. }
  15756. if (substr($name, 0, 8) === 'scripts.') {
  15757. return $this->removeSubNode('scripts', substr($name, 8));
  15758. }
  15759. return $this->removeMainKey($name);
  15760. }
  15761. public function addSubNode($mainNode, $name, $value)
  15762. {
  15763. $decoded = JsonFile::parseJson($this->contents);
  15764. $subName = null;
  15765. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  15766. list($name, $subName) = explode('.', $name, 2);
  15767. }
  15768. if (!isset($decoded[$mainNode])) {
  15769. if ($subName !== null) {
  15770. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  15771. } else {
  15772. $this->addMainKey($mainNode, array($name => $value));
  15773. }
  15774. return true;
  15775. }
  15776. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  15777. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  15778. try {
  15779. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  15780. return false;
  15781. }
  15782. } catch (\RuntimeException $e) {
  15783. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  15784. return false;
  15785. }
  15786. throw $e;
  15787. }
  15788. $children = $match['content'];
  15789. if (!@json_decode($children)) {
  15790. return false;
  15791. }
  15792. $that = $this;
  15793. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  15794. if ($this->pregMatch($childRegex, $children, $matches)) {
  15795. $children = preg_replace_callback($childRegex, function ($matches) use ($subName, $value, $that) {
  15796. if ($subName !== null) {
  15797. $curVal = json_decode($matches['content'], true);
  15798. if (!is_array($curVal)) {
  15799. $curVal = array();
  15800. }
  15801. $curVal[$subName] = $value;
  15802. $value = $curVal;
  15803. }
  15804. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  15805. }, $children);
  15806. } else {
  15807. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  15808. $whitespace = '';
  15809. if (!empty($match['trailingspace'])) {
  15810. $whitespace = $match['trailingspace'];
  15811. }
  15812. if (!empty($match['content'])) {
  15813. if ($subName !== null) {
  15814. $value = array($subName => $value);
  15815. }
  15816. $children = preg_replace(
  15817. '#'.$whitespace.'}$#',
  15818. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  15819. $children
  15820. );
  15821. } else {
  15822. if ($subName !== null) {
  15823. $value = array($subName => $value);
  15824. }
  15825. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  15826. }
  15827. }
  15828. $this->contents = preg_replace_callback($nodeRegex, function ($m) use ($children) {
  15829. return $m['start'] . $children . $m['end'];
  15830. }, $this->contents);
  15831. return true;
  15832. }
  15833. public function removeSubNode($mainNode, $name)
  15834. {
  15835. $decoded = JsonFile::parseJson($this->contents);
  15836. if (empty($decoded[$mainNode])) {
  15837. return true;
  15838. }
  15839. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  15840. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  15841. try {
  15842. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  15843. return false;
  15844. }
  15845. } catch (\RuntimeException $e) {
  15846. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  15847. return false;
  15848. }
  15849. throw $e;
  15850. }
  15851. $children = $match['content'];
  15852. if (!@json_decode($children, true)) {
  15853. return false;
  15854. }
  15855. $subName = null;
  15856. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  15857. list($name, $subName) = explode('.', $name, 2);
  15858. }
  15859. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  15860. return true;
  15861. }
  15862. if ($this->pregMatch('{"'.preg_quote($name).'"\s*:}i', $children)) {
  15863. if (preg_match_all('{'.self::$DEFINES.'"'.preg_quote($name).'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  15864. $bestMatch = '';
  15865. foreach ($matches[0] as $match) {
  15866. if (strlen($bestMatch) < strlen($match)) {
  15867. $bestMatch = $match;
  15868. }
  15869. }
  15870. $childrenClean = preg_replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  15871. if (1 !== $count) {
  15872. $childrenClean = preg_replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  15873. if (1 !== $count) {
  15874. return false;
  15875. }
  15876. }
  15877. }
  15878. } else {
  15879. $childrenClean = $children;
  15880. }
  15881. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  15882. if (empty($match['content'])) {
  15883. $newline = $this->newline;
  15884. $indent = $this->indent;
  15885. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($indent, $newline) {
  15886. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  15887. }, $this->contents);
  15888. if ($subName !== null) {
  15889. $curVal = json_decode($children, true);
  15890. unset($curVal[$name][$subName]);
  15891. $this->addSubNode($mainNode, $name, $curVal[$name]);
  15892. }
  15893. return true;
  15894. }
  15895. $that = $this;
  15896. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  15897. if ($subName !== null) {
  15898. $curVal = json_decode($matches['content'], true);
  15899. unset($curVal[$name][$subName]);
  15900. $childrenClean = $that->format($curVal, 0);
  15901. }
  15902. return $matches['start'] . $childrenClean . $matches['end'];
  15903. }, $this->contents);
  15904. return true;
  15905. }
  15906. public function addMainKey($key, $content)
  15907. {
  15908. $decoded = JsonFile::parseJson($this->contents);
  15909. $content = $this->format($content);
  15910. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  15911. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  15912. if (isset($decoded[$key]) && $this->pregMatch($regex, $this->contents, $matches)) {
  15913. if (!@json_decode('{'.$matches['key'].'}')) {
  15914. return false;
  15915. }
  15916. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  15917. return true;
  15918. }
  15919. if ($this->pregMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  15920. $this->contents = preg_replace(
  15921. '#'.$match[1].'\}$#',
  15922. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  15923. $this->contents
  15924. );
  15925. return true;
  15926. }
  15927. $this->contents = preg_replace(
  15928. '#\}$#',
  15929. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  15930. $this->contents
  15931. );
  15932. return true;
  15933. }
  15934. public function removeMainKey($key)
  15935. {
  15936. $decoded = JsonFile::parseJson($this->contents);
  15937. if (!array_key_exists($key, $decoded)) {
  15938. return true;
  15939. }
  15940. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  15941. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  15942. if ($this->pregMatch($regex, $this->contents, $matches)) {
  15943. if (!@json_decode('{'.$matches['removal'].'}')) {
  15944. return false;
  15945. }
  15946. if (preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
  15947. $matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  15948. }
  15949. $this->contents = $matches['start'] . $matches['end'];
  15950. if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
  15951. $this->contents = "{\n}";
  15952. }
  15953. return true;
  15954. }
  15955. return false;
  15956. }
  15957. public function format($data, $depth = 0)
  15958. {
  15959. if (is_array($data)) {
  15960. reset($data);
  15961. if (is_numeric(key($data))) {
  15962. foreach ($data as $key => $val) {
  15963. $data[$key] = $this->format($val, $depth + 1);
  15964. }
  15965. return '['.implode(', ', $data).']';
  15966. }
  15967. $out = '{' . $this->newline;
  15968. $elems = array();
  15969. foreach ($data as $key => $val) {
  15970. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  15971. }
  15972. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  15973. }
  15974. return JsonFile::encode($data);
  15975. }
  15976. protected function detectIndenting()
  15977. {
  15978. if ($this->pregMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  15979. $this->indent = $match[1];
  15980. } else {
  15981. $this->indent = ' ';
  15982. }
  15983. }
  15984. protected function pregMatch($re, $str, &$matches = array())
  15985. {
  15986. $count = preg_match($re, $str, $matches);
  15987. if ($count === false) {
  15988. switch (preg_last_error()) {
  15989. case PREG_NO_ERROR:
  15990. throw new \RuntimeException('Failed to execute regex: PREG_NO_ERROR', PREG_NO_ERROR);
  15991. case PREG_INTERNAL_ERROR:
  15992. throw new \RuntimeException('Failed to execute regex: PREG_INTERNAL_ERROR', PREG_INTERNAL_ERROR);
  15993. case PREG_BACKTRACK_LIMIT_ERROR:
  15994. throw new \RuntimeException('Failed to execute regex: PREG_BACKTRACK_LIMIT_ERROR', PREG_BACKTRACK_LIMIT_ERROR);
  15995. case PREG_RECURSION_LIMIT_ERROR:
  15996. throw new \RuntimeException('Failed to execute regex: PREG_RECURSION_LIMIT_ERROR', PREG_RECURSION_LIMIT_ERROR);
  15997. case PREG_BAD_UTF8_ERROR:
  15998. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_ERROR);
  15999. case PREG_BAD_UTF8_OFFSET_ERROR:
  16000. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_OFFSET_ERROR', PREG_BAD_UTF8_OFFSET_ERROR);
  16001. case 6:
  16002. if (PHP_VERSION_ID > 70000) {
  16003. throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6);
  16004. }
  16005. default:
  16006. throw new \RuntimeException('Failed to execute regex: Unknown error');
  16007. }
  16008. }
  16009. return $count;
  16010. }
  16011. }
  16012. <?php
  16013. namespace Composer\Json;
  16014. use Exception;
  16015. class JsonValidationException extends Exception
  16016. {
  16017. protected $errors;
  16018. public function __construct($message, $errors = array(), Exception $previous = null)
  16019. {
  16020. $this->errors = $errors;
  16021. parent::__construct($message, 0, $previous);
  16022. }
  16023. public function getErrors()
  16024. {
  16025. return $this->errors;
  16026. }
  16027. }
  16028. <?php
  16029. namespace Composer\Package;
  16030. use Composer\Semver\Constraint\Constraint;
  16031. use Composer\Package\Version\VersionParser;
  16032. class AliasPackage extends BasePackage implements CompletePackageInterface
  16033. {
  16034. protected $version;
  16035. protected $prettyVersion;
  16036. protected $dev;
  16037. protected $rootPackageAlias = false;
  16038. protected $stability;
  16039. protected $aliasOf;
  16040. protected $requires;
  16041. protected $devRequires;
  16042. protected $conflicts;
  16043. protected $provides;
  16044. protected $replaces;
  16045. public function __construct(PackageInterface $aliasOf, $version, $prettyVersion)
  16046. {
  16047. parent::__construct($aliasOf->getName());
  16048. $this->version = $version;
  16049. $this->prettyVersion = $prettyVersion;
  16050. $this->aliasOf = $aliasOf;
  16051. $this->stability = VersionParser::parseStability($version);
  16052. $this->dev = $this->stability === 'dev';
  16053. foreach (array('requires', 'devRequires', 'conflicts', 'provides', 'replaces') as $type) {
  16054. $links = $aliasOf->{'get' . ucfirst($type)}();
  16055. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  16056. }
  16057. }
  16058. public function getAliasOf()
  16059. {
  16060. return $this->aliasOf;
  16061. }
  16062. public function getVersion()
  16063. {
  16064. return $this->version;
  16065. }
  16066. public function getStability()
  16067. {
  16068. return $this->stability;
  16069. }
  16070. public function getPrettyVersion()
  16071. {
  16072. return $this->prettyVersion;
  16073. }
  16074. public function isDev()
  16075. {
  16076. return $this->dev;
  16077. }
  16078. public function getRequires()
  16079. {
  16080. return $this->requires;
  16081. }
  16082. public function getConflicts()
  16083. {
  16084. return $this->conflicts;
  16085. }
  16086. public function getProvides()
  16087. {
  16088. return $this->provides;
  16089. }
  16090. public function getReplaces()
  16091. {
  16092. return $this->replaces;
  16093. }
  16094. public function getDevRequires()
  16095. {
  16096. return $this->devRequires;
  16097. }
  16098. public function setRootPackageAlias($value)
  16099. {
  16100. return $this->rootPackageAlias = $value;
  16101. }
  16102. public function isRootPackageAlias()
  16103. {
  16104. return $this->rootPackageAlias;
  16105. }
  16106. protected function replaceSelfVersionDependencies(array $links, $linkType)
  16107. {
  16108. if (in_array($linkType, array('conflicts', 'provides', 'replaces'), true)) {
  16109. $newLinks = array();
  16110. foreach ($links as $link) {
  16111. if ('self.version' === $link->getPrettyConstraint()) {
  16112. $newLinks[] = new Link($link->getSource(), $link->getTarget(), new Constraint('=', $this->version), $linkType, $this->prettyVersion);
  16113. }
  16114. }
  16115. $links = array_merge($links, $newLinks);
  16116. } else {
  16117. foreach ($links as $index => $link) {
  16118. if ('self.version' === $link->getPrettyConstraint()) {
  16119. $links[$index] = new Link($link->getSource(), $link->getTarget(), new Constraint('=', $this->version), $linkType, $this->prettyVersion);
  16120. }
  16121. }
  16122. }
  16123. return $links;
  16124. }
  16125. public function getType()
  16126. {
  16127. return $this->aliasOf->getType();
  16128. }
  16129. public function getTargetDir()
  16130. {
  16131. return $this->aliasOf->getTargetDir();
  16132. }
  16133. public function getExtra()
  16134. {
  16135. return $this->aliasOf->getExtra();
  16136. }
  16137. public function setInstallationSource($type)
  16138. {
  16139. $this->aliasOf->setInstallationSource($type);
  16140. }
  16141. public function getInstallationSource()
  16142. {
  16143. return $this->aliasOf->getInstallationSource();
  16144. }
  16145. public function getSourceType()
  16146. {
  16147. return $this->aliasOf->getSourceType();
  16148. }
  16149. public function getSourceUrl()
  16150. {
  16151. return $this->aliasOf->getSourceUrl();
  16152. }
  16153. public function getSourceUrls()
  16154. {
  16155. return $this->aliasOf->getSourceUrls();
  16156. }
  16157. public function getSourceReference()
  16158. {
  16159. return $this->aliasOf->getSourceReference();
  16160. }
  16161. public function setSourceReference($reference)
  16162. {
  16163. return $this->aliasOf->setSourceReference($reference);
  16164. }
  16165. public function setSourceMirrors($mirrors)
  16166. {
  16167. return $this->aliasOf->setSourceMirrors($mirrors);
  16168. }
  16169. public function getSourceMirrors()
  16170. {
  16171. return $this->aliasOf->getSourceMirrors();
  16172. }
  16173. public function getDistType()
  16174. {
  16175. return $this->aliasOf->getDistType();
  16176. }
  16177. public function getDistUrl()
  16178. {
  16179. return $this->aliasOf->getDistUrl();
  16180. }
  16181. public function getDistUrls()
  16182. {
  16183. return $this->aliasOf->getDistUrls();
  16184. }
  16185. public function getDistReference()
  16186. {
  16187. return $this->aliasOf->getDistReference();
  16188. }
  16189. public function setDistReference($reference)
  16190. {
  16191. return $this->aliasOf->setDistReference($reference);
  16192. }
  16193. public function getDistSha1Checksum()
  16194. {
  16195. return $this->aliasOf->getDistSha1Checksum();
  16196. }
  16197. public function setTransportOptions(array $options)
  16198. {
  16199. return $this->aliasOf->setTransportOptions($options);
  16200. }
  16201. public function getTransportOptions()
  16202. {
  16203. return $this->aliasOf->getTransportOptions();
  16204. }
  16205. public function setDistMirrors($mirrors)
  16206. {
  16207. return $this->aliasOf->setDistMirrors($mirrors);
  16208. }
  16209. public function getDistMirrors()
  16210. {
  16211. return $this->aliasOf->getDistMirrors();
  16212. }
  16213. public function getScripts()
  16214. {
  16215. return $this->aliasOf->getScripts();
  16216. }
  16217. public function getLicense()
  16218. {
  16219. return $this->aliasOf->getLicense();
  16220. }
  16221. public function getAutoload()
  16222. {
  16223. return $this->aliasOf->getAutoload();
  16224. }
  16225. public function getDevAutoload()
  16226. {
  16227. return $this->aliasOf->getDevAutoload();
  16228. }
  16229. public function getIncludePaths()
  16230. {
  16231. return $this->aliasOf->getIncludePaths();
  16232. }
  16233. public function getRepositories()
  16234. {
  16235. return $this->aliasOf->getRepositories();
  16236. }
  16237. public function getReleaseDate()
  16238. {
  16239. return $this->aliasOf->getReleaseDate();
  16240. }
  16241. public function getBinaries()
  16242. {
  16243. return $this->aliasOf->getBinaries();
  16244. }
  16245. public function getKeywords()
  16246. {
  16247. return $this->aliasOf->getKeywords();
  16248. }
  16249. public function getDescription()
  16250. {
  16251. return $this->aliasOf->getDescription();
  16252. }
  16253. public function getHomepage()
  16254. {
  16255. return $this->aliasOf->getHomepage();
  16256. }
  16257. public function getSuggests()
  16258. {
  16259. return $this->aliasOf->getSuggests();
  16260. }
  16261. public function getAuthors()
  16262. {
  16263. return $this->aliasOf->getAuthors();
  16264. }
  16265. public function getSupport()
  16266. {
  16267. return $this->aliasOf->getSupport();
  16268. }
  16269. public function getNotificationUrl()
  16270. {
  16271. return $this->aliasOf->getNotificationUrl();
  16272. }
  16273. public function getArchiveExcludes()
  16274. {
  16275. return $this->aliasOf->getArchiveExcludes();
  16276. }
  16277. public function isAbandoned()
  16278. {
  16279. return $this->aliasOf->isAbandoned();
  16280. }
  16281. public function getReplacementPackage()
  16282. {
  16283. return $this->aliasOf->getReplacementPackage();
  16284. }
  16285. public function __toString()
  16286. {
  16287. return parent::__toString().' (alias of '.$this->aliasOf->getVersion().')';
  16288. }
  16289. }
  16290. <?php
  16291. namespace Composer\Package\Archiver;
  16292. use FilterIterator;
  16293. use PharData;
  16294. class ArchivableFilesFilter extends FilterIterator
  16295. {
  16296. private $dirs = array();
  16297. public function accept()
  16298. {
  16299. $file = $this->getInnerIterator()->current();
  16300. if ($file->isDir()) {
  16301. $this->dirs[] = (string) $file;
  16302. return false;
  16303. }
  16304. return true;
  16305. }
  16306. public function addEmptyDir(PharData $phar, $sources)
  16307. {
  16308. foreach ($this->dirs as $filepath) {
  16309. $localname = str_replace($sources . "/", '', $filepath);
  16310. $phar->addEmptyDir($localname);
  16311. }
  16312. }
  16313. }
  16314. <?php
  16315. namespace Composer\Package\Archiver;
  16316. use Composer\Util\Filesystem;
  16317. use FilesystemIterator;
  16318. use Symfony\Component\Finder\Finder;
  16319. use Symfony\Component\Finder\SplFileInfo;
  16320. class ArchivableFilesFinder extends \FilterIterator
  16321. {
  16322. protected $finder;
  16323. public function __construct($sources, array $excludes, $ignoreFilters = false)
  16324. {
  16325. $fs = new Filesystem();
  16326. $sources = $fs->normalizePath($sources);
  16327. if ($ignoreFilters) {
  16328. $filters = array();
  16329. } else {
  16330. $filters = array(
  16331. new HgExcludeFilter($sources),
  16332. new GitExcludeFilter($sources),
  16333. new ComposerExcludeFilter($sources, $excludes),
  16334. );
  16335. }
  16336. $this->finder = new Finder();
  16337. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  16338. if ($file->isLink() && strpos($file->getLinkTarget(), $sources) !== 0) {
  16339. return false;
  16340. }
  16341. $relativePath = preg_replace(
  16342. '#^'.preg_quote($sources, '#').'#',
  16343. '',
  16344. $fs->normalizePath($file->getRealPath())
  16345. );
  16346. $exclude = false;
  16347. foreach ($filters as $filter) {
  16348. $exclude = $filter->filter($relativePath, $exclude);
  16349. }
  16350. return !$exclude;
  16351. };
  16352. if (method_exists($filter, 'bindTo')) {
  16353. $filter = $filter->bindTo(null);
  16354. }
  16355. $this->finder
  16356. ->in($sources)
  16357. ->filter($filter)
  16358. ->ignoreVCS(true)
  16359. ->ignoreDotFiles(false);
  16360. parent::__construct($this->finder->getIterator());
  16361. }
  16362. public function accept()
  16363. {
  16364. $current = $this->getInnerIterator()->current();
  16365. if (!$current->isDir()) {
  16366. return true;
  16367. }
  16368. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  16369. return !$iterator->valid();
  16370. }
  16371. }
  16372. <?php
  16373. namespace Composer\Package\Archiver;
  16374. use Composer\Downloader\DownloadManager;
  16375. use Composer\Package\PackageInterface;
  16376. use Composer\Package\RootPackageInterface;
  16377. use Composer\Util\Filesystem;
  16378. use Composer\Json\JsonFile;
  16379. class ArchiveManager
  16380. {
  16381. protected $downloadManager;
  16382. protected $archivers = array();
  16383. protected $overwriteFiles = true;
  16384. public function __construct(DownloadManager $downloadManager)
  16385. {
  16386. $this->downloadManager = $downloadManager;
  16387. }
  16388. public function addArchiver(ArchiverInterface $archiver)
  16389. {
  16390. $this->archivers[] = $archiver;
  16391. }
  16392. public function setOverwriteFiles($overwriteFiles)
  16393. {
  16394. $this->overwriteFiles = $overwriteFiles;
  16395. return $this;
  16396. }
  16397. public function getPackageFilename(PackageInterface $package)
  16398. {
  16399. $nameParts = array(preg_replace('#[^a-z0-9-_]#i', '-', $package->getName()));
  16400. if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  16401. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  16402. } else {
  16403. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  16404. }
  16405. if ($package->getSourceReference()) {
  16406. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  16407. }
  16408. $name = implode('-', array_filter($nameParts, function ($p) {
  16409. return !empty($p);
  16410. }));
  16411. return str_replace('/', '-', $name);
  16412. }
  16413. public function archive(PackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  16414. {
  16415. if (empty($format)) {
  16416. throw new \InvalidArgumentException('Format must be specified');
  16417. }
  16418. $usableArchiver = null;
  16419. foreach ($this->archivers as $archiver) {
  16420. if ($archiver->supports($format, $package->getSourceType())) {
  16421. $usableArchiver = $archiver;
  16422. break;
  16423. }
  16424. }
  16425. if (null === $usableArchiver) {
  16426. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  16427. }
  16428. $filesystem = new Filesystem();
  16429. if (null === $fileName) {
  16430. $packageName = $this->getPackageFilename($package);
  16431. } else {
  16432. $packageName = $fileName;
  16433. }
  16434. $filesystem->ensureDirectoryExists($targetDir);
  16435. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  16436. $filesystem->ensureDirectoryExists(dirname($target));
  16437. if (!$this->overwriteFiles && file_exists($target)) {
  16438. return $target;
  16439. }
  16440. if ($package instanceof RootPackageInterface) {
  16441. $sourcePath = realpath('.');
  16442. } else {
  16443. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  16444. $filesystem->ensureDirectoryExists($sourcePath);
  16445. $this->downloadManager->download($package, $sourcePath);
  16446. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  16447. $jsonFile = new JsonFile($composerJsonPath);
  16448. $jsonData = $jsonFile->read();
  16449. if (!empty($jsonData['archive']['exclude'])) {
  16450. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  16451. }
  16452. }
  16453. }
  16454. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  16455. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  16456. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  16457. $filesystem->rename($archivePath, $target);
  16458. if (!$package instanceof RootPackageInterface) {
  16459. $filesystem->removeDirectory($sourcePath);
  16460. }
  16461. $filesystem->remove($tempTarget);
  16462. return $target;
  16463. }
  16464. }
  16465. <?php
  16466. namespace Composer\Package\Archiver;
  16467. interface ArchiverInterface
  16468. {
  16469. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  16470. public function supports($format, $sourceType);
  16471. }
  16472. <?php
  16473. namespace Composer\Package\Archiver;
  16474. use Symfony\Component\Finder;
  16475. abstract class BaseExcludeFilter
  16476. {
  16477. protected $sourcePath;
  16478. protected $excludePatterns;
  16479. public function __construct($sourcePath)
  16480. {
  16481. $this->sourcePath = $sourcePath;
  16482. $this->excludePatterns = array();
  16483. }
  16484. public function filter($relativePath, $exclude)
  16485. {
  16486. foreach ($this->excludePatterns as $patternData) {
  16487. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  16488. if ($stripLeadingSlash) {
  16489. $path = substr($relativePath, 1);
  16490. } else {
  16491. $path = $relativePath;
  16492. }
  16493. if (preg_match($pattern, $path)) {
  16494. $exclude = !$negate;
  16495. }
  16496. }
  16497. return $exclude;
  16498. }
  16499. protected function parseLines(array $lines, $lineParser)
  16500. {
  16501. return array_filter(
  16502. array_map(
  16503. function ($line) use ($lineParser) {
  16504. $line = trim($line);
  16505. if (!$line || 0 === strpos($line, '#')) {
  16506. return null;
  16507. }
  16508. return call_user_func($lineParser, $line);
  16509. },
  16510. $lines
  16511. ),
  16512. function ($pattern) {
  16513. return $pattern !== null;
  16514. }
  16515. );
  16516. }
  16517. protected function generatePatterns($rules)
  16518. {
  16519. $patterns = array();
  16520. foreach ($rules as $rule) {
  16521. $patterns[] = $this->generatePattern($rule);
  16522. }
  16523. return $patterns;
  16524. }
  16525. protected function generatePattern($rule)
  16526. {
  16527. $negate = false;
  16528. $pattern = '{';
  16529. if (strlen($rule) && $rule[0] === '!') {
  16530. $negate = true;
  16531. $rule = substr($rule, 1);
  16532. }
  16533. if (strlen($rule) && $rule[0] === '/') {
  16534. $pattern .= '^/';
  16535. $rule = substr($rule, 1);
  16536. } elseif (strlen($rule) - 1 === strpos($rule, '/')) {
  16537. $pattern .= '/';
  16538. $rule = substr($rule, 0, -1);
  16539. } elseif (false === strpos($rule, '/')) {
  16540. $pattern .= '/';
  16541. }
  16542. $pattern .= substr(Finder\Glob::toRegex($rule), 2, -2) . '(?=$|/)';
  16543. return array($pattern . '}', $negate, false);
  16544. }
  16545. }
  16546. <?php
  16547. namespace Composer\Package\Archiver;
  16548. class ComposerExcludeFilter extends BaseExcludeFilter
  16549. {
  16550. public function __construct($sourcePath, array $excludeRules)
  16551. {
  16552. parent::__construct($sourcePath);
  16553. $this->excludePatterns = $this->generatePatterns($excludeRules);
  16554. }
  16555. }
  16556. <?php
  16557. namespace Composer\Package\Archiver;
  16558. class GitExcludeFilter extends BaseExcludeFilter
  16559. {
  16560. public function __construct($sourcePath)
  16561. {
  16562. parent::__construct($sourcePath);
  16563. if (file_exists($sourcePath.'/.gitignore')) {
  16564. $this->excludePatterns = $this->parseLines(
  16565. file($sourcePath.'/.gitignore'),
  16566. array($this, 'parseGitIgnoreLine')
  16567. );
  16568. }
  16569. if (file_exists($sourcePath.'/.gitattributes')) {
  16570. $this->excludePatterns = array_merge(
  16571. $this->excludePatterns,
  16572. $this->parseLines(
  16573. file($sourcePath.'/.gitattributes'),
  16574. array($this, 'parseGitAttributesLine')
  16575. )
  16576. );
  16577. }
  16578. }
  16579. public function parseGitIgnoreLine($line)
  16580. {
  16581. return $this->generatePattern($line);
  16582. }
  16583. public function parseGitAttributesLine($line)
  16584. {
  16585. $parts = preg_split('#\s+#', $line);
  16586. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  16587. return $this->generatePattern($parts[0]);
  16588. }
  16589. return null;
  16590. }
  16591. }
  16592. <?php
  16593. namespace Composer\Package\Archiver;
  16594. use Symfony\Component\Finder;
  16595. class HgExcludeFilter extends BaseExcludeFilter
  16596. {
  16597. const HG_IGNORE_REGEX = 1;
  16598. const HG_IGNORE_GLOB = 2;
  16599. protected $patternMode;
  16600. public function __construct($sourcePath)
  16601. {
  16602. parent::__construct($sourcePath);
  16603. $this->patternMode = self::HG_IGNORE_REGEX;
  16604. if (file_exists($sourcePath.'/.hgignore')) {
  16605. $this->excludePatterns = $this->parseLines(
  16606. file($sourcePath.'/.hgignore'),
  16607. array($this, 'parseHgIgnoreLine')
  16608. );
  16609. }
  16610. }
  16611. public function parseHgIgnoreLine($line)
  16612. {
  16613. if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)) {
  16614. if ($matches[1] === 'glob') {
  16615. $this->patternMode = self::HG_IGNORE_GLOB;
  16616. } else {
  16617. $this->patternMode = self::HG_IGNORE_REGEX;
  16618. }
  16619. return null;
  16620. }
  16621. if ($this->patternMode == self::HG_IGNORE_GLOB) {
  16622. return $this->patternFromGlob($line);
  16623. }
  16624. return $this->patternFromRegex($line);
  16625. }
  16626. protected function patternFromGlob($line)
  16627. {
  16628. $pattern = '#'.substr(Finder\Glob::toRegex($line), 2, -1).'#';
  16629. $pattern = str_replace('[^/]*', '.*', $pattern);
  16630. return array($pattern, false, true);
  16631. }
  16632. public function patternFromRegex($line)
  16633. {
  16634. $pattern = '#'.preg_replace('/((?:\\\\\\\\)*)(\\\\?)#/', '\1\2\2\\#', $line).'#';
  16635. return array($pattern, false, true);
  16636. }
  16637. }
  16638. <?php
  16639. namespace Composer\Package\Archiver;
  16640. class PharArchiver implements ArchiverInterface
  16641. {
  16642. protected static $formats = array(
  16643. 'zip' => \Phar::ZIP,
  16644. 'tar' => \Phar::TAR,
  16645. 'tar.gz' => \Phar::TAR,
  16646. 'tar.bz2' => \Phar::TAR,
  16647. );
  16648. protected static $compressFormats = array(
  16649. 'tar.gz' => \Phar::GZ,
  16650. 'tar.bz2' => \Phar::BZ2,
  16651. );
  16652. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  16653. {
  16654. $sources = realpath($sources);
  16655. if (file_exists($target)) {
  16656. unlink($target);
  16657. }
  16658. try {
  16659. $filename = substr($target, 0, strrpos($target, $format) - 1);
  16660. if (isset(static::$compressFormats[$format])) {
  16661. $target = $filename . '.tar';
  16662. }
  16663. $phar = new \PharData($target, null, null, static::$formats[$format]);
  16664. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  16665. $filesOnly = new ArchivableFilesFilter($files);
  16666. $phar->buildFromIterator($filesOnly, $sources);
  16667. $filesOnly->addEmptyDir($phar, $sources);
  16668. if (isset(static::$compressFormats[$format])) {
  16669. if (!$phar->canCompress(static::$compressFormats[$format])) {
  16670. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  16671. }
  16672. unlink($target);
  16673. $phar->compress(static::$compressFormats[$format]);
  16674. $target = $filename . '.' . $format;
  16675. }
  16676. return $target;
  16677. } catch (\UnexpectedValueException $e) {
  16678. $message = sprintf(
  16679. "Could not create archive '%s' from '%s': %s",
  16680. $target,
  16681. $sources,
  16682. $e->getMessage()
  16683. );
  16684. throw new \RuntimeException($message, $e->getCode(), $e);
  16685. }
  16686. }
  16687. public function supports($format, $sourceType)
  16688. {
  16689. return isset(static::$formats[$format]);
  16690. }
  16691. }
  16692. <?php
  16693. namespace Composer\Package\Archiver;
  16694. use ZipArchive;
  16695. use Composer\Util\Filesystem;
  16696. class ZipArchiver implements ArchiverInterface
  16697. {
  16698. protected static $formats = array(
  16699. 'zip' => 1,
  16700. );
  16701. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  16702. {
  16703. $fs = new Filesystem();
  16704. $sources = $fs->normalizePath($sources);
  16705. $zip = new ZipArchive();
  16706. $res = $zip->open($target, ZipArchive::CREATE);
  16707. if ($res === true) {
  16708. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  16709. foreach ($files as $file) {
  16710. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  16711. $localname = str_replace($sources.'/', '', $filepath);
  16712. if ($file->isDir()) {
  16713. $zip->addEmptyDir($localname);
  16714. } else {
  16715. $zip->addFile($filepath, $localname);
  16716. }
  16717. }
  16718. if ($zip->close()) {
  16719. return $target;
  16720. }
  16721. }
  16722. $message = sprintf(
  16723. "Could not create archive '%s' from '%s': %s",
  16724. $target,
  16725. $sources,
  16726. $zip->getStatusString()
  16727. );
  16728. throw new \RuntimeException($message);
  16729. }
  16730. public function supports($format, $sourceType)
  16731. {
  16732. return isset(static::$formats[$format]) && $this->compressionAvailable();
  16733. }
  16734. private function compressionAvailable()
  16735. {
  16736. return class_exists('ZipArchive');
  16737. }
  16738. }
  16739. <?php
  16740. namespace Composer\Package;
  16741. use Composer\Repository\RepositoryInterface;
  16742. use Composer\Repository\PlatformRepository;
  16743. abstract class BasePackage implements PackageInterface
  16744. {
  16745. public static $supportedLinkTypes = array(
  16746. 'require' => array('description' => 'requires', 'method' => 'requires'),
  16747. 'conflict' => array('description' => 'conflicts', 'method' => 'conflicts'),
  16748. 'provide' => array('description' => 'provides', 'method' => 'provides'),
  16749. 'replace' => array('description' => 'replaces', 'method' => 'replaces'),
  16750. 'require-dev' => array('description' => 'requires (for development)', 'method' => 'devRequires'),
  16751. );
  16752. const STABILITY_STABLE = 0;
  16753. const STABILITY_RC = 5;
  16754. const STABILITY_BETA = 10;
  16755. const STABILITY_ALPHA = 15;
  16756. const STABILITY_DEV = 20;
  16757. public static $stabilities = array(
  16758. 'stable' => self::STABILITY_STABLE,
  16759. 'RC' => self::STABILITY_RC,
  16760. 'beta' => self::STABILITY_BETA,
  16761. 'alpha' => self::STABILITY_ALPHA,
  16762. 'dev' => self::STABILITY_DEV,
  16763. );
  16764. public $id;
  16765. protected $name;
  16766. protected $prettyName;
  16767. protected $repository;
  16768. protected $transportOptions = array();
  16769. public function __construct($name)
  16770. {
  16771. $this->prettyName = $name;
  16772. $this->name = strtolower($name);
  16773. $this->id = -1;
  16774. }
  16775. public function getName()
  16776. {
  16777. return $this->name;
  16778. }
  16779. public function getPrettyName()
  16780. {
  16781. return $this->prettyName;
  16782. }
  16783. public function getNames()
  16784. {
  16785. $names = array(
  16786. $this->getName() => true,
  16787. );
  16788. foreach ($this->getProvides() as $link) {
  16789. $names[$link->getTarget()] = true;
  16790. }
  16791. foreach ($this->getReplaces() as $link) {
  16792. $names[$link->getTarget()] = true;
  16793. }
  16794. return array_keys($names);
  16795. }
  16796. public function setId($id)
  16797. {
  16798. $this->id = $id;
  16799. }
  16800. public function getId()
  16801. {
  16802. return $this->id;
  16803. }
  16804. public function setRepository(RepositoryInterface $repository)
  16805. {
  16806. if ($this->repository && $repository !== $this->repository) {
  16807. throw new \LogicException('A package can only be added to one repository');
  16808. }
  16809. $this->repository = $repository;
  16810. }
  16811. public function getRepository()
  16812. {
  16813. return $this->repository;
  16814. }
  16815. public function getTransportOptions()
  16816. {
  16817. return $this->transportOptions;
  16818. }
  16819. public function setTransportOptions(array $options)
  16820. {
  16821. $this->transportOptions = $options;
  16822. }
  16823. public function isPlatform()
  16824. {
  16825. return $this->getRepository() instanceof PlatformRepository;
  16826. }
  16827. public function getUniqueName()
  16828. {
  16829. return $this->getName().'-'.$this->getVersion();
  16830. }
  16831. public function equals(PackageInterface $package)
  16832. {
  16833. $self = $this;
  16834. if ($this instanceof AliasPackage) {
  16835. $self = $this->getAliasOf();
  16836. }
  16837. if ($package instanceof AliasPackage) {
  16838. $package = $package->getAliasOf();
  16839. }
  16840. return $package === $self;
  16841. }
  16842. public function __toString()
  16843. {
  16844. return $this->getUniqueName();
  16845. }
  16846. public function getPrettyString()
  16847. {
  16848. return $this->getPrettyName().' '.$this->getPrettyVersion();
  16849. }
  16850. public function getFullPrettyVersion($truncate = true)
  16851. {
  16852. if (!$this->isDev() || !in_array($this->getSourceType(), array('hg', 'git'))) {
  16853. return $this->getPrettyVersion();
  16854. }
  16855. if ($truncate && strlen($this->getSourceReference()) === 40) {
  16856. return $this->getPrettyVersion() . ' ' . substr($this->getSourceReference(), 0, 7);
  16857. }
  16858. return $this->getPrettyVersion() . ' ' . $this->getSourceReference();
  16859. }
  16860. public function getStabilityPriority()
  16861. {
  16862. return self::$stabilities[$this->getStability()];
  16863. }
  16864. public function __clone()
  16865. {
  16866. $this->repository = null;
  16867. $this->id = -1;
  16868. }
  16869. public static function packageNameToRegexp($whiteListedPattern)
  16870. {
  16871. $cleanedWhiteListedPattern = str_replace('\\*', '.*', preg_quote($whiteListedPattern));
  16872. return "{^" . $cleanedWhiteListedPattern . "$}i";
  16873. }
  16874. }
  16875. <?php
  16876. namespace Composer\Package\Comparer;
  16877. class Comparer
  16878. {
  16879. private $source;
  16880. private $update;
  16881. private $changed;
  16882. public function setSource($source)
  16883. {
  16884. $this->source = $source;
  16885. }
  16886. public function setUpdate($update)
  16887. {
  16888. $this->update = $update;
  16889. }
  16890. public function getChanged($toString = false, $explicated = false)
  16891. {
  16892. $changed = $this->changed;
  16893. if (!count($changed)) {
  16894. return false;
  16895. }
  16896. if ($explicated) {
  16897. foreach ($changed as $sectionKey => $itemSection) {
  16898. foreach ($itemSection as $itemKey => $item) {
  16899. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  16900. }
  16901. }
  16902. }
  16903. if ($toString) {
  16904. foreach ($changed as $sectionKey => $itemSection) {
  16905. foreach ($itemSection as $itemKey => $item) {
  16906. $changed['string'][] = $item."\r\n";
  16907. }
  16908. }
  16909. $changed = implode("\r\n", $changed['string']);
  16910. }
  16911. return $changed;
  16912. }
  16913. public function doCompare()
  16914. {
  16915. $source = array();
  16916. $destination = array();
  16917. $this->changed = array();
  16918. $currentDirectory = getcwd();
  16919. chdir($this->source);
  16920. $source = $this->doTree('.', $source);
  16921. if (!is_array($source)) {
  16922. return;
  16923. }
  16924. chdir($currentDirectory);
  16925. chdir($this->update);
  16926. $destination = $this->doTree('.', $destination);
  16927. if (!is_array($destination)) {
  16928. exit;
  16929. }
  16930. chdir($currentDirectory);
  16931. foreach ($source as $dir => $value) {
  16932. foreach ($value as $file => $hash) {
  16933. if (isset($destination[$dir][$file])) {
  16934. if ($hash !== $destination[$dir][$file]) {
  16935. $this->changed['changed'][] = $dir.'/'.$file;
  16936. }
  16937. } else {
  16938. $this->changed['removed'][] = $dir.'/'.$file;
  16939. }
  16940. }
  16941. }
  16942. foreach ($destination as $dir => $value) {
  16943. foreach ($value as $file => $hash) {
  16944. if (!isset($source[$dir][$file])) {
  16945. $this->changed['added'][] = $dir.'/'.$file;
  16946. }
  16947. }
  16948. }
  16949. }
  16950. private function doTree($dir, &$array)
  16951. {
  16952. if ($dh = opendir($dir)) {
  16953. while ($file = readdir($dh)) {
  16954. if ($file !== '.' && $file !== '..') {
  16955. if (is_dir($dir.'/'.$file)) {
  16956. if (!count($array)) {
  16957. $array[0] = 'Temp';
  16958. }
  16959. if (!$this->doTree($dir.'/'.$file, $array)) {
  16960. return false;
  16961. }
  16962. } else {
  16963. if (filesize($dir.'/'.$file)) {
  16964. set_time_limit(30);
  16965. $array[$dir][$file] = md5_file($dir.'/'.$file);
  16966. }
  16967. }
  16968. }
  16969. }
  16970. if (count($array) > 1 && isset($array['0'])) {
  16971. unset($array['0']);
  16972. }
  16973. return $array;
  16974. }
  16975. return false;
  16976. }
  16977. }
  16978. <?php
  16979. namespace Composer\Package;
  16980. class CompletePackage extends Package implements CompletePackageInterface
  16981. {
  16982. protected $repositories;
  16983. protected $license = array();
  16984. protected $keywords;
  16985. protected $authors;
  16986. protected $description;
  16987. protected $homepage;
  16988. protected $scripts = array();
  16989. protected $support = array();
  16990. protected $abandoned = false;
  16991. public function setScripts(array $scripts)
  16992. {
  16993. $this->scripts = $scripts;
  16994. }
  16995. public function getScripts()
  16996. {
  16997. return $this->scripts;
  16998. }
  16999. public function setRepositories($repositories)
  17000. {
  17001. $this->repositories = $repositories;
  17002. }
  17003. public function getRepositories()
  17004. {
  17005. return $this->repositories;
  17006. }
  17007. public function setLicense(array $license)
  17008. {
  17009. $this->license = $license;
  17010. }
  17011. public function getLicense()
  17012. {
  17013. return $this->license;
  17014. }
  17015. public function setKeywords(array $keywords)
  17016. {
  17017. $this->keywords = $keywords;
  17018. }
  17019. public function getKeywords()
  17020. {
  17021. return $this->keywords;
  17022. }
  17023. public function setAuthors(array $authors)
  17024. {
  17025. $this->authors = $authors;
  17026. }
  17027. public function getAuthors()
  17028. {
  17029. return $this->authors;
  17030. }
  17031. public function setDescription($description)
  17032. {
  17033. $this->description = $description;
  17034. }
  17035. public function getDescription()
  17036. {
  17037. return $this->description;
  17038. }
  17039. public function setHomepage($homepage)
  17040. {
  17041. $this->homepage = $homepage;
  17042. }
  17043. public function getHomepage()
  17044. {
  17045. return $this->homepage;
  17046. }
  17047. public function setSupport(array $support)
  17048. {
  17049. $this->support = $support;
  17050. }
  17051. public function getSupport()
  17052. {
  17053. return $this->support;
  17054. }
  17055. public function isAbandoned()
  17056. {
  17057. return (bool) $this->abandoned;
  17058. }
  17059. public function setAbandoned($abandoned)
  17060. {
  17061. $this->abandoned = $abandoned;
  17062. }
  17063. public function getReplacementPackage()
  17064. {
  17065. return is_string($this->abandoned) ? $this->abandoned : null;
  17066. }
  17067. }
  17068. <?php
  17069. namespace Composer\Package;
  17070. interface CompletePackageInterface extends PackageInterface
  17071. {
  17072. public function getScripts();
  17073. public function getRepositories();
  17074. public function getLicense();
  17075. public function getKeywords();
  17076. public function getDescription();
  17077. public function getHomepage();
  17078. public function getAuthors();
  17079. public function getSupport();
  17080. public function isAbandoned();
  17081. public function getReplacementPackage();
  17082. }
  17083. <?php
  17084. namespace Composer\Package\Dumper;
  17085. use Composer\Package\BasePackage;
  17086. use Composer\Package\PackageInterface;
  17087. use Composer\Package\CompletePackageInterface;
  17088. use Composer\Package\RootPackageInterface;
  17089. class ArrayDumper
  17090. {
  17091. public function dump(PackageInterface $package)
  17092. {
  17093. $keys = array(
  17094. 'binaries' => 'bin',
  17095. 'type',
  17096. 'extra',
  17097. 'installationSource' => 'installation-source',
  17098. 'autoload',
  17099. 'devAutoload' => 'autoload-dev',
  17100. 'notificationUrl' => 'notification-url',
  17101. 'includePaths' => 'include-path',
  17102. );
  17103. $data = array();
  17104. $data['name'] = $package->getPrettyName();
  17105. $data['version'] = $package->getPrettyVersion();
  17106. $data['version_normalized'] = $package->getVersion();
  17107. if ($package->getTargetDir()) {
  17108. $data['target-dir'] = $package->getTargetDir();
  17109. }
  17110. if ($package->getSourceType()) {
  17111. $data['source']['type'] = $package->getSourceType();
  17112. $data['source']['url'] = $package->getSourceUrl();
  17113. $data['source']['reference'] = $package->getSourceReference();
  17114. if ($mirrors = $package->getSourceMirrors()) {
  17115. $data['source']['mirrors'] = $mirrors;
  17116. }
  17117. }
  17118. if ($package->getDistType()) {
  17119. $data['dist']['type'] = $package->getDistType();
  17120. $data['dist']['url'] = $package->getDistUrl();
  17121. $data['dist']['reference'] = $package->getDistReference();
  17122. $data['dist']['shasum'] = $package->getDistSha1Checksum();
  17123. if ($mirrors = $package->getDistMirrors()) {
  17124. $data['dist']['mirrors'] = $mirrors;
  17125. }
  17126. }
  17127. if ($package->getArchiveExcludes()) {
  17128. $data['archive']['exclude'] = $package->getArchiveExcludes();
  17129. }
  17130. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  17131. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  17132. foreach ($links as $link) {
  17133. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  17134. }
  17135. ksort($data[$type]);
  17136. }
  17137. }
  17138. if ($packages = $package->getSuggests()) {
  17139. ksort($packages);
  17140. $data['suggest'] = $packages;
  17141. }
  17142. if ($package->getReleaseDate()) {
  17143. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  17144. }
  17145. $data = $this->dumpValues($package, $keys, $data);
  17146. if ($package instanceof CompletePackageInterface) {
  17147. $keys = array(
  17148. 'scripts',
  17149. 'license',
  17150. 'authors',
  17151. 'description',
  17152. 'homepage',
  17153. 'keywords',
  17154. 'repositories',
  17155. 'support',
  17156. );
  17157. $data = $this->dumpValues($package, $keys, $data);
  17158. if (isset($data['keywords']) && is_array($data['keywords'])) {
  17159. sort($data['keywords']);
  17160. }
  17161. if ($package->isAbandoned()) {
  17162. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  17163. }
  17164. }
  17165. if ($package instanceof RootPackageInterface) {
  17166. $minimumStability = $package->getMinimumStability();
  17167. if ($minimumStability) {
  17168. $data['minimum-stability'] = $minimumStability;
  17169. }
  17170. }
  17171. if (count($package->getTransportOptions()) > 0) {
  17172. $data['transport-options'] = $package->getTransportOptions();
  17173. }
  17174. return $data;
  17175. }
  17176. private function dumpValues(PackageInterface $package, array $keys, array $data)
  17177. {
  17178. foreach ($keys as $method => $key) {
  17179. if (is_numeric($method)) {
  17180. $method = $key;
  17181. }
  17182. $getter = 'get'.ucfirst($method);
  17183. $value = $package->$getter();
  17184. if (null !== $value && !(is_array($value) && 0 === count($value))) {
  17185. $data[$key] = $value;
  17186. }
  17187. }
  17188. return $data;
  17189. }
  17190. }
  17191. <?php
  17192. namespace Composer\Package;
  17193. use Composer\Semver\Constraint\ConstraintInterface;
  17194. class Link
  17195. {
  17196. protected $source;
  17197. protected $target;
  17198. protected $constraint;
  17199. protected $description;
  17200. protected $prettyConstraint;
  17201. public function __construct($source, $target, ConstraintInterface $constraint = null, $description = 'relates to', $prettyConstraint = null)
  17202. {
  17203. $this->source = strtolower($source);
  17204. $this->target = strtolower($target);
  17205. $this->constraint = $constraint;
  17206. $this->description = $description;
  17207. $this->prettyConstraint = $prettyConstraint;
  17208. }
  17209. public function getDescription()
  17210. {
  17211. return $this->description;
  17212. }
  17213. public function getSource()
  17214. {
  17215. return $this->source;
  17216. }
  17217. public function getTarget()
  17218. {
  17219. return $this->target;
  17220. }
  17221. public function getConstraint()
  17222. {
  17223. return $this->constraint;
  17224. }
  17225. public function getPrettyConstraint()
  17226. {
  17227. if (null === $this->prettyConstraint) {
  17228. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  17229. }
  17230. return $this->prettyConstraint;
  17231. }
  17232. public function __toString()
  17233. {
  17234. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  17235. }
  17236. public function getPrettyString(PackageInterface $sourcePackage)
  17237. {
  17238. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.' '.$this->constraint->getPrettyString().'';
  17239. }
  17240. }
  17241. <?php
  17242. namespace Composer\Package\LinkConstraint;
  17243. use Composer\Semver\Constraint\EmptyConstraint as SemverEmptyConstraint;
  17244. trigger_error('The ' . __NAMESPACE__ . '\EmptyConstraint class is deprecated, use Composer\Semver\Constraint\EmptyConstraint instead.', E_USER_DEPRECATED);
  17245. class EmptyConstraint extends SemverEmptyConstraint implements LinkConstraintInterface
  17246. {
  17247. }
  17248. <?php
  17249. namespace Composer\Package\LinkConstraint;
  17250. use Composer\Semver\Constraint\ConstraintInterface;
  17251. trigger_error('The ' . __NAMESPACE__ . '\LinkConstraintInterface interface is deprecated, use Composer\Semver\Constraint\ConstraintInterface instead.', E_USER_DEPRECATED);
  17252. interface LinkConstraintInterface extends ConstraintInterface
  17253. {
  17254. }
  17255. <?php
  17256. namespace Composer\Package\LinkConstraint;
  17257. use Composer\Semver\Constraint\MultiConstraint as SemverMultiConstraint;
  17258. trigger_error('The ' . __NAMESPACE__ . '\MultiConstraint class is deprecated, use Composer\Semver\Constraint\MultiConstraint instead.', E_USER_DEPRECATED);
  17259. class MultiConstraint extends SemverMultiConstraint implements LinkConstraintInterface
  17260. {
  17261. }
  17262. <?php
  17263. namespace Composer\Package\LinkConstraint;
  17264. use Composer\Semver\Constraint\AbstractConstraint;
  17265. trigger_error('The ' . __NAMESPACE__ . '\SpecificConstraint abstract class is deprecated, there is no replacement for it.', E_USER_DEPRECATED);
  17266. abstract class SpecificConstraint extends AbstractConstraint implements LinkConstraintInterface
  17267. {
  17268. }
  17269. <?php
  17270. namespace Composer\Package\LinkConstraint;
  17271. use Composer\Semver\Constraint\Constraint;
  17272. trigger_error('The ' . __NAMESPACE__ . '\VersionConstraint class is deprecated, use Composer\Semver\Constraint\Constraint instead.', E_USER_DEPRECATED);
  17273. class VersionConstraint extends Constraint implements LinkConstraintInterface
  17274. {
  17275. }
  17276. <?php
  17277. namespace Composer\Package\Loader;
  17278. use Composer\Package;
  17279. use Composer\Package\AliasPackage;
  17280. use Composer\Package\Link;
  17281. use Composer\Package\RootAliasPackage;
  17282. use Composer\Package\RootPackageInterface;
  17283. use Composer\Package\Version\VersionParser;
  17284. use Composer\Semver\VersionParser as SemverVersionParser;
  17285. class ArrayLoader implements LoaderInterface
  17286. {
  17287. protected $versionParser;
  17288. protected $loadOptions;
  17289. public function __construct(SemverVersionParser $parser = null, $loadOptions = false)
  17290. {
  17291. if (!$parser) {
  17292. $parser = new VersionParser;
  17293. }
  17294. $this->versionParser = $parser;
  17295. $this->loadOptions = $loadOptions;
  17296. }
  17297. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  17298. {
  17299. if (!isset($config['name'])) {
  17300. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  17301. }
  17302. if (!isset($config['version'])) {
  17303. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  17304. }
  17305. if (isset($config['version_normalized'])) {
  17306. $version = $config['version_normalized'];
  17307. } else {
  17308. $version = $this->versionParser->normalize($config['version']);
  17309. }
  17310. $package = new $class($config['name'], $version, $config['version']);
  17311. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  17312. if (isset($config['target-dir'])) {
  17313. $package->setTargetDir($config['target-dir']);
  17314. }
  17315. if (isset($config['extra']) && is_array($config['extra'])) {
  17316. $package->setExtra($config['extra']);
  17317. }
  17318. if (isset($config['bin'])) {
  17319. foreach ((array) $config['bin'] as $key => $bin) {
  17320. $config['bin'][$key] = ltrim($bin, '/');
  17321. }
  17322. $package->setBinaries((array) $config['bin']);
  17323. }
  17324. if (isset($config['installation-source'])) {
  17325. $package->setInstallationSource($config['installation-source']);
  17326. }
  17327. if (isset($config['source'])) {
  17328. if (!isset($config['source']['type']) || !isset($config['source']['url']) || !isset($config['source']['reference'])) {
  17329. throw new \UnexpectedValueException(sprintf(
  17330. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  17331. $config['name'],
  17332. json_encode($config['source'])
  17333. ));
  17334. }
  17335. $package->setSourceType($config['source']['type']);
  17336. $package->setSourceUrl($config['source']['url']);
  17337. $package->setSourceReference($config['source']['reference']);
  17338. if (isset($config['source']['mirrors'])) {
  17339. $package->setSourceMirrors($config['source']['mirrors']);
  17340. }
  17341. }
  17342. if (isset($config['dist'])) {
  17343. if (!isset($config['dist']['type'])
  17344. || !isset($config['dist']['url'])) {
  17345. throw new \UnexpectedValueException(sprintf(
  17346. "Package %s's dist key should be specified as ".
  17347. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  17348. $config['name'],
  17349. json_encode($config['dist'])
  17350. ));
  17351. }
  17352. $package->setDistType($config['dist']['type']);
  17353. $package->setDistUrl($config['dist']['url']);
  17354. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  17355. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  17356. if (isset($config['dist']['mirrors'])) {
  17357. $package->setDistMirrors($config['dist']['mirrors']);
  17358. }
  17359. }
  17360. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  17361. if (isset($config[$type])) {
  17362. $method = 'set'.ucfirst($opts['method']);
  17363. $package->{$method}(
  17364. $this->parseLinks(
  17365. $package->getName(),
  17366. $package->getPrettyVersion(),
  17367. $opts['description'],
  17368. $config[$type]
  17369. )
  17370. );
  17371. }
  17372. }
  17373. if (isset($config['suggest']) && is_array($config['suggest'])) {
  17374. foreach ($config['suggest'] as $target => $reason) {
  17375. if ('self.version' === trim($reason)) {
  17376. $config['suggest'][$target] = $package->getPrettyVersion();
  17377. }
  17378. }
  17379. $package->setSuggests($config['suggest']);
  17380. }
  17381. if (isset($config['autoload'])) {
  17382. $package->setAutoload($config['autoload']);
  17383. }
  17384. if (isset($config['autoload-dev'])) {
  17385. $package->setDevAutoload($config['autoload-dev']);
  17386. }
  17387. if (isset($config['include-path'])) {
  17388. $package->setIncludePaths($config['include-path']);
  17389. }
  17390. if (!empty($config['time'])) {
  17391. $time = preg_match('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  17392. try {
  17393. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  17394. $package->setReleaseDate($date);
  17395. } catch (\Exception $e) {
  17396. }
  17397. }
  17398. if (!empty($config['notification-url'])) {
  17399. $package->setNotificationUrl($config['notification-url']);
  17400. }
  17401. if (!empty($config['archive']['exclude'])) {
  17402. $package->setArchiveExcludes($config['archive']['exclude']);
  17403. }
  17404. if ($package instanceof Package\CompletePackageInterface) {
  17405. if (isset($config['scripts']) && is_array($config['scripts'])) {
  17406. foreach ($config['scripts'] as $event => $listeners) {
  17407. $config['scripts'][$event] = (array) $listeners;
  17408. }
  17409. if (isset($config['scripts']['composer'])) {
  17410. trigger_error('The `composer` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  17411. }
  17412. $package->setScripts($config['scripts']);
  17413. }
  17414. if (!empty($config['description']) && is_string($config['description'])) {
  17415. $package->setDescription($config['description']);
  17416. }
  17417. if (!empty($config['homepage']) && is_string($config['homepage'])) {
  17418. $package->setHomepage($config['homepage']);
  17419. }
  17420. if (!empty($config['keywords']) && is_array($config['keywords'])) {
  17421. $package->setKeywords($config['keywords']);
  17422. }
  17423. if (!empty($config['license'])) {
  17424. $package->setLicense(is_array($config['license']) ? $config['license'] : array($config['license']));
  17425. }
  17426. if (!empty($config['authors']) && is_array($config['authors'])) {
  17427. $package->setAuthors($config['authors']);
  17428. }
  17429. if (isset($config['support'])) {
  17430. $package->setSupport($config['support']);
  17431. }
  17432. if (isset($config['abandoned'])) {
  17433. $package->setAbandoned($config['abandoned']);
  17434. }
  17435. }
  17436. if ($aliasNormalized = $this->getBranchAlias($config)) {
  17437. if ($package instanceof RootPackageInterface) {
  17438. $package = new RootAliasPackage($package, $aliasNormalized, preg_replace('{(\.9{7})+}', '.x', $aliasNormalized));
  17439. } else {
  17440. $package = new AliasPackage($package, $aliasNormalized, preg_replace('{(\.9{7})+}', '.x', $aliasNormalized));
  17441. }
  17442. }
  17443. if ($this->loadOptions && isset($config['transport-options'])) {
  17444. $package->setTransportOptions($config['transport-options']);
  17445. }
  17446. return $package;
  17447. }
  17448. public function parseLinks($source, $sourceVersion, $description, $links)
  17449. {
  17450. $res = array();
  17451. foreach ($links as $target => $constraint) {
  17452. if (!is_string($constraint)) {
  17453. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.gettype($constraint) . ' (' . var_export($constraint, true) . ')');
  17454. }
  17455. if ('self.version' === $constraint) {
  17456. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  17457. } else {
  17458. $parsedConstraint = $this->versionParser->parseConstraints($constraint);
  17459. }
  17460. $res[strtolower($target)] = new Link($source, $target, $parsedConstraint, $description, $constraint);
  17461. }
  17462. return $res;
  17463. }
  17464. public function getBranchAlias(array $config)
  17465. {
  17466. if (('dev-' !== substr($config['version'], 0, 4) && '-dev' !== substr($config['version'], -4))
  17467. || !isset($config['extra']['branch-alias'])
  17468. || !is_array($config['extra']['branch-alias'])
  17469. ) {
  17470. return;
  17471. }
  17472. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  17473. if ('-dev' !== substr($targetBranch, -4)) {
  17474. continue;
  17475. }
  17476. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  17477. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  17478. continue;
  17479. }
  17480. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  17481. continue;
  17482. }
  17483. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  17484. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  17485. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  17486. ) {
  17487. continue;
  17488. }
  17489. return $validatedTargetBranch;
  17490. }
  17491. }
  17492. }
  17493. <?php
  17494. namespace Composer\Package\Loader;
  17495. class InvalidPackageException extends \Exception
  17496. {
  17497. private $errors;
  17498. private $warnings;
  17499. private $data;
  17500. public function __construct(array $errors, array $warnings, array $data)
  17501. {
  17502. $this->errors = $errors;
  17503. $this->warnings = $warnings;
  17504. $this->data = $data;
  17505. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  17506. }
  17507. public function getData()
  17508. {
  17509. return $this->data;
  17510. }
  17511. public function getErrors()
  17512. {
  17513. return $this->errors;
  17514. }
  17515. public function getWarnings()
  17516. {
  17517. return $this->warnings;
  17518. }
  17519. }
  17520. <?php
  17521. namespace Composer\Package\Loader;
  17522. use Composer\Json\JsonFile;
  17523. class JsonLoader
  17524. {
  17525. private $loader;
  17526. public function __construct(LoaderInterface $loader)
  17527. {
  17528. $this->loader = $loader;
  17529. }
  17530. public function load($json)
  17531. {
  17532. if ($json instanceof JsonFile) {
  17533. $config = $json->read();
  17534. } elseif (file_exists($json)) {
  17535. $config = JsonFile::parseJson(file_get_contents($json), $json);
  17536. } elseif (is_string($json)) {
  17537. $config = JsonFile::parseJson($json);
  17538. }
  17539. return $this->loader->load($config);
  17540. }
  17541. }
  17542. <?php
  17543. namespace Composer\Package\Loader;
  17544. interface LoaderInterface
  17545. {
  17546. public function load(array $package, $class = 'Composer\Package\CompletePackage');
  17547. }
  17548. <?php
  17549. namespace Composer\Package\Loader;
  17550. use Composer\Package\BasePackage;
  17551. use Composer\Package\AliasPackage;
  17552. use Composer\Config;
  17553. use Composer\Package\RootPackageInterface;
  17554. use Composer\Repository\RepositoryFactory;
  17555. use Composer\Package\Version\VersionGuesser;
  17556. use Composer\Package\Version\VersionParser;
  17557. use Composer\Repository\RepositoryManager;
  17558. use Composer\Util\ProcessExecutor;
  17559. class RootPackageLoader extends ArrayLoader
  17560. {
  17561. private $manager;
  17562. private $config;
  17563. private $versionGuesser;
  17564. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null)
  17565. {
  17566. parent::__construct($parser);
  17567. $this->manager = $manager;
  17568. $this->config = $config;
  17569. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor(), $this->versionParser);
  17570. }
  17571. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  17572. {
  17573. if (!isset($config['name'])) {
  17574. $config['name'] = '__root__';
  17575. }
  17576. $autoVersioned = false;
  17577. if (!isset($config['version'])) {
  17578. $commit = null;
  17579. if (getenv('COMPOSER_ROOT_VERSION')) {
  17580. $config['version'] = getenv('COMPOSER_ROOT_VERSION');
  17581. } else {
  17582. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  17583. if ($versionData) {
  17584. $config['version'] = $versionData['pretty_version'];
  17585. $config['version_normalized'] = $versionData['version'];
  17586. $commit = $versionData['commit'];
  17587. }
  17588. }
  17589. if (!isset($config['version'])) {
  17590. $config['version'] = '1.0.0';
  17591. $autoVersioned = true;
  17592. }
  17593. if ($commit) {
  17594. $config['source'] = array(
  17595. 'type' => '',
  17596. 'url' => '',
  17597. 'reference' => $commit,
  17598. );
  17599. $config['dist'] = array(
  17600. 'type' => '',
  17601. 'url' => '',
  17602. 'reference' => $commit,
  17603. );
  17604. }
  17605. }
  17606. $realPackage = $package = parent::load($config, $class);
  17607. if ($realPackage instanceof AliasPackage) {
  17608. $realPackage = $package->getAliasOf();
  17609. }
  17610. if ($autoVersioned) {
  17611. $realPackage->replaceVersion($realPackage->getVersion(), 'No version set (parsed as 1.0.0)');
  17612. }
  17613. if (isset($config['minimum-stability'])) {
  17614. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  17615. }
  17616. $aliases = array();
  17617. $stabilityFlags = array();
  17618. $references = array();
  17619. foreach (array('require', 'require-dev') as $linkType) {
  17620. if (isset($config[$linkType])) {
  17621. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  17622. $method = 'get'.ucfirst($linkInfo['method']);
  17623. $links = array();
  17624. foreach ($realPackage->$method() as $link) {
  17625. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  17626. }
  17627. $aliases = $this->extractAliases($links, $aliases);
  17628. $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
  17629. $references = $this->extractReferences($links, $references);
  17630. }
  17631. }
  17632. if (isset($links[$config['name']])) {
  17633. throw new \InvalidArgumentException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  17634. 'Did you accidentally name your root package after an external package?', $config['name']));
  17635. }
  17636. $realPackage->setAliases($aliases);
  17637. $realPackage->setStabilityFlags($stabilityFlags);
  17638. $realPackage->setReferences($references);
  17639. if (isset($config['prefer-stable'])) {
  17640. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  17641. }
  17642. if (isset($config['config'])) {
  17643. $realPackage->setConfig($config['config']);
  17644. }
  17645. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  17646. foreach ($repos as $repo) {
  17647. $this->manager->addRepository($repo);
  17648. }
  17649. $realPackage->setRepositories($this->config->getRepositories());
  17650. return $package;
  17651. }
  17652. private function extractAliases(array $requires, array $aliases)
  17653. {
  17654. foreach ($requires as $reqName => $reqVersion) {
  17655. if (preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  17656. $aliases[] = array(
  17657. 'package' => strtolower($reqName),
  17658. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  17659. 'alias' => $match[2],
  17660. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  17661. );
  17662. }
  17663. }
  17664. return $aliases;
  17665. }
  17666. private function extractStabilityFlags(array $requires, array $stabilityFlags, $minimumStability)
  17667. {
  17668. $stabilities = BasePackage::$stabilities;
  17669. $minimumStability = $stabilities[$minimumStability];
  17670. foreach ($requires as $reqName => $reqVersion) {
  17671. $constraints = array();
  17672. $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
  17673. foreach ($orSplit as $orConstraint) {
  17674. $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  17675. foreach ($andSplit as $andConstraint) {
  17676. $constraints[] = $andConstraint;
  17677. }
  17678. }
  17679. $match = false;
  17680. foreach ($constraints as $constraint) {
  17681. if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  17682. $name = strtolower($reqName);
  17683. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  17684. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  17685. continue;
  17686. }
  17687. $stabilityFlags[$name] = $stability;
  17688. $match = true;
  17689. }
  17690. }
  17691. if ($match) {
  17692. continue;
  17693. }
  17694. foreach ($constraints as $constraint) {
  17695. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  17696. if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  17697. $name = strtolower($reqName);
  17698. $stability = $stabilities[$stabilityName];
  17699. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  17700. continue;
  17701. }
  17702. $stabilityFlags[$name] = $stability;
  17703. }
  17704. }
  17705. }
  17706. return $stabilityFlags;
  17707. }
  17708. private function extractReferences(array $requires, array $references)
  17709. {
  17710. foreach ($requires as $reqName => $reqVersion) {
  17711. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  17712. if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  17713. $name = strtolower($reqName);
  17714. $references[$name] = $match[1];
  17715. }
  17716. }
  17717. return $references;
  17718. }
  17719. }
  17720. <?php
  17721. namespace Composer\Package\Loader;
  17722. use Composer\Package\BasePackage;
  17723. use Composer\Semver\Constraint\Constraint;
  17724. use Composer\Package\Version\VersionParser;
  17725. use Composer\Repository\PlatformRepository;
  17726. use Composer\Spdx\SpdxLicenses;
  17727. class ValidatingArrayLoader implements LoaderInterface
  17728. {
  17729. const CHECK_ALL = 3;
  17730. const CHECK_UNBOUND_CONSTRAINTS = 1;
  17731. const CHECK_STRICT_CONSTRAINTS = 2;
  17732. private $loader;
  17733. private $versionParser;
  17734. private $errors;
  17735. private $warnings;
  17736. private $config;
  17737. private $strictName;
  17738. private $flags;
  17739. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  17740. {
  17741. $this->loader = $loader;
  17742. $this->versionParser = $parser ?: new VersionParser();
  17743. $this->strictName = $strictName;
  17744. $this->flags = $flags;
  17745. }
  17746. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  17747. {
  17748. $this->errors = array();
  17749. $this->warnings = array();
  17750. $this->config = $config;
  17751. if ($this->strictName) {
  17752. $this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
  17753. } else {
  17754. $this->validateString('name', true);
  17755. }
  17756. if (!empty($this->config['version'])) {
  17757. try {
  17758. $this->versionParser->normalize($this->config['version']);
  17759. } catch (\Exception $e) {
  17760. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  17761. unset($this->config['version']);
  17762. }
  17763. }
  17764. if (!empty($this->config['config']['platform'])) {
  17765. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  17766. try {
  17767. $this->versionParser->normalize($platform);
  17768. } catch (\Exception $e) {
  17769. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  17770. }
  17771. }
  17772. }
  17773. $this->validateRegex('type', '[A-Za-z0-9-]+');
  17774. $this->validateString('target-dir');
  17775. $this->validateArray('extra');
  17776. if (isset($this->config['bin'])) {
  17777. if (is_string($this->config['bin'])) {
  17778. $this->validateString('bin');
  17779. } else {
  17780. $this->validateFlatArray('bin');
  17781. }
  17782. }
  17783. $this->validateArray('scripts');
  17784. $this->validateString('description');
  17785. $this->validateUrl('homepage');
  17786. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  17787. $releaseDate = null;
  17788. $this->validateString('time');
  17789. if (!empty($this->config['time'])) {
  17790. try {
  17791. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  17792. } catch (\Exception $e) {
  17793. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  17794. unset($this->config['time']);
  17795. }
  17796. }
  17797. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  17798. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  17799. $licenses = (array) $this->config['license'];
  17800. foreach ($licenses as $key => $license) {
  17801. if ('proprietary' === $license) {
  17802. unset($licenses[$key]);
  17803. }
  17804. }
  17805. $licenseValidator = new SpdxLicenses();
  17806. if (count($licenses) === 1 && !$licenseValidator->validate($licenses) && $licenseValidator->validate(trim($licenses[0]))) {
  17807. $this->warnings[] = sprintf(
  17808. 'License %s must not contain extra spaces, make sure to trim it.',
  17809. json_encode($this->config['license'])
  17810. );
  17811. } elseif (array() !== $licenses && !$licenseValidator->validate($licenses)) {
  17812. $this->warnings[] = sprintf(
  17813. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  17814. 'If the software is closed-source, you may use "proprietary" as license.',
  17815. json_encode($this->config['license'])
  17816. );
  17817. }
  17818. }
  17819. }
  17820. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  17821. foreach ($this->config['authors'] as $key => $author) {
  17822. if (!is_array($author)) {
  17823. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  17824. unset($this->config['authors'][$key]);
  17825. continue;
  17826. }
  17827. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  17828. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  17829. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  17830. unset($this->config['authors'][$key][$authorData]);
  17831. }
  17832. }
  17833. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  17834. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  17835. unset($this->config['authors'][$key]['homepage']);
  17836. }
  17837. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  17838. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  17839. unset($this->config['authors'][$key]['email']);
  17840. }
  17841. if (empty($this->config['authors'][$key])) {
  17842. unset($this->config['authors'][$key]);
  17843. }
  17844. }
  17845. if (empty($this->config['authors'])) {
  17846. unset($this->config['authors']);
  17847. }
  17848. }
  17849. if ($this->validateArray('support') && !empty($this->config['support'])) {
  17850. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  17851. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  17852. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  17853. unset($this->config['support'][$key]);
  17854. }
  17855. }
  17856. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  17857. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  17858. unset($this->config['support']['email']);
  17859. }
  17860. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc'))) {
  17861. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> URL';
  17862. unset($this->config['support']['irc']);
  17863. }
  17864. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  17865. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  17866. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  17867. unset($this->config['support'][$key]);
  17868. }
  17869. }
  17870. if (empty($this->config['support'])) {
  17871. unset($this->config['support']);
  17872. }
  17873. }
  17874. $unboundConstraint = new Constraint('=', $this->versionParser->normalize('dev-master'));
  17875. $stableConstraint = new Constraint('=', '1.0.0');
  17876. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  17877. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  17878. foreach ($this->config[$linkType] as $package => $constraint) {
  17879. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
  17880. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  17881. }
  17882. if (!is_string($constraint)) {
  17883. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  17884. unset($this->config[$linkType][$package]);
  17885. } elseif ('self.version' !== $constraint) {
  17886. try {
  17887. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  17888. } catch (\Exception $e) {
  17889. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  17890. unset($this->config[$linkType][$package]);
  17891. continue;
  17892. }
  17893. if (
  17894. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  17895. && 'require' === $linkType
  17896. && $linkConstraint->matches($unboundConstraint)
  17897. && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $package)
  17898. ) {
  17899. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  17900. } elseif (
  17901. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  17902. && 'require' === $linkType
  17903. && substr($linkConstraint, 0, 1) === '='
  17904. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  17905. ) {
  17906. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  17907. }
  17908. }
  17909. }
  17910. }
  17911. }
  17912. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  17913. foreach ($this->config['suggest'] as $package => $description) {
  17914. if (!is_string($description)) {
  17915. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  17916. unset($this->config['suggest'][$package]);
  17917. }
  17918. }
  17919. }
  17920. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  17921. if (!isset(BasePackage::$stabilities[$this->config['minimum-stability']])) {
  17922. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  17923. unset($this->config['minimum-stability']);
  17924. }
  17925. }
  17926. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  17927. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  17928. foreach ($this->config['autoload'] as $type => $typeConfig) {
  17929. if (!in_array($type, $types)) {
  17930. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  17931. unset($this->config['autoload'][$type]);
  17932. }
  17933. if ($type === 'psr-4') {
  17934. foreach ($typeConfig as $namespace => $dirs) {
  17935. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  17936. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  17937. }
  17938. }
  17939. }
  17940. }
  17941. }
  17942. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  17943. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  17944. unset($this->config['autoload']['psr-4']);
  17945. }
  17946. $this->validateFlatArray('include-path');
  17947. $this->validateArray('transport-options');
  17948. if (isset($this->config['extra']['branch-alias'])) {
  17949. if (!is_array($this->config['extra']['branch-alias'])) {
  17950. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  17951. } else {
  17952. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  17953. if ('-dev' !== substr($targetBranch, -4)) {
  17954. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  17955. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  17956. continue;
  17957. }
  17958. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  17959. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  17960. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  17961. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  17962. continue;
  17963. }
  17964. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  17965. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  17966. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  17967. ) {
  17968. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  17969. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  17970. }
  17971. }
  17972. }
  17973. }
  17974. if ($this->errors) {
  17975. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  17976. }
  17977. $package = $this->loader->load($this->config, $class);
  17978. $this->config = null;
  17979. return $package;
  17980. }
  17981. public function getWarnings()
  17982. {
  17983. return $this->warnings;
  17984. }
  17985. public function getErrors()
  17986. {
  17987. return $this->errors;
  17988. }
  17989. private function validateRegex($property, $regex, $mandatory = false)
  17990. {
  17991. if (!$this->validateString($property, $mandatory)) {
  17992. return false;
  17993. }
  17994. if (!preg_match('{^'.$regex.'$}u', $this->config[$property])) {
  17995. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  17996. if ($mandatory) {
  17997. $this->errors[] = $message;
  17998. } else {
  17999. $this->warnings[] = $message;
  18000. }
  18001. unset($this->config[$property]);
  18002. return false;
  18003. }
  18004. return true;
  18005. }
  18006. private function validateString($property, $mandatory = false)
  18007. {
  18008. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  18009. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  18010. unset($this->config[$property]);
  18011. return false;
  18012. }
  18013. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  18014. if ($mandatory) {
  18015. $this->errors[] = $property.' : must be present';
  18016. }
  18017. unset($this->config[$property]);
  18018. return false;
  18019. }
  18020. return true;
  18021. }
  18022. private function validateArray($property, $mandatory = false)
  18023. {
  18024. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  18025. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  18026. unset($this->config[$property]);
  18027. return false;
  18028. }
  18029. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  18030. if ($mandatory) {
  18031. $this->errors[] = $property.' : must be present and contain at least one element';
  18032. }
  18033. unset($this->config[$property]);
  18034. return false;
  18035. }
  18036. return true;
  18037. }
  18038. private function validateFlatArray($property, $regex = null, $mandatory = false)
  18039. {
  18040. if (!$this->validateArray($property, $mandatory)) {
  18041. return false;
  18042. }
  18043. $pass = true;
  18044. foreach ($this->config[$property] as $key => $value) {
  18045. if (!is_string($value) && !is_numeric($value)) {
  18046. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  18047. unset($this->config[$property][$key]);
  18048. $pass = false;
  18049. continue;
  18050. }
  18051. if ($regex && !preg_match('{^'.$regex.'$}u', $value)) {
  18052. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  18053. unset($this->config[$property][$key]);
  18054. $pass = false;
  18055. }
  18056. }
  18057. return $pass;
  18058. }
  18059. private function validateUrl($property, $mandatory = false)
  18060. {
  18061. if (!$this->validateString($property, $mandatory)) {
  18062. return false;
  18063. }
  18064. if (!$this->filterUrl($this->config[$property])) {
  18065. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  18066. unset($this->config[$property]);
  18067. return false;
  18068. }
  18069. return true;
  18070. }
  18071. private function filterUrl($value, array $schemes = array('http', 'https'))
  18072. {
  18073. if ($value === '') {
  18074. return true;
  18075. }
  18076. $bits = parse_url($value);
  18077. if (empty($bits['scheme']) || empty($bits['host'])) {
  18078. return false;
  18079. }
  18080. if (!in_array($bits['scheme'], $schemes, true)) {
  18081. return false;
  18082. }
  18083. return true;
  18084. }
  18085. }
  18086. <?php
  18087. namespace Composer\Package;
  18088. use Composer\Json\JsonFile;
  18089. use Composer\Installer\InstallationManager;
  18090. use Composer\Repository\RepositoryManager;
  18091. use Composer\Util\ProcessExecutor;
  18092. use Composer\Repository\ArrayRepository;
  18093. use Composer\Package\Dumper\ArrayDumper;
  18094. use Composer\Package\Loader\ArrayLoader;
  18095. use Composer\Util\Git as GitUtil;
  18096. use Composer\IO\IOInterface;
  18097. use Seld\JsonLint\ParsingException;
  18098. class Locker
  18099. {
  18100. private $lockFile;
  18101. private $repositoryManager;
  18102. private $installationManager;
  18103. private $hash;
  18104. private $contentHash;
  18105. private $loader;
  18106. private $dumper;
  18107. private $process;
  18108. private $lockDataCache;
  18109. public function __construct(IOInterface $io, JsonFile $lockFile, RepositoryManager $repositoryManager, InstallationManager $installationManager, $composerFileContents)
  18110. {
  18111. $this->lockFile = $lockFile;
  18112. $this->repositoryManager = $repositoryManager;
  18113. $this->installationManager = $installationManager;
  18114. $this->hash = md5($composerFileContents);
  18115. $this->contentHash = self::getContentHash($composerFileContents);
  18116. $this->loader = new ArrayLoader(null, true);
  18117. $this->dumper = new ArrayDumper();
  18118. $this->process = new ProcessExecutor($io);
  18119. }
  18120. public static function getContentHash($composerFileContents)
  18121. {
  18122. $content = json_decode($composerFileContents, true);
  18123. $relevantKeys = array(
  18124. 'name',
  18125. 'version',
  18126. 'require',
  18127. 'require-dev',
  18128. 'conflict',
  18129. 'replace',
  18130. 'provide',
  18131. 'minimum-stability',
  18132. 'prefer-stable',
  18133. 'repositories',
  18134. 'extra',
  18135. );
  18136. $relevantContent = array();
  18137. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  18138. $relevantContent[$key] = $content[$key];
  18139. }
  18140. if (isset($content['config']['platform'])) {
  18141. $relevantContent['config']['platform'] = $content['config']['platform'];
  18142. }
  18143. ksort($relevantContent);
  18144. return md5(json_encode($relevantContent));
  18145. }
  18146. public function isLocked()
  18147. {
  18148. if (!$this->lockFile->exists()) {
  18149. return false;
  18150. }
  18151. $data = $this->getLockData();
  18152. return isset($data['packages']);
  18153. }
  18154. public function isFresh()
  18155. {
  18156. $lock = $this->lockFile->read();
  18157. if (!empty($lock['content-hash'])) {
  18158. return $this->contentHash === $lock['content-hash'];
  18159. }
  18160. if (!empty($lock['hash'])) {
  18161. return $this->hash === $lock['hash'];
  18162. }
  18163. return false;
  18164. }
  18165. public function getLockedRepository($withDevReqs = false)
  18166. {
  18167. $lockData = $this->getLockData();
  18168. $packages = new ArrayRepository();
  18169. $lockedPackages = $lockData['packages'];
  18170. if ($withDevReqs) {
  18171. if (isset($lockData['packages-dev'])) {
  18172. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  18173. } else {
  18174. throw new \RuntimeException('The lock file does not contain require-dev information, run install with the --no-dev option or run update to install those packages.');
  18175. }
  18176. }
  18177. if (empty($lockedPackages)) {
  18178. return $packages;
  18179. }
  18180. if (isset($lockedPackages[0]['name'])) {
  18181. foreach ($lockedPackages as $info) {
  18182. $packages->addPackage($this->loader->load($info));
  18183. }
  18184. return $packages;
  18185. }
  18186. throw new \RuntimeException('Your composer.lock was created before 2012-09-15, and is not supported anymore. Run "composer update" to generate a new one.');
  18187. }
  18188. public function getPlatformRequirements($withDevReqs = false)
  18189. {
  18190. $lockData = $this->getLockData();
  18191. $requirements = array();
  18192. if (!empty($lockData['platform'])) {
  18193. $requirements = $this->loader->parseLinks(
  18194. '__ROOT__',
  18195. '1.0.0',
  18196. 'requires',
  18197. isset($lockData['platform']) ? $lockData['platform'] : array()
  18198. );
  18199. }
  18200. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  18201. $devRequirements = $this->loader->parseLinks(
  18202. '__ROOT__',
  18203. '1.0.0',
  18204. 'requires',
  18205. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  18206. );
  18207. $requirements = array_merge($requirements, $devRequirements);
  18208. }
  18209. return $requirements;
  18210. }
  18211. public function getMinimumStability()
  18212. {
  18213. $lockData = $this->getLockData();
  18214. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  18215. }
  18216. public function getStabilityFlags()
  18217. {
  18218. $lockData = $this->getLockData();
  18219. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  18220. }
  18221. public function getPreferStable()
  18222. {
  18223. $lockData = $this->getLockData();
  18224. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  18225. }
  18226. public function getPreferLowest()
  18227. {
  18228. $lockData = $this->getLockData();
  18229. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  18230. }
  18231. public function getPlatformOverrides()
  18232. {
  18233. $lockData = $this->getLockData();
  18234. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  18235. }
  18236. public function getAliases()
  18237. {
  18238. $lockData = $this->getLockData();
  18239. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  18240. }
  18241. public function getLockData()
  18242. {
  18243. if (null !== $this->lockDataCache) {
  18244. return $this->lockDataCache;
  18245. }
  18246. if (!$this->lockFile->exists()) {
  18247. throw new \LogicException('No lockfile found. Unable to read locked packages');
  18248. }
  18249. return $this->lockDataCache = $this->lockFile->read();
  18250. }
  18251. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides)
  18252. {
  18253. $lock = array(
  18254. '_readme' => array('This file locks the dependencies of your project to a known state',
  18255. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  18256. 'This file is @gener'.'ated automatically', ),
  18257. 'content-hash' => $this->contentHash,
  18258. 'packages' => null,
  18259. 'packages-dev' => null,
  18260. 'aliases' => array(),
  18261. 'minimum-stability' => $minimumStability,
  18262. 'stability-flags' => $stabilityFlags,
  18263. 'prefer-stable' => $preferStable,
  18264. 'prefer-lowest' => $preferLowest,
  18265. );
  18266. foreach ($aliases as $package => $versions) {
  18267. foreach ($versions as $version => $alias) {
  18268. $lock['aliases'][] = array(
  18269. 'alias' => $alias['alias'],
  18270. 'alias_normalized' => $alias['alias_normalized'],
  18271. 'version' => $version,
  18272. 'package' => $package,
  18273. );
  18274. }
  18275. }
  18276. $lock['packages'] = $this->lockPackages($packages);
  18277. if (null !== $devPackages) {
  18278. $lock['packages-dev'] = $this->lockPackages($devPackages);
  18279. }
  18280. $lock['platform'] = $platformReqs;
  18281. $lock['platform-dev'] = $platformDevReqs;
  18282. if ($platformOverrides) {
  18283. $lock['platform-overrides'] = $platformOverrides;
  18284. }
  18285. if (empty($lock['packages']) && empty($lock['packages-dev']) && empty($lock['platform']) && empty($lock['platform-dev'])) {
  18286. if ($this->lockFile->exists()) {
  18287. unlink($this->lockFile->getPath());
  18288. }
  18289. return false;
  18290. }
  18291. try {
  18292. $isLocked = $this->isLocked();
  18293. } catch (ParsingException $e) {
  18294. $isLocked = false;
  18295. }
  18296. if (!$isLocked || $lock !== $this->getLockData()) {
  18297. $this->lockFile->write($lock);
  18298. $this->lockDataCache = null;
  18299. return true;
  18300. }
  18301. return false;
  18302. }
  18303. private function lockPackages(array $packages)
  18304. {
  18305. $locked = array();
  18306. foreach ($packages as $package) {
  18307. if ($package instanceof AliasPackage) {
  18308. continue;
  18309. }
  18310. $name = $package->getPrettyName();
  18311. $version = $package->getPrettyVersion();
  18312. if (!$name || !$version) {
  18313. throw new \LogicException(sprintf(
  18314. 'Package "%s" has no version or name and can not be locked',
  18315. $package
  18316. ));
  18317. }
  18318. $spec = $this->dumper->dump($package);
  18319. unset($spec['version_normalized']);
  18320. $time = isset($spec['time']) ? $spec['time'] : null;
  18321. unset($spec['time']);
  18322. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  18323. $time = $this->getPackageTime($package) ?: $time;
  18324. }
  18325. if (null !== $time) {
  18326. $spec['time'] = $time;
  18327. }
  18328. unset($spec['installation-source']);
  18329. $locked[] = $spec;
  18330. }
  18331. usort($locked, function ($a, $b) {
  18332. $comparison = strcmp($a['name'], $b['name']);
  18333. if (0 !== $comparison) {
  18334. return $comparison;
  18335. }
  18336. return strcmp($a['version'], $b['version']);
  18337. });
  18338. return $locked;
  18339. }
  18340. private function getPackageTime(PackageInterface $package)
  18341. {
  18342. if (!function_exists('proc_open')) {
  18343. return null;
  18344. }
  18345. $path = realpath($this->installationManager->getInstallPath($package));
  18346. $sourceType = $package->getSourceType();
  18347. $datetime = null;
  18348. if ($path && in_array($sourceType, array('git', 'hg'))) {
  18349. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  18350. switch ($sourceType) {
  18351. case 'git':
  18352. GitUtil::cleanEnv();
  18353. if (0 === $this->process->execute('git log -n1 --pretty=%ct '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*\d+\s*$}', $output)) {
  18354. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  18355. }
  18356. break;
  18357. case 'hg':
  18358. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) {
  18359. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  18360. }
  18361. break;
  18362. }
  18363. }
  18364. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  18365. }
  18366. }
  18367. <?php
  18368. namespace Composer\Package;
  18369. use Composer\Package\Version\VersionParser;
  18370. use Composer\Util\ComposerMirror;
  18371. class Package extends BasePackage
  18372. {
  18373. protected $type;
  18374. protected $targetDir;
  18375. protected $installationSource;
  18376. protected $sourceType;
  18377. protected $sourceUrl;
  18378. protected $sourceReference;
  18379. protected $sourceMirrors;
  18380. protected $distType;
  18381. protected $distUrl;
  18382. protected $distReference;
  18383. protected $distSha1Checksum;
  18384. protected $distMirrors;
  18385. protected $version;
  18386. protected $prettyVersion;
  18387. protected $releaseDate;
  18388. protected $extra = array();
  18389. protected $binaries = array();
  18390. protected $dev;
  18391. protected $stability;
  18392. protected $notificationUrl;
  18393. protected $requires = array();
  18394. protected $conflicts = array();
  18395. protected $provides = array();
  18396. protected $replaces = array();
  18397. protected $devRequires = array();
  18398. protected $suggests = array();
  18399. protected $autoload = array();
  18400. protected $devAutoload = array();
  18401. protected $includePaths = array();
  18402. protected $archiveExcludes = array();
  18403. public function __construct($name, $version, $prettyVersion)
  18404. {
  18405. parent::__construct($name);
  18406. $this->version = $version;
  18407. $this->prettyVersion = $prettyVersion;
  18408. $this->stability = VersionParser::parseStability($version);
  18409. $this->dev = $this->stability === 'dev';
  18410. }
  18411. public function isDev()
  18412. {
  18413. return $this->dev;
  18414. }
  18415. public function setType($type)
  18416. {
  18417. $this->type = $type;
  18418. }
  18419. public function getType()
  18420. {
  18421. return $this->type ?: 'library';
  18422. }
  18423. public function getStability()
  18424. {
  18425. return $this->stability;
  18426. }
  18427. public function setTargetDir($targetDir)
  18428. {
  18429. $this->targetDir = $targetDir;
  18430. }
  18431. public function getTargetDir()
  18432. {
  18433. if (null === $this->targetDir) {
  18434. return;
  18435. }
  18436. return ltrim(preg_replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  18437. }
  18438. public function setExtra(array $extra)
  18439. {
  18440. $this->extra = $extra;
  18441. }
  18442. public function getExtra()
  18443. {
  18444. return $this->extra;
  18445. }
  18446. public function setBinaries(array $binaries)
  18447. {
  18448. $this->binaries = $binaries;
  18449. }
  18450. public function getBinaries()
  18451. {
  18452. return $this->binaries;
  18453. }
  18454. public function setInstallationSource($type)
  18455. {
  18456. $this->installationSource = $type;
  18457. }
  18458. public function getInstallationSource()
  18459. {
  18460. return $this->installationSource;
  18461. }
  18462. public function setSourceType($type)
  18463. {
  18464. $this->sourceType = $type;
  18465. }
  18466. public function getSourceType()
  18467. {
  18468. return $this->sourceType;
  18469. }
  18470. public function setSourceUrl($url)
  18471. {
  18472. $this->sourceUrl = $url;
  18473. }
  18474. public function getSourceUrl()
  18475. {
  18476. return $this->sourceUrl;
  18477. }
  18478. public function setSourceReference($reference)
  18479. {
  18480. $this->sourceReference = $reference;
  18481. }
  18482. public function getSourceReference()
  18483. {
  18484. return $this->sourceReference;
  18485. }
  18486. public function setSourceMirrors($mirrors)
  18487. {
  18488. $this->sourceMirrors = $mirrors;
  18489. }
  18490. public function getSourceMirrors()
  18491. {
  18492. return $this->sourceMirrors;
  18493. }
  18494. public function getSourceUrls()
  18495. {
  18496. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  18497. }
  18498. public function setDistType($type)
  18499. {
  18500. $this->distType = $type;
  18501. }
  18502. public function getDistType()
  18503. {
  18504. return $this->distType;
  18505. }
  18506. public function setDistUrl($url)
  18507. {
  18508. $this->distUrl = $url;
  18509. }
  18510. public function getDistUrl()
  18511. {
  18512. return $this->distUrl;
  18513. }
  18514. public function setDistReference($reference)
  18515. {
  18516. $this->distReference = $reference;
  18517. }
  18518. public function getDistReference()
  18519. {
  18520. return $this->distReference;
  18521. }
  18522. public function setDistSha1Checksum($sha1checksum)
  18523. {
  18524. $this->distSha1Checksum = $sha1checksum;
  18525. }
  18526. public function getDistSha1Checksum()
  18527. {
  18528. return $this->distSha1Checksum;
  18529. }
  18530. public function setDistMirrors($mirrors)
  18531. {
  18532. $this->distMirrors = $mirrors;
  18533. }
  18534. public function getDistMirrors()
  18535. {
  18536. return $this->distMirrors;
  18537. }
  18538. public function getDistUrls()
  18539. {
  18540. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  18541. }
  18542. public function getVersion()
  18543. {
  18544. return $this->version;
  18545. }
  18546. public function getPrettyVersion()
  18547. {
  18548. return $this->prettyVersion;
  18549. }
  18550. public function setReleaseDate(\DateTime $releaseDate)
  18551. {
  18552. $this->releaseDate = $releaseDate;
  18553. }
  18554. public function getReleaseDate()
  18555. {
  18556. return $this->releaseDate;
  18557. }
  18558. public function setRequires(array $requires)
  18559. {
  18560. $this->requires = $requires;
  18561. }
  18562. public function getRequires()
  18563. {
  18564. return $this->requires;
  18565. }
  18566. public function setConflicts(array $conflicts)
  18567. {
  18568. $this->conflicts = $conflicts;
  18569. }
  18570. public function getConflicts()
  18571. {
  18572. return $this->conflicts;
  18573. }
  18574. public function setProvides(array $provides)
  18575. {
  18576. $this->provides = $provides;
  18577. }
  18578. public function getProvides()
  18579. {
  18580. return $this->provides;
  18581. }
  18582. public function setReplaces(array $replaces)
  18583. {
  18584. $this->replaces = $replaces;
  18585. }
  18586. public function getReplaces()
  18587. {
  18588. return $this->replaces;
  18589. }
  18590. public function setDevRequires(array $devRequires)
  18591. {
  18592. $this->devRequires = $devRequires;
  18593. }
  18594. public function getDevRequires()
  18595. {
  18596. return $this->devRequires;
  18597. }
  18598. public function setSuggests(array $suggests)
  18599. {
  18600. $this->suggests = $suggests;
  18601. }
  18602. public function getSuggests()
  18603. {
  18604. return $this->suggests;
  18605. }
  18606. public function setAutoload(array $autoload)
  18607. {
  18608. $this->autoload = $autoload;
  18609. }
  18610. public function getAutoload()
  18611. {
  18612. return $this->autoload;
  18613. }
  18614. public function setDevAutoload(array $devAutoload)
  18615. {
  18616. $this->devAutoload = $devAutoload;
  18617. }
  18618. public function getDevAutoload()
  18619. {
  18620. return $this->devAutoload;
  18621. }
  18622. public function setIncludePaths(array $includePaths)
  18623. {
  18624. $this->includePaths = $includePaths;
  18625. }
  18626. public function getIncludePaths()
  18627. {
  18628. return $this->includePaths;
  18629. }
  18630. public function setNotificationUrl($notificationUrl)
  18631. {
  18632. $this->notificationUrl = $notificationUrl;
  18633. }
  18634. public function getNotificationUrl()
  18635. {
  18636. return $this->notificationUrl;
  18637. }
  18638. public function setArchiveExcludes(array $excludes)
  18639. {
  18640. $this->archiveExcludes = $excludes;
  18641. }
  18642. public function getArchiveExcludes()
  18643. {
  18644. return $this->archiveExcludes;
  18645. }
  18646. public function replaceVersion($version, $prettyVersion)
  18647. {
  18648. $this->version = $version;
  18649. $this->prettyVersion = $prettyVersion;
  18650. $this->stability = VersionParser::parseStability($version);
  18651. $this->dev = $this->stability === 'dev';
  18652. }
  18653. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  18654. {
  18655. if (!$url) {
  18656. return array();
  18657. }
  18658. $urls = array($url);
  18659. if ($mirrors) {
  18660. foreach ($mirrors as $mirror) {
  18661. if ($urlType === 'dist') {
  18662. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
  18663. } elseif ($urlType === 'source' && $type === 'git') {
  18664. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  18665. } elseif ($urlType === 'source' && $type === 'hg') {
  18666. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  18667. }
  18668. if (!in_array($mirrorUrl, $urls)) {
  18669. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  18670. $func($urls, $mirrorUrl);
  18671. }
  18672. }
  18673. }
  18674. return $urls;
  18675. }
  18676. }
  18677. <?php
  18678. namespace Composer\Package;
  18679. use Composer\Repository\RepositoryInterface;
  18680. interface PackageInterface
  18681. {
  18682. public function getName();
  18683. public function getPrettyName();
  18684. public function getNames();
  18685. public function setId($id);
  18686. public function getId();
  18687. public function isDev();
  18688. public function getType();
  18689. public function getTargetDir();
  18690. public function getExtra();
  18691. public function setInstallationSource($type);
  18692. public function getInstallationSource();
  18693. public function getSourceType();
  18694. public function getSourceUrl();
  18695. public function getSourceUrls();
  18696. public function getSourceReference();
  18697. public function getSourceMirrors();
  18698. public function getDistType();
  18699. public function getDistUrl();
  18700. public function getDistUrls();
  18701. public function getDistReference();
  18702. public function getDistSha1Checksum();
  18703. public function getDistMirrors();
  18704. public function getVersion();
  18705. public function getPrettyVersion();
  18706. public function getFullPrettyVersion($truncate = true);
  18707. public function getReleaseDate();
  18708. public function getStability();
  18709. public function getRequires();
  18710. public function getConflicts();
  18711. public function getProvides();
  18712. public function getReplaces();
  18713. public function getDevRequires();
  18714. public function getSuggests();
  18715. public function getAutoload();
  18716. public function getDevAutoload();
  18717. public function getIncludePaths();
  18718. public function setRepository(RepositoryInterface $repository);
  18719. public function getRepository();
  18720. public function getBinaries();
  18721. public function getUniqueName();
  18722. public function getNotificationUrl();
  18723. public function __toString();
  18724. public function getPrettyString();
  18725. public function getArchiveExcludes();
  18726. public function getTransportOptions();
  18727. }
  18728. <?php
  18729. namespace Composer\Package;
  18730. class RootAliasPackage extends AliasPackage implements RootPackageInterface
  18731. {
  18732. public function __construct(RootPackageInterface $aliasOf, $version, $prettyVersion)
  18733. {
  18734. parent::__construct($aliasOf, $version, $prettyVersion);
  18735. }
  18736. public function getAliases()
  18737. {
  18738. return $this->aliasOf->getAliases();
  18739. }
  18740. public function getMinimumStability()
  18741. {
  18742. return $this->aliasOf->getMinimumStability();
  18743. }
  18744. public function getStabilityFlags()
  18745. {
  18746. return $this->aliasOf->getStabilityFlags();
  18747. }
  18748. public function getReferences()
  18749. {
  18750. return $this->aliasOf->getReferences();
  18751. }
  18752. public function getPreferStable()
  18753. {
  18754. return $this->aliasOf->getPreferStable();
  18755. }
  18756. public function getConfig()
  18757. {
  18758. return $this->aliasOf->getConfig();
  18759. }
  18760. public function setRequires(array $require)
  18761. {
  18762. $this->requires = $this->replaceSelfVersionDependencies($require, 'requires');
  18763. $this->aliasOf->setRequires($require);
  18764. }
  18765. public function setDevRequires(array $devRequire)
  18766. {
  18767. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, 'devRequires');
  18768. $this->aliasOf->setDevRequires($devRequire);
  18769. }
  18770. public function setConflicts(array $conflicts)
  18771. {
  18772. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, 'conflicts');
  18773. $this->aliasOf->setConflicts($conflicts);
  18774. }
  18775. public function setProvides(array $provides)
  18776. {
  18777. $this->provides = $this->replaceSelfVersionDependencies($provides, 'provides');
  18778. $this->aliasOf->setProvides($provides);
  18779. }
  18780. public function setReplaces(array $replaces)
  18781. {
  18782. $this->replaces = $this->replaceSelfVersionDependencies($replaces, 'replaces');
  18783. $this->aliasOf->setReplaces($replaces);
  18784. }
  18785. public function setRepositories($repositories)
  18786. {
  18787. $this->aliasOf->setRepositories($repositories);
  18788. }
  18789. public function setAutoload(array $autoload)
  18790. {
  18791. $this->aliasOf->setAutoload($autoload);
  18792. }
  18793. public function setDevAutoload(array $devAutoload)
  18794. {
  18795. $this->aliasOf->setDevAutoload($devAutoload);
  18796. }
  18797. public function setStabilityFlags(array $stabilityFlags)
  18798. {
  18799. $this->aliasOf->setStabilityFlags($stabilityFlags);
  18800. }
  18801. public function setSuggests(array $suggests)
  18802. {
  18803. $this->aliasOf->setSuggests($suggests);
  18804. }
  18805. public function setExtra(array $extra)
  18806. {
  18807. $this->aliasOf->setExtra($extra);
  18808. }
  18809. public function __clone()
  18810. {
  18811. parent::__clone();
  18812. $this->aliasOf = clone $this->aliasOf;
  18813. }
  18814. }
  18815. <?php
  18816. namespace Composer\Package;
  18817. class RootPackage extends CompletePackage implements RootPackageInterface
  18818. {
  18819. protected $minimumStability = 'stable';
  18820. protected $preferStable = false;
  18821. protected $stabilityFlags = array();
  18822. protected $config = array();
  18823. protected $references = array();
  18824. protected $aliases = array();
  18825. public function setMinimumStability($minimumStability)
  18826. {
  18827. $this->minimumStability = $minimumStability;
  18828. }
  18829. public function getMinimumStability()
  18830. {
  18831. return $this->minimumStability;
  18832. }
  18833. public function setStabilityFlags(array $stabilityFlags)
  18834. {
  18835. $this->stabilityFlags = $stabilityFlags;
  18836. }
  18837. public function getStabilityFlags()
  18838. {
  18839. return $this->stabilityFlags;
  18840. }
  18841. public function setPreferStable($preferStable)
  18842. {
  18843. $this->preferStable = $preferStable;
  18844. }
  18845. public function getPreferStable()
  18846. {
  18847. return $this->preferStable;
  18848. }
  18849. public function setConfig(array $config)
  18850. {
  18851. $this->config = $config;
  18852. }
  18853. public function getConfig()
  18854. {
  18855. return $this->config;
  18856. }
  18857. public function setReferences(array $references)
  18858. {
  18859. $this->references = $references;
  18860. }
  18861. public function getReferences()
  18862. {
  18863. return $this->references;
  18864. }
  18865. public function setAliases(array $aliases)
  18866. {
  18867. $this->aliases = $aliases;
  18868. }
  18869. public function getAliases()
  18870. {
  18871. return $this->aliases;
  18872. }
  18873. }
  18874. <?php
  18875. namespace Composer\Package;
  18876. interface RootPackageInterface extends CompletePackageInterface
  18877. {
  18878. public function getAliases();
  18879. public function getMinimumStability();
  18880. public function getStabilityFlags();
  18881. public function getReferences();
  18882. public function getPreferStable();
  18883. public function getConfig();
  18884. public function setRequires(array $requires);
  18885. public function setDevRequires(array $devRequires);
  18886. public function setConflicts(array $conflicts);
  18887. public function setProvides(array $provides);
  18888. public function setReplaces(array $replaces);
  18889. public function setRepositories($repositories);
  18890. public function setAutoload(array $autoload);
  18891. public function setDevAutoload(array $devAutoload);
  18892. public function setStabilityFlags(array $stabilityFlags);
  18893. public function setSuggests(array $suggests);
  18894. public function setExtra(array $extra);
  18895. }
  18896. <?php
  18897. namespace Composer\Package\Version;
  18898. use Composer\Config;
  18899. use Composer\Repository\Vcs\HgDriver;
  18900. use Composer\IO\NullIO;
  18901. use Composer\Semver\VersionParser as SemverVersionParser;
  18902. use Composer\Util\Git as GitUtil;
  18903. use Composer\Util\ProcessExecutor;
  18904. use Composer\Util\Svn as SvnUtil;
  18905. class VersionGuesser
  18906. {
  18907. private $config;
  18908. private $process;
  18909. private $versionParser;
  18910. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  18911. {
  18912. $this->config = $config;
  18913. $this->process = $process;
  18914. $this->versionParser = $versionParser;
  18915. }
  18916. public function guessVersion(array $packageConfig, $path)
  18917. {
  18918. if (function_exists('proc_open')) {
  18919. $versionData = $this->guessGitVersion($packageConfig, $path);
  18920. if (null !== $versionData && null !== $versionData['version']) {
  18921. return $this->postprocess($versionData);
  18922. }
  18923. $versionData = $this->guessHgVersion($packageConfig, $path);
  18924. if (null !== $versionData && null !== $versionData['version']) {
  18925. return $this->postprocess($versionData);
  18926. }
  18927. $versionData = $this->guessFossilVersion($packageConfig, $path);
  18928. if (null !== $versionData && null !== $versionData['version']) {
  18929. return $this->postprocess($versionData);
  18930. }
  18931. $versionData = $this->guessSvnVersion($packageConfig, $path);
  18932. if (null !== $versionData && null !== $versionData['version']) {
  18933. return $this->postprocess($versionData);
  18934. }
  18935. }
  18936. }
  18937. private function postprocess(array $versionData)
  18938. {
  18939. if ('-dev' === substr($versionData['version'], -4) && preg_match('{\.9{7}}', $versionData['version'])) {
  18940. $versionData['pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['version']);
  18941. }
  18942. return $versionData;
  18943. }
  18944. private function guessGitVersion(array $packageConfig, $path)
  18945. {
  18946. GitUtil::cleanEnv();
  18947. $commit = null;
  18948. $version = null;
  18949. $prettyVersion = null;
  18950. $isDetached = false;
  18951. if (0 === $this->process->execute('git branch --no-color --no-abbrev -v', $output, $path)) {
  18952. $branches = array();
  18953. $isFeatureBranch = false;
  18954. foreach ($this->process->splitLines($output) as $branch) {
  18955. if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  18956. if ($match[1] === '(no branch)' || substr($match[1], 0, 10) === '(detached ' || substr($match[1], 0, 17) === '(HEAD detached at') {
  18957. $version = 'dev-' . $match[2];
  18958. $prettyVersion = $version;
  18959. $isFeatureBranch = true;
  18960. $isDetached = true;
  18961. } else {
  18962. $version = $this->versionParser->normalizeBranch($match[1]);
  18963. $prettyVersion = 'dev-' . $match[1];
  18964. $isFeatureBranch = 0 === strpos($version, 'dev-');
  18965. }
  18966. if ($match[2]) {
  18967. $commit = $match[2];
  18968. }
  18969. }
  18970. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  18971. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  18972. $branches[] = $match[1];
  18973. }
  18974. }
  18975. }
  18976. if ($isFeatureBranch) {
  18977. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  18978. $version = $result['version'];
  18979. $prettyVersion = $result['pretty_version'];
  18980. }
  18981. }
  18982. if (!$version || $isDetached) {
  18983. $result = $this->versionFromGitTags($path);
  18984. if ($result) {
  18985. $version = $result['version'];
  18986. $prettyVersion = $result['pretty_version'];
  18987. }
  18988. }
  18989. if (!$commit) {
  18990. $command = 'git log --pretty="%H" -n1 HEAD';
  18991. if (0 === $this->process->execute($command, $output, $path)) {
  18992. $commit = trim($output) ?: null;
  18993. }
  18994. }
  18995. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  18996. }
  18997. private function versionFromGitTags($path)
  18998. {
  18999. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  19000. try {
  19001. $version = $this->versionParser->normalize(trim($output));
  19002. return array('version' => $version, 'pretty_version' => trim($output));
  19003. } catch (\Exception $e) {
  19004. }
  19005. }
  19006. return null;
  19007. }
  19008. private function guessHgVersion(array $packageConfig, $path)
  19009. {
  19010. if (0 === $this->process->execute('hg branch', $output, $path)) {
  19011. $branch = trim($output);
  19012. $version = $this->versionParser->normalizeBranch($branch);
  19013. $isFeatureBranch = 0 === strpos($version, 'dev-');
  19014. if ('9999999-dev' === $version) {
  19015. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  19016. }
  19017. if (!$isFeatureBranch) {
  19018. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  19019. }
  19020. $driver = new HgDriver(array('url' => $path), new NullIO(), $this->config, $this->process);
  19021. $branches = array_keys($driver->getBranches());
  19022. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  19023. $result['commit'] = '';
  19024. return $result;
  19025. }
  19026. }
  19027. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  19028. {
  19029. $prettyVersion = $version;
  19030. if ((isset($packageConfig['extra']['branch-alias']) && !isset($packageConfig['extra']['branch-alias'][$version]))
  19031. || strpos(json_encode($packageConfig), '"self.version"')
  19032. ) {
  19033. $branch = preg_replace('{^dev-}', '', $version);
  19034. $length = PHP_INT_MAX;
  19035. $nonFeatureBranches = '';
  19036. if (!empty($packageConfig['non-feature-branches'])) {
  19037. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  19038. }
  19039. foreach ($branches as $candidate) {
  19040. if ($candidate === $branch && preg_match('{^(' . $nonFeatureBranches . ')$}', $candidate)) {
  19041. break;
  19042. }
  19043. if ($candidate === $branch || !preg_match('{^(' . $nonFeatureBranches . '|master|trunk|default|develop|\d+\..+)$}', $candidate, $match)) {
  19044. continue;
  19045. }
  19046. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  19047. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  19048. continue;
  19049. }
  19050. if (strlen($output) < $length) {
  19051. $length = strlen($output);
  19052. $version = $this->versionParser->normalizeBranch($candidate);
  19053. $prettyVersion = 'dev-' . $match[1];
  19054. }
  19055. }
  19056. }
  19057. return array('version' => $version, 'pretty_version' => $prettyVersion);
  19058. }
  19059. private function guessFossilVersion(array $packageConfig, $path)
  19060. {
  19061. $version = null;
  19062. $prettyVersion = null;
  19063. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  19064. $branch = trim($output);
  19065. $version = $this->versionParser->normalizeBranch($branch);
  19066. $prettyVersion = 'dev-' . $branch;
  19067. }
  19068. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  19069. try {
  19070. $version = $this->versionParser->normalize(trim($output));
  19071. $prettyVersion = trim($output);
  19072. } catch (\Exception $e) {
  19073. }
  19074. }
  19075. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  19076. }
  19077. private function guessSvnVersion(array $packageConfig, $path)
  19078. {
  19079. SvnUtil::cleanEnv();
  19080. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  19081. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  19082. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  19083. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  19084. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  19085. if (preg_match($urlPattern, $output, $matches)) {
  19086. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  19087. $version = $this->versionParser->normalizeBranch($matches[3]);
  19088. $prettyVersion = 'dev-' . $matches[3];
  19089. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  19090. }
  19091. $prettyVersion = trim($matches[1]);
  19092. $version = $this->versionParser->normalize($prettyVersion);
  19093. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  19094. }
  19095. }
  19096. }
  19097. }
  19098. <?php
  19099. namespace Composer\Package\Version;
  19100. use Composer\Repository\PlatformRepository;
  19101. use Composer\Semver\VersionParser as SemverVersionParser;
  19102. use Composer\Semver\Semver;
  19103. class VersionParser extends SemverVersionParser
  19104. {
  19105. private static $constraints = array();
  19106. public function parseConstraints($constraints)
  19107. {
  19108. if (!isset(self::$constraints[$constraints])) {
  19109. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  19110. }
  19111. return self::$constraints[$constraints];
  19112. }
  19113. public function parseNameVersionPairs(array $pairs)
  19114. {
  19115. $pairs = array_values($pairs);
  19116. $result = array();
  19117. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  19118. $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  19119. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $pairs[$i + 1])) {
  19120. $pair .= ' '.$pairs[$i + 1];
  19121. $i++;
  19122. }
  19123. if (strpos($pair, ' ')) {
  19124. list($name, $version) = explode(' ', $pair, 2);
  19125. $result[] = array('name' => $name, 'version' => $version);
  19126. } else {
  19127. $result[] = array('name' => $pair);
  19128. }
  19129. }
  19130. return $result;
  19131. }
  19132. public static function isUpgrade($normalizedFrom, $normalizedTo)
  19133. {
  19134. if (substr($normalizedFrom, 0, 4) === 'dev-' || substr($normalizedTo, 0, 4) === 'dev-') {
  19135. return true;
  19136. }
  19137. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  19138. return $sorted[0] === $normalizedFrom;
  19139. }
  19140. }
  19141. <?php
  19142. namespace Composer\Package\Version;
  19143. use Composer\DependencyResolver\Pool;
  19144. use Composer\Package\BasePackage;
  19145. use Composer\Package\PackageInterface;
  19146. use Composer\Package\Loader\ArrayLoader;
  19147. use Composer\Package\Dumper\ArrayDumper;
  19148. use Composer\Semver\Constraint\Constraint;
  19149. class VersionSelector
  19150. {
  19151. private $pool;
  19152. private $parser;
  19153. public function __construct(Pool $pool)
  19154. {
  19155. $this->pool = $pool;
  19156. }
  19157. public function findBestCandidate($packageName, $targetPackageVersion = null, $targetPhpVersion = null, $preferredStability = 'stable')
  19158. {
  19159. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  19160. $candidates = $this->pool->whatProvides(strtolower($packageName), $constraint, true);
  19161. if ($targetPhpVersion) {
  19162. $phpConstraint = new Constraint('==', $this->getParser()->normalize($targetPhpVersion));
  19163. $candidates = array_filter($candidates, function ($pkg) use ($phpConstraint) {
  19164. $reqs = $pkg->getRequires();
  19165. return !isset($reqs['php']) || $reqs['php']->getConstraint()->matches($phpConstraint);
  19166. });
  19167. }
  19168. if (!$candidates) {
  19169. return false;
  19170. }
  19171. $package = reset($candidates);
  19172. $minPriority = BasePackage::$stabilities[$preferredStability];
  19173. foreach ($candidates as $candidate) {
  19174. $candidatePriority = $candidate->getStabilityPriority();
  19175. $currentPriority = $package->getStabilityPriority();
  19176. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  19177. continue;
  19178. }
  19179. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  19180. $package = $candidate;
  19181. continue;
  19182. }
  19183. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  19184. $package = $candidate;
  19185. continue;
  19186. }
  19187. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  19188. $package = $candidate;
  19189. }
  19190. }
  19191. return $package;
  19192. }
  19193. public function findRecommendedRequireVersion(PackageInterface $package)
  19194. {
  19195. $version = $package->getVersion();
  19196. if (!$package->isDev()) {
  19197. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  19198. }
  19199. $loader = new ArrayLoader($this->getParser());
  19200. $dumper = new ArrayDumper();
  19201. $extra = $loader->getBranchAlias($dumper->dump($package));
  19202. if ($extra) {
  19203. $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  19204. if ($count) {
  19205. $extra = str_replace('.9999999', '.0', $extra);
  19206. return $this->transformVersion($extra, $extra, 'dev');
  19207. }
  19208. }
  19209. return $package->getPrettyVersion();
  19210. }
  19211. private function transformVersion($version, $prettyVersion, $stability)
  19212. {
  19213. $semanticVersionParts = explode('.', $version);
  19214. if (count($semanticVersionParts) == 4 && preg_match('{^0\D?}', $semanticVersionParts[3])) {
  19215. if ($semanticVersionParts[0] === '0') {
  19216. unset($semanticVersionParts[3]);
  19217. } else {
  19218. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  19219. }
  19220. $version = implode('.', $semanticVersionParts);
  19221. } else {
  19222. return $prettyVersion;
  19223. }
  19224. if ($stability != 'stable') {
  19225. $version .= '@'.$stability;
  19226. }
  19227. return '^' . $version;
  19228. }
  19229. private function getParser()
  19230. {
  19231. if ($this->parser === null) {
  19232. $this->parser = new VersionParser();
  19233. }
  19234. return $this->parser;
  19235. }
  19236. }
  19237. <?php
  19238. namespace Composer\Plugin\Capability;
  19239. interface Capability
  19240. {
  19241. }
  19242. <?php
  19243. namespace Composer\Plugin\Capability;
  19244. interface CommandProvider extends Capability
  19245. {
  19246. public function getCommands();
  19247. }
  19248. <?php
  19249. namespace Composer\Plugin;
  19250. interface Capable
  19251. {
  19252. public function getCapabilities();
  19253. }
  19254. <?php
  19255. namespace Composer\Plugin;
  19256. use Composer\EventDispatcher\Event;
  19257. use Symfony\Component\Console\Input\InputInterface;
  19258. use Symfony\Component\Console\Output\OutputInterface;
  19259. class CommandEvent extends Event
  19260. {
  19261. private $commandName;
  19262. private $input;
  19263. private $output;
  19264. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  19265. {
  19266. parent::__construct($name, $args, $flags);
  19267. $this->commandName = $commandName;
  19268. $this->input = $input;
  19269. $this->output = $output;
  19270. }
  19271. public function getInput()
  19272. {
  19273. return $this->input;
  19274. }
  19275. public function getOutput()
  19276. {
  19277. return $this->output;
  19278. }
  19279. public function getCommandName()
  19280. {
  19281. return $this->commandName;
  19282. }
  19283. }
  19284. <?php
  19285. namespace Composer\Plugin;
  19286. class PluginEvents
  19287. {
  19288. const INIT = 'init';
  19289. const COMMAND = 'command';
  19290. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  19291. const PRE_COMMAND_RUN = 'pre-command-run';
  19292. }
  19293. <?php
  19294. namespace Composer\Plugin;
  19295. use Composer\Composer;
  19296. use Composer\IO\IOInterface;
  19297. interface PluginInterface
  19298. {
  19299. const PLUGIN_API_VERSION = '1.1.0';
  19300. public function activate(Composer $composer, IOInterface $io);
  19301. }
  19302. <?php
  19303. namespace Composer\Plugin;
  19304. use Composer\Composer;
  19305. use Composer\EventDispatcher\EventSubscriberInterface;
  19306. use Composer\IO\IOInterface;
  19307. use Composer\Package\Package;
  19308. use Composer\Package\Version\VersionParser;
  19309. use Composer\Repository\RepositoryInterface;
  19310. use Composer\Package\AliasPackage;
  19311. use Composer\Package\PackageInterface;
  19312. use Composer\Package\Link;
  19313. use Composer\Semver\Constraint\Constraint;
  19314. use Composer\DependencyResolver\Pool;
  19315. use Composer\Plugin\Capability\Capability;
  19316. class PluginManager
  19317. {
  19318. protected $composer;
  19319. protected $io;
  19320. protected $globalComposer;
  19321. protected $versionParser;
  19322. protected $disablePlugins = false;
  19323. protected $plugins = array();
  19324. protected $registeredPlugins = array();
  19325. private static $classCounter = 0;
  19326. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  19327. {
  19328. $this->io = $io;
  19329. $this->composer = $composer;
  19330. $this->globalComposer = $globalComposer;
  19331. $this->versionParser = new VersionParser();
  19332. $this->disablePlugins = $disablePlugins;
  19333. }
  19334. public function loadInstalledPlugins()
  19335. {
  19336. if ($this->disablePlugins) {
  19337. return;
  19338. }
  19339. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  19340. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  19341. if ($repo) {
  19342. $this->loadRepository($repo);
  19343. }
  19344. if ($globalRepo) {
  19345. $this->loadRepository($globalRepo);
  19346. }
  19347. }
  19348. public function getPlugins()
  19349. {
  19350. return $this->plugins;
  19351. }
  19352. public function getGlobalComposer()
  19353. {
  19354. return $this->globalComposer;
  19355. }
  19356. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false)
  19357. {
  19358. if ($this->disablePlugins) {
  19359. return;
  19360. }
  19361. if ($package->getType() === 'composer-plugin') {
  19362. $requiresComposer = null;
  19363. foreach ($package->getRequires() as $link) {
  19364. if ('composer-plugin-api' === $link->getTarget()) {
  19365. $requiresComposer = $link->getConstraint();
  19366. break;
  19367. }
  19368. }
  19369. if (!$requiresComposer) {
  19370. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  19371. }
  19372. $currentPluginApiVersion = $this->getPluginApiVersion();
  19373. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  19374. if ($requiresComposer->getPrettyString() === '1.0.0' && $this->getPluginApiVersion() === '1.0.0') {
  19375. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin requires composer-plugin-api 1.0.0, this *WILL* break in the future and it should be fixed ASAP (require ^1.0 for example).</warning>');
  19376. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  19377. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
  19378. return;
  19379. }
  19380. }
  19381. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  19382. if (in_array($package->getName(), $this->registeredPlugins)) {
  19383. return;
  19384. }
  19385. $extra = $package->getExtra();
  19386. if (empty($extra['class'])) {
  19387. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  19388. }
  19389. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  19390. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  19391. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  19392. $pool = new Pool('dev');
  19393. $pool->addRepository($localRepo);
  19394. if ($globalRepo) {
  19395. $pool->addRepository($globalRepo);
  19396. }
  19397. $autoloadPackages = array($package->getName() => $package);
  19398. $autoloadPackages = $this->collectDependencies($pool, $autoloadPackages, $package);
  19399. $generator = $this->composer->getAutoloadGenerator();
  19400. $autoloads = array();
  19401. foreach ($autoloadPackages as $autoloadPackage) {
  19402. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  19403. $autoloads[] = array($autoloadPackage, $downloadPath);
  19404. }
  19405. $map = $generator->parseAutoloads($autoloads, new Package('dummy', '1.0.0.0', '1.0.0'));
  19406. $classLoader = $generator->createLoader($map);
  19407. $classLoader->register();
  19408. foreach ($classes as $class) {
  19409. if (class_exists($class, false)) {
  19410. $class = trim($class, '\\');
  19411. $path = $classLoader->findFile($class);
  19412. $code = file_get_contents($path);
  19413. $separatorPos = strrpos($class, '\\');
  19414. $className = $class;
  19415. if ($separatorPos) {
  19416. $className = substr($class, $separatorPos + 1);
  19417. }
  19418. $code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  19419. $code = str_replace('__FILE__', var_export($path, true), $code);
  19420. $code = str_replace('__DIR__', var_export(dirname($path), true), $code);
  19421. $code = str_replace('__CLASS__', var_export($class, true), $code);
  19422. $code = preg_replace('/^\s*<\?(php)?/i', '', $code, 1);
  19423. eval($code);
  19424. $class .= '_composer_tmp'.self::$classCounter;
  19425. self::$classCounter++;
  19426. }
  19427. if ($oldInstallerPlugin) {
  19428. $installer = new $class($this->io, $this->composer);
  19429. $this->composer->getInstallationManager()->addInstaller($installer);
  19430. } elseif (class_exists($class)) {
  19431. $plugin = new $class();
  19432. $this->addPlugin($plugin);
  19433. $this->registeredPlugins[] = $package->getName();
  19434. } elseif ($failOnMissingClasses) {
  19435. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  19436. }
  19437. }
  19438. }
  19439. protected function getPluginApiVersion()
  19440. {
  19441. return PluginInterface::PLUGIN_API_VERSION;
  19442. }
  19443. public function addPlugin(PluginInterface $plugin)
  19444. {
  19445. $this->io->writeError('Loading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  19446. $this->plugins[] = $plugin;
  19447. $plugin->activate($this->composer, $this->io);
  19448. if ($plugin instanceof EventSubscriberInterface) {
  19449. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  19450. }
  19451. }
  19452. private function loadRepository(RepositoryInterface $repo)
  19453. {
  19454. foreach ($repo->getPackages() as $package) {
  19455. if ($package instanceof AliasPackage) {
  19456. continue;
  19457. }
  19458. if ('composer-plugin' === $package->getType()) {
  19459. $this->registerPackage($package);
  19460. } elseif ('composer-installer' === $package->getType()) {
  19461. $this->registerPackage($package);
  19462. }
  19463. }
  19464. }
  19465. private function collectDependencies(Pool $pool, array $collected, PackageInterface $package)
  19466. {
  19467. $requires = array_merge(
  19468. $package->getRequires(),
  19469. $package->getDevRequires()
  19470. );
  19471. foreach ($requires as $requireLink) {
  19472. $requiredPackage = $this->lookupInstalledPackage($pool, $requireLink);
  19473. if ($requiredPackage && !isset($collected[$requiredPackage->getName()])) {
  19474. $collected[$requiredPackage->getName()] = $requiredPackage;
  19475. $collected = $this->collectDependencies($pool, $collected, $requiredPackage);
  19476. }
  19477. }
  19478. return $collected;
  19479. }
  19480. private function lookupInstalledPackage(Pool $pool, Link $link)
  19481. {
  19482. $packages = $pool->whatProvides($link->getTarget(), $link->getConstraint());
  19483. return !empty($packages) ? $packages[0] : null;
  19484. }
  19485. private function getInstallPath(PackageInterface $package, $global = false)
  19486. {
  19487. if (!$global) {
  19488. return $this->composer->getInstallationManager()->getInstallPath($package);
  19489. }
  19490. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  19491. }
  19492. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  19493. {
  19494. if (!($plugin instanceof Capable)) {
  19495. return null;
  19496. }
  19497. $capabilities = (array) $plugin->getCapabilities();
  19498. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  19499. return trim($capabilities[$capability]);
  19500. }
  19501. if (
  19502. array_key_exists($capability, $capabilities)
  19503. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  19504. ) {
  19505. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], 1));
  19506. }
  19507. }
  19508. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  19509. {
  19510. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  19511. if (!class_exists($capabilityClass)) {
  19512. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  19513. }
  19514. $ctorArgs['plugin'] = $plugin;
  19515. $capabilityObj = new $capabilityClass($ctorArgs);
  19516. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  19517. throw new \RuntimeException(
  19518. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  19519. );
  19520. }
  19521. return $capabilityObj;
  19522. }
  19523. }
  19524. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  19525. {
  19526. $capabilities = array();
  19527. foreach ($this->getPlugins() as $plugin) {
  19528. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  19529. $capabilities[] = $capability;
  19530. }
  19531. }
  19532. return $capabilities;
  19533. }
  19534. }
  19535. <?php
  19536. namespace Composer\Plugin;
  19537. use Composer\EventDispatcher\Event;
  19538. use Symfony\Component\Console\Input\InputInterface;
  19539. class PreCommandRunEvent extends Event
  19540. {
  19541. private $input;
  19542. private $command;
  19543. public function __construct($name, InputInterface $input, $command)
  19544. {
  19545. parent::__construct($name);
  19546. $this->input = $input;
  19547. $this->command = $command;
  19548. }
  19549. public function getInput()
  19550. {
  19551. return $this->input;
  19552. }
  19553. public function getCommand()
  19554. {
  19555. return $this->command;
  19556. }
  19557. }
  19558. <?php
  19559. namespace Composer\Plugin;
  19560. use Composer\EventDispatcher\Event;
  19561. use Composer\Util\RemoteFilesystem;
  19562. class PreFileDownloadEvent extends Event
  19563. {
  19564. private $rfs;
  19565. private $processedUrl;
  19566. public function __construct($name, RemoteFilesystem $rfs, $processedUrl)
  19567. {
  19568. parent::__construct($name);
  19569. $this->rfs = $rfs;
  19570. $this->processedUrl = $processedUrl;
  19571. }
  19572. public function getRemoteFilesystem()
  19573. {
  19574. return $this->rfs;
  19575. }
  19576. public function setRemoteFilesystem(RemoteFilesystem $rfs)
  19577. {
  19578. $this->rfs = $rfs;
  19579. }
  19580. public function getProcessedUrl()
  19581. {
  19582. return $this->processedUrl;
  19583. }
  19584. }
  19585. <?php
  19586. namespace Composer\Question;
  19587. use Symfony\Component\Console\Exception\InvalidArgumentException;
  19588. use Symfony\Component\Console\Question\Question;
  19589. class StrictConfirmationQuestion extends Question
  19590. {
  19591. private $trueAnswerRegex;
  19592. private $falseAnswerRegex;
  19593. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  19594. {
  19595. parent::__construct($question, (bool) $default);
  19596. $this->trueAnswerRegex = $trueAnswerRegex;
  19597. $this->falseAnswerRegex = $falseAnswerRegex;
  19598. $this->setNormalizer($this->getDefaultNormalizer());
  19599. $this->setValidator($this->getDefaultValidator());
  19600. }
  19601. private function getDefaultNormalizer()
  19602. {
  19603. $default = $this->getDefault();
  19604. $trueRegex = $this->trueAnswerRegex;
  19605. $falseRegex = $this->falseAnswerRegex;
  19606. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  19607. if (is_bool($answer)) {
  19608. return $answer;
  19609. }
  19610. if (empty($answer) && !empty($default)) {
  19611. return $default;
  19612. }
  19613. if (preg_match($trueRegex, $answer)) {
  19614. return true;
  19615. }
  19616. if (preg_match($falseRegex, $answer)) {
  19617. return false;
  19618. }
  19619. return null;
  19620. };
  19621. }
  19622. private function getDefaultValidator()
  19623. {
  19624. return function ($answer) {
  19625. if (!is_bool($answer)) {
  19626. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  19627. }
  19628. return $answer;
  19629. };
  19630. }
  19631. }
  19632. <?php
  19633. namespace Composer\Repository;
  19634. use Composer\Package\AliasPackage;
  19635. use Composer\Package\PackageInterface;
  19636. use Composer\Package\CompletePackageInterface;
  19637. use Composer\Package\Version\VersionParser;
  19638. use Composer\Semver\Constraint\ConstraintInterface;
  19639. use Composer\Semver\Constraint\Constraint;
  19640. class ArrayRepository extends BaseRepository
  19641. {
  19642. protected $packages;
  19643. public function __construct(array $packages = array())
  19644. {
  19645. foreach ($packages as $package) {
  19646. $this->addPackage($package);
  19647. }
  19648. }
  19649. public function findPackage($name, $constraint)
  19650. {
  19651. $name = strtolower($name);
  19652. if (!$constraint instanceof ConstraintInterface) {
  19653. $versionParser = new VersionParser();
  19654. $constraint = $versionParser->parseConstraints($constraint);
  19655. }
  19656. foreach ($this->getPackages() as $package) {
  19657. if ($name === $package->getName()) {
  19658. $pkgConstraint = new Constraint('==', $package->getVersion());
  19659. if ($constraint->matches($pkgConstraint)) {
  19660. return $package;
  19661. }
  19662. }
  19663. }
  19664. return null;
  19665. }
  19666. public function findPackages($name, $constraint = null)
  19667. {
  19668. $name = strtolower($name);
  19669. $packages = array();
  19670. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  19671. $versionParser = new VersionParser();
  19672. $constraint = $versionParser->parseConstraints($constraint);
  19673. }
  19674. foreach ($this->getPackages() as $package) {
  19675. if ($name === $package->getName()) {
  19676. $pkgConstraint = new Constraint('==', $package->getVersion());
  19677. if (null === $constraint || $constraint->matches($pkgConstraint)) {
  19678. $packages[] = $package;
  19679. }
  19680. }
  19681. }
  19682. return $packages;
  19683. }
  19684. public function search($query, $mode = 0, $type = null)
  19685. {
  19686. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  19687. $matches = array();
  19688. foreach ($this->getPackages() as $package) {
  19689. $name = $package->getName();
  19690. if (isset($matches[$name])) {
  19691. continue;
  19692. }
  19693. if (preg_match($regex, $name)
  19694. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  19695. ) {
  19696. if (null !== $type && $package->getType() !== $type) {
  19697. continue;
  19698. }
  19699. $matches[$name] = array(
  19700. 'name' => $package->getPrettyName(),
  19701. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  19702. );
  19703. }
  19704. }
  19705. return array_values($matches);
  19706. }
  19707. public function hasPackage(PackageInterface $package)
  19708. {
  19709. $packageId = $package->getUniqueName();
  19710. foreach ($this->getPackages() as $repoPackage) {
  19711. if ($packageId === $repoPackage->getUniqueName()) {
  19712. return true;
  19713. }
  19714. }
  19715. return false;
  19716. }
  19717. public function addPackage(PackageInterface $package)
  19718. {
  19719. if (null === $this->packages) {
  19720. $this->initialize();
  19721. }
  19722. $package->setRepository($this);
  19723. $this->packages[] = $package;
  19724. if ($package instanceof AliasPackage) {
  19725. $aliasedPackage = $package->getAliasOf();
  19726. if (null === $aliasedPackage->getRepository()) {
  19727. $this->addPackage($aliasedPackage);
  19728. }
  19729. }
  19730. }
  19731. protected function createAliasPackage(PackageInterface $package, $alias, $prettyAlias)
  19732. {
  19733. return new AliasPackage($package instanceof AliasPackage ? $package->getAliasOf() : $package, $alias, $prettyAlias);
  19734. }
  19735. public function removePackage(PackageInterface $package)
  19736. {
  19737. $packageId = $package->getUniqueName();
  19738. foreach ($this->getPackages() as $key => $repoPackage) {
  19739. if ($packageId === $repoPackage->getUniqueName()) {
  19740. array_splice($this->packages, $key, 1);
  19741. return;
  19742. }
  19743. }
  19744. }
  19745. public function getPackages()
  19746. {
  19747. if (null === $this->packages) {
  19748. $this->initialize();
  19749. }
  19750. return $this->packages;
  19751. }
  19752. public function count()
  19753. {
  19754. return count($this->packages);
  19755. }
  19756. protected function initialize()
  19757. {
  19758. $this->packages = array();
  19759. }
  19760. }
  19761. <?php
  19762. namespace Composer\Repository;
  19763. use Composer\IO\IOInterface;
  19764. use Composer\Json\JsonFile;
  19765. use Composer\Package\Loader\ArrayLoader;
  19766. use Composer\Package\Loader\LoaderInterface;
  19767. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  19768. {
  19769. protected $loader;
  19770. protected $lookup;
  19771. protected $repoConfig;
  19772. private $io;
  19773. public function __construct(array $repoConfig, IOInterface $io)
  19774. {
  19775. parent::__construct();
  19776. if (!extension_loaded('zip')) {
  19777. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  19778. }
  19779. $this->loader = new ArrayLoader();
  19780. $this->lookup = $repoConfig['url'];
  19781. $this->io = $io;
  19782. $this->repoConfig = $repoConfig;
  19783. }
  19784. public function getRepoConfig()
  19785. {
  19786. return $this->repoConfig;
  19787. }
  19788. protected function initialize()
  19789. {
  19790. parent::initialize();
  19791. $this->scanDirectory($this->lookup);
  19792. }
  19793. private function scanDirectory($path)
  19794. {
  19795. $io = $this->io;
  19796. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  19797. $iterator = new \RecursiveIteratorIterator($directory);
  19798. $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar)$/i');
  19799. foreach ($regex as $file) {
  19800. if (!$file->isFile()) {
  19801. continue;
  19802. }
  19803. $package = $this->getComposerInformation($file);
  19804. if (!$package) {
  19805. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  19806. continue;
  19807. }
  19808. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  19809. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  19810. $this->addPackage($package);
  19811. }
  19812. }
  19813. private function locateFile(\ZipArchive $zip, $filename)
  19814. {
  19815. $indexOfShortestMatch = false;
  19816. $lengthOfShortestMatch = -1;
  19817. for ($i = 0; $i < $zip->numFiles; $i++) {
  19818. $stat = $zip->statIndex($i);
  19819. if (strcmp(basename($stat['name']), $filename) === 0) {
  19820. $directoryName = dirname($stat['name']);
  19821. if ($directoryName == '.') {
  19822. return $i;
  19823. }
  19824. if (strpos($directoryName, '\\') !== false ||
  19825. strpos($directoryName, '/') !== false) {
  19826. continue;
  19827. }
  19828. $length = strlen($stat['name']);
  19829. if ($indexOfShortestMatch === false || $length < $lengthOfShortestMatch) {
  19830. $contents = $zip->getFromIndex($i);
  19831. if ($contents !== false) {
  19832. $indexOfShortestMatch = $i;
  19833. $lengthOfShortestMatch = $length;
  19834. }
  19835. }
  19836. }
  19837. }
  19838. return $indexOfShortestMatch;
  19839. }
  19840. private function getComposerInformation(\SplFileInfo $file)
  19841. {
  19842. $zip = new \ZipArchive();
  19843. if ($zip->open($file->getPathname()) !== true) {
  19844. return false;
  19845. }
  19846. if (0 == $zip->numFiles) {
  19847. $zip->close();
  19848. return false;
  19849. }
  19850. $foundFileIndex = $this->locateFile($zip, 'composer.json');
  19851. if (false === $foundFileIndex) {
  19852. $zip->close();
  19853. return false;
  19854. }
  19855. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  19856. $zip->close();
  19857. $composerFile = "zip://{$file->getPathname()}#$configurationFileName";
  19858. $json = file_get_contents($composerFile);
  19859. $package = JsonFile::parseJson($json, $composerFile);
  19860. $package['dist'] = array(
  19861. 'type' => 'zip',
  19862. 'url' => strtr($file->getPathname(), '\\', '/'),
  19863. 'shasum' => sha1_file($file->getRealPath()),
  19864. );
  19865. try {
  19866. $package = $this->loader->load($package);
  19867. } catch (\UnexpectedValueException $e) {
  19868. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  19869. }
  19870. return $package;
  19871. }
  19872. }
  19873. <?php
  19874. namespace Composer\Repository;
  19875. use Composer\Package\RootPackageInterface;
  19876. use Composer\Semver\Constraint\ConstraintInterface;
  19877. use Composer\Semver\Constraint\Constraint;
  19878. use Composer\Package\Link;
  19879. abstract class BaseRepository implements RepositoryInterface
  19880. {
  19881. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  19882. {
  19883. $needles = array_map('strtolower', (array) $needle);
  19884. $results = array();
  19885. if (null === $packagesFound) {
  19886. $packagesFound = $needles;
  19887. }
  19888. $rootPackage = null;
  19889. foreach ($this->getPackages() as $package) {
  19890. if ($package instanceof RootPackageInterface) {
  19891. $rootPackage = $package;
  19892. break;
  19893. }
  19894. }
  19895. foreach ($this->getPackages() as $package) {
  19896. $links = $package->getRequires();
  19897. $packagesInTree = $packagesFound;
  19898. if (!$invert) {
  19899. $links += $package->getReplaces();
  19900. }
  19901. if ($package instanceof RootPackageInterface) {
  19902. $links += $package->getDevRequires();
  19903. }
  19904. foreach ($links as $link) {
  19905. foreach ($needles as $needle) {
  19906. if ($link->getTarget() === $needle) {
  19907. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  19908. if (in_array($link->getSource(), $packagesInTree)) {
  19909. $results[$link->getSource()] = array($package, $link, false);
  19910. continue;
  19911. }
  19912. $packagesInTree[] = $link->getSource();
  19913. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  19914. $results[$link->getSource()] = array($package, $link, $dependents);
  19915. }
  19916. }
  19917. }
  19918. }
  19919. if ($invert && in_array($package->getName(), $needles)) {
  19920. foreach ($package->getConflicts() as $link) {
  19921. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  19922. $version = new Constraint('=', $pkg->getVersion());
  19923. if ($link->getConstraint()->matches($version) === $invert) {
  19924. $results[] = array($package, $link, false);
  19925. }
  19926. }
  19927. }
  19928. }
  19929. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  19930. foreach ($package->getRequires() as $link) {
  19931. if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $link->getTarget())) {
  19932. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  19933. continue;
  19934. }
  19935. $platformPkg = $this->findPackage($link->getTarget(), '*');
  19936. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  19937. $results[] = array($package, new Link($package->getName(), $link->getTarget(), null, 'requires', $link->getPrettyConstraint().' '.$description), false);
  19938. continue;
  19939. }
  19940. foreach ($this->getPackages() as $pkg) {
  19941. if (!in_array($link->getTarget(), $pkg->getNames())) {
  19942. continue;
  19943. }
  19944. $version = new Constraint('=', $pkg->getVersion());
  19945. if (!$link->getConstraint()->matches($version)) {
  19946. if ($rootPackage) {
  19947. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  19948. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  19949. $results[] = array($package, $link, false);
  19950. $results[] = array($rootPackage, $rootReq, false);
  19951. continue 3;
  19952. }
  19953. }
  19954. $results[] = array($package, $link, false);
  19955. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), null, 'does not require', 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  19956. } else {
  19957. $results[] = array($package, $link, false);
  19958. }
  19959. }
  19960. continue 2;
  19961. }
  19962. }
  19963. }
  19964. }
  19965. ksort($results);
  19966. return $results;
  19967. }
  19968. }
  19969. <?php
  19970. namespace Composer\Repository;
  19971. use Composer\Package\Loader\ArrayLoader;
  19972. use Composer\Package\PackageInterface;
  19973. use Composer\Package\AliasPackage;
  19974. use Composer\Package\Version\VersionParser;
  19975. use Composer\DependencyResolver\Pool;
  19976. use Composer\Json\JsonFile;
  19977. use Composer\Cache;
  19978. use Composer\Config;
  19979. use Composer\Factory;
  19980. use Composer\IO\IOInterface;
  19981. use Composer\Util\RemoteFilesystem;
  19982. use Composer\Plugin\PluginEvents;
  19983. use Composer\Plugin\PreFileDownloadEvent;
  19984. use Composer\EventDispatcher\EventDispatcher;
  19985. use Composer\Downloader\TransportException;
  19986. use Composer\Semver\Constraint\ConstraintInterface;
  19987. use Composer\Semver\Constraint\Constraint;
  19988. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  19989. {
  19990. protected $config;
  19991. protected $repoConfig;
  19992. protected $options;
  19993. protected $url;
  19994. protected $baseUrl;
  19995. protected $io;
  19996. protected $rfs;
  19997. protected $cache;
  19998. protected $notifyUrl;
  19999. protected $searchUrl;
  20000. protected $hasProviders = false;
  20001. protected $providersUrl;
  20002. protected $lazyProvidersUrl;
  20003. protected $providerListing;
  20004. protected $providers = array();
  20005. protected $providersByUid = array();
  20006. protected $loader;
  20007. protected $rootAliases;
  20008. protected $allowSslDowngrade = false;
  20009. protected $eventDispatcher;
  20010. protected $sourceMirrors;
  20011. protected $distMirrors;
  20012. private $degradedMode = false;
  20013. private $rootData;
  20014. private $hasPartialPackages;
  20015. private $partialPackagesByName;
  20016. public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null)
  20017. {
  20018. parent::__construct();
  20019. if (!preg_match('{^[\w.]+\??://}', $repoConfig['url'])) {
  20020. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  20021. }
  20022. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  20023. if ('https?' === substr($repoConfig['url'], 0, 6)) {
  20024. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  20025. }
  20026. $urlBits = parse_url($repoConfig['url']);
  20027. if ($urlBits === false || empty($urlBits['scheme'])) {
  20028. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  20029. }
  20030. if (!isset($repoConfig['options'])) {
  20031. $repoConfig['options'] = array();
  20032. }
  20033. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  20034. $this->allowSslDowngrade = true;
  20035. }
  20036. $this->config = $config;
  20037. $this->options = $repoConfig['options'];
  20038. $this->url = $repoConfig['url'];
  20039. if (preg_match('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  20040. $this->url = $match['proto'].'://repo.packagist.org';
  20041. }
  20042. $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  20043. $this->io = $io;
  20044. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$');
  20045. $this->loader = new ArrayLoader();
  20046. if ($rfs && $this->options) {
  20047. $rfs = clone $rfs;
  20048. $rfs->setOptions($this->options);
  20049. }
  20050. $this->rfs = $rfs ?: Factory::createRemoteFilesystem($this->io, $this->config, $this->options);
  20051. $this->eventDispatcher = $eventDispatcher;
  20052. $this->repoConfig = $repoConfig;
  20053. }
  20054. public function getRepoConfig()
  20055. {
  20056. return $this->repoConfig;
  20057. }
  20058. public function setRootAliases(array $rootAliases)
  20059. {
  20060. $this->rootAliases = $rootAliases;
  20061. }
  20062. public function findPackage($name, $constraint)
  20063. {
  20064. if (!$this->hasProviders()) {
  20065. return parent::findPackage($name, $constraint);
  20066. }
  20067. $name = strtolower($name);
  20068. if (!$constraint instanceof ConstraintInterface) {
  20069. $versionParser = new VersionParser();
  20070. $constraint = $versionParser->parseConstraints($constraint);
  20071. }
  20072. foreach ($this->getProviderNames() as $providerName) {
  20073. if ($name === $providerName) {
  20074. $packages = $this->whatProvides(new Pool('dev'), $providerName);
  20075. foreach ($packages as $package) {
  20076. if ($name === $package->getName()) {
  20077. $pkgConstraint = new Constraint('==', $package->getVersion());
  20078. if ($constraint->matches($pkgConstraint)) {
  20079. return $package;
  20080. }
  20081. }
  20082. }
  20083. break;
  20084. }
  20085. }
  20086. }
  20087. public function findPackages($name, $constraint = null)
  20088. {
  20089. if (!$this->hasProviders()) {
  20090. return parent::findPackages($name, $constraint);
  20091. }
  20092. $name = strtolower($name);
  20093. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  20094. $versionParser = new VersionParser();
  20095. $constraint = $versionParser->parseConstraints($constraint);
  20096. }
  20097. $packages = array();
  20098. foreach ($this->getProviderNames() as $providerName) {
  20099. if ($name === $providerName) {
  20100. $candidates = $this->whatProvides(new Pool('dev'), $providerName);
  20101. foreach ($candidates as $package) {
  20102. if ($name === $package->getName()) {
  20103. $pkgConstraint = new Constraint('==', $package->getVersion());
  20104. if (null === $constraint || $constraint->matches($pkgConstraint)) {
  20105. $packages[] = $package;
  20106. }
  20107. }
  20108. }
  20109. break;
  20110. }
  20111. }
  20112. return $packages;
  20113. }
  20114. public function getPackages()
  20115. {
  20116. if ($this->hasProviders()) {
  20117. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getProviderNames instead.');
  20118. }
  20119. return parent::getPackages();
  20120. }
  20121. public function search($query, $mode = 0, $type = null)
  20122. {
  20123. $this->loadRootServerFile();
  20124. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  20125. $url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
  20126. $hostname = parse_url($url, PHP_URL_HOST) ?: $url;
  20127. $json = $this->rfs->getContents($hostname, $url, false);
  20128. $search = JsonFile::parseJson($json, $url);
  20129. if (empty($search['results'])) {
  20130. return array();
  20131. }
  20132. $results = array();
  20133. foreach ($search['results'] as $result) {
  20134. if (empty($result['virtual'])) {
  20135. $results[] = $result;
  20136. }
  20137. }
  20138. return $results;
  20139. }
  20140. if ($this->hasProviders()) {
  20141. $results = array();
  20142. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  20143. foreach ($this->getProviderNames() as $name) {
  20144. if (preg_match($regex, $name)) {
  20145. $results[] = array('name' => $name);
  20146. }
  20147. }
  20148. return $results;
  20149. }
  20150. return parent::search($query, $mode);
  20151. }
  20152. public function getProviderNames()
  20153. {
  20154. $this->loadRootServerFile();
  20155. if (null === $this->providerListing) {
  20156. $this->loadProviderListings($this->loadRootServerFile());
  20157. }
  20158. if ($this->lazyProvidersUrl) {
  20159. return array();
  20160. }
  20161. if ($this->providersUrl) {
  20162. return array_keys($this->providerListing);
  20163. }
  20164. return array();
  20165. }
  20166. protected function configurePackageTransportOptions(PackageInterface $package)
  20167. {
  20168. foreach ($package->getDistUrls() as $url) {
  20169. if (strpos($url, $this->baseUrl) === 0) {
  20170. $package->setTransportOptions($this->options);
  20171. return;
  20172. }
  20173. }
  20174. }
  20175. public function hasProviders()
  20176. {
  20177. $this->loadRootServerFile();
  20178. return $this->hasProviders;
  20179. }
  20180. public function resetPackageIds()
  20181. {
  20182. foreach ($this->providersByUid as $package) {
  20183. if ($package instanceof AliasPackage) {
  20184. $package->getAliasOf()->setId(-1);
  20185. }
  20186. $package->setId(-1);
  20187. }
  20188. }
  20189. public function whatProvides(Pool $pool, $name, $bypassFilters = false)
  20190. {
  20191. if (isset($this->providers[$name]) && !$bypassFilters) {
  20192. return $this->providers[$name];
  20193. }
  20194. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  20195. $this->initializePartialPackages();
  20196. }
  20197. if (!$this->hasPartialPackages || !isset($this->partialPackagesByName[$name])) {
  20198. if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name) || '__root__' === $name || 'composer-plugin-api' === $name) {
  20199. return array();
  20200. }
  20201. if (null === $this->providerListing) {
  20202. $this->loadProviderListings($this->loadRootServerFile());
  20203. }
  20204. $useLastModifiedCheck = false;
  20205. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  20206. $hash = null;
  20207. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  20208. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  20209. $useLastModifiedCheck = true;
  20210. } elseif ($this->providersUrl) {
  20211. if (!isset($this->providerListing[$name])) {
  20212. return array();
  20213. }
  20214. $hash = $this->providerListing[$name]['sha256'];
  20215. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  20216. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  20217. } else {
  20218. return array();
  20219. }
  20220. $packages = null;
  20221. if ($cacheKey) {
  20222. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  20223. $packages = json_decode($this->cache->read($cacheKey), true);
  20224. } elseif ($useLastModifiedCheck) {
  20225. if ($contents = $this->cache->read($cacheKey)) {
  20226. $contents = json_decode($contents, true);
  20227. if (isset($contents['last-modified'])) {
  20228. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  20229. if (true === $response) {
  20230. $packages = $contents;
  20231. } elseif ($response) {
  20232. $packages = $response;
  20233. }
  20234. }
  20235. }
  20236. }
  20237. }
  20238. if (!$packages) {
  20239. try {
  20240. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  20241. } catch (TransportException $e) {
  20242. if ($e->getStatusCode() === 404 && $this->lazyProvidersUrl) {
  20243. $packages = array('packages' => array());
  20244. } else {
  20245. throw $e;
  20246. }
  20247. }
  20248. }
  20249. $loadingPartialPackage = false;
  20250. } else {
  20251. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  20252. $loadingPartialPackage = true;
  20253. }
  20254. $this->providers[$name] = array();
  20255. foreach ($packages['packages'] as $versions) {
  20256. foreach ($versions as $version) {
  20257. if (!$loadingPartialPackage && $this->hasPartialPackages && isset($this->partialPackagesByName[$version['name']])) {
  20258. continue;
  20259. }
  20260. if (isset($this->providersByUid[$version['uid']])) {
  20261. if (!isset($this->providers[$name][$version['uid']])) {
  20262. if ($this->providersByUid[$version['uid']] instanceof AliasPackage) {
  20263. $this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']]->getAliasOf();
  20264. $this->providers[$name][$version['uid'].'-alias'] = $this->providersByUid[$version['uid']];
  20265. } else {
  20266. $this->providers[$name][$version['uid']] = $this->providersByUid[$version['uid']];
  20267. }
  20268. if (isset($this->providersByUid[$version['uid'].'-root'])) {
  20269. $this->providers[$name][$version['uid'].'-root'] = $this->providersByUid[$version['uid'].'-root'];
  20270. }
  20271. }
  20272. } else {
  20273. if (!$bypassFilters && !$pool->isPackageAcceptable(strtolower($version['name']), VersionParser::parseStability($version['version']))) {
  20274. continue;
  20275. }
  20276. $package = $this->createPackage($version, 'Composer\Package\CompletePackage');
  20277. $package->setRepository($this);
  20278. if ($package instanceof AliasPackage) {
  20279. $aliased = $package->getAliasOf();
  20280. $aliased->setRepository($this);
  20281. $this->providers[$name][$version['uid']] = $aliased;
  20282. $this->providers[$name][$version['uid'].'-alias'] = $package;
  20283. $this->providersByUid[$version['uid']] = $package;
  20284. } else {
  20285. $this->providers[$name][$version['uid']] = $package;
  20286. $this->providersByUid[$version['uid']] = $package;
  20287. }
  20288. unset($rootAliasData);
  20289. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  20290. $rootAliasData = $this->rootAliases[$package->getName()][$package->getVersion()];
  20291. } elseif ($package instanceof AliasPackage && isset($this->rootAliases[$package->getName()][$package->getAliasOf()->getVersion()])) {
  20292. $rootAliasData = $this->rootAliases[$package->getName()][$package->getAliasOf()->getVersion()];
  20293. }
  20294. if (isset($rootAliasData)) {
  20295. $alias = $this->createAliasPackage($package, $rootAliasData['alias_normalized'], $rootAliasData['alias']);
  20296. $alias->setRepository($this);
  20297. $this->providers[$name][$version['uid'].'-root'] = $alias;
  20298. $this->providersByUid[$version['uid'].'-root'] = $alias;
  20299. }
  20300. }
  20301. }
  20302. }
  20303. $result = $this->providers[$name];
  20304. if ($bypassFilters) {
  20305. foreach ($this->providers[$name] as $uid => $provider) {
  20306. unset($this->providersByUid[$uid]);
  20307. }
  20308. unset($this->providers[$name]);
  20309. }
  20310. return $result;
  20311. }
  20312. protected function initialize()
  20313. {
  20314. parent::initialize();
  20315. $repoData = $this->loadDataFromServer();
  20316. foreach ($repoData as $package) {
  20317. $this->addPackage($this->createPackage($package, 'Composer\Package\CompletePackage'));
  20318. }
  20319. }
  20320. public function addPackage(PackageInterface $package)
  20321. {
  20322. parent::addPackage($package);
  20323. $this->configurePackageTransportOptions($package);
  20324. }
  20325. protected function loadRootServerFile()
  20326. {
  20327. if (null !== $this->rootData) {
  20328. return $this->rootData;
  20329. }
  20330. if (!extension_loaded('openssl') && 'https' === substr($this->url, 0, 5)) {
  20331. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  20332. }
  20333. $jsonUrlParts = parse_url($this->url);
  20334. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  20335. $jsonUrl = $this->url;
  20336. } else {
  20337. $jsonUrl = $this->url . '/packages.json';
  20338. }
  20339. $data = $this->fetchFile($jsonUrl, 'packages.json');
  20340. if (!empty($data['notify-batch'])) {
  20341. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  20342. } elseif (!empty($data['notify'])) {
  20343. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  20344. }
  20345. if (!empty($data['search'])) {
  20346. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  20347. }
  20348. if (!empty($data['mirrors'])) {
  20349. foreach ($data['mirrors'] as $mirror) {
  20350. if (!empty($mirror['git-url'])) {
  20351. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  20352. }
  20353. if (!empty($mirror['hg-url'])) {
  20354. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  20355. }
  20356. if (!empty($mirror['dist-url'])) {
  20357. $this->distMirrors[] = array(
  20358. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  20359. 'preferred' => !empty($mirror['preferred']),
  20360. );
  20361. }
  20362. }
  20363. }
  20364. if (!empty($data['providers-lazy-url'])) {
  20365. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  20366. $this->hasProviders = true;
  20367. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  20368. }
  20369. if ($this->allowSslDowngrade) {
  20370. $this->url = str_replace('https://', 'http://', $this->url);
  20371. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  20372. }
  20373. if (!empty($data['providers-url'])) {
  20374. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  20375. $this->hasProviders = true;
  20376. }
  20377. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  20378. $this->hasProviders = true;
  20379. }
  20380. if (preg_match('{^https?://repo\.packagist\.org/?$}i', $this->url) && !empty($this->repoConfig['force-lazy-providers'])) {
  20381. $this->url = 'https://repo.packagist.org';
  20382. $this->baseUrl = 'https://repo.packagist.org';
  20383. $this->lazyProvidersUrl = $this->canonicalizeUrl('https://repo.packagist.org/p/%package%.json');
  20384. $this->providersUrl = null;
  20385. } elseif (!empty($this->repoConfig['force-lazy-providers'])) {
  20386. $this->lazyProvidersUrl = $this->canonicalizeUrl('/p/%package%.json');
  20387. $this->providersUrl = null;
  20388. }
  20389. return $this->rootData = $data;
  20390. }
  20391. protected function canonicalizeUrl($url)
  20392. {
  20393. if ('/' === $url[0]) {
  20394. return preg_replace('{(https?://[^/]+).*}i', '$1' . $url, $this->url);
  20395. }
  20396. return $url;
  20397. }
  20398. protected function loadDataFromServer()
  20399. {
  20400. $data = $this->loadRootServerFile();
  20401. return $this->loadIncludes($data);
  20402. }
  20403. protected function loadProviderListings($data)
  20404. {
  20405. if (isset($data['providers'])) {
  20406. if (!is_array($this->providerListing)) {
  20407. $this->providerListing = array();
  20408. }
  20409. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  20410. }
  20411. if ($this->providersUrl && isset($data['provider-includes'])) {
  20412. $includes = $data['provider-includes'];
  20413. foreach ($includes as $include => $metadata) {
  20414. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  20415. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  20416. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  20417. $includedData = json_decode($this->cache->read($cacheKey), true);
  20418. } else {
  20419. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  20420. }
  20421. $this->loadProviderListings($includedData);
  20422. }
  20423. }
  20424. }
  20425. protected function loadIncludes($data)
  20426. {
  20427. $packages = array();
  20428. if (!isset($data['packages']) && !isset($data['includes'])) {
  20429. foreach ($data as $pkg) {
  20430. foreach ($pkg['versions'] as $metadata) {
  20431. $packages[] = $metadata;
  20432. }
  20433. }
  20434. return $packages;
  20435. }
  20436. if (isset($data['packages'])) {
  20437. foreach ($data['packages'] as $package => $versions) {
  20438. foreach ($versions as $version => $metadata) {
  20439. $packages[] = $metadata;
  20440. }
  20441. }
  20442. }
  20443. if (isset($data['includes'])) {
  20444. foreach ($data['includes'] as $include => $metadata) {
  20445. if ($this->cache->sha1($include) === $metadata['sha1']) {
  20446. $includedData = json_decode($this->cache->read($include), true);
  20447. } else {
  20448. $includedData = $this->fetchFile($include);
  20449. }
  20450. $packages = array_merge($packages, $this->loadIncludes($includedData));
  20451. }
  20452. }
  20453. return $packages;
  20454. }
  20455. protected function createPackage(array $data, $class = 'Composer\Package\CompletePackage')
  20456. {
  20457. try {
  20458. if (!isset($data['notification-url'])) {
  20459. $data['notification-url'] = $this->notifyUrl;
  20460. }
  20461. $package = $this->loader->load($data, $class);
  20462. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  20463. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  20464. }
  20465. $package->setDistMirrors($this->distMirrors);
  20466. $this->configurePackageTransportOptions($package);
  20467. return $package;
  20468. } catch (\Exception $e) {
  20469. throw new \RuntimeException('Could not load package '.(isset($data['name']) ? $data['name'] : json_encode($data)).' in '.$this->url.': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
  20470. }
  20471. }
  20472. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  20473. {
  20474. if (null === $cacheKey) {
  20475. $cacheKey = $filename;
  20476. $filename = $this->baseUrl.'/'.$filename;
  20477. }
  20478. if (($pos = strpos($filename, '$')) && preg_match('{^https?://.*}i', $filename)) {
  20479. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  20480. }
  20481. $retries = 3;
  20482. while ($retries--) {
  20483. try {
  20484. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->rfs, $filename);
  20485. if ($this->eventDispatcher) {
  20486. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  20487. }
  20488. $hostname = parse_url($filename, PHP_URL_HOST) ?: $filename;
  20489. $rfs = $preFileDownloadEvent->getRemoteFilesystem();
  20490. $json = $rfs->getContents($hostname, $filename, false);
  20491. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  20492. if ($this->allowSslDowngrade) {
  20493. $this->url = str_replace('http://', 'https://', $this->url);
  20494. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  20495. $filename = str_replace('http://', 'https://', $filename);
  20496. }
  20497. if ($retries) {
  20498. usleep(100000);
  20499. continue;
  20500. }
  20501. 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.');
  20502. }
  20503. $data = JsonFile::parseJson($json, $filename);
  20504. if (!empty($data['warning'])) {
  20505. $this->io->writeError('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
  20506. }
  20507. if (!empty($data['info'])) {
  20508. $this->io->writeError('<info>Info from '.$this->url.': '.$data['info'].'</info>');
  20509. }
  20510. if ($cacheKey) {
  20511. if ($storeLastModifiedTime) {
  20512. $lastModifiedDate = $rfs->findHeaderValue($rfs->getLastHeaders(), 'last-modified');
  20513. if ($lastModifiedDate) {
  20514. $data['last-modified'] = $lastModifiedDate;
  20515. $json = json_encode($data);
  20516. }
  20517. }
  20518. $this->cache->write($cacheKey, $json);
  20519. }
  20520. break;
  20521. } catch (\Exception $e) {
  20522. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  20523. throw $e;
  20524. }
  20525. if ($retries) {
  20526. usleep(100000);
  20527. continue;
  20528. }
  20529. if ($e instanceof RepositorySecurityException) {
  20530. throw $e;
  20531. }
  20532. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  20533. if (!$this->degradedMode) {
  20534. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  20535. $this->io->writeError('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
  20536. }
  20537. $this->degradedMode = true;
  20538. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  20539. break;
  20540. }
  20541. throw $e;
  20542. }
  20543. }
  20544. return $data;
  20545. }
  20546. protected function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  20547. {
  20548. $retries = 3;
  20549. while ($retries--) {
  20550. try {
  20551. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->rfs, $filename);
  20552. if ($this->eventDispatcher) {
  20553. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  20554. }
  20555. $hostname = parse_url($filename, PHP_URL_HOST) ?: $filename;
  20556. $rfs = $preFileDownloadEvent->getRemoteFilesystem();
  20557. $options = array('http' => array('header' => array('If-Modified-Since: '.$lastModifiedTime)));
  20558. $json = $rfs->getContents($hostname, $filename, false, $options);
  20559. if ($json === '' && $rfs->findStatusCode($rfs->getLastHeaders()) === 304) {
  20560. return true;
  20561. }
  20562. $data = JsonFile::parseJson($json, $filename);
  20563. if (!empty($data['warning'])) {
  20564. $this->io->writeError('<warning>Warning from '.$this->url.': '.$data['warning'].'</warning>');
  20565. }
  20566. if (!empty($data['info'])) {
  20567. $this->io->writeError('<info>Info from '.$this->url.': '.$data['info'].'</info>');
  20568. }
  20569. $lastModifiedDate = $rfs->findHeaderValue($rfs->getLastHeaders(), 'last-modified');
  20570. if ($lastModifiedDate) {
  20571. $data['last-modified'] = $lastModifiedDate;
  20572. $json = json_encode($data);
  20573. }
  20574. $this->cache->write($cacheKey, $json);
  20575. return $data;
  20576. } catch (\Exception $e) {
  20577. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  20578. throw $e;
  20579. }
  20580. if ($retries) {
  20581. usleep(100000);
  20582. continue;
  20583. }
  20584. if (!$this->degradedMode) {
  20585. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  20586. $this->io->writeError('<warning>'.$this->url.' could not be fully loaded, package information was loaded from the local cache and may be out of date</warning>');
  20587. }
  20588. $this->degradedMode = true;
  20589. return true;
  20590. }
  20591. }
  20592. }
  20593. private function initializePartialPackages()
  20594. {
  20595. $rootData = $this->loadRootServerFile();
  20596. $this->partialPackagesByName = array();
  20597. foreach ($rootData['packages'] as $package => $versions) {
  20598. $package = strtolower($package);
  20599. foreach ($versions as $version) {
  20600. $this->partialPackagesByName[$package][] = $version;
  20601. if (!empty($version['provide']) && is_array($version['provide'])) {
  20602. foreach ($version['provide'] as $provided => $providedVersion) {
  20603. $this->partialPackagesByName[strtolower($provided)][] = $version;
  20604. }
  20605. }
  20606. if (!empty($version['replace']) && is_array($version['replace'])) {
  20607. foreach ($version['replace'] as $provided => $providedVersion) {
  20608. $this->partialPackagesByName[strtolower($provided)][] = $version;
  20609. }
  20610. }
  20611. }
  20612. }
  20613. $this->rootData = true;
  20614. }
  20615. }
  20616. <?php
  20617. namespace Composer\Repository;
  20618. use Composer\Package\PackageInterface;
  20619. class CompositeRepository extends BaseRepository
  20620. {
  20621. private $repositories;
  20622. public function __construct(array $repositories)
  20623. {
  20624. $this->repositories = array();
  20625. foreach ($repositories as $repo) {
  20626. $this->addRepository($repo);
  20627. }
  20628. }
  20629. public function getRepositories()
  20630. {
  20631. return $this->repositories;
  20632. }
  20633. public function hasPackage(PackageInterface $package)
  20634. {
  20635. foreach ($this->repositories as $repository) {
  20636. if ($repository->hasPackage($package)) {
  20637. return true;
  20638. }
  20639. }
  20640. return false;
  20641. }
  20642. public function findPackage($name, $constraint)
  20643. {
  20644. foreach ($this->repositories as $repository) {
  20645. $package = $repository->findPackage($name, $constraint);
  20646. if (null !== $package) {
  20647. return $package;
  20648. }
  20649. }
  20650. return null;
  20651. }
  20652. public function findPackages($name, $constraint = null)
  20653. {
  20654. $packages = array();
  20655. foreach ($this->repositories as $repository) {
  20656. $packages[] = $repository->findPackages($name, $constraint);
  20657. }
  20658. return $packages ? call_user_func_array('array_merge', $packages) : array();
  20659. }
  20660. public function search($query, $mode = 0, $type = null)
  20661. {
  20662. $matches = array();
  20663. foreach ($this->repositories as $repository) {
  20664. $matches[] = $repository->search($query, $mode, $type);
  20665. }
  20666. return $matches ? call_user_func_array('array_merge', $matches) : array();
  20667. }
  20668. public function getPackages()
  20669. {
  20670. $packages = array();
  20671. foreach ($this->repositories as $repository) {
  20672. $packages[] = $repository->getPackages();
  20673. }
  20674. return $packages ? call_user_func_array('array_merge', $packages) : array();
  20675. }
  20676. public function removePackage(PackageInterface $package)
  20677. {
  20678. foreach ($this->repositories as $repository) {
  20679. $repository->removePackage($package);
  20680. }
  20681. }
  20682. public function count()
  20683. {
  20684. $total = 0;
  20685. foreach ($this->repositories as $repository) {
  20686. $total += $repository->count();
  20687. }
  20688. return $total;
  20689. }
  20690. public function addRepository(RepositoryInterface $repository)
  20691. {
  20692. if ($repository instanceof self) {
  20693. foreach ($repository->getRepositories() as $repo) {
  20694. $this->addRepository($repo);
  20695. }
  20696. } else {
  20697. $this->repositories[] = $repository;
  20698. }
  20699. }
  20700. }
  20701. <?php
  20702. namespace Composer\Repository;
  20703. interface ConfigurableRepositoryInterface
  20704. {
  20705. public function getRepoConfig();
  20706. }
  20707. <?php
  20708. namespace Composer\Repository;
  20709. use Composer\Json\JsonFile;
  20710. use Composer\Package\Loader\ArrayLoader;
  20711. use Composer\Package\Dumper\ArrayDumper;
  20712. class FilesystemRepository extends WritableArrayRepository
  20713. {
  20714. private $file;
  20715. public function __construct(JsonFile $repositoryFile)
  20716. {
  20717. parent::__construct();
  20718. $this->file = $repositoryFile;
  20719. }
  20720. protected function initialize()
  20721. {
  20722. parent::initialize();
  20723. if (!$this->file->exists()) {
  20724. return;
  20725. }
  20726. try {
  20727. $packages = $this->file->read();
  20728. if (!is_array($packages)) {
  20729. throw new \UnexpectedValueException('Could not parse package list from the repository');
  20730. }
  20731. } catch (\Exception $e) {
  20732. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  20733. }
  20734. $loader = new ArrayLoader(null, true);
  20735. foreach ($packages as $packageData) {
  20736. $package = $loader->load($packageData);
  20737. $this->addPackage($package);
  20738. }
  20739. }
  20740. public function reload()
  20741. {
  20742. $this->packages = null;
  20743. $this->initialize();
  20744. }
  20745. public function write()
  20746. {
  20747. $data = array();
  20748. $dumper = new ArrayDumper();
  20749. foreach ($this->getCanonicalPackages() as $package) {
  20750. $data[] = $dumper->dump($package);
  20751. }
  20752. usort($data, function ($a, $b) {
  20753. return strcmp($a['name'], $b['name']);
  20754. });
  20755. $this->file->write($data);
  20756. }
  20757. }
  20758. <?php
  20759. namespace Composer\Repository;
  20760. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  20761. {
  20762. }
  20763. <?php
  20764. namespace Composer\Repository;
  20765. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  20766. {
  20767. }
  20768. <?php
  20769. namespace Composer\Repository;
  20770. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  20771. {
  20772. }
  20773. <?php
  20774. namespace Composer\Repository;
  20775. class InvalidRepositoryException extends \Exception
  20776. {
  20777. }
  20778. <?php
  20779. namespace Composer\Repository;
  20780. use Composer\Package\Loader\ArrayLoader;
  20781. use Composer\Package\Loader\ValidatingArrayLoader;
  20782. class PackageRepository extends ArrayRepository
  20783. {
  20784. private $config;
  20785. public function __construct(array $config)
  20786. {
  20787. parent::__construct();
  20788. $this->config = $config['package'];
  20789. if (!is_numeric(key($this->config))) {
  20790. $this->config = array($this->config);
  20791. }
  20792. }
  20793. protected function initialize()
  20794. {
  20795. parent::initialize();
  20796. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
  20797. foreach ($this->config as $package) {
  20798. try {
  20799. $package = $loader->load($package);
  20800. } catch (\Exception $e) {
  20801. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  20802. }
  20803. $this->addPackage($package);
  20804. }
  20805. }
  20806. }
  20807. <?php
  20808. namespace Composer\Repository;
  20809. use Composer\Config;
  20810. use Composer\IO\IOInterface;
  20811. use Composer\Json\JsonFile;
  20812. use Composer\Package\Loader\ArrayLoader;
  20813. use Composer\Package\Version\VersionGuesser;
  20814. use Composer\Package\Version\VersionParser;
  20815. use Composer\Util\Platform;
  20816. use Composer\Util\ProcessExecutor;
  20817. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  20818. {
  20819. private $loader;
  20820. private $versionGuesser;
  20821. private $url;
  20822. private $repoConfig;
  20823. private $process;
  20824. private $options;
  20825. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  20826. {
  20827. if (!isset($repoConfig['url'])) {
  20828. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  20829. }
  20830. $this->loader = new ArrayLoader(null, true);
  20831. $this->url = Platform::expandPath($repoConfig['url']);
  20832. $this->process = new ProcessExecutor($io);
  20833. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  20834. $this->repoConfig = $repoConfig;
  20835. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  20836. parent::__construct();
  20837. }
  20838. public function getRepoConfig()
  20839. {
  20840. return $this->repoConfig;
  20841. }
  20842. protected function initialize()
  20843. {
  20844. parent::initialize();
  20845. foreach ($this->getUrlMatches() as $url) {
  20846. $path = realpath($url) . DIRECTORY_SEPARATOR;
  20847. $composerFilePath = $path.'composer.json';
  20848. if (!file_exists($composerFilePath)) {
  20849. continue;
  20850. }
  20851. $json = file_get_contents($composerFilePath);
  20852. $package = JsonFile::parseJson($json, $composerFilePath);
  20853. $package['dist'] = array(
  20854. 'type' => 'path',
  20855. 'url' => $url,
  20856. 'reference' => sha1($json . serialize($this->options)),
  20857. );
  20858. $package['transport-options'] = $this->options;
  20859. if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
  20860. if (
  20861. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  20862. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  20863. && $ref1 === $ref2
  20864. ) {
  20865. $package['version'] = $rootVersion;
  20866. }
  20867. }
  20868. if (!isset($package['version'])) {
  20869. $versionData = $this->versionGuesser->guessVersion($package, $path);
  20870. $package['version'] = $versionData['pretty_version'] ?: 'dev-master';
  20871. }
  20872. $output = '';
  20873. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
  20874. $package['dist']['reference'] = trim($output);
  20875. }
  20876. $package = $this->loader->load($package);
  20877. $this->addPackage($package);
  20878. }
  20879. }
  20880. private function getUrlMatches()
  20881. {
  20882. $flags = GLOB_MARK | GLOB_ONLYDIR;
  20883. if (defined('GLOB_BRACE')) {
  20884. $flags |= GLOB_BRACE;
  20885. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  20886. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  20887. }
  20888. return array_map(function ($val) {
  20889. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  20890. }, glob($this->url, $flags));
  20891. }
  20892. }
  20893. <?php
  20894. namespace Composer\Repository\Pear;
  20895. use Composer\Util\RemoteFilesystem;
  20896. abstract class BaseChannelReader
  20897. {
  20898. const CHANNEL_NS = 'http://pear.php.net/channel-1.0';
  20899. const ALL_CATEGORIES_NS = 'http://pear.php.net/dtd/rest.allcategories';
  20900. const CATEGORY_PACKAGES_INFO_NS = 'http://pear.php.net/dtd/rest.categorypackageinfo';
  20901. const ALL_PACKAGES_NS = 'http://pear.php.net/dtd/rest.allpackages';
  20902. const ALL_RELEASES_NS = 'http://pear.php.net/dtd/rest.allreleases';
  20903. const PACKAGE_INFO_NS = 'http://pear.php.net/dtd/rest.package';
  20904. private $rfs;
  20905. protected function __construct(RemoteFilesystem $rfs)
  20906. {
  20907. $this->rfs = $rfs;
  20908. }
  20909. protected function requestContent($origin, $path)
  20910. {
  20911. $url = rtrim($origin, '/') . '/' . ltrim($path, '/');
  20912. $content = $this->rfs->getContents($origin, $url, false);
  20913. if (!$content) {
  20914. throw new \UnexpectedValueException('The PEAR channel at ' . $url . ' did not respond.');
  20915. }
  20916. return str_replace('http://pear.php.net/rest/', 'https://pear.php.net/rest/', $content);
  20917. }
  20918. protected function requestXml($origin, $path)
  20919. {
  20920. $xml = simplexml_load_string($this->requestContent($origin, $path), "SimpleXMLElement", LIBXML_NOERROR);
  20921. if (false === $xml) {
  20922. throw new \UnexpectedValueException(sprintf('The PEAR channel at ' . $origin . ' is broken. (Invalid XML at file `%s`)', $path));
  20923. }
  20924. return $xml;
  20925. }
  20926. }
  20927. <?php
  20928. namespace Composer\Repository\Pear;
  20929. class ChannelInfo
  20930. {
  20931. private $name;
  20932. private $alias;
  20933. private $packages;
  20934. public function __construct($name, $alias, array $packages)
  20935. {
  20936. $this->name = $name;
  20937. $this->alias = $alias;
  20938. $this->packages = $packages;
  20939. }
  20940. public function getName()
  20941. {
  20942. return $this->name;
  20943. }
  20944. public function getAlias()
  20945. {
  20946. return $this->alias;
  20947. }
  20948. public function getPackages()
  20949. {
  20950. return $this->packages;
  20951. }
  20952. }
  20953. <?php
  20954. namespace Composer\Repository\Pear;
  20955. use Composer\Util\RemoteFilesystem;
  20956. class ChannelReader extends BaseChannelReader
  20957. {
  20958. private $readerMap;
  20959. public function __construct(RemoteFilesystem $rfs)
  20960. {
  20961. parent::__construct($rfs);
  20962. $rest10reader = new ChannelRest10Reader($rfs);
  20963. $rest11reader = new ChannelRest11Reader($rfs);
  20964. $this->readerMap = array(
  20965. 'REST1.3' => $rest11reader,
  20966. 'REST1.2' => $rest11reader,
  20967. 'REST1.1' => $rest11reader,
  20968. 'REST1.0' => $rest10reader,
  20969. );
  20970. }
  20971. public function read($url)
  20972. {
  20973. $xml = $this->requestXml($url, "/channel.xml");
  20974. $channelName = (string) $xml->name;
  20975. $channelAlias = (string) $xml->suggestedalias;
  20976. $supportedVersions = array_keys($this->readerMap);
  20977. $selectedRestVersion = $this->selectRestVersion($xml, $supportedVersions);
  20978. if (!$selectedRestVersion) {
  20979. throw new \UnexpectedValueException(sprintf('PEAR repository %s does not supports any of %s protocols.', $url, implode(', ', $supportedVersions)));
  20980. }
  20981. $reader = $this->readerMap[$selectedRestVersion['version']];
  20982. $packageDefinitions = $reader->read($selectedRestVersion['baseUrl']);
  20983. return new ChannelInfo($channelName, $channelAlias, $packageDefinitions);
  20984. }
  20985. private function selectRestVersion($channelXml, $supportedVersions)
  20986. {
  20987. $channelXml->registerXPathNamespace('ns', self::CHANNEL_NS);
  20988. foreach ($supportedVersions as $version) {
  20989. $xpathTest = "ns:servers/ns:*/ns:rest/ns:baseurl[@type='{$version}']";
  20990. $testResult = $channelXml->xpath($xpathTest);
  20991. foreach ($testResult as $result) {
  20992. $result = (string) $result;
  20993. if (preg_match('{^https://}i', $result)) {
  20994. return array('version' => $version, 'baseUrl' => $result);
  20995. }
  20996. }
  20997. if (count($testResult) > 0) {
  20998. return array('version' => $version, 'baseUrl' => (string) $testResult[0]);
  20999. }
  21000. }
  21001. return null;
  21002. }
  21003. }
  21004. <?php
  21005. namespace Composer\Repository\Pear;
  21006. use Composer\Downloader\TransportException;
  21007. class ChannelRest10Reader extends BaseChannelReader
  21008. {
  21009. private $dependencyReader;
  21010. public function __construct($rfs)
  21011. {
  21012. parent::__construct($rfs);
  21013. $this->dependencyReader = new PackageDependencyParser();
  21014. }
  21015. public function read($baseUrl)
  21016. {
  21017. return $this->readPackages($baseUrl);
  21018. }
  21019. private function readPackages($baseUrl)
  21020. {
  21021. $result = array();
  21022. $xmlPath = '/p/packages.xml';
  21023. $xml = $this->requestXml($baseUrl, $xmlPath);
  21024. $xml->registerXPathNamespace('ns', self::ALL_PACKAGES_NS);
  21025. foreach ($xml->xpath('ns:p') as $node) {
  21026. $packageName = (string) $node;
  21027. $packageInfo = $this->readPackage($baseUrl, $packageName);
  21028. $result[] = $packageInfo;
  21029. }
  21030. return $result;
  21031. }
  21032. private function readPackage($baseUrl, $packageName)
  21033. {
  21034. $xmlPath = '/p/' . strtolower($packageName) . '/info.xml';
  21035. $xml = $this->requestXml($baseUrl, $xmlPath);
  21036. $xml->registerXPathNamespace('ns', self::PACKAGE_INFO_NS);
  21037. $channelName = (string) $xml->c;
  21038. $packageName = (string) $xml->n;
  21039. $license = (string) $xml->l;
  21040. $shortDescription = (string) $xml->s;
  21041. $description = (string) $xml->d;
  21042. return new PackageInfo(
  21043. $channelName,
  21044. $packageName,
  21045. $license,
  21046. $shortDescription,
  21047. $description,
  21048. $this->readPackageReleases($baseUrl, $packageName)
  21049. );
  21050. }
  21051. private function readPackageReleases($baseUrl, $packageName)
  21052. {
  21053. $result = array();
  21054. try {
  21055. $xmlPath = '/r/' . strtolower($packageName) . '/allreleases.xml';
  21056. $xml = $this->requestXml($baseUrl, $xmlPath);
  21057. $xml->registerXPathNamespace('ns', self::ALL_RELEASES_NS);
  21058. foreach ($xml->xpath('ns:r') as $node) {
  21059. $releaseVersion = (string) $node->v;
  21060. $releaseStability = (string) $node->s;
  21061. try {
  21062. $result[$releaseVersion] = new ReleaseInfo(
  21063. $releaseStability,
  21064. $this->readPackageReleaseDependencies($baseUrl, $packageName, $releaseVersion)
  21065. );
  21066. } catch (TransportException $exception) {
  21067. if ($exception->getCode() != 404) {
  21068. throw $exception;
  21069. }
  21070. }
  21071. }
  21072. } catch (TransportException $exception) {
  21073. if ($exception->getCode() != 404) {
  21074. throw $exception;
  21075. }
  21076. }
  21077. return $result;
  21078. }
  21079. private function readPackageReleaseDependencies($baseUrl, $packageName, $version)
  21080. {
  21081. $dependencyReader = new PackageDependencyParser();
  21082. $depthPath = '/r/' . strtolower($packageName) . '/deps.' . $version . '.txt';
  21083. $content = $this->requestContent($baseUrl, $depthPath);
  21084. $dependencyArray = unserialize($content);
  21085. return $dependencyReader->buildDependencyInfo($dependencyArray);
  21086. }
  21087. }
  21088. <?php
  21089. namespace Composer\Repository\Pear;
  21090. class ChannelRest11Reader extends BaseChannelReader
  21091. {
  21092. private $dependencyReader;
  21093. public function __construct($rfs)
  21094. {
  21095. parent::__construct($rfs);
  21096. $this->dependencyReader = new PackageDependencyParser();
  21097. }
  21098. public function read($baseUrl)
  21099. {
  21100. return $this->readChannelPackages($baseUrl);
  21101. }
  21102. private function readChannelPackages($baseUrl)
  21103. {
  21104. $result = array();
  21105. $xml = $this->requestXml($baseUrl, "/c/categories.xml");
  21106. $xml->registerXPathNamespace('ns', self::ALL_CATEGORIES_NS);
  21107. foreach ($xml->xpath('ns:c') as $node) {
  21108. $categoryName = (string) $node;
  21109. $categoryPackages = $this->readCategoryPackages($baseUrl, $categoryName);
  21110. $result = array_merge($result, $categoryPackages);
  21111. }
  21112. return $result;
  21113. }
  21114. private function readCategoryPackages($baseUrl, $categoryName)
  21115. {
  21116. $result = array();
  21117. $categoryPath = '/c/'.urlencode($categoryName).'/packagesinfo.xml';
  21118. $xml = $this->requestXml($baseUrl, $categoryPath);
  21119. $xml->registerXPathNamespace('ns', self::CATEGORY_PACKAGES_INFO_NS);
  21120. foreach ($xml->xpath('ns:pi') as $node) {
  21121. $packageInfo = $this->parsePackage($node);
  21122. $result[] = $packageInfo;
  21123. }
  21124. return $result;
  21125. }
  21126. private function parsePackage($packageInfo)
  21127. {
  21128. $packageInfo->registerXPathNamespace('ns', self::CATEGORY_PACKAGES_INFO_NS);
  21129. $channelName = (string) $packageInfo->p->c;
  21130. $packageName = (string) $packageInfo->p->n;
  21131. $license = (string) $packageInfo->p->l;
  21132. $shortDescription = (string) $packageInfo->p->s;
  21133. $description = (string) $packageInfo->p->d;
  21134. $dependencies = array();
  21135. foreach ($packageInfo->xpath('ns:deps') as $node) {
  21136. $dependencyVersion = (string) $node->v;
  21137. $dependencyArray = unserialize((string) $node->d);
  21138. $dependencyInfo = $this->dependencyReader->buildDependencyInfo($dependencyArray);
  21139. $dependencies[$dependencyVersion] = $dependencyInfo;
  21140. }
  21141. $releases = array();
  21142. $releasesInfo = $packageInfo->xpath('ns:a/ns:r');
  21143. if ($releasesInfo) {
  21144. foreach ($releasesInfo as $node) {
  21145. $releaseVersion = (string) $node->v;
  21146. $releaseStability = (string) $node->s;
  21147. $releases[$releaseVersion] = new ReleaseInfo(
  21148. $releaseStability,
  21149. isset($dependencies[$releaseVersion]) ? $dependencies[$releaseVersion] : new DependencyInfo(array(), array())
  21150. );
  21151. }
  21152. }
  21153. return new PackageInfo(
  21154. $channelName,
  21155. $packageName,
  21156. $license,
  21157. $shortDescription,
  21158. $description,
  21159. $releases
  21160. );
  21161. }
  21162. }
  21163. <?php
  21164. namespace Composer\Repository\Pear;
  21165. class DependencyConstraint
  21166. {
  21167. private $type;
  21168. private $constraint;
  21169. private $channelName;
  21170. private $packageName;
  21171. public function __construct($type, $constraint, $channelName, $packageName)
  21172. {
  21173. $this->type = $type;
  21174. $this->constraint = $constraint;
  21175. $this->channelName = $channelName;
  21176. $this->packageName = $packageName;
  21177. }
  21178. public function getChannelName()
  21179. {
  21180. return $this->channelName;
  21181. }
  21182. public function getConstraint()
  21183. {
  21184. return $this->constraint;
  21185. }
  21186. public function getPackageName()
  21187. {
  21188. return $this->packageName;
  21189. }
  21190. public function getType()
  21191. {
  21192. return $this->type;
  21193. }
  21194. }
  21195. <?php
  21196. namespace Composer\Repository\Pear;
  21197. class DependencyInfo
  21198. {
  21199. private $requires;
  21200. private $optionals;
  21201. public function __construct($requires, $optionals)
  21202. {
  21203. $this->requires = $requires;
  21204. $this->optionals = $optionals;
  21205. }
  21206. public function getRequires()
  21207. {
  21208. return $this->requires;
  21209. }
  21210. public function getOptionals()
  21211. {
  21212. return $this->optionals;
  21213. }
  21214. }
  21215. <?php
  21216. namespace Composer\Repository\Pear;
  21217. class PackageDependencyParser
  21218. {
  21219. public function buildDependencyInfo($depArray)
  21220. {
  21221. if (!is_array($depArray)) {
  21222. return new DependencyInfo(array(), array());
  21223. }
  21224. if (!$this->isHash($depArray)) {
  21225. return new DependencyInfo($this->buildDependency10Info($depArray), array());
  21226. }
  21227. return $this->buildDependency20Info($depArray);
  21228. }
  21229. private function buildDependency10Info($depArray)
  21230. {
  21231. static $dep10toOperatorMap = array('has' => '==', 'eq' => '==', 'ge' => '>=', 'gt' => '>', 'le' => '<=', 'lt' => '<', 'not' => '!=');
  21232. $result = array();
  21233. foreach ($depArray as $depItem) {
  21234. if (empty($depItem['rel']) || !array_key_exists($depItem['rel'], $dep10toOperatorMap)) {
  21235. continue;
  21236. }
  21237. $depType = !empty($depItem['optional']) && 'yes' == $depItem['optional']
  21238. ? 'optional'
  21239. : 'required';
  21240. $depType = 'not' == $depItem['rel']
  21241. ? 'conflicts'
  21242. : $depType;
  21243. $depVersion = !empty($depItem['version']) ? $this->parseVersion($depItem['version']) : '*';
  21244. $depVersionConstraint = ('has' == $depItem['rel'] || 'not' == $depItem['rel']) && '*' == $depVersion
  21245. ? '*'
  21246. : $dep10toOperatorMap[$depItem['rel']] . $depVersion;
  21247. switch ($depItem['type']) {
  21248. case 'php':
  21249. $depChannelName = 'php';
  21250. $depPackageName = '';
  21251. break;
  21252. case 'pkg':
  21253. $depChannelName = !empty($depItem['channel']) ? $depItem['channel'] : 'pear.php.net';
  21254. $depPackageName = $depItem['name'];
  21255. break;
  21256. case 'ext':
  21257. $depChannelName = 'ext';
  21258. $depPackageName = $depItem['name'];
  21259. break;
  21260. case 'os':
  21261. case 'sapi':
  21262. $depChannelName = '';
  21263. $depPackageName = '';
  21264. break;
  21265. default:
  21266. $depChannelName = '';
  21267. $depPackageName = '';
  21268. break;
  21269. }
  21270. if ('' != $depChannelName) {
  21271. $result[] = new DependencyConstraint(
  21272. $depType,
  21273. $depVersionConstraint,
  21274. $depChannelName,
  21275. $depPackageName
  21276. );
  21277. }
  21278. }
  21279. return $result;
  21280. }
  21281. private function buildDependency20Info($depArray)
  21282. {
  21283. $result = array();
  21284. $optionals = array();
  21285. $defaultOptionals = array();
  21286. foreach ($depArray as $depType => $depTypeGroup) {
  21287. if (!is_array($depTypeGroup)) {
  21288. continue;
  21289. }
  21290. if ('required' == $depType || 'optional' == $depType) {
  21291. foreach ($depTypeGroup as $depItemType => $depItem) {
  21292. switch ($depItemType) {
  21293. case 'php':
  21294. $result[] = new DependencyConstraint(
  21295. $depType,
  21296. $this->parse20VersionConstraint($depItem),
  21297. 'php',
  21298. ''
  21299. );
  21300. break;
  21301. case 'package':
  21302. $deps = $this->buildDepPackageConstraints($depItem, $depType);
  21303. $result = array_merge($result, $deps);
  21304. break;
  21305. case 'extension':
  21306. $deps = $this->buildDepExtensionConstraints($depItem, $depType);
  21307. $result = array_merge($result, $deps);
  21308. break;
  21309. case 'subpackage':
  21310. $deps = $this->buildDepPackageConstraints($depItem, 'replaces');
  21311. $defaultOptionals += $deps;
  21312. break;
  21313. case 'os':
  21314. case 'pearinstaller':
  21315. break;
  21316. default:
  21317. break;
  21318. }
  21319. }
  21320. } elseif ('group' == $depType) {
  21321. if ($this->isHash($depTypeGroup)) {
  21322. $depTypeGroup = array($depTypeGroup);
  21323. }
  21324. foreach ($depTypeGroup as $depItem) {
  21325. $groupName = $depItem['attribs']['name'];
  21326. if (!isset($optionals[$groupName])) {
  21327. $optionals[$groupName] = array();
  21328. }
  21329. if (isset($depItem['subpackage'])) {
  21330. $optionals[$groupName] += $this->buildDepPackageConstraints($depItem['subpackage'], 'replaces');
  21331. } else {
  21332. $result += $this->buildDepPackageConstraints($depItem['package'], 'optional');
  21333. }
  21334. }
  21335. }
  21336. }
  21337. if (count($defaultOptionals) > 0) {
  21338. $optionals['*'] = $defaultOptionals;
  21339. }
  21340. return new DependencyInfo($result, $optionals);
  21341. }
  21342. private function buildDepExtensionConstraints($depItem, $depType)
  21343. {
  21344. if ($this->isHash($depItem)) {
  21345. $depItem = array($depItem);
  21346. }
  21347. $result = array();
  21348. foreach ($depItem as $subDepItem) {
  21349. $depChannelName = 'ext';
  21350. $depPackageName = $subDepItem['name'];
  21351. $depVersionConstraint = $this->parse20VersionConstraint($subDepItem);
  21352. $result[] = new DependencyConstraint(
  21353. $depType,
  21354. $depVersionConstraint,
  21355. $depChannelName,
  21356. $depPackageName
  21357. );
  21358. }
  21359. return $result;
  21360. }
  21361. private function buildDepPackageConstraints($depItem, $depType)
  21362. {
  21363. if ($this->isHash($depItem)) {
  21364. $depItem = array($depItem);
  21365. }
  21366. $result = array();
  21367. foreach ($depItem as $subDepItem) {
  21368. if (!array_key_exists('channel', $subDepItem)) {
  21369. $subDepItem['channel'] = $subDepItem['uri'];
  21370. }
  21371. $depChannelName = $subDepItem['channel'];
  21372. $depPackageName = $subDepItem['name'];
  21373. $depVersionConstraint = $this->parse20VersionConstraint($subDepItem);
  21374. if (isset($subDepItem['conflicts'])) {
  21375. $depType = 'conflicts';
  21376. }
  21377. $result[] = new DependencyConstraint(
  21378. $depType,
  21379. $depVersionConstraint,
  21380. $depChannelName,
  21381. $depPackageName
  21382. );
  21383. }
  21384. return $result;
  21385. }
  21386. private function parse20VersionConstraint(array $data)
  21387. {
  21388. static $dep20toOperatorMap = array('has' => '==', 'min' => '>=', 'max' => '<=', 'exclude' => '!=');
  21389. $versions = array();
  21390. $values = array_intersect_key($data, $dep20toOperatorMap);
  21391. if (0 == count($values)) {
  21392. return '*';
  21393. }
  21394. if (isset($values['min']) && isset($values['exclude']) && $data['min'] == $data['exclude']) {
  21395. $versions[] = '>' . $this->parseVersion($values['min']);
  21396. } elseif (isset($values['max']) && isset($values['exclude']) && $data['max'] == $data['exclude']) {
  21397. $versions[] = '<' . $this->parseVersion($values['max']);
  21398. } else {
  21399. foreach ($values as $op => $version) {
  21400. if ('exclude' == $op && is_array($version)) {
  21401. foreach ($version as $versionPart) {
  21402. $versions[] = $dep20toOperatorMap[$op] . $this->parseVersion($versionPart);
  21403. }
  21404. } else {
  21405. $versions[] = $dep20toOperatorMap[$op] . $this->parseVersion($version);
  21406. }
  21407. }
  21408. }
  21409. return implode(',', $versions);
  21410. }
  21411. private function parseVersion($version)
  21412. {
  21413. if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?}i', $version, $matches)) {
  21414. $version = $matches[1]
  21415. .(!empty($matches[2]) ? $matches[2] : '.0')
  21416. .(!empty($matches[3]) ? $matches[3] : '.0')
  21417. .(!empty($matches[4]) ? $matches[4] : '.0');
  21418. return $version;
  21419. }
  21420. return null;
  21421. }
  21422. private function isHash(array $array)
  21423. {
  21424. return !array_key_exists(1, $array) && !array_key_exists(0, $array);
  21425. }
  21426. }
  21427. <?php
  21428. namespace Composer\Repository\Pear;
  21429. class PackageInfo
  21430. {
  21431. private $channelName;
  21432. private $packageName;
  21433. private $license;
  21434. private $shortDescription;
  21435. private $description;
  21436. private $releases;
  21437. public function __construct($channelName, $packageName, $license, $shortDescription, $description, $releases)
  21438. {
  21439. $this->channelName = $channelName;
  21440. $this->packageName = $packageName;
  21441. $this->license = $license;
  21442. $this->shortDescription = $shortDescription;
  21443. $this->description = $description;
  21444. $this->releases = $releases;
  21445. }
  21446. public function getChannelName()
  21447. {
  21448. return $this->channelName;
  21449. }
  21450. public function getPackageName()
  21451. {
  21452. return $this->packageName;
  21453. }
  21454. public function getDescription()
  21455. {
  21456. return $this->description;
  21457. }
  21458. public function getShortDescription()
  21459. {
  21460. return $this->shortDescription;
  21461. }
  21462. public function getLicense()
  21463. {
  21464. return $this->license;
  21465. }
  21466. public function getReleases()
  21467. {
  21468. return $this->releases;
  21469. }
  21470. }
  21471. <?php
  21472. namespace Composer\Repository\Pear;
  21473. class ReleaseInfo
  21474. {
  21475. private $stability;
  21476. private $dependencyInfo;
  21477. public function __construct($stability, $dependencyInfo)
  21478. {
  21479. $this->stability = $stability;
  21480. $this->dependencyInfo = $dependencyInfo;
  21481. }
  21482. public function getDependencyInfo()
  21483. {
  21484. return $this->dependencyInfo;
  21485. }
  21486. public function getStability()
  21487. {
  21488. return $this->stability;
  21489. }
  21490. }
  21491. <?php
  21492. namespace Composer\Repository;
  21493. use Composer\IO\IOInterface;
  21494. use Composer\Semver\VersionParser as SemverVersionParser;
  21495. use Composer\Package\Version\VersionParser;
  21496. use Composer\Repository\Pear\ChannelReader;
  21497. use Composer\Package\CompletePackage;
  21498. use Composer\Repository\Pear\ChannelInfo;
  21499. use Composer\EventDispatcher\EventDispatcher;
  21500. use Composer\Package\Link;
  21501. use Composer\Semver\Constraint\Constraint;
  21502. use Composer\Util\RemoteFilesystem;
  21503. use Composer\Config;
  21504. use Composer\Factory;
  21505. class PearRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  21506. {
  21507. private $url;
  21508. private $io;
  21509. private $rfs;
  21510. private $versionParser;
  21511. private $repoConfig;
  21512. private $vendorAlias;
  21513. public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $dispatcher = null, RemoteFilesystem $rfs = null)
  21514. {
  21515. parent::__construct();
  21516. if (!preg_match('{^https?://}', $repoConfig['url'])) {
  21517. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  21518. }
  21519. $urlBits = parse_url($repoConfig['url']);
  21520. if (empty($urlBits['scheme']) || empty($urlBits['host'])) {
  21521. throw new \UnexpectedValueException('Invalid url given for PEAR repository: '.$repoConfig['url']);
  21522. }
  21523. $this->url = rtrim($repoConfig['url'], '/');
  21524. $this->io = $io;
  21525. $this->rfs = $rfs ?: Factory::createRemoteFilesystem($this->io, $config);
  21526. $this->vendorAlias = isset($repoConfig['vendor-alias']) ? $repoConfig['vendor-alias'] : null;
  21527. $this->versionParser = new VersionParser();
  21528. $this->repoConfig = $repoConfig;
  21529. }
  21530. public function getRepoConfig()
  21531. {
  21532. return $this->repoConfig;
  21533. }
  21534. protected function initialize()
  21535. {
  21536. parent::initialize();
  21537. $this->io->writeError('Initializing PEAR repository '.$this->url);
  21538. $reader = new ChannelReader($this->rfs);
  21539. try {
  21540. $channelInfo = $reader->read($this->url);
  21541. } catch (\Exception $e) {
  21542. $this->io->writeError('<warning>PEAR repository from '.$this->url.' could not be loaded. '.$e->getMessage().'</warning>');
  21543. return;
  21544. }
  21545. $packages = $this->buildComposerPackages($channelInfo, $this->versionParser);
  21546. foreach ($packages as $package) {
  21547. $this->addPackage($package);
  21548. }
  21549. }
  21550. private function buildComposerPackages(ChannelInfo $channelInfo, SemverVersionParser $versionParser)
  21551. {
  21552. $result = array();
  21553. foreach ($channelInfo->getPackages() as $packageDefinition) {
  21554. foreach ($packageDefinition->getReleases() as $version => $releaseInfo) {
  21555. try {
  21556. $normalizedVersion = $versionParser->normalize($version);
  21557. } catch (\UnexpectedValueException $e) {
  21558. $this->io->writeError('Could not load '.$packageDefinition->getPackageName().' '.$version.': '.$e->getMessage(), true, IOInterface::VERBOSE);
  21559. continue;
  21560. }
  21561. $composerPackageName = $this->buildComposerPackageName($packageDefinition->getChannelName(), $packageDefinition->getPackageName());
  21562. $urlBits = parse_url($this->url);
  21563. $scheme = (isset($urlBits['scheme']) && 'https' === $urlBits['scheme'] && extension_loaded('openssl')) ? 'https' : 'http';
  21564. $distUrl = "{$scheme}://{$packageDefinition->getChannelName()}/get/{$packageDefinition->getPackageName()}-{$version}.tgz";
  21565. $requires = array();
  21566. $suggests = array();
  21567. $conflicts = array();
  21568. $replaces = array();
  21569. if ($channelInfo->getName() == $packageDefinition->getChannelName()) {
  21570. $composerPackageAlias = $this->buildComposerPackageName($channelInfo->getAlias(), $packageDefinition->getPackageName());
  21571. $aliasConstraint = new Constraint('==', $normalizedVersion);
  21572. $replaces[] = new Link($composerPackageName, $composerPackageAlias, $aliasConstraint, 'replaces', (string) $aliasConstraint);
  21573. }
  21574. if (!empty($this->vendorAlias)
  21575. && ($this->vendorAlias != 'pear-'.$channelInfo->getAlias() || $channelInfo->getName() != $packageDefinition->getChannelName())
  21576. ) {
  21577. $composerPackageAlias = "{$this->vendorAlias}/{$packageDefinition->getPackageName()}";
  21578. $aliasConstraint = new Constraint('==', $normalizedVersion);
  21579. $replaces[] = new Link($composerPackageName, $composerPackageAlias, $aliasConstraint, 'replaces', (string) $aliasConstraint);
  21580. }
  21581. foreach ($releaseInfo->getDependencyInfo()->getRequires() as $dependencyConstraint) {
  21582. $dependencyPackageName = $this->buildComposerPackageName($dependencyConstraint->getChannelName(), $dependencyConstraint->getPackageName());
  21583. $constraint = $versionParser->parseConstraints($dependencyConstraint->getConstraint());
  21584. $link = new Link($composerPackageName, $dependencyPackageName, $constraint, $dependencyConstraint->getType(), $dependencyConstraint->getConstraint());
  21585. switch ($dependencyConstraint->getType()) {
  21586. case 'required':
  21587. $requires[] = $link;
  21588. break;
  21589. case 'conflicts':
  21590. $conflicts[] = $link;
  21591. break;
  21592. case 'replaces':
  21593. $replaces[] = $link;
  21594. break;
  21595. }
  21596. }
  21597. foreach ($releaseInfo->getDependencyInfo()->getOptionals() as $group => $dependencyConstraints) {
  21598. foreach ($dependencyConstraints as $dependencyConstraint) {
  21599. $dependencyPackageName = $this->buildComposerPackageName($dependencyConstraint->getChannelName(), $dependencyConstraint->getPackageName());
  21600. $suggests[$group.'-'.$dependencyPackageName] = $dependencyConstraint->getConstraint();
  21601. }
  21602. }
  21603. $package = new CompletePackage($composerPackageName, $normalizedVersion, $version);
  21604. $package->setType('pear-library');
  21605. $package->setDescription($packageDefinition->getDescription());
  21606. $package->setLicense(array($packageDefinition->getLicense()));
  21607. $package->setDistType('file');
  21608. $package->setDistUrl($distUrl);
  21609. $package->setAutoload(array('classmap' => array('')));
  21610. $package->setIncludePaths(array('/'));
  21611. $package->setRequires($requires);
  21612. $package->setConflicts($conflicts);
  21613. $package->setSuggests($suggests);
  21614. $package->setReplaces($replaces);
  21615. $result[] = $package;
  21616. }
  21617. }
  21618. return $result;
  21619. }
  21620. private function buildComposerPackageName($channelName, $packageName)
  21621. {
  21622. if ('php' === $channelName) {
  21623. return "php";
  21624. }
  21625. if ('ext' === $channelName) {
  21626. return "ext-{$packageName}";
  21627. }
  21628. return "pear-{$channelName}/{$packageName}";
  21629. }
  21630. }
  21631. <?php
  21632. namespace Composer\Repository;
  21633. use Composer\Package\CompletePackage;
  21634. use Composer\Package\PackageInterface;
  21635. use Composer\Package\Version\VersionParser;
  21636. use Composer\Plugin\PluginInterface;
  21637. use Composer\Util\Silencer;
  21638. use Composer\XdebugHandler\XdebugHandler;
  21639. class PlatformRepository extends ArrayRepository
  21640. {
  21641. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[^/ ]+)$}i';
  21642. private $versionParser;
  21643. private $overrides = array();
  21644. public function __construct(array $packages = array(), array $overrides = array())
  21645. {
  21646. foreach ($overrides as $name => $version) {
  21647. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  21648. }
  21649. parent::__construct($packages);
  21650. }
  21651. protected function initialize()
  21652. {
  21653. parent::initialize();
  21654. $this->versionParser = new VersionParser();
  21655. foreach ($this->overrides as $override) {
  21656. if (!preg_match(self::PLATFORM_PACKAGE_REGEX, $override['name'])) {
  21657. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  21658. }
  21659. $this->addOverriddenPackage($override);
  21660. }
  21661. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  21662. $version = $this->versionParser->normalize($prettyVersion);
  21663. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  21664. $composerPluginApi->setDescription('The Composer Plugin API');
  21665. $this->addPackage($composerPluginApi);
  21666. try {
  21667. $prettyVersion = PHP_VERSION;
  21668. $version = $this->versionParser->normalize($prettyVersion);
  21669. } catch (\UnexpectedValueException $e) {
  21670. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', PHP_VERSION);
  21671. $version = $this->versionParser->normalize($prettyVersion);
  21672. }
  21673. $php = new CompletePackage('php', $version, $prettyVersion);
  21674. $php->setDescription('The PHP interpreter');
  21675. $this->addPackage($php);
  21676. if (PHP_DEBUG) {
  21677. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  21678. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  21679. $this->addPackage($phpdebug);
  21680. }
  21681. if (defined('PHP_ZTS') && PHP_ZTS) {
  21682. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  21683. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  21684. $this->addPackage($phpzts);
  21685. }
  21686. if (PHP_INT_SIZE === 8) {
  21687. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  21688. $php64->setDescription('The PHP interpreter, 64bit');
  21689. $this->addPackage($php64);
  21690. }
  21691. if (defined('AF_INET6') || Silencer::call('inet_pton', '::') !== false) {
  21692. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  21693. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  21694. $this->addPackage($phpIpv6);
  21695. }
  21696. $loadedExtensions = get_loaded_extensions();
  21697. foreach ($loadedExtensions as $name) {
  21698. if (in_array($name, array('standard', 'Core'))) {
  21699. continue;
  21700. }
  21701. $reflExt = new \ReflectionExtension($name);
  21702. $prettyVersion = $reflExt->getVersion();
  21703. $this->addExtension($name, $prettyVersion);
  21704. }
  21705. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  21706. $this->addExtension('xdebug', $prettyVersion);
  21707. }
  21708. foreach ($loadedExtensions as $name) {
  21709. $prettyVersion = null;
  21710. $description = 'The '.$name.' PHP library';
  21711. switch ($name) {
  21712. case 'curl':
  21713. $curlVersion = curl_version();
  21714. $prettyVersion = $curlVersion['version'];
  21715. break;
  21716. case 'iconv':
  21717. $prettyVersion = ICONV_VERSION;
  21718. break;
  21719. case 'intl':
  21720. $name = 'ICU';
  21721. if (defined('INTL_ICU_VERSION')) {
  21722. $prettyVersion = INTL_ICU_VERSION;
  21723. } else {
  21724. $reflector = new \ReflectionExtension('intl');
  21725. ob_start();
  21726. $reflector->info();
  21727. $output = ob_get_clean();
  21728. preg_match('/^ICU version => (.*)$/m', $output, $matches);
  21729. $prettyVersion = $matches[1];
  21730. }
  21731. break;
  21732. case 'imagick':
  21733. $imagick = new \Imagick();
  21734. $imageMagickVersion = $imagick->getVersion();
  21735. preg_match('/^ImageMagick ([\d.]+)-(\d+)/', $imageMagickVersion['versionString'], $matches);
  21736. $prettyVersion = "{$matches[1]}.{$matches[2]}";
  21737. break;
  21738. case 'libxml':
  21739. $prettyVersion = LIBXML_DOTTED_VERSION;
  21740. break;
  21741. case 'openssl':
  21742. $prettyVersion = preg_replace_callback('{^(?:OpenSSL|LibreSSL)?\s*([0-9.]+)([a-z]*).*}i', function ($match) {
  21743. if (empty($match[2])) {
  21744. return $match[1];
  21745. }
  21746. if (!preg_match('{^z*[a-z]$}', $match[2])) {
  21747. return 0;
  21748. }
  21749. $len = strlen($match[2]);
  21750. $patchVersion = ($len - 1) * 26;
  21751. $patchVersion += ord($match[2][$len - 1]) - 96;
  21752. return $match[1].'.'.$patchVersion;
  21753. }, OPENSSL_VERSION_TEXT);
  21754. $description = OPENSSL_VERSION_TEXT;
  21755. break;
  21756. case 'pcre':
  21757. $prettyVersion = preg_replace('{^(\S+).*}', '$1', PCRE_VERSION);
  21758. break;
  21759. case 'uuid':
  21760. $prettyVersion = phpversion('uuid');
  21761. break;
  21762. case 'xsl':
  21763. $prettyVersion = LIBXSLT_DOTTED_VERSION;
  21764. break;
  21765. default:
  21766. continue 2;
  21767. }
  21768. try {
  21769. $version = $this->versionParser->normalize($prettyVersion);
  21770. } catch (\UnexpectedValueException $e) {
  21771. continue;
  21772. }
  21773. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  21774. $lib->setDescription($description);
  21775. $this->addPackage($lib);
  21776. }
  21777. if (defined('HHVM_VERSION')) {
  21778. try {
  21779. $prettyVersion = HHVM_VERSION;
  21780. $version = $this->versionParser->normalize($prettyVersion);
  21781. } catch (\UnexpectedValueException $e) {
  21782. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', HHVM_VERSION);
  21783. $version = $this->versionParser->normalize($prettyVersion);
  21784. }
  21785. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  21786. $hhvm->setDescription('The HHVM Runtime (64bit)');
  21787. $this->addPackage($hhvm);
  21788. }
  21789. }
  21790. public function addPackage(PackageInterface $package)
  21791. {
  21792. if (isset($this->overrides[$package->getName()])) {
  21793. $overrider = $this->findPackage($package->getName(), '*');
  21794. if ($package->getVersion() === $overrider->getVersion()) {
  21795. $actualText = 'same as actual';
  21796. } else {
  21797. $actualText = 'actual: '.$package->getPrettyVersion();
  21798. }
  21799. $overrider->setDescription($overrider->getDescription().' ('.$actualText.')');
  21800. return;
  21801. }
  21802. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  21803. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  21804. if ($package->getVersion() === $overrider->getVersion()) {
  21805. $actualText = 'same as actual';
  21806. } else {
  21807. $actualText = 'actual: '.$package->getPrettyVersion();
  21808. }
  21809. $overrider->setDescription($overrider->getDescription().' ('.$actualText.')');
  21810. return;
  21811. }
  21812. parent::addPackage($package);
  21813. }
  21814. private function addOverriddenPackage(array $override, $name = null)
  21815. {
  21816. $version = $this->versionParser->normalize($override['version']);
  21817. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  21818. $package->setDescription('Package overridden via config.platform');
  21819. $package->setExtra(array('config.platform' => true));
  21820. parent::addPackage($package);
  21821. return $package;
  21822. }
  21823. private function addExtension($name, $prettyVersion)
  21824. {
  21825. $extraDescription = null;
  21826. try {
  21827. $version = $this->versionParser->normalize($prettyVersion);
  21828. } catch (\UnexpectedValueException $e) {
  21829. $extraDescription = ' (actual version: '.$prettyVersion.')';
  21830. if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  21831. $prettyVersion = $match[1];
  21832. } else {
  21833. $prettyVersion = '0';
  21834. }
  21835. $version = $this->versionParser->normalize($prettyVersion);
  21836. }
  21837. $packageName = $this->buildPackageName($name);
  21838. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  21839. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  21840. $this->addPackage($ext);
  21841. }
  21842. private function buildPackageName($name)
  21843. {
  21844. return 'ext-' . str_replace(' ', '-', $name);
  21845. }
  21846. }
  21847. <?php
  21848. namespace Composer\Repository;
  21849. use Composer\Factory;
  21850. use Composer\IO\IOInterface;
  21851. use Composer\Config;
  21852. use Composer\EventDispatcher\EventDispatcher;
  21853. use Composer\Util\RemoteFilesystem;
  21854. use Composer\Json\JsonFile;
  21855. class RepositoryFactory
  21856. {
  21857. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  21858. {
  21859. if (0 === strpos($repository, 'http')) {
  21860. $repoConfig = array('type' => 'composer', 'url' => $repository);
  21861. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  21862. $json = new JsonFile($repository, Factory::createRemoteFilesystem($io, $config));
  21863. $data = $json->read();
  21864. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  21865. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  21866. } elseif ($allowFilesystem) {
  21867. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  21868. } else {
  21869. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  21870. }
  21871. } elseif ('{' === substr($repository, 0, 1)) {
  21872. $repoConfig = JsonFile::parseJson($repository);
  21873. } else {
  21874. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  21875. }
  21876. return $repoConfig;
  21877. }
  21878. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  21879. {
  21880. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  21881. return static::createRepo($io, $config, $repoConfig);
  21882. }
  21883. public static function createRepo(IOInterface $io, Config $config, array $repoConfig)
  21884. {
  21885. $rm = static::manager($io, $config, null, Factory::createRemoteFilesystem($io, $config));
  21886. $repos = static::createRepos($rm, array($repoConfig));
  21887. return reset($repos);
  21888. }
  21889. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  21890. {
  21891. if (!$config) {
  21892. $config = Factory::createConfig($io);
  21893. }
  21894. if (!$rm) {
  21895. if (!$io) {
  21896. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  21897. }
  21898. $rm = static::manager($io, $config, null, Factory::createRemoteFilesystem($io, $config));
  21899. }
  21900. return static::createRepos($rm, $config->getRepositories());
  21901. }
  21902. public static function manager(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null)
  21903. {
  21904. $rm = new RepositoryManager($io, $config, $eventDispatcher, $rfs);
  21905. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  21906. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  21907. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  21908. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  21909. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  21910. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  21911. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  21912. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  21913. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  21914. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  21915. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  21916. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  21917. $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
  21918. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  21919. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  21920. return $rm;
  21921. }
  21922. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  21923. {
  21924. $repos = array();
  21925. foreach ($repoConfigs as $index => $repo) {
  21926. if (is_string($repo)) {
  21927. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  21928. }
  21929. if (!is_array($repo)) {
  21930. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  21931. }
  21932. if (!isset($repo['type'])) {
  21933. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  21934. }
  21935. $name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
  21936. while (isset($repos[$name])) {
  21937. $name .= '2';
  21938. }
  21939. if ($repo['type'] === 'filesystem') {
  21940. $repos[$name] = new FilesystemRepository($repo['json']);
  21941. } else {
  21942. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  21943. }
  21944. }
  21945. return $repos;
  21946. }
  21947. }
  21948. <?php
  21949. namespace Composer\Repository;
  21950. use Composer\Package\PackageInterface;
  21951. interface RepositoryInterface extends \Countable
  21952. {
  21953. const SEARCH_FULLTEXT = 0;
  21954. const SEARCH_NAME = 1;
  21955. public function hasPackage(PackageInterface $package);
  21956. public function findPackage($name, $constraint);
  21957. public function findPackages($name, $constraint = null);
  21958. public function getPackages();
  21959. public function search($query, $mode = 0);
  21960. }
  21961. <?php
  21962. namespace Composer\Repository;
  21963. use Composer\IO\IOInterface;
  21964. use Composer\Config;
  21965. use Composer\EventDispatcher\EventDispatcher;
  21966. use Composer\Package\PackageInterface;
  21967. use Composer\Util\RemoteFilesystem;
  21968. class RepositoryManager
  21969. {
  21970. private $localRepository;
  21971. private $repositories = array();
  21972. private $repositoryClasses = array();
  21973. private $io;
  21974. private $config;
  21975. private $eventDispatcher;
  21976. private $rfs;
  21977. public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, RemoteFilesystem $rfs = null)
  21978. {
  21979. $this->io = $io;
  21980. $this->config = $config;
  21981. $this->eventDispatcher = $eventDispatcher;
  21982. $this->rfs = $rfs;
  21983. }
  21984. public function findPackage($name, $constraint)
  21985. {
  21986. foreach ($this->repositories as $repository) {
  21987. if ($package = $repository->findPackage($name, $constraint)) {
  21988. return $package;
  21989. }
  21990. }
  21991. return null;
  21992. }
  21993. public function findPackages($name, $constraint)
  21994. {
  21995. $packages = array();
  21996. foreach ($this->getRepositories() as $repository) {
  21997. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  21998. }
  21999. return $packages;
  22000. }
  22001. public function addRepository(RepositoryInterface $repository)
  22002. {
  22003. $this->repositories[] = $repository;
  22004. }
  22005. public function prependRepository(RepositoryInterface $repository)
  22006. {
  22007. array_unshift($this->repositories, $repository);
  22008. }
  22009. public function createRepository($type, $config, $name = null)
  22010. {
  22011. if (!isset($this->repositoryClasses[$type])) {
  22012. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  22013. }
  22014. if (isset($config['packagist']) && false === $config['packagist']) {
  22015. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  22016. }
  22017. $class = $this->repositoryClasses[$type];
  22018. $reflMethod = new \ReflectionMethod($class, '__construct');
  22019. $params = $reflMethod->getParameters();
  22020. if (isset($params[4]) && $params[4]->getClass() && $params[4]->getClass()->getName() === 'Composer\Util\RemoteFilesystem') {
  22021. return new $class($config, $this->io, $this->config, $this->eventDispatcher, $this->rfs);
  22022. }
  22023. return new $class($config, $this->io, $this->config, $this->eventDispatcher);
  22024. }
  22025. public function setRepositoryClass($type, $class)
  22026. {
  22027. $this->repositoryClasses[$type] = $class;
  22028. }
  22029. public function getRepositories()
  22030. {
  22031. return $this->repositories;
  22032. }
  22033. public function setLocalRepository(WritableRepositoryInterface $repository)
  22034. {
  22035. $this->localRepository = $repository;
  22036. }
  22037. public function getLocalRepository()
  22038. {
  22039. return $this->localRepository;
  22040. }
  22041. }
  22042. <?php
  22043. namespace Composer\Repository;
  22044. class RepositorySecurityException extends \Exception
  22045. {
  22046. }
  22047. <?php
  22048. namespace Composer\Repository\Vcs;
  22049. use Composer\Cache;
  22050. use Composer\Downloader\TransportException;
  22051. use Composer\Json\JsonFile;
  22052. use Composer\Util\Bitbucket;
  22053. abstract class BitbucketDriver extends VcsDriver
  22054. {
  22055. protected $cache;
  22056. protected $owner;
  22057. protected $repository;
  22058. protected $hasIssues;
  22059. protected $rootIdentifier;
  22060. protected $tags;
  22061. protected $branches;
  22062. protected $infoCache = array();
  22063. protected $branchesUrl = '';
  22064. protected $tagsUrl = '';
  22065. protected $homeUrl = '';
  22066. protected $website = '';
  22067. protected $cloneHttpsUrl = '';
  22068. protected $fallbackDriver;
  22069. protected $vcsType;
  22070. public function initialize()
  22071. {
  22072. preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)$#', $this->url, $match);
  22073. $this->owner = $match[1];
  22074. $this->repository = $match[2];
  22075. $this->originUrl = 'bitbucket.org';
  22076. $this->cache = new Cache(
  22077. $this->io,
  22078. implode('/', array(
  22079. $this->config->get('cache-repo-dir'),
  22080. $this->originUrl,
  22081. $this->owner,
  22082. $this->repository,
  22083. ))
  22084. );
  22085. }
  22086. public function getUrl()
  22087. {
  22088. if ($this->fallbackDriver) {
  22089. return $this->fallbackDriver->getUrl();
  22090. }
  22091. return $this->cloneHttpsUrl;
  22092. }
  22093. protected function getRepoData()
  22094. {
  22095. $resource = sprintf(
  22096. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  22097. $this->owner,
  22098. $this->repository,
  22099. http_build_query(
  22100. array('fields' => '-project,-owner'),
  22101. null,
  22102. '&'
  22103. )
  22104. );
  22105. $repoData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource, true), $resource);
  22106. if ($this->fallbackDriver) {
  22107. return false;
  22108. }
  22109. $this->parseCloneUrls($repoData['links']['clone']);
  22110. $this->hasIssues = !empty($repoData['has_issues']);
  22111. $this->branchesUrl = $repoData['links']['branches']['href'];
  22112. $this->tagsUrl = $repoData['links']['tags']['href'];
  22113. $this->homeUrl = $repoData['links']['html']['href'];
  22114. $this->website = $repoData['website'];
  22115. $this->vcsType = $repoData['scm'];
  22116. return true;
  22117. }
  22118. public function getComposerInformation($identifier)
  22119. {
  22120. if ($this->fallbackDriver) {
  22121. return $this->fallbackDriver->getComposerInformation($identifier);
  22122. }
  22123. if (!isset($this->infoCache[$identifier])) {
  22124. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  22125. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  22126. }
  22127. $composer = $this->getBaseComposerInformation($identifier);
  22128. if (!isset($composer['support']['source'])) {
  22129. $label = array_search(
  22130. $identifier,
  22131. $this->getTags()
  22132. ) ?: array_search(
  22133. $identifier,
  22134. $this->getBranches()
  22135. ) ?: $identifier;
  22136. if (array_key_exists($label, $tags = $this->getTags())) {
  22137. $hash = $tags[$label];
  22138. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  22139. $hash = $branches[$label];
  22140. }
  22141. if (! isset($hash)) {
  22142. $composer['support']['source'] = sprintf(
  22143. 'https://%s/%s/%s/src',
  22144. $this->originUrl,
  22145. $this->owner,
  22146. $this->repository
  22147. );
  22148. } else {
  22149. $composer['support']['source'] = sprintf(
  22150. 'https://%s/%s/%s/src/%s/?at=%s',
  22151. $this->originUrl,
  22152. $this->owner,
  22153. $this->repository,
  22154. $hash,
  22155. $label
  22156. );
  22157. }
  22158. }
  22159. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  22160. $composer['support']['issues'] = sprintf(
  22161. 'https://%s/%s/%s/issues',
  22162. $this->originUrl,
  22163. $this->owner,
  22164. $this->repository
  22165. );
  22166. }
  22167. if (!isset($composer['homepage'])) {
  22168. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  22169. }
  22170. $this->infoCache[$identifier] = $composer;
  22171. if ($this->shouldCache($identifier)) {
  22172. $this->cache->write($identifier, json_encode($composer));
  22173. }
  22174. }
  22175. return $this->infoCache[$identifier];
  22176. }
  22177. public function getFileContent($file, $identifier)
  22178. {
  22179. if ($this->fallbackDriver) {
  22180. return $this->fallbackDriver->getFileContent($file, $identifier);
  22181. }
  22182. if (strpos($identifier, '/') !== false) {
  22183. $branches = $this->getBranches();
  22184. if (isset($branches[$identifier])) {
  22185. $identifier = $branches[$identifier];
  22186. }
  22187. }
  22188. $resource = sprintf(
  22189. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  22190. $this->owner,
  22191. $this->repository,
  22192. $identifier,
  22193. $file
  22194. );
  22195. return $this->getContentsWithOAuthCredentials($resource);
  22196. }
  22197. public function getChangeDate($identifier)
  22198. {
  22199. if ($this->fallbackDriver) {
  22200. return $this->fallbackDriver->getChangeDate($identifier);
  22201. }
  22202. $resource = sprintf(
  22203. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  22204. $this->owner,
  22205. $this->repository,
  22206. $identifier
  22207. );
  22208. $commit = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
  22209. return new \DateTime($commit['date']);
  22210. }
  22211. public function getSource($identifier)
  22212. {
  22213. if ($this->fallbackDriver) {
  22214. return $this->fallbackDriver->getSource($identifier);
  22215. }
  22216. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  22217. }
  22218. public function getDist($identifier)
  22219. {
  22220. if ($this->fallbackDriver) {
  22221. return $this->fallbackDriver->getDist($identifier);
  22222. }
  22223. $url = sprintf(
  22224. 'https://bitbucket.org/%s/%s/get/%s.zip',
  22225. $this->owner,
  22226. $this->repository,
  22227. $identifier
  22228. );
  22229. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  22230. }
  22231. public function getTags()
  22232. {
  22233. if ($this->fallbackDriver) {
  22234. return $this->fallbackDriver->getTags();
  22235. }
  22236. if (null === $this->tags) {
  22237. $this->tags = array();
  22238. $resource = sprintf(
  22239. '%s?%s',
  22240. $this->tagsUrl,
  22241. http_build_query(
  22242. array(
  22243. 'pagelen' => 100,
  22244. 'fields' => 'values.name,values.target.hash,next',
  22245. 'sort' => '-target.date',
  22246. ),
  22247. null,
  22248. '&'
  22249. )
  22250. );
  22251. $hasNext = true;
  22252. while ($hasNext) {
  22253. $tagsData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
  22254. foreach ($tagsData['values'] as $data) {
  22255. $this->tags[$data['name']] = $data['target']['hash'];
  22256. }
  22257. if (empty($tagsData['next'])) {
  22258. $hasNext = false;
  22259. } else {
  22260. $resource = $tagsData['next'];
  22261. }
  22262. }
  22263. if ($this->vcsType === 'hg') {
  22264. unset($this->tags['tip']);
  22265. }
  22266. }
  22267. return $this->tags;
  22268. }
  22269. public function getBranches()
  22270. {
  22271. if ($this->fallbackDriver) {
  22272. return $this->fallbackDriver->getBranches();
  22273. }
  22274. if (null === $this->branches) {
  22275. $this->branches = array();
  22276. $resource = sprintf(
  22277. '%s?%s',
  22278. $this->branchesUrl,
  22279. http_build_query(
  22280. array(
  22281. 'pagelen' => 100,
  22282. 'fields' => 'values.name,values.target.hash,values.heads,next',
  22283. 'sort' => '-target.date',
  22284. ),
  22285. null,
  22286. '&'
  22287. )
  22288. );
  22289. $hasNext = true;
  22290. while ($hasNext) {
  22291. $branchData = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
  22292. foreach ($branchData['values'] as $data) {
  22293. if ($this->vcsType === 'hg' && empty($data['heads'])) {
  22294. continue;
  22295. }
  22296. $this->branches[$data['name']] = $data['target']['hash'];
  22297. }
  22298. if (empty($branchData['next'])) {
  22299. $hasNext = false;
  22300. } else {
  22301. $resource = $branchData['next'];
  22302. }
  22303. }
  22304. }
  22305. return $this->branches;
  22306. }
  22307. protected function getContentsWithOAuthCredentials($url, $fetchingRepoData = false)
  22308. {
  22309. try {
  22310. return parent::getContents($url);
  22311. } catch (TransportException $e) {
  22312. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->remoteFilesystem);
  22313. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  22314. if (!$this->io->hasAuthentication($this->originUrl)
  22315. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  22316. ) {
  22317. return parent::getContents($url);
  22318. }
  22319. if (!$this->io->isInteractive() && $fetchingRepoData) {
  22320. return $this->attemptCloneFallback();
  22321. }
  22322. }
  22323. throw $e;
  22324. }
  22325. }
  22326. abstract protected function generateSshUrl();
  22327. protected function attemptCloneFallback()
  22328. {
  22329. try {
  22330. $this->setupFallbackDriver($this->generateSshUrl());
  22331. } catch (\RuntimeException $e) {
  22332. $this->fallbackDriver = null;
  22333. $this->io->writeError(
  22334. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  22335. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  22336. );
  22337. throw $e;
  22338. }
  22339. }
  22340. abstract protected function setupFallbackDriver($url);
  22341. protected function parseCloneUrls(array $cloneLinks)
  22342. {
  22343. foreach ($cloneLinks as $cloneLink) {
  22344. if ($cloneLink['name'] === 'https') {
  22345. $this->cloneHttpsUrl = preg_replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  22346. }
  22347. }
  22348. }
  22349. protected function getMainBranchData()
  22350. {
  22351. $resource = sprintf(
  22352. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  22353. $this->owner,
  22354. $this->repository
  22355. );
  22356. $data = JsonFile::parseJson($this->getContentsWithOAuthCredentials($resource), $resource);
  22357. if (isset($data['mainbranch'])) {
  22358. return $data['mainbranch'];
  22359. }
  22360. return null;
  22361. }
  22362. }
  22363. <?php
  22364. namespace Composer\Repository\Vcs;
  22365. use Composer\Config;
  22366. use Composer\Util\ProcessExecutor;
  22367. use Composer\Util\Filesystem;
  22368. use Composer\IO\IOInterface;
  22369. class FossilDriver extends VcsDriver
  22370. {
  22371. protected $tags;
  22372. protected $branches;
  22373. protected $rootIdentifier;
  22374. protected $repoFile;
  22375. protected $checkoutDir;
  22376. protected $infoCache = array();
  22377. public function initialize()
  22378. {
  22379. $this->checkFossil();
  22380. $this->config->prohibitUrlByConfig($this->url, $this->io);
  22381. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  22382. $this->checkoutDir = $this->url;
  22383. } else {
  22384. $localName = preg_replace('{[^a-z0-9]}i', '-', $this->url);
  22385. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  22386. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  22387. $this->updateLocalRepo();
  22388. }
  22389. $this->getTags();
  22390. $this->getBranches();
  22391. }
  22392. protected function checkFossil()
  22393. {
  22394. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  22395. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  22396. }
  22397. }
  22398. protected function updateLocalRepo()
  22399. {
  22400. $fs = new Filesystem();
  22401. $fs->ensureDirectoryExists($this->checkoutDir);
  22402. if (!is_writable(dirname($this->checkoutDir))) {
  22403. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  22404. }
  22405. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  22406. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  22407. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  22408. }
  22409. } else {
  22410. $fs->removeDirectory($this->checkoutDir);
  22411. $fs->remove($this->repoFile);
  22412. $fs->ensureDirectoryExists($this->checkoutDir);
  22413. if (0 !== $this->process->execute(sprintf('fossil clone %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  22414. $output = $this->process->getErrorOutput();
  22415. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  22416. }
  22417. if (0 !== $this->process->execute(sprintf('fossil open %s --nested', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  22418. $output = $this->process->getErrorOutput();
  22419. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  22420. }
  22421. }
  22422. }
  22423. public function getRootIdentifier()
  22424. {
  22425. if (null === $this->rootIdentifier) {
  22426. $this->rootIdentifier = 'trunk';
  22427. }
  22428. return $this->rootIdentifier;
  22429. }
  22430. public function getUrl()
  22431. {
  22432. return $this->url;
  22433. }
  22434. public function getSource($identifier)
  22435. {
  22436. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  22437. }
  22438. public function getDist($identifier)
  22439. {
  22440. return null;
  22441. }
  22442. public function getFileContent($file, $identifier)
  22443. {
  22444. $command = sprintf('fossil cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  22445. $this->process->execute($command, $content, $this->checkoutDir);
  22446. if (!trim($content)) {
  22447. return null;
  22448. }
  22449. return $content;
  22450. }
  22451. public function getChangeDate($identifier)
  22452. {
  22453. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  22454. list($ckout, $date, $message) = explode(' ', trim($output), 3);
  22455. return new \DateTime($date, new \DateTimeZone('UTC'));
  22456. }
  22457. public function getTags()
  22458. {
  22459. if (null === $this->tags) {
  22460. $tags = array();
  22461. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  22462. foreach ($this->process->splitLines($output) as $tag) {
  22463. $tags[$tag] = $tag;
  22464. }
  22465. $this->tags = $tags;
  22466. }
  22467. return $this->tags;
  22468. }
  22469. public function getBranches()
  22470. {
  22471. if (null === $this->branches) {
  22472. $branches = array();
  22473. $bookmarks = array();
  22474. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  22475. foreach ($this->process->splitLines($output) as $branch) {
  22476. $branch = trim(preg_replace('/^\*/', '', trim($branch)));
  22477. $branches[$branch] = $branch;
  22478. }
  22479. $this->branches = $branches;
  22480. }
  22481. return $this->branches;
  22482. }
  22483. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  22484. {
  22485. if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  22486. return true;
  22487. }
  22488. if (preg_match('!/fossil/|\.fossil!', $url)) {
  22489. return true;
  22490. }
  22491. if (Filesystem::isLocalPath($url)) {
  22492. $url = Filesystem::getPlatformPath($url);
  22493. if (!is_dir($url)) {
  22494. return false;
  22495. }
  22496. $process = new ProcessExecutor($io);
  22497. if ($process->execute('fossil info', $output, $url) === 0) {
  22498. return true;
  22499. }
  22500. }
  22501. return false;
  22502. }
  22503. }
  22504. <?php
  22505. namespace Composer\Repository\Vcs;
  22506. use Composer\Config;
  22507. use Composer\IO\IOInterface;
  22508. class GitBitbucketDriver extends BitbucketDriver
  22509. {
  22510. public function getRootIdentifier()
  22511. {
  22512. if ($this->fallbackDriver) {
  22513. return $this->fallbackDriver->getRootIdentifier();
  22514. }
  22515. if (null === $this->rootIdentifier) {
  22516. if (! $this->getRepoData()) {
  22517. return $this->fallbackDriver->getRootIdentifier();
  22518. }
  22519. if ($this->vcsType !== 'git') {
  22520. throw new \RuntimeException(
  22521. $this->url.' does not appear to be a git repository, use '.
  22522. $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository'
  22523. );
  22524. }
  22525. $mainBranchData = $this->getMainBranchData();
  22526. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  22527. }
  22528. return $this->rootIdentifier;
  22529. }
  22530. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  22531. {
  22532. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/(.+?)\.git$#', $url)) {
  22533. return false;
  22534. }
  22535. if (!extension_loaded('openssl')) {
  22536. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  22537. return false;
  22538. }
  22539. return true;
  22540. }
  22541. protected function setupFallbackDriver($url)
  22542. {
  22543. $this->fallbackDriver = new GitDriver(
  22544. array('url' => $url),
  22545. $this->io,
  22546. $this->config,
  22547. $this->process,
  22548. $this->remoteFilesystem
  22549. );
  22550. $this->fallbackDriver->initialize();
  22551. }
  22552. protected function generateSshUrl()
  22553. {
  22554. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  22555. }
  22556. }
  22557. <?php
  22558. namespace Composer\Repository\Vcs;
  22559. use Composer\Util\ProcessExecutor;
  22560. use Composer\Util\Filesystem;
  22561. use Composer\Util\Git as GitUtil;
  22562. use Composer\IO\IOInterface;
  22563. use Composer\Cache;
  22564. use Composer\Config;
  22565. class GitDriver extends VcsDriver
  22566. {
  22567. protected $cache;
  22568. protected $tags;
  22569. protected $branches;
  22570. protected $rootIdentifier;
  22571. protected $repoDir;
  22572. protected $infoCache = array();
  22573. public function initialize()
  22574. {
  22575. if (Filesystem::isLocalPath($this->url)) {
  22576. $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url);
  22577. $this->repoDir = $this->url;
  22578. $cacheUrl = realpath($this->url);
  22579. } else {
  22580. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  22581. GitUtil::cleanEnv();
  22582. $fs = new Filesystem();
  22583. $fs->ensureDirectoryExists(dirname($this->repoDir));
  22584. if (!is_writable(dirname($this->repoDir))) {
  22585. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  22586. }
  22587. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  22588. throw new \InvalidArgumentException('The source URL '.$this->url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://[email protected]:22/path or just [email protected]:path if you do not want to provide a password or custom port.');
  22589. }
  22590. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  22591. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  22592. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  22593. }
  22594. $cacheUrl = $this->url;
  22595. }
  22596. $this->getTags();
  22597. $this->getBranches();
  22598. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $cacheUrl));
  22599. }
  22600. public function getRootIdentifier()
  22601. {
  22602. if (null === $this->rootIdentifier) {
  22603. $this->rootIdentifier = 'master';
  22604. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  22605. $branches = $this->process->splitLines($output);
  22606. if (!in_array('* master', $branches)) {
  22607. foreach ($branches as $branch) {
  22608. if ($branch && preg_match('{^\* +(\S+)}', $branch, $match)) {
  22609. $this->rootIdentifier = $match[1];
  22610. break;
  22611. }
  22612. }
  22613. }
  22614. }
  22615. return $this->rootIdentifier;
  22616. }
  22617. public function getUrl()
  22618. {
  22619. return $this->url;
  22620. }
  22621. public function getSource($identifier)
  22622. {
  22623. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  22624. }
  22625. public function getDist($identifier)
  22626. {
  22627. return null;
  22628. }
  22629. public function getFileContent($file, $identifier)
  22630. {
  22631. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  22632. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  22633. if (!trim($content)) {
  22634. return null;
  22635. }
  22636. return $content;
  22637. }
  22638. public function getChangeDate($identifier)
  22639. {
  22640. $this->process->execute(sprintf(
  22641. 'git log -1 --format=%%at %s',
  22642. ProcessExecutor::escape($identifier)
  22643. ), $output, $this->repoDir);
  22644. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  22645. }
  22646. public function getTags()
  22647. {
  22648. if (null === $this->tags) {
  22649. $this->tags = array();
  22650. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  22651. foreach ($output = $this->process->splitLines($output) as $tag) {
  22652. if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  22653. $this->tags[$match[2]] = $match[1];
  22654. }
  22655. }
  22656. }
  22657. return $this->tags;
  22658. }
  22659. public function getBranches()
  22660. {
  22661. if (null === $this->branches) {
  22662. $branches = array();
  22663. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  22664. foreach ($this->process->splitLines($output) as $branch) {
  22665. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  22666. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  22667. $branches[$match[1]] = $match[2];
  22668. }
  22669. }
  22670. }
  22671. $this->branches = $branches;
  22672. }
  22673. return $this->branches;
  22674. }
  22675. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  22676. {
  22677. if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  22678. return true;
  22679. }
  22680. if (Filesystem::isLocalPath($url)) {
  22681. $url = Filesystem::getPlatformPath($url);
  22682. if (!is_dir($url)) {
  22683. return false;
  22684. }
  22685. $process = new ProcessExecutor($io);
  22686. if ($process->execute('git tag', $output, $url) === 0) {
  22687. return true;
  22688. }
  22689. }
  22690. if (!$deep) {
  22691. return false;
  22692. }
  22693. $process = new ProcessExecutor($io);
  22694. return $process->execute('git ls-remote --heads ' . ProcessExecutor::escape($url), $output) === 0;
  22695. }
  22696. }
  22697. <?php
  22698. namespace Composer\Repository\Vcs;
  22699. use Composer\Config;
  22700. use Composer\Downloader\TransportException;
  22701. use Composer\Json\JsonFile;
  22702. use Composer\Cache;
  22703. use Composer\IO\IOInterface;
  22704. use Composer\Util\GitHub;
  22705. class GitHubDriver extends VcsDriver
  22706. {
  22707. protected $cache;
  22708. protected $owner;
  22709. protected $repository;
  22710. protected $tags;
  22711. protected $branches;
  22712. protected $rootIdentifier;
  22713. protected $repoData;
  22714. protected $hasIssues;
  22715. protected $infoCache = array();
  22716. protected $isPrivate = false;
  22717. protected $gitDriver;
  22718. public function initialize()
  22719. {
  22720. preg_match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  22721. $this->owner = $match[3];
  22722. $this->repository = $match[4];
  22723. $this->originUrl = !empty($match[1]) ? $match[1] : $match[2];
  22724. if ($this->originUrl === 'www.github.com') {
  22725. $this->originUrl = 'github.com';
  22726. }
  22727. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  22728. if (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api']) {
  22729. $this->setupGitDriver($this->url);
  22730. return;
  22731. }
  22732. $this->fetchRootIdentifier();
  22733. }
  22734. public function getRepositoryUrl()
  22735. {
  22736. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  22737. }
  22738. public function getRootIdentifier()
  22739. {
  22740. if ($this->gitDriver) {
  22741. return $this->gitDriver->getRootIdentifier();
  22742. }
  22743. return $this->rootIdentifier;
  22744. }
  22745. public function getUrl()
  22746. {
  22747. if ($this->gitDriver) {
  22748. return $this->gitDriver->getUrl();
  22749. }
  22750. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  22751. }
  22752. protected function getApiUrl()
  22753. {
  22754. if ('github.com' === $this->originUrl) {
  22755. $apiUrl = 'api.github.com';
  22756. } else {
  22757. $apiUrl = $this->originUrl . '/api/v3';
  22758. }
  22759. return 'https://' . $apiUrl;
  22760. }
  22761. public function getSource($identifier)
  22762. {
  22763. if ($this->gitDriver) {
  22764. return $this->gitDriver->getSource($identifier);
  22765. }
  22766. if ($this->isPrivate) {
  22767. $url = $this->generateSshUrl();
  22768. } else {
  22769. $url = $this->getUrl();
  22770. }
  22771. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  22772. }
  22773. public function getDist($identifier)
  22774. {
  22775. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  22776. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  22777. }
  22778. public function getComposerInformation($identifier)
  22779. {
  22780. if ($this->gitDriver) {
  22781. return $this->gitDriver->getComposerInformation($identifier);
  22782. }
  22783. if (!isset($this->infoCache[$identifier])) {
  22784. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  22785. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  22786. }
  22787. $composer = $this->getBaseComposerInformation($identifier);
  22788. if ($composer) {
  22789. if (!isset($composer['support']['source'])) {
  22790. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  22791. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  22792. }
  22793. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  22794. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  22795. }
  22796. }
  22797. if ($this->shouldCache($identifier)) {
  22798. $this->cache->write($identifier, json_encode($composer));
  22799. }
  22800. $this->infoCache[$identifier] = $composer;
  22801. }
  22802. return $this->infoCache[$identifier];
  22803. }
  22804. public function getFileContent($file, $identifier)
  22805. {
  22806. if ($this->gitDriver) {
  22807. return $this->gitDriver->getFileContent($file, $identifier);
  22808. }
  22809. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  22810. $resource = JsonFile::parseJson($this->getContents($resource));
  22811. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  22812. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  22813. }
  22814. return $content;
  22815. }
  22816. public function getChangeDate($identifier)
  22817. {
  22818. if ($this->gitDriver) {
  22819. return $this->gitDriver->getChangeDate($identifier);
  22820. }
  22821. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  22822. $commit = JsonFile::parseJson($this->getContents($resource), $resource);
  22823. return new \DateTime($commit['commit']['committer']['date']);
  22824. }
  22825. public function getTags()
  22826. {
  22827. if ($this->gitDriver) {
  22828. return $this->gitDriver->getTags();
  22829. }
  22830. if (null === $this->tags) {
  22831. $this->tags = array();
  22832. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  22833. do {
  22834. $tagsData = JsonFile::parseJson($this->getContents($resource), $resource);
  22835. foreach ($tagsData as $tag) {
  22836. $this->tags[$tag['name']] = $tag['commit']['sha'];
  22837. }
  22838. $resource = $this->getNextPage();
  22839. } while ($resource);
  22840. }
  22841. return $this->tags;
  22842. }
  22843. public function getBranches()
  22844. {
  22845. if ($this->gitDriver) {
  22846. return $this->gitDriver->getBranches();
  22847. }
  22848. if (null === $this->branches) {
  22849. $this->branches = array();
  22850. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  22851. $branchBlacklist = array('gh-pages');
  22852. do {
  22853. $branchData = JsonFile::parseJson($this->getContents($resource), $resource);
  22854. foreach ($branchData as $branch) {
  22855. $name = substr($branch['ref'], 11);
  22856. if (!in_array($name, $branchBlacklist)) {
  22857. $this->branches[$name] = $branch['object']['sha'];
  22858. }
  22859. }
  22860. $resource = $this->getNextPage();
  22861. } while ($resource);
  22862. }
  22863. return $this->branches;
  22864. }
  22865. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  22866. {
  22867. if (!preg_match('#^((?:https?|git)://([^/]+)/|git@([^:]+):)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  22868. return false;
  22869. }
  22870. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  22871. if (!in_array(preg_replace('{^www\.}i', '', $originUrl), $config->get('github-domains'))) {
  22872. return false;
  22873. }
  22874. if (!extension_loaded('openssl')) {
  22875. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  22876. return false;
  22877. }
  22878. return true;
  22879. }
  22880. public function getRepoData()
  22881. {
  22882. $this->fetchRootIdentifier();
  22883. return $this->repoData;
  22884. }
  22885. protected function generateSshUrl()
  22886. {
  22887. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  22888. }
  22889. protected function getContents($url, $fetchingRepoData = false)
  22890. {
  22891. try {
  22892. return parent::getContents($url);
  22893. } catch (TransportException $e) {
  22894. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->remoteFilesystem);
  22895. switch ($e->getCode()) {
  22896. case 401:
  22897. case 404:
  22898. if (!$fetchingRepoData) {
  22899. throw $e;
  22900. }
  22901. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  22902. return parent::getContents($url);
  22903. }
  22904. if (!$this->io->isInteractive()) {
  22905. return $this->attemptCloneFallback();
  22906. }
  22907. $scopesIssued = array();
  22908. $scopesNeeded = array();
  22909. if ($headers = $e->getHeaders()) {
  22910. if ($scopes = $this->remoteFilesystem->findHeaderValue($headers, 'X-OAuth-Scopes')) {
  22911. $scopesIssued = explode(' ', $scopes);
  22912. }
  22913. if ($scopes = $this->remoteFilesystem->findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  22914. $scopesNeeded = explode(' ', $scopes);
  22915. }
  22916. }
  22917. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  22918. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  22919. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  22920. }
  22921. return parent::getContents($url);
  22922. case 403:
  22923. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  22924. return parent::getContents($url);
  22925. }
  22926. if (!$this->io->isInteractive() && $fetchingRepoData) {
  22927. return $this->attemptCloneFallback();
  22928. }
  22929. $rateLimited = $gitHubUtil->isRateLimited($e->getHeaders());
  22930. if (!$this->io->hasAuthentication($this->originUrl)) {
  22931. if (!$this->io->isInteractive()) {
  22932. $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>');
  22933. throw $e;
  22934. }
  22935. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  22936. return parent::getContents($url);
  22937. }
  22938. if ($rateLimited) {
  22939. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  22940. $this->io->writeError(sprintf(
  22941. '<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>',
  22942. $rateLimit['limit'],
  22943. $rateLimit['reset']
  22944. ));
  22945. }
  22946. throw $e;
  22947. default:
  22948. throw $e;
  22949. }
  22950. }
  22951. }
  22952. protected function fetchRootIdentifier()
  22953. {
  22954. if ($this->repoData) {
  22955. return;
  22956. }
  22957. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  22958. $this->repoData = JsonFile::parseJson($this->getContents($repoDataUrl, true), $repoDataUrl);
  22959. if (null === $this->repoData && null !== $this->gitDriver) {
  22960. return;
  22961. }
  22962. $this->owner = $this->repoData['owner']['login'];
  22963. $this->repository = $this->repoData['name'];
  22964. $this->isPrivate = !empty($this->repoData['private']);
  22965. if (isset($this->repoData['default_branch'])) {
  22966. $this->rootIdentifier = $this->repoData['default_branch'];
  22967. } elseif (isset($this->repoData['master_branch'])) {
  22968. $this->rootIdentifier = $this->repoData['master_branch'];
  22969. } else {
  22970. $this->rootIdentifier = 'master';
  22971. }
  22972. $this->hasIssues = !empty($this->repoData['has_issues']);
  22973. }
  22974. protected function attemptCloneFallback()
  22975. {
  22976. $this->isPrivate = true;
  22977. try {
  22978. $this->setupGitDriver($this->generateSshUrl());
  22979. return;
  22980. } catch (\RuntimeException $e) {
  22981. $this->gitDriver = null;
  22982. $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>');
  22983. throw $e;
  22984. }
  22985. }
  22986. protected function setupGitDriver($url)
  22987. {
  22988. $this->gitDriver = new GitDriver(
  22989. array('url' => $url),
  22990. $this->io,
  22991. $this->config,
  22992. $this->process,
  22993. $this->remoteFilesystem
  22994. );
  22995. $this->gitDriver->initialize();
  22996. }
  22997. protected function getNextPage()
  22998. {
  22999. $headers = $this->remoteFilesystem->getLastHeaders();
  23000. foreach ($headers as $header) {
  23001. if (preg_match('{^link:\s*(.+?)\s*$}i', $header, $match)) {
  23002. $links = explode(',', $match[1]);
  23003. foreach ($links as $link) {
  23004. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  23005. return $match[1];
  23006. }
  23007. }
  23008. }
  23009. }
  23010. }
  23011. }
  23012. <?php
  23013. namespace Composer\Repository\Vcs;
  23014. use Composer\Config;
  23015. use Composer\Cache;
  23016. use Composer\IO\IOInterface;
  23017. use Composer\Json\JsonFile;
  23018. use Composer\Downloader\TransportException;
  23019. use Composer\Util\RemoteFilesystem;
  23020. use Composer\Util\GitLab;
  23021. class GitLabDriver extends VcsDriver
  23022. {
  23023. private $scheme;
  23024. private $namespace;
  23025. private $repository;
  23026. private $project;
  23027. private $commits = array();
  23028. private $tags;
  23029. private $branches;
  23030. protected $gitDriver;
  23031. private $isPrivate = true;
  23032. protected $portNumber;
  23033. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  23034. public function initialize()
  23035. {
  23036. if (!preg_match(self::URL_REGEX, $this->url, $match)) {
  23037. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  23038. }
  23039. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  23040. $configuredDomains = $this->config->get('gitlab-domains');
  23041. $urlParts = explode('/', $match['parts']);
  23042. $this->scheme = !empty($match['scheme'])
  23043. ? $match['scheme']
  23044. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  23045. ;
  23046. $this->originUrl = $this->determineOrigin($configuredDomains, $guessedDomain, $urlParts);
  23047. if (!empty($match['port']) && true === is_numeric($match['port'])) {
  23048. $this->portNumber = (int) $match['port'];
  23049. }
  23050. $this->namespace = implode('/', $urlParts);
  23051. $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
  23052. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  23053. $this->fetchProject();
  23054. }
  23055. public function setRemoteFilesystem(RemoteFilesystem $remoteFilesystem)
  23056. {
  23057. $this->remoteFilesystem = $remoteFilesystem;
  23058. }
  23059. public function getFileContent($file, $identifier)
  23060. {
  23061. if ($this->gitDriver) {
  23062. return $this->gitDriver->getFileContent($file, $identifier);
  23063. }
  23064. if (!preg_match('{[a-f0-9]{40}}i', $identifier)) {
  23065. $branches = $this->getBranches();
  23066. if (isset($branches[$identifier])) {
  23067. $identifier = $branches[$identifier];
  23068. }
  23069. }
  23070. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  23071. try {
  23072. $content = $this->getContents($resource);
  23073. } catch (TransportException $e) {
  23074. if ($e->getCode() !== 404) {
  23075. throw $e;
  23076. }
  23077. return null;
  23078. }
  23079. return $content;
  23080. }
  23081. public function getChangeDate($identifier)
  23082. {
  23083. if ($this->gitDriver) {
  23084. return $this->gitDriver->getChangeDate($identifier);
  23085. }
  23086. if (isset($this->commits[$identifier])) {
  23087. return new \DateTime($this->commits[$identifier]['committed_date']);
  23088. }
  23089. return new \DateTime();
  23090. }
  23091. public function getRepositoryUrl()
  23092. {
  23093. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  23094. }
  23095. public function getUrl()
  23096. {
  23097. if ($this->gitDriver) {
  23098. return $this->gitDriver->getUrl();
  23099. }
  23100. return $this->project['web_url'];
  23101. }
  23102. public function getDist($identifier)
  23103. {
  23104. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  23105. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  23106. }
  23107. public function getSource($identifier)
  23108. {
  23109. if ($this->gitDriver) {
  23110. return $this->gitDriver->getSource($identifier);
  23111. }
  23112. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  23113. }
  23114. public function getRootIdentifier()
  23115. {
  23116. if ($this->gitDriver) {
  23117. return $this->gitDriver->getRootIdentifier();
  23118. }
  23119. return $this->project['default_branch'];
  23120. }
  23121. public function getBranches()
  23122. {
  23123. if ($this->gitDriver) {
  23124. return $this->gitDriver->getBranches();
  23125. }
  23126. if (!$this->branches) {
  23127. $this->branches = $this->getReferences('branches');
  23128. }
  23129. return $this->branches;
  23130. }
  23131. public function getTags()
  23132. {
  23133. if ($this->gitDriver) {
  23134. return $this->gitDriver->getTags();
  23135. }
  23136. if (!$this->tags) {
  23137. $this->tags = $this->getReferences('tags');
  23138. }
  23139. return $this->tags;
  23140. }
  23141. public function getApiUrl()
  23142. {
  23143. $domainName = $this->originUrl;
  23144. $portNumber = (true === is_numeric($this->portNumber)) ? sprintf(':%s', $this->portNumber) : '';
  23145. return $this->scheme.'://'.$domainName.$portNumber.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  23146. }
  23147. private function urlEncodeAll($string)
  23148. {
  23149. $encoded = '';
  23150. for ($i = 0; isset($string[$i]); $i++) {
  23151. $character = $string[$i];
  23152. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  23153. $character = '%' . sprintf('%02X', ord($character));
  23154. }
  23155. $encoded .= $character;
  23156. }
  23157. return $encoded;
  23158. }
  23159. protected function getReferences($type)
  23160. {
  23161. $perPage = 100;
  23162. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  23163. $references = array();
  23164. do {
  23165. $data = JsonFile::parseJson($this->getContents($resource), $resource);
  23166. foreach ($data as $datum) {
  23167. $references[$datum['name']] = $datum['commit']['id'];
  23168. $this->commits[$datum['commit']['id']] = $datum['commit'];
  23169. }
  23170. if (count($data) >= $perPage) {
  23171. $resource = $this->getNextPage();
  23172. } else {
  23173. $resource = false;
  23174. }
  23175. } while ($resource);
  23176. return $references;
  23177. }
  23178. protected function fetchProject()
  23179. {
  23180. $resource = $this->getApiUrl();
  23181. $this->project = JsonFile::parseJson($this->getContents($resource, true), $resource);
  23182. if (isset($this->project['visibility'])) {
  23183. $this->isPrivate = $this->project['visibility'] !== 'public';
  23184. } else {
  23185. $this->isPrivate = false;
  23186. }
  23187. }
  23188. protected function attemptCloneFallback()
  23189. {
  23190. try {
  23191. if ($this->isPrivate === false) {
  23192. $url = $this->generatePublicUrl();
  23193. } else {
  23194. $url = $this->generateSshUrl();
  23195. }
  23196. $this->setupGitDriver($url);
  23197. return;
  23198. } catch (\RuntimeException $e) {
  23199. $this->gitDriver = null;
  23200. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  23201. throw $e;
  23202. }
  23203. }
  23204. protected function generateSshUrl()
  23205. {
  23206. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  23207. }
  23208. protected function generatePublicUrl()
  23209. {
  23210. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  23211. }
  23212. protected function setupGitDriver($url)
  23213. {
  23214. $this->gitDriver = new GitDriver(
  23215. array('url' => $url),
  23216. $this->io,
  23217. $this->config,
  23218. $this->process,
  23219. $this->remoteFilesystem
  23220. );
  23221. $this->gitDriver->initialize();
  23222. }
  23223. protected function getContents($url, $fetchingRepoData = false)
  23224. {
  23225. try {
  23226. $res = parent::getContents($url);
  23227. if ($fetchingRepoData) {
  23228. $json = JsonFile::parseJson($res, $url);
  23229. if (!isset($json['default_branch'])) {
  23230. if (!empty($json['id'])) {
  23231. $this->isPrivate = false;
  23232. }
  23233. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  23234. }
  23235. }
  23236. return $res;
  23237. } catch (TransportException $e) {
  23238. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->remoteFilesystem);
  23239. switch ($e->getCode()) {
  23240. case 401:
  23241. case 404:
  23242. if (!$fetchingRepoData) {
  23243. throw $e;
  23244. }
  23245. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  23246. return parent::getContents($url);
  23247. }
  23248. if (!$this->io->isInteractive()) {
  23249. return $this->attemptCloneFallback();
  23250. }
  23251. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  23252. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  23253. return parent::getContents($url);
  23254. case 403:
  23255. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  23256. return parent::getContents($url);
  23257. }
  23258. if (!$this->io->isInteractive() && $fetchingRepoData) {
  23259. return $this->attemptCloneFallback();
  23260. }
  23261. throw $e;
  23262. default:
  23263. throw $e;
  23264. }
  23265. }
  23266. }
  23267. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  23268. {
  23269. if (!preg_match(self::URL_REGEX, $url, $match)) {
  23270. return false;
  23271. }
  23272. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  23273. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  23274. $urlParts = explode('/', $match['parts']);
  23275. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts)) {
  23276. return false;
  23277. }
  23278. if ('https' === $scheme && !extension_loaded('openssl')) {
  23279. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  23280. return false;
  23281. }
  23282. return true;
  23283. }
  23284. private function getNextPage()
  23285. {
  23286. $headers = $this->remoteFilesystem->getLastHeaders();
  23287. foreach ($headers as $header) {
  23288. if (preg_match('{^link:\s*(.+?)\s*$}i', $header, $match)) {
  23289. $links = explode(',', $match[1]);
  23290. foreach ($links as $link) {
  23291. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  23292. return $match[1];
  23293. }
  23294. }
  23295. }
  23296. }
  23297. }
  23298. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts)
  23299. {
  23300. if (in_array($guessedDomain, $configuredDomains)) {
  23301. return $guessedDomain;
  23302. }
  23303. while (null !== ($part = array_shift($urlParts))) {
  23304. $guessedDomain .= '/' . $part;
  23305. if (in_array($guessedDomain, $configuredDomains)) {
  23306. return $guessedDomain;
  23307. }
  23308. }
  23309. return false;
  23310. }
  23311. }
  23312. <?php
  23313. namespace Composer\Repository\Vcs;
  23314. use Composer\Config;
  23315. use Composer\IO\IOInterface;
  23316. class HgBitbucketDriver extends BitbucketDriver
  23317. {
  23318. public function getRootIdentifier()
  23319. {
  23320. if ($this->fallbackDriver) {
  23321. return $this->fallbackDriver->getRootIdentifier();
  23322. }
  23323. if (null === $this->rootIdentifier) {
  23324. if (! $this->getRepoData()) {
  23325. return $this->fallbackDriver->getRootIdentifier();
  23326. }
  23327. if ($this->vcsType !== 'hg') {
  23328. throw new \RuntimeException(
  23329. $this->url.' does not appear to be a mercurial repository, use '.
  23330. $this->cloneHttpsUrl.' if this is a git bitbucket repository'
  23331. );
  23332. }
  23333. $mainBranchData = $this->getMainBranchData();
  23334. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default';
  23335. }
  23336. return $this->rootIdentifier;
  23337. }
  23338. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  23339. {
  23340. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#', $url)) {
  23341. return false;
  23342. }
  23343. if (!extension_loaded('openssl')) {
  23344. $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  23345. return false;
  23346. }
  23347. return true;
  23348. }
  23349. protected function setupFallbackDriver($url)
  23350. {
  23351. $this->fallbackDriver = new HgDriver(
  23352. array('url' => $url),
  23353. $this->io,
  23354. $this->config,
  23355. $this->process,
  23356. $this->remoteFilesystem
  23357. );
  23358. $this->fallbackDriver->initialize();
  23359. }
  23360. protected function generateSshUrl()
  23361. {
  23362. return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository;
  23363. }
  23364. }
  23365. <?php
  23366. namespace Composer\Repository\Vcs;
  23367. use Composer\Config;
  23368. use Composer\Util\Hg as HgUtils;
  23369. use Composer\Util\ProcessExecutor;
  23370. use Composer\Util\Filesystem;
  23371. use Composer\IO\IOInterface;
  23372. class HgDriver extends VcsDriver
  23373. {
  23374. protected $tags;
  23375. protected $branches;
  23376. protected $rootIdentifier;
  23377. protected $repoDir;
  23378. protected $infoCache = array();
  23379. public function initialize()
  23380. {
  23381. if (Filesystem::isLocalPath($this->url)) {
  23382. $this->repoDir = $this->url;
  23383. } else {
  23384. $cacheDir = $this->config->get('cache-vcs-dir');
  23385. $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  23386. $fs = new Filesystem();
  23387. $fs->ensureDirectoryExists($cacheDir);
  23388. if (!is_writable(dirname($this->repoDir))) {
  23389. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  23390. }
  23391. $this->config->prohibitUrlByConfig($this->url, $this->io);
  23392. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  23393. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  23394. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  23395. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  23396. }
  23397. } else {
  23398. $fs->removeDirectory($this->repoDir);
  23399. $command = function ($url) {
  23400. return sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($this->repoDir));
  23401. };
  23402. $hgUtils->runCommand($command, $this->url, $this->repoDir);
  23403. }
  23404. }
  23405. $this->getTags();
  23406. $this->getBranches();
  23407. }
  23408. public function getRootIdentifier()
  23409. {
  23410. if (null === $this->rootIdentifier) {
  23411. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  23412. $output = $this->process->splitLines($output);
  23413. $this->rootIdentifier = $output[0];
  23414. }
  23415. return $this->rootIdentifier;
  23416. }
  23417. public function getUrl()
  23418. {
  23419. return $this->url;
  23420. }
  23421. public function getSource($identifier)
  23422. {
  23423. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  23424. }
  23425. public function getDist($identifier)
  23426. {
  23427. return null;
  23428. }
  23429. public function getFileContent($file, $identifier)
  23430. {
  23431. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  23432. $this->process->execute($resource, $content, $this->repoDir);
  23433. if (!trim($content)) {
  23434. return;
  23435. }
  23436. return $content;
  23437. }
  23438. public function getChangeDate($identifier)
  23439. {
  23440. $this->process->execute(
  23441. sprintf(
  23442. 'hg log --template "{date|rfc3339date}" -r %s',
  23443. ProcessExecutor::escape($identifier)
  23444. ),
  23445. $output,
  23446. $this->repoDir
  23447. );
  23448. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  23449. }
  23450. public function getTags()
  23451. {
  23452. if (null === $this->tags) {
  23453. $tags = array();
  23454. $this->process->execute('hg tags', $output, $this->repoDir);
  23455. foreach ($this->process->splitLines($output) as $tag) {
  23456. if ($tag && preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  23457. $tags[$match[1]] = $match[2];
  23458. }
  23459. }
  23460. unset($tags['tip']);
  23461. $this->tags = $tags;
  23462. }
  23463. return $this->tags;
  23464. }
  23465. public function getBranches()
  23466. {
  23467. if (null === $this->branches) {
  23468. $branches = array();
  23469. $bookmarks = array();
  23470. $this->process->execute('hg branches', $output, $this->repoDir);
  23471. foreach ($this->process->splitLines($output) as $branch) {
  23472. if ($branch && preg_match('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  23473. $branches[$match[1]] = $match[2];
  23474. }
  23475. }
  23476. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  23477. foreach ($this->process->splitLines($output) as $branch) {
  23478. if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  23479. $bookmarks[$match[1]] = $match[2];
  23480. }
  23481. }
  23482. $this->branches = array_merge($bookmarks, $branches);
  23483. }
  23484. return $this->branches;
  23485. }
  23486. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  23487. {
  23488. if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  23489. return true;
  23490. }
  23491. if (Filesystem::isLocalPath($url)) {
  23492. $url = Filesystem::getPlatformPath($url);
  23493. if (!is_dir($url)) {
  23494. return false;
  23495. }
  23496. $process = new ProcessExecutor($io);
  23497. if ($process->execute('hg summary', $output, $url) === 0) {
  23498. return true;
  23499. }
  23500. }
  23501. if (!$deep) {
  23502. return false;
  23503. }
  23504. $processExecutor = new ProcessExecutor($io);
  23505. $exit = $processExecutor->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored);
  23506. return $exit === 0;
  23507. }
  23508. }
  23509. <?php
  23510. namespace Composer\Repository\Vcs;
  23511. use Composer\Config;
  23512. use Composer\IO\IOInterface;
  23513. use Composer\Util\ProcessExecutor;
  23514. use Composer\Util\Perforce;
  23515. class PerforceDriver extends VcsDriver
  23516. {
  23517. protected $depot;
  23518. protected $branch;
  23519. protected $perforce;
  23520. public function initialize()
  23521. {
  23522. $this->depot = $this->repoConfig['depot'];
  23523. $this->branch = '';
  23524. if (!empty($this->repoConfig['branch'])) {
  23525. $this->branch = $this->repoConfig['branch'];
  23526. }
  23527. $this->initPerforce($this->repoConfig);
  23528. $this->perforce->p4Login();
  23529. $this->perforce->checkStream();
  23530. $this->perforce->writeP4ClientSpec();
  23531. $this->perforce->connectClient();
  23532. return true;
  23533. }
  23534. private function initPerforce($repoConfig)
  23535. {
  23536. if (!empty($this->perforce)) {
  23537. return;
  23538. }
  23539. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  23540. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  23541. }
  23542. public function getFileContent($file, $identifier)
  23543. {
  23544. return $this->perforce->getFileContent($file, $identifier);
  23545. }
  23546. public function getChangeDate($identifier)
  23547. {
  23548. return null;
  23549. }
  23550. public function getRootIdentifier()
  23551. {
  23552. return $this->branch;
  23553. }
  23554. public function getBranches()
  23555. {
  23556. return $this->perforce->getBranches();
  23557. }
  23558. public function getTags()
  23559. {
  23560. return $this->perforce->getTags();
  23561. }
  23562. public function getDist($identifier)
  23563. {
  23564. return null;
  23565. }
  23566. public function getSource($identifier)
  23567. {
  23568. $source = array(
  23569. 'type' => 'perforce',
  23570. 'url' => $this->repoConfig['url'],
  23571. 'reference' => $identifier,
  23572. 'p4user' => $this->perforce->getUser(),
  23573. );
  23574. return $source;
  23575. }
  23576. public function getUrl()
  23577. {
  23578. return $this->url;
  23579. }
  23580. public function hasComposerFile($identifier)
  23581. {
  23582. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  23583. $composerInfoIdentifier = $identifier;
  23584. return !empty($composerInfo);
  23585. }
  23586. public function getContents($url)
  23587. {
  23588. return false;
  23589. }
  23590. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  23591. {
  23592. if ($deep || preg_match('#\b(perforce|p4)\b#i', $url)) {
  23593. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  23594. }
  23595. return false;
  23596. }
  23597. public function cleanup()
  23598. {
  23599. $this->perforce->cleanupClientSpec();
  23600. $this->perforce = null;
  23601. }
  23602. public function getDepot()
  23603. {
  23604. return $this->depot;
  23605. }
  23606. public function getBranch()
  23607. {
  23608. return $this->branch;
  23609. }
  23610. }
  23611. <?php
  23612. namespace Composer\Repository\Vcs;
  23613. use Composer\Cache;
  23614. use Composer\Config;
  23615. use Composer\Json\JsonFile;
  23616. use Composer\Util\ProcessExecutor;
  23617. use Composer\Util\Filesystem;
  23618. use Composer\Util\Svn as SvnUtil;
  23619. use Composer\IO\IOInterface;
  23620. use Composer\Downloader\TransportException;
  23621. class SvnDriver extends VcsDriver
  23622. {
  23623. protected $cache;
  23624. protected $baseUrl;
  23625. protected $tags;
  23626. protected $branches;
  23627. protected $rootIdentifier;
  23628. protected $infoCache = array();
  23629. protected $trunkPath = 'trunk';
  23630. protected $branchesPath = 'branches';
  23631. protected $tagsPath = 'tags';
  23632. protected $packagePath = '';
  23633. protected $cacheCredentials = true;
  23634. private $util;
  23635. public function initialize()
  23636. {
  23637. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  23638. SvnUtil::cleanEnv();
  23639. if (isset($this->repoConfig['trunk-path'])) {
  23640. $this->trunkPath = $this->repoConfig['trunk-path'];
  23641. }
  23642. if (isset($this->repoConfig['branches-path'])) {
  23643. $this->branchesPath = $this->repoConfig['branches-path'];
  23644. }
  23645. if (isset($this->repoConfig['tags-path'])) {
  23646. $this->tagsPath = $this->repoConfig['tags-path'];
  23647. }
  23648. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  23649. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  23650. }
  23651. if (isset($this->repoConfig['package-path'])) {
  23652. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  23653. }
  23654. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  23655. $this->baseUrl = substr($this->url, 0, $pos);
  23656. }
  23657. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->baseUrl));
  23658. $this->getBranches();
  23659. $this->getTags();
  23660. }
  23661. public function getRootIdentifier()
  23662. {
  23663. return $this->rootIdentifier ?: $this->trunkPath;
  23664. }
  23665. public function getUrl()
  23666. {
  23667. return $this->url;
  23668. }
  23669. public function getSource($identifier)
  23670. {
  23671. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  23672. }
  23673. public function getDist($identifier)
  23674. {
  23675. return null;
  23676. }
  23677. protected function shouldCache($identifier)
  23678. {
  23679. return $this->cache && preg_match('{@\d+$}', $identifier);
  23680. }
  23681. public function getComposerInformation($identifier)
  23682. {
  23683. if (!isset($this->infoCache[$identifier])) {
  23684. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  23685. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  23686. }
  23687. try {
  23688. $composer = $this->getBaseComposerInformation($identifier);
  23689. } catch (TransportException $e) {
  23690. $message = $e->getMessage();
  23691. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  23692. throw $e;
  23693. }
  23694. $composer = '';
  23695. }
  23696. if ($this->shouldCache($identifier)) {
  23697. $this->cache->write($identifier.'.json', json_encode($composer));
  23698. }
  23699. $this->infoCache[$identifier] = $composer;
  23700. }
  23701. return $this->infoCache[$identifier];
  23702. }
  23703. public function getFileContent($file, $identifier)
  23704. {
  23705. $identifier = '/' . trim($identifier, '/') . '/';
  23706. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  23707. if (!empty($match[2])) {
  23708. $path = $match[1];
  23709. $rev = $match[2];
  23710. } else {
  23711. $path = $identifier;
  23712. $rev = '';
  23713. }
  23714. try {
  23715. $resource = $path.$file;
  23716. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  23717. if (!trim($output)) {
  23718. return null;
  23719. }
  23720. } catch (\RuntimeException $e) {
  23721. throw new TransportException($e->getMessage());
  23722. }
  23723. return $output;
  23724. }
  23725. public function getChangeDate($identifier)
  23726. {
  23727. $identifier = '/' . trim($identifier, '/') . '/';
  23728. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  23729. if (!empty($match[2])) {
  23730. $path = $match[1];
  23731. $rev = $match[2];
  23732. } else {
  23733. $path = $identifier;
  23734. $rev = '';
  23735. }
  23736. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  23737. foreach ($this->process->splitLines($output) as $line) {
  23738. if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  23739. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  23740. }
  23741. }
  23742. return null;
  23743. }
  23744. public function getTags()
  23745. {
  23746. if (null === $this->tags) {
  23747. $this->tags = array();
  23748. if ($this->tagsPath !== false) {
  23749. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  23750. if ($output) {
  23751. foreach ($this->process->splitLines($output) as $line) {
  23752. $line = trim($line);
  23753. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  23754. if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
  23755. $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  23756. '/' . $this->tagsPath . '/' . $match[2],
  23757. $match[1]
  23758. );
  23759. }
  23760. }
  23761. }
  23762. }
  23763. }
  23764. }
  23765. return $this->tags;
  23766. }
  23767. public function getBranches()
  23768. {
  23769. if (null === $this->branches) {
  23770. $this->branches = array();
  23771. if (false === $this->trunkPath) {
  23772. $trunkParent = $this->baseUrl . '/';
  23773. } else {
  23774. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  23775. }
  23776. $output = $this->execute('svn ls --verbose', $trunkParent);
  23777. if ($output) {
  23778. foreach ($this->process->splitLines($output) as $line) {
  23779. $line = trim($line);
  23780. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  23781. if (isset($match[1]) && isset($match[2]) && $match[2] === './') {
  23782. $this->branches['trunk'] = $this->buildIdentifier(
  23783. '/' . $this->trunkPath,
  23784. $match[1]
  23785. );
  23786. $this->rootIdentifier = $this->branches['trunk'];
  23787. break;
  23788. }
  23789. }
  23790. }
  23791. }
  23792. unset($output);
  23793. if ($this->branchesPath !== false) {
  23794. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  23795. if ($output) {
  23796. foreach ($this->process->splitLines(trim($output)) as $line) {
  23797. $line = trim($line);
  23798. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  23799. if (isset($match[1]) && isset($match[2]) && $match[2] !== './') {
  23800. $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  23801. '/' . $this->branchesPath . '/' . $match[2],
  23802. $match[1]
  23803. );
  23804. }
  23805. }
  23806. }
  23807. }
  23808. }
  23809. }
  23810. return $this->branches;
  23811. }
  23812. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  23813. {
  23814. $url = self::normalizeUrl($url);
  23815. if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  23816. return true;
  23817. }
  23818. if (!$deep && !Filesystem::isLocalPath($url)) {
  23819. return false;
  23820. }
  23821. $processExecutor = new ProcessExecutor($io);
  23822. $exit = $processExecutor->execute(
  23823. "svn info --non-interactive ".ProcessExecutor::escape($url),
  23824. $ignoredOutput
  23825. );
  23826. if ($exit === 0) {
  23827. return true;
  23828. }
  23829. if (false !== stripos($processExecutor->getErrorOutput(), 'authorization failed:')) {
  23830. return true;
  23831. }
  23832. if (false !== stripos($processExecutor->getErrorOutput(), 'Authentication failed')) {
  23833. return true;
  23834. }
  23835. return false;
  23836. }
  23837. protected static function normalizeUrl($url)
  23838. {
  23839. $fs = new Filesystem();
  23840. if ($fs->isAbsolutePath($url)) {
  23841. return 'file://' . strtr($url, '\\', '/');
  23842. }
  23843. return $url;
  23844. }
  23845. protected function execute($command, $url)
  23846. {
  23847. if (null === $this->util) {
  23848. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  23849. $this->util->setCacheCredentials($this->cacheCredentials);
  23850. }
  23851. try {
  23852. return $this->util->execute($command, $url);
  23853. } catch (\RuntimeException $e) {
  23854. if (null === $this->util->binaryVersion()) {
  23855. 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());
  23856. }
  23857. throw new \RuntimeException(
  23858. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  23859. );
  23860. }
  23861. }
  23862. protected function buildIdentifier($baseDir, $revision)
  23863. {
  23864. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  23865. }
  23866. }
  23867. <?php
  23868. namespace Composer\Repository\Vcs;
  23869. use Composer\Cache;
  23870. use Composer\Downloader\TransportException;
  23871. use Composer\Config;
  23872. use Composer\Factory;
  23873. use Composer\IO\IOInterface;
  23874. use Composer\Json\JsonFile;
  23875. use Composer\Util\ProcessExecutor;
  23876. use Composer\Util\RemoteFilesystem;
  23877. use Composer\Util\Filesystem;
  23878. abstract class VcsDriver implements VcsDriverInterface
  23879. {
  23880. protected $url;
  23881. protected $originUrl;
  23882. protected $repoConfig;
  23883. protected $io;
  23884. protected $config;
  23885. protected $process;
  23886. protected $remoteFilesystem;
  23887. protected $infoCache = array();
  23888. protected $cache;
  23889. final public function __construct(array $repoConfig, IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null)
  23890. {
  23891. if (Filesystem::isLocalPath($repoConfig['url'])) {
  23892. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  23893. }
  23894. $this->url = $repoConfig['url'];
  23895. $this->originUrl = $repoConfig['url'];
  23896. $this->repoConfig = $repoConfig;
  23897. $this->io = $io;
  23898. $this->config = $config;
  23899. $this->process = $process ?: new ProcessExecutor($io);
  23900. $this->remoteFilesystem = $remoteFilesystem ?: Factory::createRemoteFilesystem($this->io, $config);
  23901. }
  23902. protected function shouldCache($identifier)
  23903. {
  23904. return $this->cache && preg_match('{[a-f0-9]{40}}i', $identifier);
  23905. }
  23906. public function getComposerInformation($identifier)
  23907. {
  23908. if (!isset($this->infoCache[$identifier])) {
  23909. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  23910. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  23911. }
  23912. $composer = $this->getBaseComposerInformation($identifier);
  23913. if ($this->shouldCache($identifier)) {
  23914. $this->cache->write($identifier, json_encode($composer));
  23915. }
  23916. $this->infoCache[$identifier] = $composer;
  23917. }
  23918. return $this->infoCache[$identifier];
  23919. }
  23920. protected function getBaseComposerInformation($identifier)
  23921. {
  23922. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  23923. if (!$composerFileContent) {
  23924. return null;
  23925. }
  23926. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  23927. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  23928. $composer['time'] = $changeDate->format(DATE_RFC3339);
  23929. }
  23930. return $composer;
  23931. }
  23932. public function hasComposerFile($identifier)
  23933. {
  23934. try {
  23935. return (bool) $this->getComposerInformation($identifier);
  23936. } catch (TransportException $e) {
  23937. }
  23938. return false;
  23939. }
  23940. protected function getScheme()
  23941. {
  23942. if (extension_loaded('openssl')) {
  23943. return 'https';
  23944. }
  23945. return 'http';
  23946. }
  23947. protected function getContents($url)
  23948. {
  23949. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  23950. return $this->remoteFilesystem->getContents($this->originUrl, $url, false, $options);
  23951. }
  23952. public function cleanup()
  23953. {
  23954. return;
  23955. }
  23956. }
  23957. <?php
  23958. namespace Composer\Repository\Vcs;
  23959. use Composer\Config;
  23960. use Composer\IO\IOInterface;
  23961. interface VcsDriverInterface
  23962. {
  23963. public function initialize();
  23964. public function getComposerInformation($identifier);
  23965. public function getFileContent($file, $identifier);
  23966. public function getChangeDate($identifier);
  23967. public function getRootIdentifier();
  23968. public function getBranches();
  23969. public function getTags();
  23970. public function getDist($identifier);
  23971. public function getSource($identifier);
  23972. public function getUrl();
  23973. public function hasComposerFile($identifier);
  23974. public function cleanup();
  23975. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  23976. }
  23977. <?php
  23978. namespace Composer\Repository;
  23979. use Composer\Downloader\TransportException;
  23980. use Composer\Repository\Vcs\VcsDriverInterface;
  23981. use Composer\Package\Version\VersionParser;
  23982. use Composer\Package\Loader\ArrayLoader;
  23983. use Composer\Package\Loader\ValidatingArrayLoader;
  23984. use Composer\Package\Loader\InvalidPackageException;
  23985. use Composer\Package\Loader\LoaderInterface;
  23986. use Composer\EventDispatcher\EventDispatcher;
  23987. use Composer\IO\IOInterface;
  23988. use Composer\Config;
  23989. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  23990. {
  23991. protected $url;
  23992. protected $packageName;
  23993. protected $verbose;
  23994. protected $io;
  23995. protected $config;
  23996. protected $versionParser;
  23997. protected $type;
  23998. protected $loader;
  23999. protected $repoConfig;
  24000. protected $branchErrorOccurred = false;
  24001. private $drivers;
  24002. private $driver;
  24003. private $versionCache;
  24004. public function __construct(array $repoConfig, IOInterface $io, Config $config, EventDispatcher $dispatcher = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  24005. {
  24006. parent::__construct();
  24007. $this->drivers = $drivers ?: array(
  24008. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  24009. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  24010. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  24011. 'git' => 'Composer\Repository\Vcs\GitDriver',
  24012. 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
  24013. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  24014. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  24015. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  24016. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  24017. );
  24018. $this->url = $repoConfig['url'];
  24019. $this->io = $io;
  24020. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  24021. $this->verbose = $io->isVeryVerbose();
  24022. $this->config = $config;
  24023. $this->repoConfig = $repoConfig;
  24024. $this->versionCache = $versionCache;
  24025. }
  24026. public function getRepoConfig()
  24027. {
  24028. return $this->repoConfig;
  24029. }
  24030. public function setLoader(LoaderInterface $loader)
  24031. {
  24032. $this->loader = $loader;
  24033. }
  24034. public function getDriver()
  24035. {
  24036. if ($this->driver) {
  24037. return $this->driver;
  24038. }
  24039. if (isset($this->drivers[$this->type])) {
  24040. $class = $this->drivers[$this->type];
  24041. $this->driver = new $class($this->repoConfig, $this->io, $this->config);
  24042. $this->driver->initialize();
  24043. return $this->driver;
  24044. }
  24045. foreach ($this->drivers as $driver) {
  24046. if ($driver::supports($this->io, $this->config, $this->url)) {
  24047. $this->driver = new $driver($this->repoConfig, $this->io, $this->config);
  24048. $this->driver->initialize();
  24049. return $this->driver;
  24050. }
  24051. }
  24052. foreach ($this->drivers as $driver) {
  24053. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  24054. $this->driver = new $driver($this->repoConfig, $this->io, $this->config);
  24055. $this->driver->initialize();
  24056. return $this->driver;
  24057. }
  24058. }
  24059. }
  24060. public function hadInvalidBranches()
  24061. {
  24062. return $this->branchErrorOccurred;
  24063. }
  24064. protected function initialize()
  24065. {
  24066. parent::initialize();
  24067. $verbose = $this->verbose;
  24068. $driver = $this->getDriver();
  24069. if (!$driver) {
  24070. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  24071. }
  24072. $this->versionParser = new VersionParser;
  24073. if (!$this->loader) {
  24074. $this->loader = new ArrayLoader($this->versionParser);
  24075. }
  24076. try {
  24077. if ($driver->hasComposerFile($driver->getRootIdentifier())) {
  24078. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  24079. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  24080. }
  24081. } catch (\Exception $e) {
  24082. if ($verbose) {
  24083. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  24084. }
  24085. }
  24086. foreach ($driver->getTags() as $tag => $identifier) {
  24087. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  24088. if ($verbose) {
  24089. $this->io->writeError($msg);
  24090. } else {
  24091. $this->io->overwriteError($msg, false);
  24092. }
  24093. $tag = str_replace('release-', '', $tag);
  24094. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $verbose);
  24095. if ($cachedPackage) {
  24096. $this->addPackage($cachedPackage);
  24097. continue;
  24098. }
  24099. if (!$parsedTag = $this->validateTag($tag)) {
  24100. if ($verbose) {
  24101. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  24102. }
  24103. continue;
  24104. }
  24105. try {
  24106. if (!$data = $driver->getComposerInformation($identifier)) {
  24107. if ($verbose) {
  24108. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  24109. }
  24110. continue;
  24111. }
  24112. if (isset($data['version'])) {
  24113. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  24114. } else {
  24115. $data['version'] = $tag;
  24116. $data['version_normalized'] = $parsedTag;
  24117. }
  24118. $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
  24119. $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  24120. if ($data['version_normalized'] !== $parsedTag) {
  24121. if ($verbose) {
  24122. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  24123. }
  24124. continue;
  24125. }
  24126. $tagPackageName = isset($data['name']) ? $data['name'] : $this->packageName;
  24127. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  24128. if ($verbose) {
  24129. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  24130. }
  24131. continue;
  24132. }
  24133. if ($verbose) {
  24134. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  24135. }
  24136. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  24137. } catch (\Exception $e) {
  24138. if ($verbose) {
  24139. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()).'</warning>');
  24140. }
  24141. continue;
  24142. }
  24143. }
  24144. if (!$verbose) {
  24145. $this->io->overwriteError('', false);
  24146. }
  24147. $branches = $driver->getBranches();
  24148. foreach ($branches as $branch => $identifier) {
  24149. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  24150. if ($verbose) {
  24151. $this->io->writeError($msg);
  24152. } else {
  24153. $this->io->overwriteError($msg, false);
  24154. }
  24155. if ($branch === 'trunk' && isset($branches['master'])) {
  24156. if ($verbose) {
  24157. $this->io->writeError('<warning>Skipped branch '.$branch.', can not parse both master and trunk branches as they both resolve to 9999999-dev internally</warning>');
  24158. }
  24159. continue;
  24160. }
  24161. if (!$parsedBranch = $this->validateBranch($branch)) {
  24162. if ($verbose) {
  24163. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  24164. }
  24165. continue;
  24166. }
  24167. if ('dev-' === substr($parsedBranch, 0, 4) || '9999999-dev' === $parsedBranch) {
  24168. $version = 'dev-' . $branch;
  24169. } else {
  24170. $prefix = substr($branch, 0, 1) === 'v' ? 'v' : '';
  24171. $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
  24172. }
  24173. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $verbose);
  24174. if ($cachedPackage) {
  24175. $this->addPackage($cachedPackage);
  24176. continue;
  24177. }
  24178. try {
  24179. if (!$data = $driver->getComposerInformation($identifier)) {
  24180. if ($verbose) {
  24181. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  24182. }
  24183. continue;
  24184. }
  24185. $data['version'] = $version;
  24186. $data['version_normalized'] = $parsedBranch;
  24187. if ($verbose) {
  24188. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  24189. }
  24190. $packageData = $this->preProcess($driver, $data, $identifier);
  24191. $package = $this->loader->load($packageData);
  24192. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  24193. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  24194. }
  24195. $this->addPackage($package);
  24196. } catch (TransportException $e) {
  24197. if ($verbose) {
  24198. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found</warning>');
  24199. }
  24200. continue;
  24201. } catch (\Exception $e) {
  24202. if (!$verbose) {
  24203. $this->io->writeError('');
  24204. }
  24205. $this->branchErrorOccurred = true;
  24206. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  24207. $this->io->writeError('');
  24208. continue;
  24209. }
  24210. }
  24211. $driver->cleanup();
  24212. if (!$verbose) {
  24213. $this->io->overwriteError('', false);
  24214. }
  24215. if (!$this->getPackages()) {
  24216. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  24217. }
  24218. }
  24219. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  24220. {
  24221. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  24222. $data['name'] = $this->packageName ?: $dataPackageName;
  24223. if (!isset($data['dist'])) {
  24224. $data['dist'] = $driver->getDist($identifier);
  24225. }
  24226. if (!isset($data['source'])) {
  24227. $data['source'] = $driver->getSource($identifier);
  24228. }
  24229. return $data;
  24230. }
  24231. private function validateBranch($branch)
  24232. {
  24233. try {
  24234. return $this->versionParser->normalizeBranch($branch);
  24235. } catch (\Exception $e) {
  24236. }
  24237. return false;
  24238. }
  24239. private function validateTag($version)
  24240. {
  24241. try {
  24242. return $this->versionParser->normalize($version);
  24243. } catch (\Exception $e) {
  24244. }
  24245. return false;
  24246. }
  24247. private function getCachedPackageVersion($version, $identifier, $verbose)
  24248. {
  24249. if (!$this->versionCache) {
  24250. return;
  24251. }
  24252. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  24253. if ($cachedPackage) {
  24254. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  24255. if ($verbose) {
  24256. $this->io->writeError($msg);
  24257. } else {
  24258. $this->io->overwriteError($msg, false);
  24259. }
  24260. if ($existingPackage = $this->findPackage($cachedPackage['name'], $cachedPackage['version_normalized'])) {
  24261. if ($verbose) {
  24262. $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>');
  24263. }
  24264. $cachedPackage = null;
  24265. }
  24266. }
  24267. if ($cachedPackage) {
  24268. return $this->loader->load($cachedPackage);
  24269. }
  24270. return null;
  24271. }
  24272. }
  24273. <?php
  24274. namespace Composer\Repository;
  24275. interface VersionCacheInterface
  24276. {
  24277. public function getVersionPackage($version, $identifier);
  24278. }
  24279. <?php
  24280. namespace Composer\Repository;
  24281. use Composer\Package\AliasPackage;
  24282. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  24283. {
  24284. public function write()
  24285. {
  24286. }
  24287. public function reload()
  24288. {
  24289. }
  24290. public function getCanonicalPackages()
  24291. {
  24292. $packages = $this->getPackages();
  24293. $packagesByName = array();
  24294. foreach ($packages as $package) {
  24295. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  24296. $packagesByName[$package->getName()] = $package;
  24297. }
  24298. }
  24299. $canonicalPackages = array();
  24300. foreach ($packagesByName as $package) {
  24301. while ($package instanceof AliasPackage) {
  24302. $package = $package->getAliasOf();
  24303. }
  24304. $canonicalPackages[] = $package;
  24305. }
  24306. return $canonicalPackages;
  24307. }
  24308. }
  24309. <?php
  24310. namespace Composer\Repository;
  24311. use Composer\Package\PackageInterface;
  24312. interface WritableRepositoryInterface extends RepositoryInterface
  24313. {
  24314. public function write();
  24315. public function addPackage(PackageInterface $package);
  24316. public function removePackage(PackageInterface $package);
  24317. public function getCanonicalPackages();
  24318. public function reload();
  24319. }
  24320. <?php
  24321. namespace Composer\Script;
  24322. class CommandEvent extends Event
  24323. {
  24324. }
  24325. <?php
  24326. namespace Composer\Script;
  24327. use Composer\Composer;
  24328. use Composer\IO\IOInterface;
  24329. use Composer\EventDispatcher\Event as BaseEvent;
  24330. class Event extends BaseEvent
  24331. {
  24332. private $composer;
  24333. private $io;
  24334. private $devMode;
  24335. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  24336. {
  24337. parent::__construct($name, $args, $flags);
  24338. $this->composer = $composer;
  24339. $this->io = $io;
  24340. $this->devMode = $devMode;
  24341. }
  24342. public function getComposer()
  24343. {
  24344. return $this->composer;
  24345. }
  24346. public function getIO()
  24347. {
  24348. return $this->io;
  24349. }
  24350. public function isDevMode()
  24351. {
  24352. return $this->devMode;
  24353. }
  24354. }
  24355. <?php
  24356. namespace Composer\Script;
  24357. use Composer\Installer\PackageEvent as BasePackageEvent;
  24358. class PackageEvent extends BasePackageEvent
  24359. {
  24360. }
  24361. <?php
  24362. namespace Composer\Script;
  24363. class ScriptEvents
  24364. {
  24365. const PRE_INSTALL_CMD = 'pre-install-cmd';
  24366. const POST_INSTALL_CMD = 'post-install-cmd';
  24367. const PRE_UPDATE_CMD = 'pre-update-cmd';
  24368. const POST_UPDATE_CMD = 'post-update-cmd';
  24369. const PRE_STATUS_CMD = 'pre-status-cmd';
  24370. const POST_STATUS_CMD = 'post-status-cmd';
  24371. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  24372. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  24373. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  24374. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  24375. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  24376. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  24377. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  24378. const POST_PACKAGE_INSTALL = 'post-package-install';
  24379. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  24380. const POST_PACKAGE_UPDATE = 'post-package-update';
  24381. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  24382. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  24383. }
  24384. <?php
  24385. namespace Composer\SelfUpdate;
  24386. class Keys
  24387. {
  24388. public static function fingerprint($path)
  24389. {
  24390. $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path))));
  24391. return implode(' ', array(
  24392. substr($hash, 0, 8),
  24393. substr($hash, 8, 8),
  24394. substr($hash, 16, 8),
  24395. substr($hash, 24, 8),
  24396. '',
  24397. substr($hash, 32, 8),
  24398. substr($hash, 40, 8),
  24399. substr($hash, 48, 8),
  24400. substr($hash, 56, 8),
  24401. ));
  24402. }
  24403. }
  24404. <?php
  24405. namespace Composer\SelfUpdate;
  24406. use Composer\Util\RemoteFilesystem;
  24407. use Composer\Config;
  24408. use Composer\Json\JsonFile;
  24409. class Versions
  24410. {
  24411. private $rfs;
  24412. private $config;
  24413. private $channel;
  24414. public function __construct(Config $config, RemoteFilesystem $rfs)
  24415. {
  24416. $this->rfs = $rfs;
  24417. $this->config = $config;
  24418. }
  24419. public function getChannel()
  24420. {
  24421. if ($this->channel) {
  24422. return $this->channel;
  24423. }
  24424. $channelFile = $this->config->get('home').'/update-channel';
  24425. if (file_exists($channelFile)) {
  24426. $channel = trim(file_get_contents($channelFile));
  24427. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  24428. return $this->channel = $channel;
  24429. }
  24430. }
  24431. return $this->channel = 'stable';
  24432. }
  24433. public function setChannel($channel)
  24434. {
  24435. if (!in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  24436. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: stable, preview, snapshot');
  24437. }
  24438. $channelFile = $this->config->get('home').'/update-channel';
  24439. $this->channel = $channel;
  24440. file_put_contents($channelFile, $channel.PHP_EOL);
  24441. }
  24442. public function getLatest()
  24443. {
  24444. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  24445. $versions = JsonFile::parseJson($this->rfs->getContents('getcomposer.org', $protocol . '://getcomposer.org/versions', false));
  24446. foreach ($versions[$this->getChannel()] as $version) {
  24447. if ($version['min-php'] <= PHP_VERSION_ID) {
  24448. return $version;
  24449. }
  24450. }
  24451. throw new \LogicException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  24452. }
  24453. }
  24454. <?php
  24455. namespace Composer\Util;
  24456. use Composer\Config;
  24457. use Composer\IO\IOInterface;
  24458. class AuthHelper
  24459. {
  24460. protected $io;
  24461. protected $config;
  24462. public function __construct(IOInterface $io, Config $config)
  24463. {
  24464. $this->io = $io;
  24465. $this->config = $config;
  24466. }
  24467. public function storeAuth($originUrl, $storeAuth)
  24468. {
  24469. $store = false;
  24470. $configSource = $this->config->getAuthConfigSource();
  24471. if ($storeAuth === true) {
  24472. $store = $configSource;
  24473. } elseif ($storeAuth === 'prompt') {
  24474. $answer = $this->io->askAndValidate(
  24475. 'Do you want to store credentials for '.$originUrl.' in '.$configSource->getName().' ? [Yn] ',
  24476. function ($value) {
  24477. $input = strtolower(substr(trim($value), 0, 1));
  24478. if (in_array($input, array('y','n'))) {
  24479. return $input;
  24480. }
  24481. throw new \RuntimeException('Please answer (y)es or (n)o');
  24482. },
  24483. null,
  24484. 'y'
  24485. );
  24486. if ($answer === 'y') {
  24487. $store = $configSource;
  24488. }
  24489. }
  24490. if ($store) {
  24491. $store->addConfigSetting(
  24492. 'http-basic.'.$originUrl,
  24493. $this->io->getAuthentication($originUrl)
  24494. );
  24495. }
  24496. }
  24497. }
  24498. <?php
  24499. namespace Composer\Util;
  24500. use Composer\Factory;
  24501. use Composer\IO\IOInterface;
  24502. use Composer\Config;
  24503. use Composer\Downloader\TransportException;
  24504. class Bitbucket
  24505. {
  24506. private $io;
  24507. private $config;
  24508. private $process;
  24509. private $remoteFilesystem;
  24510. private $token = array();
  24511. private $time;
  24512. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  24513. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null, $time = null)
  24514. {
  24515. $this->io = $io;
  24516. $this->config = $config;
  24517. $this->process = $process ?: new ProcessExecutor($io);
  24518. $this->remoteFilesystem = $remoteFilesystem ?: Factory::createRemoteFilesystem($this->io, $config);
  24519. $this->time = $time;
  24520. }
  24521. public function getToken()
  24522. {
  24523. if (!isset($this->token['access_token'])) {
  24524. return '';
  24525. }
  24526. return $this->token['access_token'];
  24527. }
  24528. public function authorizeOAuth($originUrl)
  24529. {
  24530. if ($originUrl !== 'bitbucket.org') {
  24531. return false;
  24532. }
  24533. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  24534. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  24535. return true;
  24536. }
  24537. return false;
  24538. }
  24539. private function requestAccessToken($originUrl)
  24540. {
  24541. try {
  24542. $json = $this->remoteFilesystem->getContents($originUrl, self::OAUTH2_ACCESS_TOKEN_URL, false, array(
  24543. 'retry-auth-failure' => false,
  24544. 'http' => array(
  24545. 'method' => 'POST',
  24546. 'content' => 'grant_type=client_credentials',
  24547. ),
  24548. ));
  24549. $this->token = json_decode($json, true);
  24550. } catch (TransportException $e) {
  24551. if ($e->getCode() === 400) {
  24552. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  24553. $this->io->writeError('This can have two reasons:');
  24554. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  24555. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  24556. return false;
  24557. } elseif (in_array($e->getCode(), array(403, 401))) {
  24558. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  24559. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  24560. return false;
  24561. }
  24562. throw $e;
  24563. }
  24564. return true;
  24565. }
  24566. public function authorizeOAuthInteractively($originUrl, $message = null)
  24567. {
  24568. if ($message) {
  24569. $this->io->writeError($message);
  24570. }
  24571. $url = 'https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html';
  24572. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  24573. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  24574. $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)');
  24575. $consumerKey = trim($this->io->askAndHideAnswer('Consumer Key (hidden): '));
  24576. if (!$consumerKey) {
  24577. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  24578. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  24579. return false;
  24580. }
  24581. $consumerSecret = trim($this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  24582. if (!$consumerSecret) {
  24583. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  24584. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  24585. return false;
  24586. }
  24587. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  24588. if (!$this->requestAccessToken($originUrl)) {
  24589. return false;
  24590. }
  24591. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  24592. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  24593. $this->io->writeError('<info>Consumer stored successfully.</info>');
  24594. return true;
  24595. }
  24596. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  24597. {
  24598. if (!empty($this->token) || $this->getTokenFromConfig($originUrl)) {
  24599. return $this->token['access_token'];
  24600. }
  24601. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  24602. if (!$this->requestAccessToken($originUrl)) {
  24603. return '';
  24604. }
  24605. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  24606. return $this->token['access_token'];
  24607. }
  24608. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  24609. {
  24610. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  24611. $time = null === $this->time ? time() : $this->time;
  24612. $consumer = array(
  24613. "consumer-key" => $consumerKey,
  24614. "consumer-secret" => $consumerSecret,
  24615. "access-token" => $this->token['access_token'],
  24616. "access-token-expiration" => $time + $this->token['expires_in'],
  24617. );
  24618. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  24619. }
  24620. private function getTokenFromConfig($originUrl)
  24621. {
  24622. $authConfig = $this->config->get('bitbucket-oauth');
  24623. if (
  24624. !isset($authConfig[$originUrl]['access-token'])
  24625. || !isset($authConfig[$originUrl]['access-token-expiration'])
  24626. || time() > $authConfig[$originUrl]['access-token-expiration']
  24627. ) {
  24628. return false;
  24629. }
  24630. $this->token = array(
  24631. 'access_token' => $authConfig[$originUrl]['access-token'],
  24632. );
  24633. return true;
  24634. }
  24635. }
  24636. <?php
  24637. namespace Composer\Util;
  24638. class ComposerMirror
  24639. {
  24640. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)
  24641. {
  24642. if ($reference) {
  24643. $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  24644. }
  24645. $version = strpos($version, '/') === false ? $version : md5($version);
  24646. return str_replace(
  24647. array('%package%', '%version%', '%reference%', '%type%'),
  24648. array($packageName, $version, $reference, $type),
  24649. $mirrorUrl
  24650. );
  24651. }
  24652. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  24653. {
  24654. if (preg_match('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  24655. $url = 'gh-'.$match[1].'/'.$match[2];
  24656. } elseif (preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  24657. $url = 'bb-'.$match[1].'/'.$match[2];
  24658. } else {
  24659. $url = preg_replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  24660. }
  24661. return str_replace(
  24662. array('%package%', '%normalizedUrl%', '%type%'),
  24663. array($packageName, $url, $type),
  24664. $mirrorUrl
  24665. );
  24666. }
  24667. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  24668. {
  24669. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  24670. }
  24671. }
  24672. <?php
  24673. namespace Composer\Util;
  24674. use Composer\Package\Loader\ArrayLoader;
  24675. use Composer\Package\Loader\ValidatingArrayLoader;
  24676. use Composer\Package\Loader\InvalidPackageException;
  24677. use Composer\Json\JsonValidationException;
  24678. use Composer\IO\IOInterface;
  24679. use Composer\Json\JsonFile;
  24680. use Composer\Spdx\SpdxLicenses;
  24681. class ConfigValidator
  24682. {
  24683. private $io;
  24684. public function __construct(IOInterface $io)
  24685. {
  24686. $this->io = $io;
  24687. }
  24688. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL)
  24689. {
  24690. $errors = array();
  24691. $publishErrors = array();
  24692. $warnings = array();
  24693. $laxValid = false;
  24694. try {
  24695. $json = new JsonFile($file, null, $this->io);
  24696. $manifest = $json->read();
  24697. $json->validateSchema(JsonFile::LAX_SCHEMA);
  24698. $laxValid = true;
  24699. $json->validateSchema();
  24700. } catch (JsonValidationException $e) {
  24701. foreach ($e->getErrors() as $message) {
  24702. if ($laxValid) {
  24703. $publishErrors[] = $message;
  24704. } else {
  24705. $errors[] = $message;
  24706. }
  24707. }
  24708. } catch (\Exception $e) {
  24709. $errors[] = $e->getMessage();
  24710. return array($errors, $publishErrors, $warnings);
  24711. }
  24712. if (empty($manifest['license'])) {
  24713. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  24714. } else {
  24715. $licenses = (array) $manifest['license'];
  24716. foreach ($licenses as $key => $license) {
  24717. if ('proprietary' === $license) {
  24718. unset($licenses[$key]);
  24719. }
  24720. }
  24721. $licenseValidator = new SpdxLicenses();
  24722. foreach ($licenses as $license) {
  24723. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  24724. if ($spdxLicense && $spdxLicense[3]) {
  24725. if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  24726. $warnings[] = sprintf(
  24727. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  24728. $license
  24729. );
  24730. } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  24731. $warnings[] = sprintf(
  24732. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  24733. $license
  24734. );
  24735. } else {
  24736. $warnings[] = sprintf(
  24737. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  24738. $license
  24739. );
  24740. }
  24741. }
  24742. }
  24743. }
  24744. if (isset($manifest['version'])) {
  24745. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  24746. }
  24747. if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {
  24748. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  24749. $suggestName = strtolower($suggestName);
  24750. $publishErrors[] = sprintf(
  24751. '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.',
  24752. $manifest['name'],
  24753. $suggestName
  24754. );
  24755. }
  24756. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  24757. $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.";
  24758. }
  24759. if (isset($manifest['require']) && isset($manifest['require-dev'])) {
  24760. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  24761. if (!empty($requireOverrides)) {
  24762. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  24763. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  24764. }
  24765. }
  24766. $require = isset($manifest['require']) ? $manifest['require'] : array();
  24767. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  24768. $packages = array_merge($require, $requireDev);
  24769. foreach ($packages as $package => $version) {
  24770. if (preg_match('/#/', $version) === 1) {
  24771. $warnings[] = sprintf(
  24772. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  24773. $package
  24774. );
  24775. }
  24776. }
  24777. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  24778. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  24779. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  24780. if (!array_key_exists($scriptName, $scripts)) {
  24781. $warnings[] = sprintf(
  24782. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  24783. $scriptName
  24784. );
  24785. }
  24786. }
  24787. if (isset($manifest['autoload']['psr-0'][''])) {
  24788. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  24789. }
  24790. if (isset($manifest['autoload']['psr-4'][''])) {
  24791. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  24792. }
  24793. try {
  24794. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  24795. if (!isset($manifest['version'])) {
  24796. $manifest['version'] = '1.0.0';
  24797. }
  24798. if (!isset($manifest['name'])) {
  24799. $manifest['name'] = 'dummy/dummy';
  24800. }
  24801. $loader->load($manifest);
  24802. } catch (InvalidPackageException $e) {
  24803. $errors = array_merge($errors, $e->getErrors());
  24804. }
  24805. $warnings = array_merge($warnings, $loader->getWarnings());
  24806. return array($errors, $publishErrors, $warnings);
  24807. }
  24808. }
  24809. <?php
  24810. namespace Composer\Util;
  24811. use Composer\IO\IOInterface;
  24812. class ErrorHandler
  24813. {
  24814. private static $io;
  24815. public static function handle($level, $message, $file, $line)
  24816. {
  24817. if (!(error_reporting() & $level)) {
  24818. return;
  24819. }
  24820. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  24821. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  24822. "\na legitimately suppressed error that you were not supposed to see.";
  24823. }
  24824. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  24825. throw new \ErrorException($message, 0, $level, $file, $line);
  24826. }
  24827. if (self::$io) {
  24828. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  24829. if (self::$io->isVerbose()) {
  24830. self::$io->writeError('<warning>Stack trace:</warning>');
  24831. self::$io->writeError(array_filter(array_map(function ($a) {
  24832. if (isset($a['line'], $a['file'])) {
  24833. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  24834. }
  24835. return null;
  24836. }, array_slice(debug_backtrace(), 2))));
  24837. }
  24838. }
  24839. }
  24840. public static function register(IOInterface $io = null)
  24841. {
  24842. set_error_handler(array(__CLASS__, 'handle'));
  24843. error_reporting(E_ALL | E_STRICT);
  24844. self::$io = $io;
  24845. }
  24846. }
  24847. <?php
  24848. namespace Composer\Util;
  24849. use RecursiveDirectoryIterator;
  24850. use RecursiveIteratorIterator;
  24851. use Symfony\Component\Filesystem\Exception\IOException;
  24852. use Symfony\Component\Finder\Finder;
  24853. class Filesystem
  24854. {
  24855. private $processExecutor;
  24856. public function __construct(ProcessExecutor $executor = null)
  24857. {
  24858. $this->processExecutor = $executor ?: new ProcessExecutor();
  24859. }
  24860. public function remove($file)
  24861. {
  24862. if (is_dir($file)) {
  24863. return $this->removeDirectory($file);
  24864. }
  24865. if (file_exists($file)) {
  24866. return $this->unlink($file);
  24867. }
  24868. return false;
  24869. }
  24870. public function isDirEmpty($dir)
  24871. {
  24872. $finder = Finder::create()
  24873. ->ignoreVCS(false)
  24874. ->ignoreDotFiles(false)
  24875. ->depth(0)
  24876. ->in($dir);
  24877. return count($finder) === 0;
  24878. }
  24879. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  24880. {
  24881. if (file_exists($dir) && is_link($dir)) {
  24882. $this->unlink($dir);
  24883. }
  24884. if ($ensureDirectoryExists) {
  24885. $this->ensureDirectoryExists($dir);
  24886. }
  24887. if (is_dir($dir)) {
  24888. $finder = Finder::create()
  24889. ->ignoreVCS(false)
  24890. ->ignoreDotFiles(false)
  24891. ->depth(0)
  24892. ->in($dir);
  24893. foreach ($finder as $path) {
  24894. $this->remove((string) $path);
  24895. }
  24896. }
  24897. }
  24898. public function removeDirectory($directory)
  24899. {
  24900. if ($this->isSymlinkedDirectory($directory)) {
  24901. return $this->unlinkSymlinkedDirectory($directory);
  24902. }
  24903. if ($this->isJunction($directory)) {
  24904. return $this->removeJunction($directory);
  24905. }
  24906. if (is_link($directory)) {
  24907. return unlink($directory);
  24908. }
  24909. if (!file_exists($directory) || !is_dir($directory)) {
  24910. return true;
  24911. }
  24912. if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  24913. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  24914. }
  24915. if (!function_exists('proc_open')) {
  24916. return $this->removeDirectoryPhp($directory);
  24917. }
  24918. if (Platform::isWindows()) {
  24919. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  24920. } else {
  24921. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  24922. }
  24923. $result = $this->getProcess()->execute($cmd, $output) === 0;
  24924. clearstatcache();
  24925. if ($result && !file_exists($directory)) {
  24926. return true;
  24927. }
  24928. return $this->removeDirectoryPhp($directory);
  24929. }
  24930. public function removeDirectoryPhp($directory)
  24931. {
  24932. try {
  24933. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  24934. } catch (\UnexpectedValueException $e) {
  24935. clearstatcache();
  24936. usleep(100000);
  24937. if (!is_dir($directory)) {
  24938. return true;
  24939. }
  24940. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  24941. }
  24942. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  24943. foreach ($ri as $file) {
  24944. if ($file->isDir()) {
  24945. $this->rmdir($file->getPathname());
  24946. } else {
  24947. $this->unlink($file->getPathname());
  24948. }
  24949. }
  24950. return $this->rmdir($directory);
  24951. }
  24952. public function ensureDirectoryExists($directory)
  24953. {
  24954. if (!is_dir($directory)) {
  24955. if (file_exists($directory)) {
  24956. throw new \RuntimeException(
  24957. $directory.' exists and is not a directory.'
  24958. );
  24959. }
  24960. if (!@mkdir($directory, 0777, true)) {
  24961. throw new \RuntimeException(
  24962. $directory.' does not exist and could not be created.'
  24963. );
  24964. }
  24965. }
  24966. }
  24967. public function unlink($path)
  24968. {
  24969. if (!@$this->unlinkImplementation($path)) {
  24970. if (!Platform::isWindows() || (usleep(350000) && !@$this->unlinkImplementation($path))) {
  24971. $error = error_get_last();
  24972. $message = 'Could not delete '.$path.': ' . @$error['message'];
  24973. if (Platform::isWindows()) {
  24974. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  24975. }
  24976. throw new \RuntimeException($message);
  24977. }
  24978. }
  24979. return true;
  24980. }
  24981. public function rmdir($path)
  24982. {
  24983. if (!@rmdir($path)) {
  24984. if (!Platform::isWindows() || (usleep(350000) && !@rmdir($path))) {
  24985. $error = error_get_last();
  24986. $message = 'Could not delete '.$path.': ' . @$error['message'];
  24987. if (Platform::isWindows()) {
  24988. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  24989. }
  24990. throw new \RuntimeException($message);
  24991. }
  24992. }
  24993. return true;
  24994. }
  24995. public function copyThenRemove($source, $target)
  24996. {
  24997. $this->copy($source, $target);
  24998. if (!is_dir($source)) {
  24999. $this->unlink($source);
  25000. return;
  25001. }
  25002. $this->removeDirectoryPhp($source);
  25003. }
  25004. public function copy($source, $target)
  25005. {
  25006. if (!is_dir($source)) {
  25007. return copy($source, $target);
  25008. }
  25009. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  25010. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  25011. $this->ensureDirectoryExists($target);
  25012. $result = true;
  25013. foreach ($ri as $file) {
  25014. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
  25015. if ($file->isDir()) {
  25016. $this->ensureDirectoryExists($targetPath);
  25017. } else {
  25018. $result = $result && copy($file->getPathname(), $targetPath);
  25019. }
  25020. }
  25021. return $result;
  25022. }
  25023. public function rename($source, $target)
  25024. {
  25025. if (true === @rename($source, $target)) {
  25026. return;
  25027. }
  25028. if (!function_exists('proc_open')) {
  25029. return $this->copyThenRemove($source, $target);
  25030. }
  25031. if (Platform::isWindows()) {
  25032. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  25033. $result = $this->processExecutor->execute($command, $output);
  25034. clearstatcache();
  25035. if (0 === $result) {
  25036. $this->remove($source);
  25037. return;
  25038. }
  25039. } else {
  25040. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  25041. $result = $this->processExecutor->execute($command, $output);
  25042. clearstatcache();
  25043. if (0 === $result) {
  25044. return;
  25045. }
  25046. }
  25047. return $this->copyThenRemove($source, $target);
  25048. }
  25049. public function findShortestPath($from, $to, $directories = false)
  25050. {
  25051. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  25052. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  25053. }
  25054. $from = lcfirst($this->normalizePath($from));
  25055. $to = lcfirst($this->normalizePath($to));
  25056. if ($directories) {
  25057. $from = rtrim($from, '/') . '/dummy_file';
  25058. }
  25059. if (dirname($from) === dirname($to)) {
  25060. return './'.basename($to);
  25061. }
  25062. $commonPath = $to;
  25063. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
  25064. $commonPath = strtr(dirname($commonPath), '\\', '/');
  25065. }
  25066. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  25067. return $to;
  25068. }
  25069. $commonPath = rtrim($commonPath, '/') . '/';
  25070. $sourcePathDepth = substr_count(substr($from, strlen($commonPath)), '/');
  25071. $commonPathCode = str_repeat('../', $sourcePathDepth);
  25072. return ($commonPathCode . substr($to, strlen($commonPath))) ?: './';
  25073. }
  25074. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  25075. {
  25076. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  25077. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  25078. }
  25079. $from = lcfirst($this->normalizePath($from));
  25080. $to = lcfirst($this->normalizePath($to));
  25081. if ($from === $to) {
  25082. return $directories ? '__DIR__' : '__FILE__';
  25083. }
  25084. $commonPath = $to;
  25085. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  25086. $commonPath = strtr(dirname($commonPath), '\\', '/');
  25087. }
  25088. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  25089. return var_export($to, true);
  25090. }
  25091. $commonPath = rtrim($commonPath, '/') . '/';
  25092. if (strpos($to, $from.'/') === 0) {
  25093. return '__DIR__ . '.var_export(substr($to, strlen($from)), true);
  25094. }
  25095. $sourcePathDepth = substr_count(substr($from, strlen($commonPath)), '/') + $directories;
  25096. if ($staticCode) {
  25097. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  25098. } else {
  25099. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  25100. }
  25101. $relTarget = substr($to, strlen($commonPath));
  25102. return $commonPathCode . (strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  25103. }
  25104. public function isAbsolutePath($path)
  25105. {
  25106. return substr($path, 0, 1) === '/' || substr($path, 1, 1) === ':';
  25107. }
  25108. public function size($path)
  25109. {
  25110. if (!file_exists($path)) {
  25111. throw new \RuntimeException("$path does not exist.");
  25112. }
  25113. if (is_dir($path)) {
  25114. return $this->directorySize($path);
  25115. }
  25116. return filesize($path);
  25117. }
  25118. public function normalizePath($path)
  25119. {
  25120. $parts = array();
  25121. $path = strtr($path, '\\', '/');
  25122. $prefix = '';
  25123. $absolute = false;
  25124. if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  25125. $prefix = $match[1];
  25126. $path = substr($path, strlen($prefix));
  25127. }
  25128. if (substr($path, 0, 1) === '/') {
  25129. $absolute = true;
  25130. $path = substr($path, 1);
  25131. }
  25132. $up = false;
  25133. foreach (explode('/', $path) as $chunk) {
  25134. if ('..' === $chunk && ($absolute || $up)) {
  25135. array_pop($parts);
  25136. $up = !(empty($parts) || '..' === end($parts));
  25137. } elseif ('.' !== $chunk && '' !== $chunk) {
  25138. $parts[] = $chunk;
  25139. $up = '..' !== $chunk;
  25140. }
  25141. }
  25142. return $prefix.($absolute ? '/' : '').implode('/', $parts);
  25143. }
  25144. public static function isLocalPath($path)
  25145. {
  25146. return (bool) preg_match('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  25147. }
  25148. public static function getPlatformPath($path)
  25149. {
  25150. if (Platform::isWindows()) {
  25151. $path = preg_replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  25152. }
  25153. return preg_replace('{^file://}i', '', $path);
  25154. }
  25155. protected function directorySize($directory)
  25156. {
  25157. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  25158. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  25159. $size = 0;
  25160. foreach ($ri as $file) {
  25161. if ($file->isFile()) {
  25162. $size += $file->getSize();
  25163. }
  25164. }
  25165. return $size;
  25166. }
  25167. protected function getProcess()
  25168. {
  25169. return $this->processExecutor;
  25170. }
  25171. private function unlinkImplementation($path)
  25172. {
  25173. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  25174. return rmdir($path);
  25175. }
  25176. return unlink($path);
  25177. }
  25178. public function relativeSymlink($target, $link)
  25179. {
  25180. $cwd = getcwd();
  25181. $relativePath = $this->findShortestPath($link, $target);
  25182. chdir(dirname($link));
  25183. $result = @symlink($relativePath, $link);
  25184. chdir($cwd);
  25185. return $result;
  25186. }
  25187. public function isSymlinkedDirectory($directory)
  25188. {
  25189. if (!is_dir($directory)) {
  25190. return false;
  25191. }
  25192. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  25193. return is_link($resolved);
  25194. }
  25195. private function unlinkSymlinkedDirectory($directory)
  25196. {
  25197. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  25198. return $this->unlink($resolved);
  25199. }
  25200. private function resolveSymlinkedDirectorySymlink($pathname)
  25201. {
  25202. if (!is_dir($pathname)) {
  25203. return $pathname;
  25204. }
  25205. $resolved = rtrim($pathname, '/');
  25206. if (!strlen($resolved)) {
  25207. return $pathname;
  25208. }
  25209. return $resolved;
  25210. }
  25211. public function junction($target, $junction)
  25212. {
  25213. if (!Platform::isWindows()) {
  25214. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  25215. }
  25216. if (!is_dir($target)) {
  25217. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  25218. }
  25219. $cmd = sprintf(
  25220. 'mklink /J %s %s',
  25221. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  25222. ProcessExecutor::escape(realpath($target))
  25223. );
  25224. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  25225. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  25226. }
  25227. clearstatcache(true, $junction);
  25228. }
  25229. public function isJunction($junction)
  25230. {
  25231. if (!Platform::isWindows()) {
  25232. return false;
  25233. }
  25234. if (!is_dir($junction) || is_link($junction)) {
  25235. return false;
  25236. }
  25237. clearstatcache(true, $junction);
  25238. clearstatcache(false);
  25239. $stat = lstat($junction);
  25240. return !($stat['mode'] & 0xC000);
  25241. }
  25242. public function removeJunction($junction)
  25243. {
  25244. if (!Platform::isWindows()) {
  25245. return false;
  25246. }
  25247. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  25248. if (!$this->isJunction($junction)) {
  25249. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  25250. }
  25251. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape($junction));
  25252. clearstatcache(true, $junction);
  25253. return ($this->getProcess()->execute($cmd, $output) === 0);
  25254. }
  25255. }
  25256. <?php
  25257. namespace Composer\Util;
  25258. use Composer\Config;
  25259. use Composer\IO\IOInterface;
  25260. class Git
  25261. {
  25262. private static $version;
  25263. protected $io;
  25264. protected $config;
  25265. protected $process;
  25266. protected $filesystem;
  25267. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  25268. {
  25269. $this->io = $io;
  25270. $this->config = $config;
  25271. $this->process = $process;
  25272. $this->filesystem = $fs;
  25273. }
  25274. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  25275. {
  25276. $this->config->prohibitUrlByConfig($url, $this->io);
  25277. if ($initialClone) {
  25278. $origCwd = $cwd;
  25279. $cwd = null;
  25280. }
  25281. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  25282. throw new \InvalidArgumentException('The source URL ' . $url . ' is invalid, ssh URLs should have a port number after ":".' . "\n" . 'Use ssh://[email protected]:22/path or just [email protected]:path if you do not want to provide a password or custom port.');
  25283. }
  25284. if (!$initialClone) {
  25285. $this->process->execute('git remote -v', $output, $cwd);
  25286. if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match)) {
  25287. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  25288. }
  25289. }
  25290. $protocols = $this->config->get('github-protocols');
  25291. if (!is_array($protocols)) {
  25292. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  25293. }
  25294. if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  25295. $messages = array();
  25296. foreach ($protocols as $protocol) {
  25297. if ('ssh' === $protocol) {
  25298. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  25299. } else {
  25300. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  25301. }
  25302. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  25303. return;
  25304. }
  25305. $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
  25306. if ($initialClone) {
  25307. $this->filesystem->removeDirectory($origCwd);
  25308. }
  25309. }
  25310. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  25311. }
  25312. $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  25313. $command = call_user_func($commandCallable, $url);
  25314. $auth = null;
  25315. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  25316. if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)) {
  25317. if (!$this->io->hasAuthentication($match[1])) {
  25318. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  25319. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  25320. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  25321. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  25322. }
  25323. }
  25324. if ($this->io->hasAuthentication($match[1])) {
  25325. $auth = $this->io->getAuthentication($match[1]);
  25326. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  25327. $command = call_user_func($commandCallable, $authUrl);
  25328. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  25329. return;
  25330. }
  25331. }
  25332. } elseif (preg_match('{^https://(bitbucket\.org)/(.*)(\.git)?$}U', $url, $match)) {
  25333. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  25334. if (!$this->io->hasAuthentication($match[1])) {
  25335. $message = 'Enter your Bitbucket credentials to access private repos';
  25336. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  25337. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  25338. $accessToken = $bitbucketUtil->getToken();
  25339. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  25340. }
  25341. } else {
  25342. $auth = $this->io->getAuthentication($match[1]);
  25343. if ($auth['username'] !== 'x-token-auth') {
  25344. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  25345. if (! empty($accessToken)) {
  25346. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  25347. }
  25348. }
  25349. }
  25350. if ($this->io->hasAuthentication($match[1])) {
  25351. $auth = $this->io->getAuthentication($match[1]);
  25352. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  25353. $command = call_user_func($commandCallable, $authUrl);
  25354. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  25355. return;
  25356. }
  25357. } else {
  25358. $sshUrl = '[email protected]:' . $match[2] . '.git';
  25359. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  25360. $command = call_user_func($commandCallable, $sshUrl);
  25361. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  25362. return;
  25363. }
  25364. }
  25365. } elseif ($this->isAuthenticationFailure($url, $match)) {
  25366. if (strpos($match[2], '@')) {
  25367. list($authParts, $match[2]) = explode('@', $match[2], 2);
  25368. }
  25369. $storeAuth = false;
  25370. if ($this->io->hasAuthentication($match[2])) {
  25371. $auth = $this->io->getAuthentication($match[2]);
  25372. } elseif ($this->io->isInteractive()) {
  25373. $defaultUsername = null;
  25374. if (isset($authParts) && $authParts) {
  25375. if (false !== strpos($authParts, ':')) {
  25376. list($defaultUsername, ) = explode(':', $authParts, 2);
  25377. } else {
  25378. $defaultUsername = $authParts;
  25379. }
  25380. }
  25381. $this->io->writeError(' Authentication required (<info>' . parse_url($url, PHP_URL_HOST) . '</info>):');
  25382. $auth = array(
  25383. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  25384. 'password' => $this->io->askAndHideAnswer(' Password: '),
  25385. );
  25386. $storeAuth = $this->config->get('store-auths');
  25387. }
  25388. if ($auth) {
  25389. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  25390. $command = call_user_func($commandCallable, $authUrl);
  25391. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  25392. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  25393. $authHelper = new AuthHelper($this->io, $this->config);
  25394. $authHelper->storeAuth($match[2], $storeAuth);
  25395. return;
  25396. }
  25397. }
  25398. }
  25399. if ($initialClone) {
  25400. $this->filesystem->removeDirectory($origCwd);
  25401. }
  25402. $this->throwException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput(), $url);
  25403. }
  25404. }
  25405. public function syncMirror($url, $dir)
  25406. {
  25407. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  25408. try {
  25409. $commandCallable = function ($url) {
  25410. return sprintf('git remote set-url origin %s && git remote update --prune origin', ProcessExecutor::escape($url));
  25411. };
  25412. $this->runCommand($commandCallable, $url, $dir);
  25413. } catch (\Exception $e) {
  25414. return false;
  25415. }
  25416. return true;
  25417. }
  25418. $this->filesystem->removeDirectory($dir);
  25419. $commandCallable = function ($url) use ($dir) {
  25420. return sprintf('git clone --mirror %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  25421. };
  25422. $this->runCommand($commandCallable, $url, $dir, true);
  25423. return true;
  25424. }
  25425. public function fetchRefOrSyncMirror($url, $dir, $ref)
  25426. {
  25427. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  25428. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  25429. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $output, $dir);
  25430. if ($exitCode === 0) {
  25431. return true;
  25432. }
  25433. }
  25434. $this->syncMirror($url, $dir);
  25435. return false;
  25436. }
  25437. private function isAuthenticationFailure($url, &$match)
  25438. {
  25439. if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  25440. return false;
  25441. }
  25442. $authFailures = array(
  25443. 'fatal: Authentication failed',
  25444. 'remote error: Invalid username or password.',
  25445. 'error: 401 Unauthorized',
  25446. 'fatal: unable to access',
  25447. 'fatal: could not read Username',
  25448. );
  25449. $errorOutput = $this->process->getErrorOutput();
  25450. foreach ($authFailures as $authFailure) {
  25451. if (strpos($errorOutput, $authFailure) !== false) {
  25452. return true;
  25453. }
  25454. }
  25455. return false;
  25456. }
  25457. public static function cleanEnv()
  25458. {
  25459. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  25460. 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');
  25461. }
  25462. if (getenv('GIT_ASKPASS') !== 'echo') {
  25463. putenv('GIT_ASKPASS=echo');
  25464. unset($_SERVER['GIT_ASKPASS']);
  25465. }
  25466. if (getenv('GIT_DIR')) {
  25467. putenv('GIT_DIR');
  25468. unset($_SERVER['GIT_DIR']);
  25469. }
  25470. if (getenv('GIT_WORK_TREE')) {
  25471. putenv('GIT_WORK_TREE');
  25472. unset($_SERVER['GIT_WORK_TREE']);
  25473. }
  25474. if (getenv('LANGUAGE') !== 'C') {
  25475. putenv('LANGUAGE=C');
  25476. }
  25477. putenv("DYLD_LIBRARY_PATH");
  25478. unset($_SERVER['DYLD_LIBRARY_PATH']);
  25479. }
  25480. public static function getGitHubDomainsRegex(Config $config)
  25481. {
  25482. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  25483. }
  25484. public static function sanitizeUrl($message)
  25485. {
  25486. return preg_replace_callback('{://(?P<user>[^@]+?):(?P<password>.+?)@}', function ($m) {
  25487. if (preg_match('{^[a-f0-9]{12,}$}', $m[1])) {
  25488. return '://***:***@';
  25489. }
  25490. return '://' . $m[1] . ':***@';
  25491. }, $message);
  25492. }
  25493. private function throwException($message, $url)
  25494. {
  25495. clearstatcache();
  25496. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  25497. throw new \RuntimeException(self::sanitizeUrl('Failed to clone ' . $url . ', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()));
  25498. }
  25499. throw new \RuntimeException(self::sanitizeUrl($message));
  25500. }
  25501. public function getVersion()
  25502. {
  25503. if (isset(self::$version)) {
  25504. return self::$version;
  25505. }
  25506. if (0 !== $this->process->execute('git --version', $output)) {
  25507. return;
  25508. }
  25509. if (preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  25510. return self::$version = $matches[1];
  25511. }
  25512. }
  25513. }
  25514. <?php
  25515. namespace Composer\Util;
  25516. use Composer\Factory;
  25517. use Composer\IO\IOInterface;
  25518. use Composer\Config;
  25519. use Composer\Downloader\TransportException;
  25520. class GitHub
  25521. {
  25522. protected $io;
  25523. protected $config;
  25524. protected $process;
  25525. protected $remoteFilesystem;
  25526. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null)
  25527. {
  25528. $this->io = $io;
  25529. $this->config = $config;
  25530. $this->process = $process ?: new ProcessExecutor($io);
  25531. $this->remoteFilesystem = $remoteFilesystem ?: Factory::createRemoteFilesystem($this->io, $config);
  25532. }
  25533. public function authorizeOAuth($originUrl)
  25534. {
  25535. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  25536. return false;
  25537. }
  25538. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  25539. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  25540. return true;
  25541. }
  25542. return false;
  25543. }
  25544. public function authorizeOAuthInteractively($originUrl, $message = null)
  25545. {
  25546. if ($message) {
  25547. $this->io->writeError($message);
  25548. }
  25549. $note = 'Composer';
  25550. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  25551. $note .= ' on ' . trim($output);
  25552. }
  25553. $note .= ' ' . date('Y-m-d Hi');
  25554. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  25555. $this->io->writeError(sprintf('Head to %s', $url));
  25556. $this->io->writeError(sprintf('to retrieve a token. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  25557. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  25558. if (!$token) {
  25559. $this->io->writeError('<warning>No token given, aborting.</warning>');
  25560. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  25561. return false;
  25562. }
  25563. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  25564. try {
  25565. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  25566. $this->remoteFilesystem->getContents($originUrl, 'https://'. $apiUrl, false, array(
  25567. 'retry-auth-failure' => false,
  25568. ));
  25569. } catch (TransportException $e) {
  25570. if (in_array($e->getCode(), array(403, 401))) {
  25571. $this->io->writeError('<error>Invalid token provided.</error>');
  25572. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  25573. return false;
  25574. }
  25575. throw $e;
  25576. }
  25577. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  25578. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  25579. $this->io->writeError('<info>Token stored successfully.</info>');
  25580. return true;
  25581. }
  25582. public function getRateLimit(array $headers)
  25583. {
  25584. $rateLimit = array(
  25585. 'limit' => '?',
  25586. 'reset' => '?',
  25587. );
  25588. foreach ($headers as $header) {
  25589. $header = trim($header);
  25590. if (false === strpos($header, 'X-RateLimit-')) {
  25591. continue;
  25592. }
  25593. list($type, $value) = explode(':', $header, 2);
  25594. switch ($type) {
  25595. case 'X-RateLimit-Limit':
  25596. $rateLimit['limit'] = (int) trim($value);
  25597. break;
  25598. case 'X-RateLimit-Reset':
  25599. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  25600. break;
  25601. }
  25602. }
  25603. return $rateLimit;
  25604. }
  25605. public function isRateLimited(array $headers)
  25606. {
  25607. foreach ($headers as $header) {
  25608. if (preg_match('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  25609. return true;
  25610. }
  25611. }
  25612. return false;
  25613. }
  25614. }
  25615. <?php
  25616. namespace Composer\Util;
  25617. use Composer\IO\IOInterface;
  25618. use Composer\Config;
  25619. use Composer\Factory;
  25620. use Composer\Downloader\TransportException;
  25621. use Composer\Json\JsonFile;
  25622. class GitLab
  25623. {
  25624. protected $io;
  25625. protected $config;
  25626. protected $process;
  25627. protected $remoteFilesystem;
  25628. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, RemoteFilesystem $remoteFilesystem = null)
  25629. {
  25630. $this->io = $io;
  25631. $this->config = $config;
  25632. $this->process = $process ?: new ProcessExecutor($io);
  25633. $this->remoteFilesystem = $remoteFilesystem ?: Factory::createRemoteFilesystem($this->io, $config);
  25634. }
  25635. public function authorizeOAuth($originUrl)
  25636. {
  25637. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true)) {
  25638. return false;
  25639. }
  25640. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  25641. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  25642. return true;
  25643. }
  25644. $authTokens = $this->config->get('gitlab-token');
  25645. if (isset($authTokens[$originUrl])) {
  25646. $this->io->setAuthentication($originUrl, $authTokens[$originUrl], 'private-token');
  25647. return true;
  25648. }
  25649. return false;
  25650. }
  25651. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  25652. {
  25653. if ($message) {
  25654. $this->io->writeError($message);
  25655. }
  25656. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  25657. $this->io->writeError('To revoke access to this token you can visit '.$originUrl.'/profile/applications');
  25658. $attemptCounter = 0;
  25659. while ($attemptCounter++ < 5) {
  25660. try {
  25661. $response = $this->createToken($scheme, $originUrl);
  25662. } catch (TransportException $e) {
  25663. if (in_array($e->getCode(), array(403, 401))) {
  25664. if (401 === $e->getCode()) {
  25665. $this->io->writeError('Bad credentials.');
  25666. } else {
  25667. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  25668. }
  25669. $this->io->writeError('You can also manually create a personal token at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  25670. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  25671. continue;
  25672. }
  25673. throw $e;
  25674. }
  25675. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  25676. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  25677. return true;
  25678. }
  25679. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  25680. }
  25681. private function createToken($scheme, $originUrl)
  25682. {
  25683. $username = $this->io->ask('Username: ');
  25684. $password = $this->io->askAndHideAnswer('Password: ');
  25685. $headers = array('Content-Type: application/x-www-form-urlencoded');
  25686. $apiUrl = $originUrl;
  25687. $data = http_build_query(array(
  25688. 'username' => $username,
  25689. 'password' => $password,
  25690. 'grant_type' => 'password',
  25691. ), null, '&');
  25692. $options = array(
  25693. 'retry-auth-failure' => false,
  25694. 'http' => array(
  25695. 'method' => 'POST',
  25696. 'header' => $headers,
  25697. 'content' => $data,
  25698. ),
  25699. );
  25700. $json = $this->remoteFilesystem->getContents($originUrl, $scheme.'://'.$apiUrl.'/oauth/token', false, $options);
  25701. $this->io->writeError('Token successfully created');
  25702. return JsonFile::parseJson($json);
  25703. }
  25704. }
  25705. <?php
  25706. namespace Composer\Util;
  25707. use Composer\Config;
  25708. use Composer\IO\IOInterface;
  25709. class Hg
  25710. {
  25711. private $io;
  25712. private $config;
  25713. private $process;
  25714. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  25715. {
  25716. $this->io = $io;
  25717. $this->config = $config;
  25718. $this->process = $process;
  25719. }
  25720. public function runCommand($commandCallable, $url, $cwd)
  25721. {
  25722. $this->config->prohibitUrlByConfig($url, $this->io);
  25723. $command = call_user_func($commandCallable, $url);
  25724. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  25725. return;
  25726. }
  25727. if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  25728. $auth = $this->io->getAuthentication($match[5]);
  25729. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  25730. $command = call_user_func($commandCallable, $authenticatedUrl);
  25731. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  25732. return;
  25733. }
  25734. $error = $this->process->getErrorOutput();
  25735. } else {
  25736. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  25737. }
  25738. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  25739. }
  25740. public static function sanitizeUrl($message)
  25741. {
  25742. return preg_replace_callback('{://(?P<user>[^@]+?):(?P<password>.+?)@}', function ($m) {
  25743. if (preg_match('{^[a-f0-9]{12,}$}', $m[1])) {
  25744. return '://***:***@';
  25745. }
  25746. return '://' . $m[1] . ':***@';
  25747. }, $message);
  25748. }
  25749. private function throwException($message, $url)
  25750. {
  25751. if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
  25752. throw new \RuntimeException(self::sanitizeUrl('Failed to clone ' . $url . ', hg was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput()));
  25753. }
  25754. throw new \RuntimeException(self::sanitizeUrl($message));
  25755. }
  25756. }
  25757. <?php
  25758. namespace Composer\Util;
  25759. use Composer\XdebugHandler\XdebugHandler;
  25760. class IniHelper
  25761. {
  25762. public static function getAll()
  25763. {
  25764. return XdebugHandler::getAllIniFiles();
  25765. }
  25766. public static function getMessage()
  25767. {
  25768. $paths = self::getAll();
  25769. if (empty($paths[0])) {
  25770. array_shift($paths);
  25771. }
  25772. $ini = array_shift($paths);
  25773. if (empty($ini)) {
  25774. return 'A php.ini file does not exist. You will have to create one.';
  25775. }
  25776. if (!empty($paths)) {
  25777. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  25778. }
  25779. return 'The php.ini used by your command-line PHP is: '.$ini;
  25780. }
  25781. }
  25782. <?php
  25783. namespace Composer\Util;
  25784. class NoProxyPattern
  25785. {
  25786. protected $rules = array();
  25787. public function __construct($pattern)
  25788. {
  25789. $this->rules = preg_split("/[\s,]+/", $pattern);
  25790. }
  25791. public function test($url)
  25792. {
  25793. $host = parse_url($url, PHP_URL_HOST);
  25794. $port = parse_url($url, PHP_URL_PORT);
  25795. if (empty($port)) {
  25796. switch (parse_url($url, PHP_URL_SCHEME)) {
  25797. case 'http':
  25798. $port = 80;
  25799. break;
  25800. case 'https':
  25801. $port = 443;
  25802. break;
  25803. }
  25804. }
  25805. foreach ($this->rules as $rule) {
  25806. if ($rule == '*') {
  25807. return true;
  25808. }
  25809. $match = false;
  25810. list($ruleHost) = explode(':', $rule);
  25811. list($base) = explode('/', $ruleHost);
  25812. if (filter_var($base, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
  25813. if (!isset($ip)) {
  25814. $ip = gethostbyname($host);
  25815. }
  25816. if (strpos($ruleHost, '/') === false) {
  25817. $match = $ip === $ruleHost;
  25818. } else {
  25819. if ($ip === $host) {
  25820. $match = false;
  25821. } else {
  25822. $match = self::inCIDRBlock($ruleHost, $ip);
  25823. }
  25824. }
  25825. } else {
  25826. $haystack = '.' . trim($host, '.') . '.';
  25827. $needle = '.'. trim($ruleHost, '.') .'.';
  25828. $match = stripos(strrev($haystack), strrev($needle)) === 0;
  25829. }
  25830. if ($match && strpos($rule, ':') !== false) {
  25831. list(, $rulePort) = explode(':', $rule);
  25832. if (!empty($rulePort) && $port != $rulePort) {
  25833. $match = false;
  25834. }
  25835. }
  25836. if ($match) {
  25837. return true;
  25838. }
  25839. }
  25840. return false;
  25841. }
  25842. private static function inCIDRBlock($cidr, $ip)
  25843. {
  25844. list($base, $bits) = explode('/', $cidr);
  25845. list($a, $b, $c, $d) = explode('.', $base);
  25846. $i = ($a << 24) + ($b << 16) + ($c << 8) + $d;
  25847. $mask = $bits == 0 ? 0 : (~0 << (32 - $bits));
  25848. $low = $i & $mask;
  25849. $high = $i | (~$mask & 0xFFFFFFFF);
  25850. list($a, $b, $c, $d) = explode('.', $ip);
  25851. $check = ($a << 24) + ($b << 16) + ($c << 8) + $d;
  25852. return $check >= $low && $check <= $high;
  25853. }
  25854. }
  25855. <?php
  25856. namespace Composer\Util;
  25857. use Composer\IO\IOInterface;
  25858. use Symfony\Component\Process\Process;
  25859. class Perforce
  25860. {
  25861. protected $path;
  25862. protected $p4Depot;
  25863. protected $p4Client;
  25864. protected $p4User;
  25865. protected $p4Password;
  25866. protected $p4Port;
  25867. protected $p4Stream;
  25868. protected $p4ClientSpec;
  25869. protected $p4DepotType;
  25870. protected $p4Branch;
  25871. protected $process;
  25872. protected $uniquePerforceClientName;
  25873. protected $windowsFlag;
  25874. protected $commandResult;
  25875. protected $io;
  25876. protected $filesystem;
  25877. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  25878. {
  25879. $this->windowsFlag = $isWindows;
  25880. $this->p4Port = $port;
  25881. $this->initializePath($path);
  25882. $this->process = $process;
  25883. $this->initialize($repoConfig);
  25884. $this->io = $io;
  25885. }
  25886. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  25887. {
  25888. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  25889. }
  25890. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  25891. {
  25892. $output = null;
  25893. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  25894. }
  25895. public function initialize($repoConfig)
  25896. {
  25897. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  25898. if (!$repoConfig) {
  25899. return;
  25900. }
  25901. if (isset($repoConfig['unique_perforce_client_name'])) {
  25902. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  25903. }
  25904. if (isset($repoConfig['depot'])) {
  25905. $this->p4Depot = $repoConfig['depot'];
  25906. }
  25907. if (isset($repoConfig['branch'])) {
  25908. $this->p4Branch = $repoConfig['branch'];
  25909. }
  25910. if (isset($repoConfig['p4user'])) {
  25911. $this->p4User = $repoConfig['p4user'];
  25912. } else {
  25913. $this->p4User = $this->getP4variable('P4USER');
  25914. }
  25915. if (isset($repoConfig['p4password'])) {
  25916. $this->p4Password = $repoConfig['p4password'];
  25917. }
  25918. }
  25919. public function initializeDepotAndBranch($depot, $branch)
  25920. {
  25921. if (isset($depot)) {
  25922. $this->p4Depot = $depot;
  25923. }
  25924. if (isset($branch)) {
  25925. $this->p4Branch = $branch;
  25926. }
  25927. }
  25928. public function generateUniquePerforceClientName()
  25929. {
  25930. return gethostname() . "_" . time();
  25931. }
  25932. public function cleanupClientSpec()
  25933. {
  25934. $client = $this->getClient();
  25935. $task = 'client -d ' . ProcessExecutor::escape($client);
  25936. $useP4Client = false;
  25937. $command = $this->generateP4Command($task, $useP4Client);
  25938. $this->executeCommand($command);
  25939. $clientSpec = $this->getP4ClientSpec();
  25940. $fileSystem = $this->getFilesystem();
  25941. $fileSystem->remove($clientSpec);
  25942. }
  25943. protected function executeCommand($command)
  25944. {
  25945. $this->commandResult = '';
  25946. return $this->process->execute($command, $this->commandResult);
  25947. }
  25948. public function getClient()
  25949. {
  25950. if (!isset($this->p4Client)) {
  25951. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  25952. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  25953. }
  25954. return $this->p4Client;
  25955. }
  25956. protected function getPath()
  25957. {
  25958. return $this->path;
  25959. }
  25960. public function initializePath($path)
  25961. {
  25962. $this->path = $path;
  25963. $fs = $this->getFilesystem();
  25964. $fs->ensureDirectoryExists($path);
  25965. }
  25966. protected function getPort()
  25967. {
  25968. return $this->p4Port;
  25969. }
  25970. public function setStream($stream)
  25971. {
  25972. $this->p4Stream = $stream;
  25973. $index = strrpos($stream, '/');
  25974. if ($index > 2) {
  25975. $this->p4DepotType = 'stream';
  25976. }
  25977. }
  25978. public function isStream()
  25979. {
  25980. return (strcmp($this->p4DepotType, 'stream') === 0);
  25981. }
  25982. public function getStream()
  25983. {
  25984. if (!isset($this->p4Stream)) {
  25985. if ($this->isStream()) {
  25986. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  25987. } else {
  25988. $this->p4Stream = '//' . $this->p4Depot;
  25989. }
  25990. }
  25991. return $this->p4Stream;
  25992. }
  25993. public function getStreamWithoutLabel($stream)
  25994. {
  25995. $index = strpos($stream, '@');
  25996. if ($index === false) {
  25997. return $stream;
  25998. }
  25999. return substr($stream, 0, $index);
  26000. }
  26001. public function getP4ClientSpec()
  26002. {
  26003. return $this->path . '/' . $this->getClient() . '.p4.spec';
  26004. }
  26005. public function getUser()
  26006. {
  26007. return $this->p4User;
  26008. }
  26009. public function setUser($user)
  26010. {
  26011. $this->p4User = $user;
  26012. }
  26013. public function queryP4User()
  26014. {
  26015. $this->getUser();
  26016. if (strlen($this->p4User) > 0) {
  26017. return;
  26018. }
  26019. $this->p4User = $this->getP4variable('P4USER');
  26020. if (strlen($this->p4User) > 0) {
  26021. return;
  26022. }
  26023. $this->p4User = $this->io->ask('Enter P4 User:');
  26024. if ($this->windowsFlag) {
  26025. $command = 'p4 set P4USER=' . $this->p4User;
  26026. } else {
  26027. $command = 'export P4USER=' . $this->p4User;
  26028. }
  26029. $this->executeCommand($command);
  26030. }
  26031. protected function getP4variable($name)
  26032. {
  26033. if ($this->windowsFlag) {
  26034. $command = 'p4 set';
  26035. $this->executeCommand($command);
  26036. $result = trim($this->commandResult);
  26037. $resArray = explode(PHP_EOL, $result);
  26038. foreach ($resArray as $line) {
  26039. $fields = explode('=', $line);
  26040. if (strcmp($name, $fields[0]) == 0) {
  26041. $index = strpos($fields[1], ' ');
  26042. if ($index === false) {
  26043. $value = $fields[1];
  26044. } else {
  26045. $value = substr($fields[1], 0, $index);
  26046. }
  26047. $value = trim($value);
  26048. return $value;
  26049. }
  26050. }
  26051. return null;
  26052. }
  26053. $command = 'echo $' . $name;
  26054. $this->executeCommand($command);
  26055. $result = trim($this->commandResult);
  26056. return $result;
  26057. }
  26058. public function queryP4Password()
  26059. {
  26060. if (isset($this->p4Password)) {
  26061. return $this->p4Password;
  26062. }
  26063. $password = $this->getP4variable('P4PASSWD');
  26064. if (strlen($password) <= 0) {
  26065. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  26066. }
  26067. $this->p4Password = $password;
  26068. return $password;
  26069. }
  26070. public function generateP4Command($command, $useClient = true)
  26071. {
  26072. $p4Command = 'p4 ';
  26073. $p4Command .= '-u ' . $this->getUser() . ' ';
  26074. if ($useClient) {
  26075. $p4Command .= '-c ' . $this->getClient() . ' ';
  26076. }
  26077. $p4Command = $p4Command . '-p ' . $this->getPort() . ' ' . $command;
  26078. return $p4Command;
  26079. }
  26080. public function isLoggedIn()
  26081. {
  26082. $command = $this->generateP4Command('login -s', false);
  26083. $exitCode = $this->executeCommand($command);
  26084. if ($exitCode) {
  26085. $errorOutput = $this->process->getErrorOutput();
  26086. $index = strpos($errorOutput, $this->getUser());
  26087. if ($index === false) {
  26088. $index = strpos($errorOutput, 'p4');
  26089. if ($index === false) {
  26090. return false;
  26091. }
  26092. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  26093. }
  26094. throw new \Exception('Invalid user name: ' . $this->getUser());
  26095. }
  26096. return true;
  26097. }
  26098. public function connectClient()
  26099. {
  26100. $p4CreateClientCommand = $this->generateP4Command(
  26101. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  26102. );
  26103. $this->executeCommand($p4CreateClientCommand);
  26104. }
  26105. public function syncCodeBase($sourceReference)
  26106. {
  26107. $prevDir = getcwd();
  26108. chdir($this->path);
  26109. $p4SyncCommand = $this->generateP4Command('sync -f ');
  26110. if (null !== $sourceReference) {
  26111. $p4SyncCommand .= '@' . $sourceReference;
  26112. }
  26113. $this->executeCommand($p4SyncCommand);
  26114. chdir($prevDir);
  26115. }
  26116. public function writeClientSpecToFile($spec)
  26117. {
  26118. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  26119. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  26120. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  26121. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  26122. fwrite($spec, 'Description:' . PHP_EOL);
  26123. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  26124. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  26125. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  26126. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  26127. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  26128. if ($this->isStream()) {
  26129. fwrite($spec, 'Stream:' . PHP_EOL);
  26130. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  26131. } else {
  26132. fwrite(
  26133. $spec,
  26134. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  26135. );
  26136. }
  26137. }
  26138. public function writeP4ClientSpec()
  26139. {
  26140. $clientSpec = $this->getP4ClientSpec();
  26141. $spec = fopen($clientSpec, 'w');
  26142. try {
  26143. $this->writeClientSpecToFile($spec);
  26144. } catch (\Exception $e) {
  26145. fclose($spec);
  26146. throw $e;
  26147. }
  26148. fclose($spec);
  26149. }
  26150. protected function read($pipe, $name)
  26151. {
  26152. if (feof($pipe)) {
  26153. return;
  26154. }
  26155. $line = fgets($pipe);
  26156. while ($line !== false) {
  26157. $line = fgets($pipe);
  26158. }
  26159. return;
  26160. }
  26161. public function windowsLogin($password)
  26162. {
  26163. $command = $this->generateP4Command(' login -a');
  26164. $process = new Process($command, null, null, $password);
  26165. return $process->run();
  26166. }
  26167. public function p4Login()
  26168. {
  26169. $this->queryP4User();
  26170. if (!$this->isLoggedIn()) {
  26171. $password = $this->queryP4Password();
  26172. if ($this->windowsFlag) {
  26173. $this->windowsLogin($password);
  26174. } else {
  26175. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  26176. $exitCode = $this->executeCommand($command);
  26177. $result = trim($this->commandResult);
  26178. if ($exitCode) {
  26179. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  26180. }
  26181. }
  26182. }
  26183. }
  26184. public function getComposerInformation($identifier)
  26185. {
  26186. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  26187. if (!$composerFileContent) {
  26188. return;
  26189. }
  26190. return json_decode($composerFileContent, true);
  26191. }
  26192. public function getFileContent($file, $identifier)
  26193. {
  26194. $path = $this->getFilePath($file, $identifier);
  26195. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  26196. $this->executeCommand($command);
  26197. $result = $this->commandResult;
  26198. if (!trim($result)) {
  26199. return null;
  26200. }
  26201. return $result;
  26202. }
  26203. public function getFilePath($file, $identifier)
  26204. {
  26205. $index = strpos($identifier, '@');
  26206. if ($index === false) {
  26207. $path = $identifier. '/' . $file;
  26208. return $path;
  26209. }
  26210. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  26211. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  26212. $this->executeCommand($command);
  26213. $result = $this->commandResult;
  26214. $index2 = strpos($result, 'no such file(s).');
  26215. if ($index2 === false) {
  26216. $index3 = strpos($result, 'change');
  26217. if ($index3 !== false) {
  26218. $phrase = trim(substr($result, $index3));
  26219. $fields = explode(' ', $phrase);
  26220. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  26221. }
  26222. }
  26223. return null;
  26224. }
  26225. public function getBranches()
  26226. {
  26227. $possibleBranches = array();
  26228. if (!$this->isStream()) {
  26229. $possibleBranches[$this->p4Branch] = $this->getStream();
  26230. } else {
  26231. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  26232. $this->executeCommand($command);
  26233. $result = $this->commandResult;
  26234. $resArray = explode(PHP_EOL, $result);
  26235. foreach ($resArray as $line) {
  26236. $resBits = explode(' ', $line);
  26237. if (count($resBits) > 4) {
  26238. $branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  26239. $possibleBranches[$branch] = $resBits[1];
  26240. }
  26241. }
  26242. }
  26243. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  26244. $this->executeCommand($command);
  26245. $result = $this->commandResult;
  26246. $resArray = explode(PHP_EOL, $result);
  26247. $lastCommit = $resArray[0];
  26248. $lastCommitArr = explode(' ', $lastCommit);
  26249. $lastCommitNum = $lastCommitArr[1];
  26250. $branches = array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  26251. return $branches;
  26252. }
  26253. public function getTags()
  26254. {
  26255. $command = $this->generateP4Command('labels');
  26256. $this->executeCommand($command);
  26257. $result = $this->commandResult;
  26258. $resArray = explode(PHP_EOL, $result);
  26259. $tags = array();
  26260. foreach ($resArray as $line) {
  26261. if (strpos($line, 'Label') !== false) {
  26262. $fields = explode(' ', $line);
  26263. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  26264. }
  26265. }
  26266. return $tags;
  26267. }
  26268. public function checkStream()
  26269. {
  26270. $command = $this->generateP4Command('depots', false);
  26271. $this->executeCommand($command);
  26272. $result = $this->commandResult;
  26273. $resArray = explode(PHP_EOL, $result);
  26274. foreach ($resArray as $line) {
  26275. if (strpos($line, 'Depot') !== false) {
  26276. $fields = explode(' ', $line);
  26277. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  26278. $this->p4DepotType = $fields[3];
  26279. return $this->isStream();
  26280. }
  26281. }
  26282. }
  26283. return false;
  26284. }
  26285. protected function getChangeList($reference)
  26286. {
  26287. $index = strpos($reference, '@');
  26288. if ($index === false) {
  26289. return null;
  26290. }
  26291. $label = substr($reference, $index);
  26292. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  26293. $this->executeCommand($command);
  26294. $changes = $this->commandResult;
  26295. if (strpos($changes, 'Change') !== 0) {
  26296. return null;
  26297. }
  26298. $fields = explode(' ', $changes);
  26299. return $fields[1];
  26300. }
  26301. public function getCommitLogs($fromReference, $toReference)
  26302. {
  26303. $fromChangeList = $this->getChangeList($fromReference);
  26304. if ($fromChangeList === null) {
  26305. return null;
  26306. }
  26307. $toChangeList = $this->getChangeList($toReference);
  26308. if ($toChangeList === null) {
  26309. return null;
  26310. }
  26311. $index = strpos($fromReference, '@');
  26312. $main = substr($fromReference, 0, $index) . '/...';
  26313. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  26314. $this->executeCommand($command);
  26315. return $this->commandResult;
  26316. }
  26317. public function getFilesystem()
  26318. {
  26319. if (empty($this->filesystem)) {
  26320. $this->filesystem = new Filesystem($this->process);
  26321. }
  26322. return $this->filesystem;
  26323. }
  26324. public function setFilesystem(Filesystem $fs)
  26325. {
  26326. $this->filesystem = $fs;
  26327. }
  26328. }
  26329. <?php
  26330. namespace Composer\Util;
  26331. class Platform
  26332. {
  26333. public static function expandPath($path)
  26334. {
  26335. if (preg_match('#^~[\\/]#', $path)) {
  26336. return self::getUserDirectory() . substr($path, 1);
  26337. }
  26338. return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  26339. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  26340. return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
  26341. }
  26342. return getenv($matches['var']) . $matches['path'];
  26343. }, $path);
  26344. }
  26345. public static function getUserDirectory()
  26346. {
  26347. if (false !== ($home = getenv('HOME'))) {
  26348. return $home;
  26349. }
  26350. if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
  26351. return $home;
  26352. }
  26353. if (function_exists('posix_getuid') && function_exists('posix_getpwuid')) {
  26354. $info = posix_getpwuid(posix_getuid());
  26355. return $info['dir'];
  26356. }
  26357. throw new \RuntimeException('Could not determine user directory');
  26358. }
  26359. public static function isWindows()
  26360. {
  26361. return defined('PHP_WINDOWS_VERSION_BUILD');
  26362. }
  26363. public static function strlen($str)
  26364. {
  26365. static $useMbString = null;
  26366. if (null === $useMbString) {
  26367. $useMbString = function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  26368. }
  26369. if ($useMbString) {
  26370. return mb_strlen($str, '8bit');
  26371. }
  26372. return strlen($str);
  26373. }
  26374. }
  26375. <?php
  26376. namespace Composer\Util;
  26377. use Composer\IO\IOInterface;
  26378. use Symfony\Component\Process\Process;
  26379. use Symfony\Component\Process\ProcessUtils;
  26380. class ProcessExecutor
  26381. {
  26382. protected static $timeout = 300;
  26383. protected $captureOutput;
  26384. protected $errorOutput;
  26385. protected $io;
  26386. public function __construct(IOInterface $io = null)
  26387. {
  26388. $this->io = $io;
  26389. }
  26390. public function execute($command, &$output = null, $cwd = null)
  26391. {
  26392. if ($this->io && $this->io->isDebug()) {
  26393. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  26394. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  26395. return '://***:***@';
  26396. }
  26397. return '://'.$m['user'].':***@';
  26398. }, $command);
  26399. $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  26400. }
  26401. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  26402. $cwd = realpath(getcwd());
  26403. }
  26404. $this->captureOutput = func_num_args() > 1;
  26405. $this->errorOutput = null;
  26406. $process = new Process($command, $cwd, null, null, static::getTimeout());
  26407. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  26408. $process->run($callback);
  26409. if ($this->captureOutput && !is_callable($output)) {
  26410. $output = $process->getOutput();
  26411. }
  26412. $this->errorOutput = $process->getErrorOutput();
  26413. return $process->getExitCode();
  26414. }
  26415. public function splitLines($output)
  26416. {
  26417. $output = trim($output);
  26418. return ((string) $output === '') ? array() : preg_split('{\r?\n}', $output);
  26419. }
  26420. public function getErrorOutput()
  26421. {
  26422. return $this->errorOutput;
  26423. }
  26424. public function outputHandler($type, $buffer)
  26425. {
  26426. if ($this->captureOutput) {
  26427. return;
  26428. }
  26429. if (null === $this->io) {
  26430. echo $buffer;
  26431. return;
  26432. }
  26433. if (Process::ERR === $type) {
  26434. $this->io->writeError($buffer, false);
  26435. } else {
  26436. $this->io->write($buffer, false);
  26437. }
  26438. }
  26439. public static function getTimeout()
  26440. {
  26441. return static::$timeout;
  26442. }
  26443. public static function setTimeout($timeout)
  26444. {
  26445. static::$timeout = $timeout;
  26446. }
  26447. public static function escape($argument)
  26448. {
  26449. return self::escapeArgument($argument);
  26450. }
  26451. private static function escapeArgument($argument)
  26452. {
  26453. if ('\\' === DIRECTORY_SEPARATOR) {
  26454. if ('' === $argument) {
  26455. return escapeshellarg($argument);
  26456. }
  26457. $escapedArgument = '';
  26458. $quote = false;
  26459. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  26460. if ('"' === $part) {
  26461. $escapedArgument .= '\\"';
  26462. } elseif (self::isSurroundedBy($part, '%')) {
  26463. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  26464. } else {
  26465. if ('\\' === substr($part, -1)) {
  26466. $part .= '\\';
  26467. }
  26468. $quote = true;
  26469. $escapedArgument .= $part;
  26470. }
  26471. }
  26472. if ($quote) {
  26473. $escapedArgument = '"'.$escapedArgument.'"';
  26474. }
  26475. return $escapedArgument;
  26476. }
  26477. return "'".str_replace("'", "'\\''", $argument)."'";
  26478. }
  26479. private static function isSurroundedBy($arg, $char)
  26480. {
  26481. return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
  26482. }
  26483. }
  26484. <?php
  26485. namespace Composer\Util;
  26486. use Composer\Config;
  26487. use Composer\IO\IOInterface;
  26488. use Composer\Downloader\TransportException;
  26489. use Composer\CaBundle\CaBundle;
  26490. use Psr\Log\LoggerInterface;
  26491. class RemoteFilesystem
  26492. {
  26493. private $io;
  26494. private $config;
  26495. private $scheme;
  26496. private $bytesMax;
  26497. private $originUrl;
  26498. private $fileUrl;
  26499. private $fileName;
  26500. private $retry;
  26501. private $progress;
  26502. private $lastProgress;
  26503. private $options = array();
  26504. private $peerCertificateMap = array();
  26505. private $disableTls = false;
  26506. private $retryAuthFailure;
  26507. private $lastHeaders;
  26508. private $storeAuth;
  26509. private $degradedMode = false;
  26510. private $redirects;
  26511. private $maxRedirects = 20;
  26512. public function __construct(IOInterface $io, Config $config = null, array $options = array(), $disableTls = false)
  26513. {
  26514. $this->io = $io;
  26515. if ($disableTls === false) {
  26516. $this->options = $this->getTlsDefaults($options);
  26517. } else {
  26518. $this->disableTls = true;
  26519. }
  26520. $this->options = array_replace_recursive($this->options, $options);
  26521. $this->config = $config;
  26522. }
  26523. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  26524. {
  26525. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  26526. }
  26527. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  26528. {
  26529. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  26530. }
  26531. public function getOptions()
  26532. {
  26533. return $this->options;
  26534. }
  26535. public function setOptions(array $options)
  26536. {
  26537. $this->options = array_replace_recursive($this->options, $options);
  26538. }
  26539. public function isTlsDisabled()
  26540. {
  26541. return $this->disableTls === true;
  26542. }
  26543. public function getLastHeaders()
  26544. {
  26545. return $this->lastHeaders;
  26546. }
  26547. public function findHeaderValue(array $headers, $name)
  26548. {
  26549. $value = null;
  26550. foreach ($headers as $header) {
  26551. if (preg_match('{^'.$name.':\s*(.+?)\s*$}i', $header, $match)) {
  26552. $value = $match[1];
  26553. } elseif (preg_match('{^HTTP/}i', $header)) {
  26554. $value = null;
  26555. }
  26556. }
  26557. return $value;
  26558. }
  26559. public function findStatusCode(array $headers)
  26560. {
  26561. $value = null;
  26562. foreach ($headers as $header) {
  26563. if (preg_match('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  26564. $value = (int) $match[1];
  26565. }
  26566. }
  26567. return $value;
  26568. }
  26569. public function findStatusMessage(array $headers)
  26570. {
  26571. $value = null;
  26572. foreach ($headers as $header) {
  26573. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  26574. $value = $header;
  26575. }
  26576. }
  26577. return $value;
  26578. }
  26579. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  26580. {
  26581. if (strpos($originUrl, '.github.com') === (strlen($originUrl) - 11)) {
  26582. $originUrl = 'github.com';
  26583. }
  26584. if (
  26585. $this->config
  26586. && is_array($this->config->get('gitlab-domains'))
  26587. && false === strpos($originUrl, '/')
  26588. && !in_array($originUrl, $this->config->get('gitlab-domains'))
  26589. ) {
  26590. foreach ($this->config->get('gitlab-domains') as $gitlabDomain) {
  26591. if (0 === strpos($gitlabDomain, $originUrl)) {
  26592. $originUrl = $gitlabDomain;
  26593. break;
  26594. }
  26595. }
  26596. unset($gitlabDomain);
  26597. }
  26598. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  26599. $this->bytesMax = 0;
  26600. $this->originUrl = $originUrl;
  26601. $this->fileUrl = $fileUrl;
  26602. $this->fileName = $fileName;
  26603. $this->progress = $progress;
  26604. $this->lastProgress = null;
  26605. $this->retryAuthFailure = true;
  26606. $this->lastHeaders = array();
  26607. $this->redirects = 1;
  26608. if (preg_match('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $fileUrl, $match)) {
  26609. $this->io->setAuthentication($originUrl, rawurldecode($match[1]), rawurldecode($match[2]));
  26610. }
  26611. $tempAdditionalOptions = $additionalOptions;
  26612. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  26613. $this->retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  26614. unset($tempAdditionalOptions['retry-auth-failure']);
  26615. }
  26616. $isRedirect = false;
  26617. if (isset($tempAdditionalOptions['redirects'])) {
  26618. $this->redirects = $tempAdditionalOptions['redirects'];
  26619. $isRedirect = true;
  26620. unset($tempAdditionalOptions['redirects']);
  26621. }
  26622. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  26623. unset($tempAdditionalOptions);
  26624. $origFileUrl = $fileUrl;
  26625. if (isset($options['github-token'])) {
  26626. if (preg_match('{^https?://([a-z0-9-]+\.)*github\.com/}', $fileUrl)) {
  26627. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['github-token'];
  26628. }
  26629. unset($options['github-token']);
  26630. }
  26631. if (isset($options['gitlab-token'])) {
  26632. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  26633. unset($options['gitlab-token']);
  26634. }
  26635. if (isset($options['http'])) {
  26636. $options['http']['ignore_errors'] = true;
  26637. }
  26638. if ($this->degradedMode && substr($fileUrl, 0, 26) === 'http://repo.packagist.org/') {
  26639. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  26640. $degradedPackagist = true;
  26641. }
  26642. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  26643. $actualContextOptions = stream_context_get_options($ctx);
  26644. $usingProxy = !empty($actualContextOptions['http']['proxy']) ? ' using proxy ' . $actualContextOptions['http']['proxy'] : '';
  26645. $this->io->writeError((substr($origFileUrl, 0, 4) === 'http' ? 'Downloading ' : 'Reading ') . $origFileUrl . $usingProxy, true, IOInterface::DEBUG);
  26646. unset($origFileUrl, $actualContextOptions);
  26647. if ((!preg_match('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
  26648. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  26649. }
  26650. if ($this->progress && !$isRedirect) {
  26651. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  26652. }
  26653. $errorMessage = '';
  26654. $errorCode = 0;
  26655. $result = false;
  26656. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  26657. if ($errorMessage) {
  26658. $errorMessage .= "\n";
  26659. }
  26660. $errorMessage .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg);
  26661. });
  26662. try {
  26663. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header);
  26664. if (!empty($http_response_header[0])) {
  26665. $statusCode = $this->findStatusCode($http_response_header);
  26666. if (in_array($statusCode, array(401, 403)) && $this->retryAuthFailure) {
  26667. $warning = null;
  26668. if ($this->findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  26669. $data = json_decode($result, true);
  26670. if (!empty($data['warning'])) {
  26671. $warning = $data['warning'];
  26672. }
  26673. }
  26674. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $warning, $http_response_header);
  26675. }
  26676. }
  26677. $contentLength = !empty($http_response_header[0]) ? $this->findHeaderValue($http_response_header, 'content-length') : null;
  26678. if ($contentLength && Platform::strlen($result) < $contentLength) {
  26679. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  26680. $e->setHeaders($http_response_header);
  26681. $e->setStatusCode($this->findStatusCode($http_response_header));
  26682. $e->setResponse($result);
  26683. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  26684. throw $e;
  26685. }
  26686. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  26687. $params = stream_context_get_params($ctx);
  26688. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  26689. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  26690. if ($expectedPeerFingerprint !== $peerFingerprint) {
  26691. throw new TransportException('Peer fingerprint did not match');
  26692. }
  26693. }
  26694. } catch (\Exception $e) {
  26695. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  26696. $e->setHeaders($http_response_header);
  26697. $e->setStatusCode($this->findStatusCode($http_response_header));
  26698. }
  26699. if ($e instanceof TransportException && $result !== false) {
  26700. $e->setResponse($result);
  26701. }
  26702. $result = false;
  26703. }
  26704. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  26705. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  26706. }
  26707. restore_error_handler();
  26708. if (isset($e) && !$this->retry) {
  26709. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  26710. $this->degradedMode = true;
  26711. $this->io->writeError('');
  26712. $this->io->writeError(array(
  26713. '<error>'.$e->getMessage().'</error>',
  26714. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  26715. ));
  26716. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  26717. }
  26718. throw $e;
  26719. }
  26720. $statusCode = null;
  26721. $contentType = null;
  26722. $locationHeader = null;
  26723. if (!empty($http_response_header[0])) {
  26724. $statusCode = $this->findStatusCode($http_response_header);
  26725. $contentType = $this->findHeaderValue($http_response_header, 'content-type');
  26726. $locationHeader = $this->findHeaderValue($http_response_header, 'location');
  26727. }
  26728. if ($originUrl === 'bitbucket.org'
  26729. && !$this->isPublicBitBucketDownload($fileUrl)
  26730. && substr($fileUrl, -4) === '.zip'
  26731. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  26732. && $contentType && preg_match('{^text/html\b}i', $contentType)
  26733. ) {
  26734. $result = false;
  26735. if ($this->retryAuthFailure) {
  26736. $this->promptAuthAndRetry(401);
  26737. }
  26738. }
  26739. if ($statusCode === 404
  26740. && $this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  26741. && false !== strpos($fileUrl, 'archive.zip')
  26742. ) {
  26743. $result = false;
  26744. if ($this->retryAuthFailure) {
  26745. $this->promptAuthAndRetry(401);
  26746. }
  26747. }
  26748. $hasFollowedRedirect = false;
  26749. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  26750. $hasFollowedRedirect = true;
  26751. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  26752. }
  26753. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  26754. if (!$this->retry) {
  26755. if ($this->progress && !$this->retry && !$isRedirect) {
  26756. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  26757. }
  26758. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  26759. $e->setHeaders($http_response_header);
  26760. $e->setResponse($result);
  26761. $e->setStatusCode($statusCode);
  26762. throw $e;
  26763. }
  26764. $result = false;
  26765. }
  26766. if ($this->progress && !$this->retry && !$isRedirect) {
  26767. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  26768. }
  26769. if ($result && extension_loaded('zlib') && substr($fileUrl, 0, 4) === 'http' && !$hasFollowedRedirect) {
  26770. $contentEncoding = $this->findHeaderValue($http_response_header, 'content-encoding');
  26771. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  26772. if ($decode) {
  26773. try {
  26774. if (PHP_VERSION_ID >= 50400) {
  26775. $result = zlib_decode($result);
  26776. } else {
  26777. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  26778. }
  26779. if (!$result) {
  26780. throw new TransportException('Failed to decode zlib stream');
  26781. }
  26782. } catch (\Exception $e) {
  26783. if ($this->degradedMode) {
  26784. throw $e;
  26785. }
  26786. $this->degradedMode = true;
  26787. $this->io->writeError(array(
  26788. '',
  26789. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  26790. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  26791. ));
  26792. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  26793. }
  26794. }
  26795. }
  26796. if (false !== $result && null !== $fileName && !$isRedirect) {
  26797. if ('' === $result) {
  26798. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  26799. }
  26800. $errorMessage = '';
  26801. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  26802. if ($errorMessage) {
  26803. $errorMessage .= "\n";
  26804. }
  26805. $errorMessage .= preg_replace('{^file_put_contents\(.*?\): }', '', $msg);
  26806. });
  26807. $result = (bool) file_put_contents($fileName, $result);
  26808. restore_error_handler();
  26809. if (false === $result) {
  26810. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  26811. }
  26812. }
  26813. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  26814. if (CaBundle::isOpensslParseSafe()) {
  26815. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  26816. if ($certDetails) {
  26817. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  26818. $this->retry = true;
  26819. }
  26820. } else {
  26821. $this->io->writeError('');
  26822. $this->io->writeError(sprintf(
  26823. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  26824. PHP_VERSION
  26825. ));
  26826. }
  26827. }
  26828. if ($this->retry) {
  26829. $this->retry = false;
  26830. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  26831. if ($this->storeAuth && $this->config) {
  26832. $authHelper = new AuthHelper($this->io, $this->config);
  26833. $authHelper->storeAuth($this->originUrl, $this->storeAuth);
  26834. $this->storeAuth = false;
  26835. }
  26836. return $result;
  26837. }
  26838. if (false === $result) {
  26839. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  26840. if (!empty($http_response_header[0])) {
  26841. $e->setHeaders($http_response_header);
  26842. }
  26843. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  26844. $this->degradedMode = true;
  26845. $this->io->writeError('');
  26846. $this->io->writeError(array(
  26847. '<error>'.$e->getMessage().'</error>',
  26848. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  26849. ));
  26850. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  26851. }
  26852. throw $e;
  26853. }
  26854. if (!empty($http_response_header[0])) {
  26855. $this->lastHeaders = $http_response_header;
  26856. }
  26857. return $result;
  26858. }
  26859. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null)
  26860. {
  26861. try {
  26862. $e = null;
  26863. $result = file_get_contents($fileUrl, false, $context);
  26864. } catch (\Throwable $e) {
  26865. } catch (\Exception $e) {
  26866. }
  26867. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  26868. if (null !== $e) {
  26869. throw $e;
  26870. }
  26871. return $result;
  26872. }
  26873. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  26874. {
  26875. switch ($notificationCode) {
  26876. case STREAM_NOTIFY_FAILURE:
  26877. if (400 === $messageCode) {
  26878. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  26879. }
  26880. break;
  26881. case STREAM_NOTIFY_FILE_SIZE_IS:
  26882. $this->bytesMax = $bytesMax;
  26883. break;
  26884. case STREAM_NOTIFY_PROGRESS:
  26885. if ($this->bytesMax > 0 && $this->progress) {
  26886. $progression = min(100, round($bytesTransferred / $this->bytesMax * 100));
  26887. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  26888. $this->lastProgress = $progression;
  26889. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  26890. }
  26891. }
  26892. break;
  26893. default:
  26894. break;
  26895. }
  26896. }
  26897. protected function promptAuthAndRetry($httpStatus, $reason = null, $warning = null, $headers = array())
  26898. {
  26899. if ($this->config && in_array($this->originUrl, $this->config->get('github-domains'), true)) {
  26900. $gitHubUtil = new GitHub($this->io, $this->config, null);
  26901. $message = "\n";
  26902. $rateLimited = $gitHubUtil->isRateLimited($headers);
  26903. if ($rateLimited) {
  26904. $rateLimit = $gitHubUtil->getRateLimit($headers);
  26905. if ($this->io->hasAuthentication($this->originUrl)) {
  26906. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  26907. } else {
  26908. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  26909. }
  26910. $message = sprintf(
  26911. 'GitHub API limit (%d calls/hr) is exhausted, could not fetch '.$this->fileUrl.'. '.$message.' You can also wait until %s for the rate limit to reset.',
  26912. $rateLimit['limit'],
  26913. $rateLimit['reset']
  26914. )."\n";
  26915. } else {
  26916. $message .= 'Could not fetch '.$this->fileUrl.', please ';
  26917. if ($this->io->hasAuthentication($this->originUrl)) {
  26918. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  26919. } else {
  26920. $message .= 'create a GitHub OAuth token to access private repos';
  26921. }
  26922. }
  26923. if (!$gitHubUtil->authorizeOAuth($this->originUrl)
  26924. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($this->originUrl, $message))
  26925. ) {
  26926. throw new TransportException('Could not authenticate against '.$this->originUrl, 401);
  26927. }
  26928. } elseif ($this->config && in_array($this->originUrl, $this->config->get('gitlab-domains'), true)) {
  26929. $message = "\n".'Could not fetch '.$this->fileUrl.', enter your ' . $this->originUrl . ' credentials ' .($httpStatus === 401 ? 'to access private repos' : 'to go over the API rate limit');
  26930. $gitLabUtil = new GitLab($this->io, $this->config, null);
  26931. if ($this->io->hasAuthentication($this->originUrl) && ($auth = $this->io->getAuthentication($this->originUrl)) && $auth['password'] === 'private-token') {
  26932. throw new TransportException("Invalid credentials for '" . $this->fileUrl . "', aborting.", $httpStatus);
  26933. }
  26934. if (!$gitLabUtil->authorizeOAuth($this->originUrl)
  26935. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, $message))
  26936. ) {
  26937. throw new TransportException('Could not authenticate against '.$this->originUrl, 401);
  26938. }
  26939. } elseif ($this->config && $this->originUrl === 'bitbucket.org') {
  26940. $askForOAuthToken = true;
  26941. if ($this->io->hasAuthentication($this->originUrl)) {
  26942. $auth = $this->io->getAuthentication($this->originUrl);
  26943. if ($auth['username'] !== 'x-token-auth') {
  26944. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  26945. $accessToken = $bitbucketUtil->requestToken($this->originUrl, $auth['username'], $auth['password']);
  26946. if (!empty($accessToken)) {
  26947. $this->io->setAuthentication($this->originUrl, 'x-token-auth', $accessToken);
  26948. $askForOAuthToken = false;
  26949. }
  26950. } else {
  26951. throw new TransportException('Could not authenticate against ' . $this->originUrl, 401);
  26952. }
  26953. }
  26954. if ($askForOAuthToken) {
  26955. $message = "\n".'Could not fetch ' . $this->fileUrl . ', please create a bitbucket OAuth token to ' . (($httpStatus === 401 || $httpStatus === 403) ? 'access private repos' : 'go over the API rate limit');
  26956. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  26957. if (! $bitBucketUtil->authorizeOAuth($this->originUrl)
  26958. && (! $this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($this->originUrl, $message))
  26959. ) {
  26960. throw new TransportException('Could not authenticate against ' . $this->originUrl, 401);
  26961. }
  26962. }
  26963. } else {
  26964. if ($httpStatus === 404) {
  26965. return;
  26966. }
  26967. if (!$this->io->isInteractive()) {
  26968. if ($httpStatus === 401) {
  26969. $message = "The '" . $this->fileUrl . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  26970. }
  26971. if ($httpStatus === 403) {
  26972. $message = "The '" . $this->fileUrl . "' URL could not be accessed: " . $reason;
  26973. }
  26974. throw new TransportException($message, $httpStatus);
  26975. }
  26976. if ($this->io->hasAuthentication($this->originUrl)) {
  26977. throw new TransportException("Invalid credentials for '" . $this->fileUrl . "', aborting.", $httpStatus);
  26978. }
  26979. $this->io->overwriteError('');
  26980. if ($warning) {
  26981. $this->io->writeError(' <warning>'.$warning.'</warning>');
  26982. }
  26983. $this->io->writeError(' Authentication required (<info>'.parse_url($this->fileUrl, PHP_URL_HOST).'</info>):');
  26984. $username = $this->io->ask(' Username: ');
  26985. $password = $this->io->askAndHideAnswer(' Password: ');
  26986. $this->io->setAuthentication($this->originUrl, $username, $password);
  26987. $this->storeAuth = $this->config->get('store-auths');
  26988. }
  26989. $this->retry = true;
  26990. throw new TransportException('RETRY');
  26991. }
  26992. protected function getOptionsForUrl($originUrl, $additionalOptions)
  26993. {
  26994. $tlsOptions = array();
  26995. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  26996. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  26997. if (PHP_VERSION_ID < 50304) {
  26998. if ($host === 'github.com' || $host === 'api.github.com') {
  26999. $host = '*.github.com';
  27000. }
  27001. }
  27002. $tlsOptions['ssl']['CN_match'] = $host;
  27003. $tlsOptions['ssl']['SNI_server_name'] = $host;
  27004. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  27005. if (isset($this->peerCertificateMap[$urlAuthority])) {
  27006. $certMap = $this->peerCertificateMap[$urlAuthority];
  27007. $this->io->writeError('', true, IOInterface::DEBUG);
  27008. $this->io->writeError(sprintf(
  27009. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  27010. $certMap['cn'],
  27011. $urlAuthority
  27012. ), true, IOInterface::DEBUG);
  27013. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  27014. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  27015. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  27016. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  27017. }
  27018. }
  27019. $headers = array();
  27020. if (extension_loaded('zlib')) {
  27021. $headers[] = 'Accept-Encoding: gzip';
  27022. }
  27023. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  27024. if (!$this->degradedMode) {
  27025. $options['http']['protocol_version'] = 1.1;
  27026. $headers[] = 'Connection: close';
  27027. }
  27028. if ($this->io->hasAuthentication($originUrl)) {
  27029. $auth = $this->io->getAuthentication($originUrl);
  27030. if ('github.com' === $originUrl && 'x-oauth-basic' === $auth['password']) {
  27031. $options['github-token'] = $auth['username'];
  27032. } elseif ($this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)) {
  27033. if ($auth['password'] === 'oauth2') {
  27034. $headers[] = 'Authorization: Bearer '.$auth['username'];
  27035. } elseif ($auth['password'] === 'private-token') {
  27036. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  27037. }
  27038. } elseif ('bitbucket.org' === $originUrl
  27039. && $this->fileUrl !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL && 'x-token-auth' === $auth['username']
  27040. ) {
  27041. if (!$this->isPublicBitBucketDownload($this->fileUrl)) {
  27042. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  27043. }
  27044. } else {
  27045. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  27046. $headers[] = 'Authorization: Basic '.$authStr;
  27047. }
  27048. }
  27049. $options['http']['follow_location'] = 0;
  27050. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  27051. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  27052. }
  27053. foreach ($headers as $header) {
  27054. $options['http']['header'][] = $header;
  27055. }
  27056. return $options;
  27057. }
  27058. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  27059. {
  27060. if ($locationHeader = $this->findHeaderValue($http_response_header, 'location')) {
  27061. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  27062. $targetUrl = $locationHeader;
  27063. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  27064. $targetUrl = $this->scheme.':'.$locationHeader;
  27065. } elseif ('/' === $locationHeader[0]) {
  27066. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  27067. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  27068. } else {
  27069. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  27070. }
  27071. }
  27072. if (!empty($targetUrl)) {
  27073. $this->redirects++;
  27074. $this->io->writeError('', true, IOInterface::DEBUG);
  27075. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, $targetUrl), true, IOInterface::DEBUG);
  27076. $additionalOptions['redirects'] = $this->redirects;
  27077. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  27078. }
  27079. if (!$this->retry) {
  27080. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  27081. $e->setHeaders($http_response_header);
  27082. $e->setResponse($result);
  27083. throw $e;
  27084. }
  27085. return false;
  27086. }
  27087. private function getTlsDefaults(array $options)
  27088. {
  27089. $ciphers = implode(':', array(
  27090. 'ECDHE-RSA-AES128-GCM-SHA256',
  27091. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  27092. 'ECDHE-RSA-AES256-GCM-SHA384',
  27093. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  27094. 'DHE-RSA-AES128-GCM-SHA256',
  27095. 'DHE-DSS-AES128-GCM-SHA256',
  27096. 'kEDH+AESGCM',
  27097. 'ECDHE-RSA-AES128-SHA256',
  27098. 'ECDHE-ECDSA-AES128-SHA256',
  27099. 'ECDHE-RSA-AES128-SHA',
  27100. 'ECDHE-ECDSA-AES128-SHA',
  27101. 'ECDHE-RSA-AES256-SHA384',
  27102. 'ECDHE-ECDSA-AES256-SHA384',
  27103. 'ECDHE-RSA-AES256-SHA',
  27104. 'ECDHE-ECDSA-AES256-SHA',
  27105. 'DHE-RSA-AES128-SHA256',
  27106. 'DHE-RSA-AES128-SHA',
  27107. 'DHE-DSS-AES128-SHA256',
  27108. 'DHE-RSA-AES256-SHA256',
  27109. 'DHE-DSS-AES256-SHA',
  27110. 'DHE-RSA-AES256-SHA',
  27111. 'AES128-GCM-SHA256',
  27112. 'AES256-GCM-SHA384',
  27113. 'AES128-SHA256',
  27114. 'AES256-SHA256',
  27115. 'AES128-SHA',
  27116. 'AES256-SHA',
  27117. 'AES',
  27118. 'CAMELLIA',
  27119. 'DES-CBC3-SHA',
  27120. '!aNULL',
  27121. '!eNULL',
  27122. '!EXPORT',
  27123. '!DES',
  27124. '!RC4',
  27125. '!MD5',
  27126. '!PSK',
  27127. '!aECDH',
  27128. '!EDH-DSS-DES-CBC3-SHA',
  27129. '!EDH-RSA-DES-CBC3-SHA',
  27130. '!KRB5-DES-CBC3-SHA',
  27131. ));
  27132. $defaults = array(
  27133. 'ssl' => array(
  27134. 'ciphers' => $ciphers,
  27135. 'verify_peer' => true,
  27136. 'verify_depth' => 7,
  27137. 'SNI_enabled' => true,
  27138. 'capture_peer_cert' => true,
  27139. ),
  27140. );
  27141. if (isset($options['ssl'])) {
  27142. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  27143. }
  27144. $caBundleLogger = $this->io instanceof LoggerInterface ? $this->io : null;
  27145. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  27146. $result = CaBundle::getSystemCaRootBundlePath($caBundleLogger);
  27147. if (is_dir($result)) {
  27148. $defaults['ssl']['capath'] = $result;
  27149. } else {
  27150. $defaults['ssl']['cafile'] = $result;
  27151. }
  27152. }
  27153. if (isset($defaults['ssl']['cafile']) && (!is_readable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $caBundleLogger))) {
  27154. throw new TransportException('The configured cafile was not valid or could not be read.');
  27155. }
  27156. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !is_readable($defaults['ssl']['capath']))) {
  27157. throw new TransportException('The configured capath was not valid or could not be read.');
  27158. }
  27159. if (PHP_VERSION_ID >= 50413) {
  27160. $defaults['ssl']['disable_compression'] = true;
  27161. }
  27162. return $defaults;
  27163. }
  27164. private function getCertificateCnAndFp($url, $options)
  27165. {
  27166. if (PHP_VERSION_ID >= 50600) {
  27167. throw new \BadMethodCallException(sprintf(
  27168. '%s must not be used on PHP >= 5.6',
  27169. __METHOD__
  27170. ));
  27171. }
  27172. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  27173. 'ssl' => array(
  27174. 'capture_peer_cert' => true,
  27175. 'verify_peer' => false,
  27176. ), ),
  27177. ));
  27178. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  27179. return;
  27180. }
  27181. fclose($handle);
  27182. $handle = null;
  27183. $params = stream_context_get_params($context);
  27184. if (!empty($params['options']['ssl']['peer_certificate'])) {
  27185. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  27186. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  27187. return array(
  27188. 'cn' => $commonName,
  27189. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  27190. );
  27191. }
  27192. }
  27193. }
  27194. private function getUrlAuthority($url)
  27195. {
  27196. $defaultPorts = array(
  27197. 'ftp' => 21,
  27198. 'http' => 80,
  27199. 'https' => 443,
  27200. 'ssh2.sftp' => 22,
  27201. 'ssh2.scp' => 22,
  27202. );
  27203. $scheme = parse_url($url, PHP_URL_SCHEME);
  27204. if (!isset($defaultPorts[$scheme])) {
  27205. throw new \InvalidArgumentException(sprintf(
  27206. 'Could not get default port for unknown scheme: %s',
  27207. $scheme
  27208. ));
  27209. }
  27210. $defaultPort = $defaultPorts[$scheme];
  27211. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  27212. return parse_url($url, PHP_URL_HOST).':'.$port;
  27213. }
  27214. private function isPublicBitBucketDownload($urlToBitBucketFile)
  27215. {
  27216. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  27217. if (strpos($domain, 'bitbucket.org') === false) {
  27218. return true;
  27219. }
  27220. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  27221. $pathParts = explode('/', $path);
  27222. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  27223. }
  27224. }
  27225. <?php
  27226. namespace Composer\Util;
  27227. class Silencer
  27228. {
  27229. private static $stack = array();
  27230. public static function suppress($mask = null)
  27231. {
  27232. if (!isset($mask)) {
  27233. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  27234. }
  27235. $old = error_reporting();
  27236. self::$stack[] = $old;
  27237. error_reporting($old & ~$mask);
  27238. return $old;
  27239. }
  27240. public static function restore()
  27241. {
  27242. if (!empty(self::$stack)) {
  27243. error_reporting(array_pop(self::$stack));
  27244. }
  27245. }
  27246. public static function call($callable )
  27247. {
  27248. try {
  27249. self::suppress();
  27250. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  27251. self::restore();
  27252. return $result;
  27253. } catch (\Exception $e) {
  27254. self::restore();
  27255. throw $e;
  27256. }
  27257. }
  27258. }
  27259. <?php
  27260. namespace Composer\Util;
  27261. use Composer\Spdx\SpdxLicenses;
  27262. trigger_error('The ' . __NAMESPACE__ . '\SpdxLicense class is deprecated, use Composer\Spdx\SpdxLicenses instead.', E_USER_DEPRECATED);
  27263. class SpdxLicense extends SpdxLicenses
  27264. {
  27265. }
  27266. <?php
  27267. namespace Composer\Util;
  27268. use Composer\Composer;
  27269. final class StreamContextFactory
  27270. {
  27271. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  27272. {
  27273. $options = array('http' => array(
  27274. 'follow_location' => 1,
  27275. 'max_redirects' => 20,
  27276. ));
  27277. if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) {
  27278. $proxy = parse_url(!empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY']);
  27279. }
  27280. if (!empty($_SERVER['CGI_HTTP_PROXY'])) {
  27281. $proxy = parse_url($_SERVER['CGI_HTTP_PROXY']);
  27282. }
  27283. if (preg_match('{^https://}i', $url) && (!empty($_SERVER['HTTPS_PROXY']) || !empty($_SERVER['https_proxy']))) {
  27284. $proxy = parse_url(!empty($_SERVER['https_proxy']) ? $_SERVER['https_proxy'] : $_SERVER['HTTPS_PROXY']);
  27285. }
  27286. if (!empty($_SERVER['NO_PROXY']) || !empty($_SERVER['no_proxy']) && parse_url($url, PHP_URL_HOST)) {
  27287. $pattern = new NoProxyPattern(!empty($_SERVER['no_proxy']) ? $_SERVER['no_proxy'] : $_SERVER['NO_PROXY']);
  27288. if ($pattern->test($url)) {
  27289. unset($proxy);
  27290. }
  27291. }
  27292. if (!empty($proxy)) {
  27293. $proxyURL = isset($proxy['scheme']) ? $proxy['scheme'] . '://' : '';
  27294. $proxyURL .= isset($proxy['host']) ? $proxy['host'] : '';
  27295. if (isset($proxy['port'])) {
  27296. $proxyURL .= ":" . $proxy['port'];
  27297. } elseif ('http://' == substr($proxyURL, 0, 7)) {
  27298. $proxyURL .= ":80";
  27299. } elseif ('https://' == substr($proxyURL, 0, 8)) {
  27300. $proxyURL .= ":443";
  27301. }
  27302. $proxyURL = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyURL);
  27303. if (0 === strpos($proxyURL, 'ssl:') && !extension_loaded('openssl')) {
  27304. throw new \RuntimeException('You must enable the openssl extension to use a proxy over https');
  27305. }
  27306. $options['http']['proxy'] = $proxyURL;
  27307. switch (parse_url($url, PHP_URL_SCHEME)) {
  27308. case 'http':
  27309. $reqFullUriEnv = getenv('HTTP_PROXY_REQUEST_FULLURI');
  27310. if ($reqFullUriEnv === false || $reqFullUriEnv === '' || (strtolower($reqFullUriEnv) !== 'false' && (bool) $reqFullUriEnv)) {
  27311. $options['http']['request_fulluri'] = true;
  27312. }
  27313. break;
  27314. case 'https':
  27315. $reqFullUriEnv = getenv('HTTPS_PROXY_REQUEST_FULLURI');
  27316. if ($reqFullUriEnv === false || $reqFullUriEnv === '' || (strtolower($reqFullUriEnv) !== 'false' && (bool) $reqFullUriEnv)) {
  27317. $options['http']['request_fulluri'] = true;
  27318. }
  27319. break;
  27320. }
  27321. if ('https' === parse_url($url, PHP_URL_SCHEME)) {
  27322. $options['ssl']['SNI_enabled'] = true;
  27323. if (PHP_VERSION_ID < 50600) {
  27324. $options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST);
  27325. }
  27326. }
  27327. if (isset($proxy['user'])) {
  27328. $auth = rawurldecode($proxy['user']);
  27329. if (isset($proxy['pass'])) {
  27330. $auth .= ':' . rawurldecode($proxy['pass']);
  27331. }
  27332. $auth = base64_encode($auth);
  27333. if (isset($defaultOptions['http']['header'])) {
  27334. if (is_string($defaultOptions['http']['header'])) {
  27335. $defaultOptions['http']['header'] = array($defaultOptions['http']['header']);
  27336. }
  27337. $defaultOptions['http']['header'][] = "Proxy-Authorization: Basic {$auth}";
  27338. } else {
  27339. $options['http']['header'] = array("Proxy-Authorization: Basic {$auth}");
  27340. }
  27341. }
  27342. }
  27343. $options = array_replace_recursive($options, $defaultOptions);
  27344. if (isset($options['http']['header'])) {
  27345. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  27346. }
  27347. if (defined('HHVM_VERSION')) {
  27348. $phpVersion = 'HHVM ' . HHVM_VERSION;
  27349. } else {
  27350. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  27351. }
  27352. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  27353. $options['http']['header'][] = sprintf(
  27354. 'User-Agent: Composer/%s (%s; %s; %s%s)',
  27355. Composer::VERSION === '@package_version@' ? 'source' : Composer::VERSION,
  27356. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  27357. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  27358. $phpVersion,
  27359. getenv('CI') ? '; CI' : ''
  27360. );
  27361. }
  27362. return stream_context_create($options, $defaultParams);
  27363. }
  27364. private static function fixHttpHeaderField($header)
  27365. {
  27366. if (!is_array($header)) {
  27367. $header = explode("\r\n", $header);
  27368. }
  27369. uasort($header, function ($el) {
  27370. return stripos($el, 'content-type') === 0 ? 1 : -1;
  27371. });
  27372. return $header;
  27373. }
  27374. }
  27375. <?php
  27376. namespace Composer\Util;
  27377. use Composer\Config;
  27378. use Composer\IO\IOInterface;
  27379. class Svn
  27380. {
  27381. const MAX_QTY_AUTH_TRIES = 5;
  27382. protected $credentials;
  27383. protected $hasAuth;
  27384. protected $io;
  27385. protected $url;
  27386. protected $cacheCredentials = true;
  27387. protected $process;
  27388. protected $qtyAuthTries = 0;
  27389. protected $config;
  27390. private static $version;
  27391. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  27392. {
  27393. $this->url = $url;
  27394. $this->io = $io;
  27395. $this->config = $config;
  27396. $this->process = $process ?: new ProcessExecutor($io);
  27397. }
  27398. public static function cleanEnv()
  27399. {
  27400. putenv("DYLD_LIBRARY_PATH");
  27401. unset($_SERVER['DYLD_LIBRARY_PATH']);
  27402. }
  27403. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  27404. {
  27405. $this->config->prohibitUrlByConfig($url, $this->io);
  27406. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  27407. }
  27408. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  27409. {
  27410. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  27411. }
  27412. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  27413. {
  27414. $command = $this->getCommand($svnCommand, $url, $path);
  27415. $output = null;
  27416. $io = $this->io;
  27417. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  27418. if ($type !== 'out') {
  27419. return;
  27420. }
  27421. if ('Redirecting to URL ' === substr($buffer, 0, 19)) {
  27422. return;
  27423. }
  27424. $output .= $buffer;
  27425. if ($verbose) {
  27426. $io->writeError($buffer, false);
  27427. }
  27428. };
  27429. $status = $this->process->execute($command, $handler, $cwd);
  27430. if (0 === $status) {
  27431. return $output;
  27432. }
  27433. $errorOutput = $this->process->getErrorOutput();
  27434. $fullOutput = implode("\n", array($output, $errorOutput));
  27435. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  27436. && false === stripos($fullOutput, 'authorization failed')
  27437. && false === stripos($fullOutput, 'svn: E170001:')
  27438. && false === stripos($fullOutput, 'svn: E215004:')) {
  27439. throw new \RuntimeException($fullOutput);
  27440. }
  27441. if (!$this->hasAuth()) {
  27442. $this->doAuthDance();
  27443. }
  27444. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  27445. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  27446. }
  27447. throw new \RuntimeException(
  27448. 'wrong credentials provided ('.$fullOutput.')'
  27449. );
  27450. }
  27451. public function setCacheCredentials($cacheCredentials)
  27452. {
  27453. $this->cacheCredentials = $cacheCredentials;
  27454. }
  27455. protected function doAuthDance()
  27456. {
  27457. if (!$this->io->isInteractive()) {
  27458. throw new \RuntimeException(
  27459. 'can not ask for authentication in non interactive mode'
  27460. );
  27461. }
  27462. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  27463. $this->hasAuth = true;
  27464. $this->credentials['username'] = $this->io->ask("Username: ");
  27465. $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
  27466. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ", true);
  27467. return $this;
  27468. }
  27469. protected function getCommand($cmd, $url, $path = null)
  27470. {
  27471. $cmd = sprintf(
  27472. '%s %s%s %s',
  27473. $cmd,
  27474. '--non-interactive ',
  27475. $this->getCredentialString(),
  27476. ProcessExecutor::escape($url)
  27477. );
  27478. if ($path) {
  27479. $cmd .= ' ' . ProcessExecutor::escape($path);
  27480. }
  27481. return $cmd;
  27482. }
  27483. protected function getCredentialString()
  27484. {
  27485. if (!$this->hasAuth()) {
  27486. return '';
  27487. }
  27488. return sprintf(
  27489. ' %s--username %s --password %s ',
  27490. $this->getAuthCache(),
  27491. ProcessExecutor::escape($this->getUsername()),
  27492. ProcessExecutor::escape($this->getPassword())
  27493. );
  27494. }
  27495. protected function getPassword()
  27496. {
  27497. if ($this->credentials === null) {
  27498. throw new \LogicException("No svn auth detected.");
  27499. }
  27500. return isset($this->credentials['password']) ? $this->credentials['password'] : '';
  27501. }
  27502. protected function getUsername()
  27503. {
  27504. if ($this->credentials === null) {
  27505. throw new \LogicException("No svn auth detected.");
  27506. }
  27507. return $this->credentials['username'];
  27508. }
  27509. protected function hasAuth()
  27510. {
  27511. if (null !== $this->hasAuth) {
  27512. return $this->hasAuth;
  27513. }
  27514. if (false === $this->createAuthFromConfig()) {
  27515. $this->createAuthFromUrl();
  27516. }
  27517. return $this->hasAuth;
  27518. }
  27519. protected function getAuthCache()
  27520. {
  27521. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  27522. }
  27523. private function createAuthFromConfig()
  27524. {
  27525. if (!$this->config->has('http-basic')) {
  27526. return $this->hasAuth = false;
  27527. }
  27528. $authConfig = $this->config->get('http-basic');
  27529. $host = parse_url($this->url, PHP_URL_HOST);
  27530. if (isset($authConfig[$host])) {
  27531. $this->credentials['username'] = $authConfig[$host]['username'];
  27532. $this->credentials['password'] = $authConfig[$host]['password'];
  27533. return $this->hasAuth = true;
  27534. }
  27535. return $this->hasAuth = false;
  27536. }
  27537. private function createAuthFromUrl()
  27538. {
  27539. $uri = parse_url($this->url);
  27540. if (empty($uri['user'])) {
  27541. return $this->hasAuth = false;
  27542. }
  27543. $this->credentials['username'] = $uri['user'];
  27544. if (!empty($uri['pass'])) {
  27545. $this->credentials['password'] = $uri['pass'];
  27546. }
  27547. return $this->hasAuth = true;
  27548. }
  27549. public function binaryVersion()
  27550. {
  27551. if (!self::$version) {
  27552. if (0 === $this->process->execute('svn --version', $output)) {
  27553. if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
  27554. self::$version = $match[1];
  27555. }
  27556. }
  27557. }
  27558. return self::$version;
  27559. }
  27560. }
  27561. <?php
  27562. namespace Composer\Util;
  27563. use Composer\CaBundle\CaBundle;
  27564. final class TlsHelper
  27565. {
  27566. private static $useOpensslParse;
  27567. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  27568. {
  27569. $names = self::getCertificateNames($certificate);
  27570. if (empty($names)) {
  27571. return false;
  27572. }
  27573. $combinedNames = array_merge($names['san'], array($names['cn']));
  27574. $hostname = strtolower($hostname);
  27575. foreach ($combinedNames as $certName) {
  27576. $matcher = self::certNameMatcher($certName);
  27577. if ($matcher && $matcher($hostname)) {
  27578. $cn = $names['cn'];
  27579. return true;
  27580. }
  27581. }
  27582. return false;
  27583. }
  27584. public static function getCertificateNames($certificate)
  27585. {
  27586. if (is_array($certificate)) {
  27587. $info = $certificate;
  27588. } elseif (CaBundle::isOpensslParseSafe()) {
  27589. $info = openssl_x509_parse($certificate, false);
  27590. }
  27591. if (!isset($info['subject']['commonName'])) {
  27592. return null;
  27593. }
  27594. $commonName = strtolower($info['subject']['commonName']);
  27595. $subjectAltNames = array();
  27596. if (isset($info['extensions']['subjectAltName'])) {
  27597. $subjectAltNames = preg_split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  27598. $subjectAltNames = array_filter(array_map(function ($name) {
  27599. if (0 === strpos($name, 'DNS:')) {
  27600. return strtolower(ltrim(substr($name, 4)));
  27601. }
  27602. return null;
  27603. }, $subjectAltNames));
  27604. $subjectAltNames = array_values($subjectAltNames);
  27605. }
  27606. return array(
  27607. 'cn' => $commonName,
  27608. 'san' => $subjectAltNames,
  27609. );
  27610. }
  27611. public static function getCertificateFingerprint($certificate)
  27612. {
  27613. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  27614. $pubkeypem = $pubkeydetails['key'];
  27615. $start = '-----BEGIN PUBLIC KEY-----';
  27616. $end = '-----END PUBLIC KEY-----';
  27617. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  27618. $der = base64_decode($pemtrim);
  27619. return sha1($der);
  27620. }
  27621. public static function isOpensslParseSafe()
  27622. {
  27623. return CaBundle::isOpensslParseSafe();
  27624. }
  27625. private static function certNameMatcher($certName)
  27626. {
  27627. $wildcards = substr_count($certName, '*');
  27628. if (0 === $wildcards) {
  27629. return function ($hostname) use ($certName) {
  27630. return $hostname === $certName;
  27631. };
  27632. }
  27633. if (1 === $wildcards) {
  27634. $components = explode('.', $certName);
  27635. if (3 > count($components)) {
  27636. return;
  27637. }
  27638. $firstComponent = $components[0];
  27639. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  27640. return;
  27641. }
  27642. $wildcardRegex = preg_quote($certName);
  27643. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  27644. $wildcardRegex = "{^{$wildcardRegex}$}";
  27645. return function ($hostname) use ($wildcardRegex) {
  27646. return 1 === preg_match($wildcardRegex, $hostname);
  27647. };
  27648. }
  27649. }
  27650. }
  27651. <?php
  27652. namespace Composer\Util;
  27653. use Composer\Config;
  27654. class Url
  27655. {
  27656. public static function updateDistReference(Config $config, $url, $ref)
  27657. {
  27658. $host = parse_url($url, PHP_URL_HOST);
  27659. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  27660. if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  27661. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  27662. } elseif (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  27663. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  27664. } elseif (preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  27665. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  27666. }
  27667. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  27668. if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  27669. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  27670. }
  27671. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  27672. if (preg_match('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  27673. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  27674. }
  27675. } elseif (in_array($host, $config->get('github-domains'), true)) {
  27676. $url = preg_replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  27677. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  27678. $url = preg_replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  27679. }
  27680. return $url;
  27681. }
  27682. }
  27683. <?php
  27684. namespace Composer;
  27685. use Symfony\Component\Console\Output\OutputInterface;
  27686. trigger_error('The ' . __NAMESPACE__ . '\XdebugHandler class is deprecated, use Composer\XdebugHandler\XdebugHandler instead,', E_USER_DEPRECATED);
  27687. class XdebugHandler extends XdebugHandler\XdebugHandler
  27688. {
  27689. const ENV_ALLOW = 'COMPOSER_ALLOW_XDEBUG';
  27690. const ENV_VERSION = 'COMPOSER_XDEBUG_VERSION';
  27691. public function __construct(OutputInterface $output)
  27692. {
  27693. parent::__construct('composer', '--ansi');
  27694. }
  27695. }
  27696. <?php
  27697. function includeIfExists($file)
  27698. {
  27699. return file_exists($file) ? include $file : false;
  27700. }
  27701. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  27702. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  27703. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  27704. exit(1);
  27705. }
  27706. return $loader;
  27707. <?php
  27708. /*
  27709. * This file is part of Composer.
  27710. *
  27711. * (c) Nils Adermann <[email protected]>
  27712. * Jordi Boggiano <[email protected]>
  27713. *
  27714. * For the full copyright and license information, please view the LICENSE
  27715. * file that was distributed with this source code.
  27716. */
  27717. namespace Composer\Autoload;
  27718. /**
  27719. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  27720. *
  27721. * $loader = new \Composer\Autoload\ClassLoader();
  27722. *
  27723. * // register classes with namespaces
  27724. * $loader->add('Symfony\Component', __DIR__.'/component');
  27725. * $loader->add('Symfony', __DIR__.'/framework');
  27726. *
  27727. * // activate the autoloader
  27728. * $loader->register();
  27729. *
  27730. * // to enable searching the include path (eg. for PEAR packages)
  27731. * $loader->setUseIncludePath(true);
  27732. *
  27733. * In this example, if you try to use a class in the Symfony\Component
  27734. * namespace or one of its children (Symfony\Component\Console for instance),
  27735. * the autoloader will first look for the class under the component/
  27736. * directory, and it will then fallback to the framework/ directory if not
  27737. * found before giving up.
  27738. *
  27739. * This class is loosely based on the Symfony UniversalClassLoader.
  27740. *
  27741. * @author Fabien Potencier <[email protected]>
  27742. * @author Jordi Boggiano <[email protected]>
  27743. * @see http://www.php-fig.org/psr/psr-0/
  27744. * @see http://www.php-fig.org/psr/psr-4/
  27745. */
  27746. class ClassLoader
  27747. {
  27748. // PSR-4
  27749. private $prefixLengthsPsr4 = array();
  27750. private $prefixDirsPsr4 = array();
  27751. private $fallbackDirsPsr4 = array();
  27752. // PSR-0
  27753. private $prefixesPsr0 = array();
  27754. private $fallbackDirsPsr0 = array();
  27755. private $useIncludePath = false;
  27756. private $classMap = array();
  27757. private $classMapAuthoritative = false;
  27758. private $missingClasses = array();
  27759. private $apcuPrefix;
  27760. public function getPrefixes()
  27761. {
  27762. if (!empty($this->prefixesPsr0)) {
  27763. return call_user_func_array('array_merge', $this->prefixesPsr0);
  27764. }
  27765. return array();
  27766. }
  27767. public function getPrefixesPsr4()
  27768. {
  27769. return $this->prefixDirsPsr4;
  27770. }
  27771. public function getFallbackDirs()
  27772. {
  27773. return $this->fallbackDirsPsr0;
  27774. }
  27775. public function getFallbackDirsPsr4()
  27776. {
  27777. return $this->fallbackDirsPsr4;
  27778. }
  27779. public function getClassMap()
  27780. {
  27781. return $this->classMap;
  27782. }
  27783. /**
  27784. * @param array $classMap Class to filename map
  27785. */
  27786. public function addClassMap(array $classMap)
  27787. {
  27788. if ($this->classMap) {
  27789. $this->classMap = array_merge($this->classMap, $classMap);
  27790. } else {
  27791. $this->classMap = $classMap;
  27792. }
  27793. }
  27794. /**
  27795. * Registers a set of PSR-0 directories for a given prefix, either
  27796. * appending or prepending to the ones previously set for this prefix.
  27797. *
  27798. * @param string $prefix The prefix
  27799. * @param array|string $paths The PSR-0 root directories
  27800. * @param bool $prepend Whether to prepend the directories
  27801. */
  27802. public function add($prefix, $paths, $prepend = false)
  27803. {
  27804. if (!$prefix) {
  27805. if ($prepend) {
  27806. $this->fallbackDirsPsr0 = array_merge(
  27807. (array) $paths,
  27808. $this->fallbackDirsPsr0
  27809. );
  27810. } else {
  27811. $this->fallbackDirsPsr0 = array_merge(
  27812. $this->fallbackDirsPsr0,
  27813. (array) $paths
  27814. );
  27815. }
  27816. return;
  27817. }
  27818. $first = $prefix[0];
  27819. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  27820. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  27821. return;
  27822. }
  27823. if ($prepend) {
  27824. $this->prefixesPsr0[$first][$prefix] = array_merge(
  27825. (array) $paths,
  27826. $this->prefixesPsr0[$first][$prefix]
  27827. );
  27828. } else {
  27829. $this->prefixesPsr0[$first][$prefix] = array_merge(
  27830. $this->prefixesPsr0[$first][$prefix],
  27831. (array) $paths
  27832. );
  27833. }
  27834. }
  27835. /**
  27836. * Registers a set of PSR-4 directories for a given namespace, either
  27837. * appending or prepending to the ones previously set for this namespace.
  27838. *
  27839. * @param string $prefix The prefix/namespace, with trailing '\\'
  27840. * @param array|string $paths The PSR-4 base directories
  27841. * @param bool $prepend Whether to prepend the directories
  27842. *
  27843. * @throws \InvalidArgumentException
  27844. */
  27845. public function addPsr4($prefix, $paths, $prepend = false)
  27846. {
  27847. if (!$prefix) {
  27848. // Register directories for the root namespace.
  27849. if ($prepend) {
  27850. $this->fallbackDirsPsr4 = array_merge(
  27851. (array) $paths,
  27852. $this->fallbackDirsPsr4
  27853. );
  27854. } else {
  27855. $this->fallbackDirsPsr4 = array_merge(
  27856. $this->fallbackDirsPsr4,
  27857. (array) $paths
  27858. );
  27859. }
  27860. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  27861. // Register directories for a new namespace.
  27862. $length = strlen($prefix);
  27863. if ('\\' !== $prefix[$length - 1]) {
  27864. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  27865. }
  27866. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  27867. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  27868. } elseif ($prepend) {
  27869. // Prepend directories for an already registered namespace.
  27870. $this->prefixDirsPsr4[$prefix] = array_merge(
  27871. (array) $paths,
  27872. $this->prefixDirsPsr4[$prefix]
  27873. );
  27874. } else {
  27875. // Append directories for an already registered namespace.
  27876. $this->prefixDirsPsr4[$prefix] = array_merge(
  27877. $this->prefixDirsPsr4[$prefix],
  27878. (array) $paths
  27879. );
  27880. }
  27881. }
  27882. /**
  27883. * Registers a set of PSR-0 directories for a given prefix,
  27884. * replacing any others previously set for this prefix.
  27885. *
  27886. * @param string $prefix The prefix
  27887. * @param array|string $paths The PSR-0 base directories
  27888. */
  27889. public function set($prefix, $paths)
  27890. {
  27891. if (!$prefix) {
  27892. $this->fallbackDirsPsr0 = (array) $paths;
  27893. } else {
  27894. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  27895. }
  27896. }
  27897. /**
  27898. * Registers a set of PSR-4 directories for a given namespace,
  27899. * replacing any others previously set for this namespace.
  27900. *
  27901. * @param string $prefix The prefix/namespace, with trailing '\\'
  27902. * @param array|string $paths The PSR-4 base directories
  27903. *
  27904. * @throws \InvalidArgumentException
  27905. */
  27906. public function setPsr4($prefix, $paths)
  27907. {
  27908. if (!$prefix) {
  27909. $this->fallbackDirsPsr4 = (array) $paths;
  27910. } else {
  27911. $length = strlen($prefix);
  27912. if ('\\' !== $prefix[$length - 1]) {
  27913. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  27914. }
  27915. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  27916. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  27917. }
  27918. }
  27919. /**
  27920. * Turns on searching the include path for class files.
  27921. *
  27922. * @param bool $useIncludePath
  27923. */
  27924. public function setUseIncludePath($useIncludePath)
  27925. {
  27926. $this->useIncludePath = $useIncludePath;
  27927. }
  27928. /**
  27929. * Can be used to check if the autoloader uses the include path to check
  27930. * for classes.
  27931. *
  27932. * @return bool
  27933. */
  27934. public function getUseIncludePath()
  27935. {
  27936. return $this->useIncludePath;
  27937. }
  27938. /**
  27939. * Turns off searching the prefix and fallback directories for classes
  27940. * that have not been registered with the class map.
  27941. *
  27942. * @param bool $classMapAuthoritative
  27943. */
  27944. public function setClassMapAuthoritative($classMapAuthoritative)
  27945. {
  27946. $this->classMapAuthoritative = $classMapAuthoritative;
  27947. }
  27948. /**
  27949. * Should class lookup fail if not found in the current class map?
  27950. *
  27951. * @return bool
  27952. */
  27953. public function isClassMapAuthoritative()
  27954. {
  27955. return $this->classMapAuthoritative;
  27956. }
  27957. /**
  27958. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  27959. *
  27960. * @param string|null $apcuPrefix
  27961. */
  27962. public function setApcuPrefix($apcuPrefix)
  27963. {
  27964. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  27965. }
  27966. /**
  27967. * The APCu prefix in use, or null if APCu caching is not enabled.
  27968. *
  27969. * @return string|null
  27970. */
  27971. public function getApcuPrefix()
  27972. {
  27973. return $this->apcuPrefix;
  27974. }
  27975. /**
  27976. * Registers this instance as an autoloader.
  27977. *
  27978. * @param bool $prepend Whether to prepend the autoloader or not
  27979. */
  27980. public function register($prepend = false)
  27981. {
  27982. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  27983. }
  27984. /**
  27985. * Unregisters this instance as an autoloader.
  27986. */
  27987. public function unregister()
  27988. {
  27989. spl_autoload_unregister(array($this, 'loadClass'));
  27990. }
  27991. /**
  27992. * Loads the given class or interface.
  27993. *
  27994. * @param string $class The name of the class
  27995. * @return bool|null True if loaded, null otherwise
  27996. */
  27997. public function loadClass($class)
  27998. {
  27999. if ($file = $this->findFile($class)) {
  28000. includeFile($file);
  28001. return true;
  28002. }
  28003. }
  28004. /**
  28005. * Finds the path to the file where the class is defined.
  28006. *
  28007. * @param string $class The name of the class
  28008. *
  28009. * @return string|false The path if found, false otherwise
  28010. */
  28011. public function findFile($class)
  28012. {
  28013. // class map lookup
  28014. if (isset($this->classMap[$class])) {
  28015. return $this->classMap[$class];
  28016. }
  28017. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  28018. return false;
  28019. }
  28020. if (null !== $this->apcuPrefix) {
  28021. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  28022. if ($hit) {
  28023. return $file;
  28024. }
  28025. }
  28026. $file = $this->findFileWithExtension($class, '.php');
  28027. // Search for Hack files if we are running on HHVM
  28028. if (false === $file && defined('HHVM_VERSION')) {
  28029. $file = $this->findFileWithExtension($class, '.hh');
  28030. }
  28031. if (null !== $this->apcuPrefix) {
  28032. apcu_add($this->apcuPrefix.$class, $file);
  28033. }
  28034. if (false === $file) {
  28035. // Remember that this class does not exist.
  28036. $this->missingClasses[$class] = true;
  28037. }
  28038. return $file;
  28039. }
  28040. private function findFileWithExtension($class, $ext)
  28041. {
  28042. // PSR-4 lookup
  28043. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  28044. $first = $class[0];
  28045. if (isset($this->prefixLengthsPsr4[$first])) {
  28046. $subPath = $class;
  28047. while (false !== $lastPos = strrpos($subPath, '\\')) {
  28048. $subPath = substr($subPath, 0, $lastPos);
  28049. $search = $subPath . '\\';
  28050. if (isset($this->prefixDirsPsr4[$search])) {
  28051. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  28052. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  28053. if (file_exists($file = $dir . $pathEnd)) {
  28054. return $file;
  28055. }
  28056. }
  28057. }
  28058. }
  28059. }
  28060. // PSR-4 fallback dirs
  28061. foreach ($this->fallbackDirsPsr4 as $dir) {
  28062. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  28063. return $file;
  28064. }
  28065. }
  28066. // PSR-0 lookup
  28067. if (false !== $pos = strrpos($class, '\\')) {
  28068. // namespaced class name
  28069. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  28070. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  28071. } else {
  28072. // PEAR-like class name
  28073. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  28074. }
  28075. if (isset($this->prefixesPsr0[$first])) {
  28076. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  28077. if (0 === strpos($class, $prefix)) {
  28078. foreach ($dirs as $dir) {
  28079. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  28080. return $file;
  28081. }
  28082. }
  28083. }
  28084. }
  28085. }
  28086. // PSR-0 fallback dirs
  28087. foreach ($this->fallbackDirsPsr0 as $dir) {
  28088. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  28089. return $file;
  28090. }
  28091. }
  28092. // PSR-0 include paths.
  28093. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  28094. return $file;
  28095. }
  28096. return false;
  28097. }
  28098. }
  28099. /**
  28100. * Scope isolated include.
  28101. *
  28102. * Prevents access to $this/self from included files.
  28103. */
  28104. function includeFile($file)
  28105. {
  28106. include $file;
  28107. }
  28108. {
  28109. "$schema": "http://json-schema.org/draft-04/schema#",
  28110. "description": "A representation of packages metadata.",
  28111. "type": "object",
  28112. "oneOf": [
  28113. { "required": [ "packages" ] },
  28114. { "required": [ "providers" ] },
  28115. { "required": [ "provider-includes", "providers-url" ] }
  28116. ],
  28117. "properties": {
  28118. "packages": {
  28119. "type": ["object", "array"],
  28120. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  28121. "additionalProperties": { "$ref": "#/definitions/versions" }
  28122. },
  28123. "providers-url": {
  28124. "type": "string",
  28125. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  28126. },
  28127. "provider-includes": {
  28128. "type": "object",
  28129. "description": "A hashmap of provider listings.",
  28130. "additionalProperties": { "$ref": "#/definitions/provider" }
  28131. },
  28132. "providers": {
  28133. "type": "object",
  28134. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  28135. "additionalProperties": { "$ref": "#/definitions/provider" }
  28136. },
  28137. "notify-batch": {
  28138. "type": "string",
  28139. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  28140. },
  28141. "search": {
  28142. "type": "string",
  28143. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  28144. },
  28145. "warning": {
  28146. "type": "string",
  28147. "description": "A message that will be output by Composer as a warning when this source is consulted."
  28148. }
  28149. },
  28150. "definitions": {
  28151. "versions": {
  28152. "type": "object",
  28153. "description": "A hashmap of versions and their metadata.",
  28154. "additionalProperties": { "$ref": "#/definitions/version" }
  28155. },
  28156. "version": {
  28157. "type": "object",
  28158. "oneOf": [
  28159. { "$ref": "#/definitions/package" },
  28160. { "$ref": "#/definitions/metapackage" }
  28161. ]
  28162. },
  28163. "package-base": {
  28164. "properties": {
  28165. "name": { "type": "string" },
  28166. "type": { "type": "string" },
  28167. "version": { "type": "string" },
  28168. "version_normalized": {
  28169. "type": "string",
  28170. "description": "Normalized version, optional but can save computational time on client side."
  28171. },
  28172. "autoload": { "type": "object" },
  28173. "require": { "type": "object" },
  28174. "replace": { "type": "object" },
  28175. "conflict": { "type": "object" },
  28176. "provide": { "type": "object" },
  28177. "time": { "type": "string" }
  28178. },
  28179. "additionalProperties": true
  28180. },
  28181. "package": {
  28182. "allOf": [
  28183. { "$ref": "#/definitions/package-base" },
  28184. {
  28185. "properties": {
  28186. "dist": { "type": "object" },
  28187. "source": { "type": "object" }
  28188. }
  28189. },
  28190. { "oneOf": [
  28191. { "required": [ "name", "version", "source" ] },
  28192. { "required": [ "name", "version", "dist" ] }
  28193. ] }
  28194. ]
  28195. },
  28196. "metapackage": {
  28197. "allOf": [
  28198. { "$ref": "#/definitions/package-base" },
  28199. {
  28200. "properties": {
  28201. "type": { "type": "string", "enum": [ "metapackage" ] }
  28202. },
  28203. "required": [ "name", "version", "type" ]
  28204. }
  28205. ]
  28206. },
  28207. "provider": {
  28208. "type": "object",
  28209. "properties": {
  28210. "sha256": {
  28211. "type": "string",
  28212. "description": "Hash value that can be used to validate the resource."
  28213. }
  28214. }
  28215. }
  28216. }
  28217. }
  28218. {
  28219. "$schema": "http://json-schema.org/draft-04/schema#",
  28220. "name": "Package",
  28221. "type": "object",
  28222. "additionalProperties": false,
  28223. "required": [ "name", "description" ],
  28224. "properties": {
  28225. "name": {
  28226. "type": "string",
  28227. "description": "Package name, including 'vendor-name/' prefix."
  28228. },
  28229. "type": {
  28230. "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.",
  28231. "type": "string"
  28232. },
  28233. "target-dir": {
  28234. "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.",
  28235. "type": "string"
  28236. },
  28237. "description": {
  28238. "type": "string",
  28239. "description": "Short package description."
  28240. },
  28241. "keywords": {
  28242. "type": "array",
  28243. "items": {
  28244. "type": "string",
  28245. "description": "A tag/keyword that this package relates to."
  28246. }
  28247. },
  28248. "homepage": {
  28249. "type": "string",
  28250. "description": "Homepage URL for the project.",
  28251. "format": "uri"
  28252. },
  28253. "readme": {
  28254. "type": "string",
  28255. "description": "Relative path to the readme document."
  28256. },
  28257. "version": {
  28258. "type": "string",
  28259. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes."
  28260. },
  28261. "time": {
  28262. "type": "string",
  28263. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  28264. },
  28265. "license": {
  28266. "type": ["string", "array"],
  28267. "description": "License name. Or an array of license names."
  28268. },
  28269. "authors": {
  28270. "$ref": "#/definitions/authors"
  28271. },
  28272. "require": {
  28273. "type": "object",
  28274. "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
  28275. "additionalProperties": {
  28276. "type": "string"
  28277. }
  28278. },
  28279. "replace": {
  28280. "type": "object",
  28281. "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
  28282. "additionalProperties": {
  28283. "type": "string"
  28284. }
  28285. },
  28286. "conflict": {
  28287. "type": "object",
  28288. "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
  28289. "additionalProperties": {
  28290. "type": "string"
  28291. }
  28292. },
  28293. "provide": {
  28294. "type": "object",
  28295. "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  28296. "additionalProperties": {
  28297. "type": "string"
  28298. }
  28299. },
  28300. "require-dev": {
  28301. "type": "object",
  28302. "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  28303. "additionalProperties": {
  28304. "type": "string"
  28305. }
  28306. },
  28307. "suggest": {
  28308. "type": "object",
  28309. "description": "This is a hash of package name (keys) and descriptions (values) that this package suggests work well with it (this will be suggested to the user during installation).",
  28310. "additionalProperties": {
  28311. "type": "string"
  28312. }
  28313. },
  28314. "config": {
  28315. "type": "object",
  28316. "description": "Composer options.",
  28317. "properties": {
  28318. "process-timeout": {
  28319. "type": "integer",
  28320. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  28321. },
  28322. "use-include-path": {
  28323. "type": "boolean",
  28324. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  28325. },
  28326. "preferred-install": {
  28327. "type": ["string", "object"],
  28328. "description": "The install method Composer will prefer to use, defaults to auto and can be any of source, dist, auto, or a hash of {\"pattern\": \"preference\"}."
  28329. },
  28330. "notify-on-install": {
  28331. "type": "boolean",
  28332. "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."
  28333. },
  28334. "github-protocols": {
  28335. "type": "array",
  28336. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  28337. "items": {
  28338. "type": "string"
  28339. }
  28340. },
  28341. "github-oauth": {
  28342. "type": "object",
  28343. "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  28344. "additionalProperties": {
  28345. "type": "string"
  28346. }
  28347. },
  28348. "gitlab-oauth": {
  28349. "type": "object",
  28350. "description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  28351. "additionalProperties": {
  28352. "type": "string"
  28353. }
  28354. },
  28355. "gitlab-token": {
  28356. "type": "object",
  28357. "description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  28358. "additionalProperties": true
  28359. },
  28360. "disable-tls": {
  28361. "type": "boolean",
  28362. "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."
  28363. },
  28364. "secure-http": {
  28365. "type": "boolean",
  28366. "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."
  28367. },
  28368. "cafile": {
  28369. "type": "string",
  28370. "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."
  28371. },
  28372. "capath": {
  28373. "type": "string",
  28374. "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."
  28375. },
  28376. "http-basic": {
  28377. "type": "object",
  28378. "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  28379. "additionalProperties": {
  28380. "type": "object",
  28381. "required": ["username", "password"],
  28382. "properties": {
  28383. "username": {
  28384. "type": "string",
  28385. "description": "The username used for HTTP Basic authentication"
  28386. },
  28387. "password": {
  28388. "type": "string",
  28389. "description": "The password used for HTTP Basic authentication"
  28390. }
  28391. }
  28392. }
  28393. },
  28394. "store-auths": {
  28395. "type": ["string", "boolean"],
  28396. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  28397. },
  28398. "platform": {
  28399. "type": "object",
  28400. "description": "This is a hash of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  28401. "additionalProperties": {
  28402. "type": "string"
  28403. }
  28404. },
  28405. "vendor-dir": {
  28406. "type": "string",
  28407. "description": "The location where all packages are installed, defaults to \"vendor\"."
  28408. },
  28409. "bin-dir": {
  28410. "type": "string",
  28411. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  28412. },
  28413. "data-dir": {
  28414. "type": "string",
  28415. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  28416. },
  28417. "cache-dir": {
  28418. "type": "string",
  28419. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  28420. },
  28421. "cache-files-dir": {
  28422. "type": "string",
  28423. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  28424. },
  28425. "cache-repo-dir": {
  28426. "type": "string",
  28427. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  28428. },
  28429. "cache-vcs-dir": {
  28430. "type": "string",
  28431. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  28432. },
  28433. "cache-ttl": {
  28434. "type": "integer",
  28435. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  28436. },
  28437. "cache-files-ttl": {
  28438. "type": "integer",
  28439. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  28440. },
  28441. "cache-files-maxsize": {
  28442. "type": ["string", "integer"],
  28443. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  28444. },
  28445. "bin-compat": {
  28446. "enum": ["auto", "full"],
  28447. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)."
  28448. },
  28449. "discard-changes": {
  28450. "type": ["string", "boolean"],
  28451. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  28452. },
  28453. "autoloader-suffix": {
  28454. "type": "string",
  28455. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  28456. },
  28457. "optimize-autoloader": {
  28458. "type": "boolean",
  28459. "description": "Always optimize when dumping the autoloader."
  28460. },
  28461. "prepend-autoloader": {
  28462. "type": "boolean",
  28463. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  28464. },
  28465. "classmap-authoritative": {
  28466. "type": "boolean",
  28467. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  28468. },
  28469. "apcu-autoloader": {
  28470. "type": "boolean",
  28471. "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."
  28472. },
  28473. "github-domains": {
  28474. "type": "array",
  28475. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  28476. "items": {
  28477. "type": "string"
  28478. }
  28479. },
  28480. "github-expose-hostname": {
  28481. "type": "boolean",
  28482. "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."
  28483. },
  28484. "gitlab-domains": {
  28485. "type": "array",
  28486. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  28487. "items": {
  28488. "type": "string"
  28489. }
  28490. },
  28491. "archive-format": {
  28492. "type": "string",
  28493. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  28494. },
  28495. "archive-dir": {
  28496. "type": "string",
  28497. "description": "The default archive path when not provided on cli, defaults to \".\"."
  28498. },
  28499. "htaccess-protect": {
  28500. "type": "boolean",
  28501. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  28502. },
  28503. "sort-packages": {
  28504. "type": "boolean",
  28505. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  28506. }
  28507. }
  28508. },
  28509. "extra": {
  28510. "type": ["object", "array"],
  28511. "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.",
  28512. "additionalProperties": true
  28513. },
  28514. "autoload": {
  28515. "$ref": "#/definitions/autoload"
  28516. },
  28517. "autoload-dev": {
  28518. "type": "object",
  28519. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  28520. "properties": {
  28521. "psr-0": {
  28522. "type": "object",
  28523. "description": "This is a hash of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
  28524. "additionalProperties": {
  28525. "type": ["string", "array"],
  28526. "items": {
  28527. "type": "string"
  28528. }
  28529. }
  28530. },
  28531. "psr-4": {
  28532. "type": "object",
  28533. "description": "This is a hash of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  28534. "additionalProperties": {
  28535. "type": ["string", "array"],
  28536. "items": {
  28537. "type": "string"
  28538. }
  28539. }
  28540. },
  28541. "classmap": {
  28542. "type": "array",
  28543. "description": "This is an array of directories that contain classes to be included in the class-map generation process."
  28544. },
  28545. "files": {
  28546. "type": "array",
  28547. "description": "This is an array of files that are always required on every request."
  28548. }
  28549. }
  28550. },
  28551. "archive": {
  28552. "type": ["object"],
  28553. "description": "Options for creating package archives for distribution.",
  28554. "properties": {
  28555. "exclude": {
  28556. "type": "array",
  28557. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  28558. }
  28559. }
  28560. },
  28561. "repositories": {
  28562. "type": ["object", "array"],
  28563. "description": "A set of additional repositories where packages can be found.",
  28564. "additionalProperties": {
  28565. "oneOf": [
  28566. { "$ref": "#/definitions/repository" },
  28567. { "type": "boolean", "enum": [false] }
  28568. ]
  28569. },
  28570. "items": {
  28571. "oneOf": [
  28572. { "$ref": "#/definitions/repository" },
  28573. {
  28574. "type": "object",
  28575. "additionalProperties": { "type": "boolean", "enum": [false] },
  28576. "minProperties": 1,
  28577. "maxProperties": 1
  28578. }
  28579. ]
  28580. }
  28581. },
  28582. "minimum-stability": {
  28583. "type": ["string"],
  28584. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  28585. "pattern": "^dev|alpha|beta|rc|RC|stable$"
  28586. },
  28587. "prefer-stable": {
  28588. "type": ["boolean"],
  28589. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  28590. },
  28591. "bin": {
  28592. "type": ["string", "array"],
  28593. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  28594. "items": {
  28595. "type": "string"
  28596. }
  28597. },
  28598. "include-path": {
  28599. "type": ["array"],
  28600. "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.",
  28601. "items": {
  28602. "type": "string"
  28603. }
  28604. },
  28605. "scripts": {
  28606. "type": ["object"],
  28607. "description": "Script listeners that will be executed before/after some events.",
  28608. "properties": {
  28609. "pre-install-cmd": {
  28610. "type": ["array", "string"],
  28611. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  28612. },
  28613. "post-install-cmd": {
  28614. "type": ["array", "string"],
  28615. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  28616. },
  28617. "pre-update-cmd": {
  28618. "type": ["array", "string"],
  28619. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  28620. },
  28621. "post-update-cmd": {
  28622. "type": ["array", "string"],
  28623. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  28624. },
  28625. "pre-status-cmd": {
  28626. "type": ["array", "string"],
  28627. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  28628. },
  28629. "post-status-cmd": {
  28630. "type": ["array", "string"],
  28631. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  28632. },
  28633. "pre-package-install": {
  28634. "type": ["array", "string"],
  28635. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  28636. },
  28637. "post-package-install": {
  28638. "type": ["array", "string"],
  28639. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  28640. },
  28641. "pre-package-update": {
  28642. "type": ["array", "string"],
  28643. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  28644. },
  28645. "post-package-update": {
  28646. "type": ["array", "string"],
  28647. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  28648. },
  28649. "pre-package-uninstall": {
  28650. "type": ["array", "string"],
  28651. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  28652. },
  28653. "post-package-uninstall": {
  28654. "type": ["array", "string"],
  28655. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  28656. },
  28657. "pre-autoload-dump": {
  28658. "type": ["array", "string"],
  28659. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  28660. },
  28661. "post-autoload-dump": {
  28662. "type": ["array", "string"],
  28663. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  28664. },
  28665. "post-root-package-install": {
  28666. "type": ["array", "string"],
  28667. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  28668. },
  28669. "post-create-project-cmd": {
  28670. "type": ["array", "string"],
  28671. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  28672. }
  28673. }
  28674. },
  28675. "scripts-descriptions": {
  28676. "type": ["object"],
  28677. "description": "Descriptions for custom commands, shown in console help.",
  28678. "additionalProperties": {
  28679. "type": "string"
  28680. }
  28681. },
  28682. "support": {
  28683. "type": "object",
  28684. "properties": {
  28685. "email": {
  28686. "type": "string",
  28687. "description": "Email address for support.",
  28688. "format": "email"
  28689. },
  28690. "issues": {
  28691. "type": "string",
  28692. "description": "URL to the issue tracker.",
  28693. "format": "uri"
  28694. },
  28695. "forum": {
  28696. "type": "string",
  28697. "description": "URL to the forum.",
  28698. "format": "uri"
  28699. },
  28700. "wiki": {
  28701. "type": "string",
  28702. "description": "URL to the wiki.",
  28703. "format": "uri"
  28704. },
  28705. "irc": {
  28706. "type": "string",
  28707. "description": "IRC channel for support, as irc://server/channel.",
  28708. "format": "uri"
  28709. },
  28710. "chat": {
  28711. "type": "string",
  28712. "description": "URL to the support chat.",
  28713. "format": "uri"
  28714. },
  28715. "source": {
  28716. "type": "string",
  28717. "description": "URL to browse or download the sources.",
  28718. "format": "uri"
  28719. },
  28720. "docs": {
  28721. "type": "string",
  28722. "description": "URL to the documentation.",
  28723. "format": "uri"
  28724. },
  28725. "rss": {
  28726. "type": "string",
  28727. "description": "URL to the RSS feed.",
  28728. "format": "uri"
  28729. }
  28730. }
  28731. },
  28732. "non-feature-branches": {
  28733. "type": ["array"],
  28734. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  28735. "items": {
  28736. "type": "string"
  28737. }
  28738. },
  28739. "abandoned": {
  28740. "type": ["boolean", "string"],
  28741. "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."
  28742. },
  28743. "_comment": {
  28744. "type": ["array", "string"],
  28745. "description": "A key to store comments in"
  28746. }
  28747. },
  28748. "definitions": {
  28749. "authors": {
  28750. "type": "array",
  28751. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  28752. "items": {
  28753. "type": "object",
  28754. "additionalProperties": false,
  28755. "required": [ "name"],
  28756. "properties": {
  28757. "name": {
  28758. "type": "string",
  28759. "description": "Full name of the author."
  28760. },
  28761. "email": {
  28762. "type": "string",
  28763. "description": "Email address of the author.",
  28764. "format": "email"
  28765. },
  28766. "homepage": {
  28767. "type": "string",
  28768. "description": "Homepage URL for the author.",
  28769. "format": "uri"
  28770. },
  28771. "role": {
  28772. "type": "string",
  28773. "description": "Author's role in the project."
  28774. }
  28775. }
  28776. }
  28777. },
  28778. "autoload": {
  28779. "type": "object",
  28780. "description": "Description of how the package can be autoloaded.",
  28781. "properties": {
  28782. "psr-0": {
  28783. "type": "object",
  28784. "description": "This is a hash of namespaces (keys) and the directories they can be found in (values, can be arrays of paths) by the autoloader.",
  28785. "additionalProperties": {
  28786. "type": ["string", "array"],
  28787. "items": {
  28788. "type": "string"
  28789. }
  28790. }
  28791. },
  28792. "psr-4": {
  28793. "type": "object",
  28794. "description": "This is a hash of namespaces (keys) and the PSR-4 directories they can map to (values, can be arrays of paths) by the autoloader.",
  28795. "additionalProperties": {
  28796. "type": ["string", "array"],
  28797. "items": {
  28798. "type": "string"
  28799. }
  28800. }
  28801. },
  28802. "classmap": {
  28803. "type": "array",
  28804. "description": "This is an array of directories that contain classes to be included in the class-map generation process."
  28805. },
  28806. "files": {
  28807. "type": "array",
  28808. "description": "This is an array of files that are always required on every request."
  28809. },
  28810. "exclude-from-classmap": {
  28811. "type": "array",
  28812. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  28813. }
  28814. }
  28815. },
  28816. "repository": {
  28817. "type": "object",
  28818. "oneOf": [
  28819. { "$ref": "#/definitions/composer-repository" },
  28820. { "$ref": "#/definitions/vcs-repository" },
  28821. { "$ref": "#/definitions/path-repository" },
  28822. { "$ref": "#/definitions/artifact-repository" },
  28823. { "$ref": "#/definitions/pear-repository" },
  28824. { "$ref": "#/definitions/package-repository" }
  28825. ]
  28826. },
  28827. "composer-repository": {
  28828. "type": "object",
  28829. "required": ["type", "url"],
  28830. "properties": {
  28831. "type": { "type": "string", "enum": ["composer"] },
  28832. "url": { "type": "string" },
  28833. "options": {
  28834. "type": "object",
  28835. "additionalProperties": true
  28836. },
  28837. "allow_ssl_downgrade": { "type": "boolean" },
  28838. "force-lazy-providers": { "type": "boolean" }
  28839. }
  28840. },
  28841. "vcs-repository": {
  28842. "type": "object",
  28843. "required": ["type", "url"],
  28844. "properties": {
  28845. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] },
  28846. "url": { "type": "string" },
  28847. "no-api": { "type": "boolean" },
  28848. "secure-http": { "type": "boolean" },
  28849. "svn-cache-credentials": { "type": "boolean" },
  28850. "trunk-path": { "type": ["string", "boolean"] },
  28851. "branches-path": { "type": ["string", "boolean"] },
  28852. "tags-path": { "type": ["string", "boolean"] },
  28853. "package-path": { "type": "string" },
  28854. "depot": { "type": "string" },
  28855. "branch": { "type": "string" },
  28856. "unique_perforce_client_name": { "type": "string" },
  28857. "p4user": { "type": "string" },
  28858. "p4password": { "type": "string" }
  28859. }
  28860. },
  28861. "path-repository": {
  28862. "type": "object",
  28863. "required": ["type", "url"],
  28864. "properties": {
  28865. "type": { "type": "string", "enum": ["path"] },
  28866. "url": { "type": "string" },
  28867. "options": {
  28868. "type": "object",
  28869. "properties": {
  28870. "symlink": { "type": ["boolean", "null"] }
  28871. },
  28872. "additionalProperties": true
  28873. }
  28874. }
  28875. },
  28876. "artifact-repository": {
  28877. "type": "object",
  28878. "required": ["type", "url"],
  28879. "properties": {
  28880. "type": { "type": "string", "enum": ["artifact"] },
  28881. "url": { "type": "string" }
  28882. }
  28883. },
  28884. "pear-repository": {
  28885. "type": "object",
  28886. "required": ["type", "url"],
  28887. "properties": {
  28888. "type": { "type": "string", "enum": ["pear"] },
  28889. "url": { "type": "string" },
  28890. "vendor-alias": { "type": "string" }
  28891. }
  28892. },
  28893. "package-repository": {
  28894. "type": "object",
  28895. "required": ["type", "package"],
  28896. "properties": {
  28897. "type": { "type": "string", "enum": ["package"] },
  28898. "package": {
  28899. "oneOf": [
  28900. { "$ref": "#/definitions/inline-package" },
  28901. {
  28902. "type": "array",
  28903. "items": { "$ref": "#/definitions/inline-package" }
  28904. }
  28905. ]
  28906. }
  28907. }
  28908. },
  28909. "inline-package": {
  28910. "type": "object",
  28911. "required": ["name", "version"],
  28912. "properties": {
  28913. "name": {
  28914. "type": "string",
  28915. "description": "Package name, including 'vendor-name/' prefix."
  28916. },
  28917. "type": {
  28918. "type": "string"
  28919. },
  28920. "target-dir": {
  28921. "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.",
  28922. "type": "string"
  28923. },
  28924. "description": {
  28925. "type": "string"
  28926. },
  28927. "keywords": {
  28928. "type": "array",
  28929. "items": {
  28930. "type": "string"
  28931. }
  28932. },
  28933. "homepage": {
  28934. "type": "string",
  28935. "format": "uri"
  28936. },
  28937. "version": {
  28938. "type": "string"
  28939. },
  28940. "time": {
  28941. "type": "string"
  28942. },
  28943. "license": {
  28944. "type": [
  28945. "string",
  28946. "array"
  28947. ]
  28948. },
  28949. "authors": {
  28950. "$ref": "#/definitions/authors"
  28951. },
  28952. "require": {
  28953. "type": "object",
  28954. "additionalProperties": {
  28955. "type": "string"
  28956. }
  28957. },
  28958. "replace": {
  28959. "type": "object",
  28960. "additionalProperties": {
  28961. "type": "string"
  28962. }
  28963. },
  28964. "conflict": {
  28965. "type": "object",
  28966. "additionalProperties": {
  28967. "type": "string"
  28968. }
  28969. },
  28970. "provide": {
  28971. "type": "object",
  28972. "additionalProperties": {
  28973. "type": "string"
  28974. }
  28975. },
  28976. "require-dev": {
  28977. "type": "object",
  28978. "additionalProperties": {
  28979. "type": "string"
  28980. }
  28981. },
  28982. "suggest": {
  28983. "type": "object",
  28984. "additionalProperties": {
  28985. "type": "string"
  28986. }
  28987. },
  28988. "extra": {
  28989. "type": ["object", "array"],
  28990. "additionalProperties": true
  28991. },
  28992. "autoload": {
  28993. "$ref": "#/definitions/autoload"
  28994. },
  28995. "archive": {
  28996. "type": ["object"],
  28997. "properties": {
  28998. "exclude": {
  28999. "type": "array"
  29000. }
  29001. }
  29002. },
  29003. "bin": {
  29004. "type": ["string", "array"],
  29005. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  29006. "items": {
  29007. "type": "string"
  29008. }
  29009. },
  29010. "include-path": {
  29011. "type": ["array"],
  29012. "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.",
  29013. "items": {
  29014. "type": "string"
  29015. }
  29016. },
  29017. "source": {
  29018. "type": "object",
  29019. "required": ["type", "url", "reference"],
  29020. "properties": {
  29021. "type": {
  29022. "type": "string"
  29023. },
  29024. "url": {
  29025. "type": "string"
  29026. },
  29027. "reference": {
  29028. "type": "string"
  29029. },
  29030. "mirrors": {
  29031. "type": "array"
  29032. }
  29033. }
  29034. },
  29035. "dist": {
  29036. "type": "object",
  29037. "required": ["type", "url"],
  29038. "properties": {
  29039. "type": {
  29040. "type": "string"
  29041. },
  29042. "url": {
  29043. "type": "string"
  29044. },
  29045. "reference": {
  29046. "type": "string"
  29047. },
  29048. "shasum": {
  29049. "type": "string"
  29050. },
  29051. "mirrors": {
  29052. "type": "array"
  29053. }
  29054. }
  29055. }
  29056. },
  29057. "additionalProperties": true
  29058. }
  29059. }
  29060. }
  29061. {
  29062. "389-exception": [
  29063. "389 Directory Server Exception"
  29064. ],
  29065. "Autoconf-exception-2.0": [
  29066. "Autoconf exception 2.0"
  29067. ],
  29068. "Autoconf-exception-3.0": [
  29069. "Autoconf exception 3.0"
  29070. ],
  29071. "Bison-exception-2.2": [
  29072. "Bison exception 2.2"
  29073. ],
  29074. "Bootloader-exception": [
  29075. "Bootloader Distribution Exception"
  29076. ],
  29077. "Classpath-exception-2.0": [
  29078. "Classpath exception 2.0"
  29079. ],
  29080. "CLISP-exception-2.0": [
  29081. "CLISP exception 2.0"
  29082. ],
  29083. "DigiRule-FOSS-exception": [
  29084. "DigiRule FOSS License Exception"
  29085. ],
  29086. "eCos-exception-2.0": [
  29087. "eCos exception 2.0"
  29088. ],
  29089. "Fawkes-Runtime-exception": [
  29090. "Fawkes Runtime Exception"
  29091. ],
  29092. "FLTK-exception": [
  29093. "FLTK exception"
  29094. ],
  29095. "Font-exception-2.0": [
  29096. "Font exception 2.0"
  29097. ],
  29098. "freertos-exception-2.0": [
  29099. "FreeRTOS Exception 2.0"
  29100. ],
  29101. "GCC-exception-2.0": [
  29102. "GCC Runtime Library exception 2.0"
  29103. ],
  29104. "GCC-exception-3.1": [
  29105. "GCC Runtime Library exception 3.1"
  29106. ],
  29107. "gnu-javamail-exception": [
  29108. "GNU JavaMail exception"
  29109. ],
  29110. "i2p-gpl-java-exception": [
  29111. "i2p GPL+Java Exception"
  29112. ],
  29113. "Libtool-exception": [
  29114. "Libtool Exception"
  29115. ],
  29116. "Linux-syscall-note": [
  29117. "Linux Syscall Note"
  29118. ],
  29119. "LLVM-exception": [
  29120. "LLVM Exception"
  29121. ],
  29122. "LZMA-exception": [
  29123. "LZMA exception"
  29124. ],
  29125. "mif-exception": [
  29126. "Macros and Inline Functions Exception"
  29127. ],
  29128. "Nokia-Qt-exception-1.1": [
  29129. "Nokia Qt LGPL exception 1.1"
  29130. ],
  29131. "OCaml-LGPL-linking-exception": [
  29132. "OCaml LGPL Linking Exception"
  29133. ],
  29134. "OCCT-exception-1.0": [
  29135. "Open CASCADE Exception 1.0"
  29136. ],
  29137. "OpenJDK-assembly-exception-1.0": [
  29138. "OpenJDK Assembly exception 1.0"
  29139. ],
  29140. "openvpn-openssl-exception": [
  29141. "OpenVPN OpenSSL Exception"
  29142. ],
  29143. "PS-or-PDF-font-exception-20170817": [
  29144. "PS/PDF font exception (2017-08-17)"
  29145. ],
  29146. "Qt-GPL-exception-1.0": [
  29147. "Qt GPL exception 1.0"
  29148. ],
  29149. "Qt-LGPL-exception-1.1": [
  29150. "Qt LGPL exception 1.1"
  29151. ],
  29152. "Qwt-exception-1.0": [
  29153. "Qwt exception 1.0"
  29154. ],
  29155. "u-boot-exception-2.0": [
  29156. "U-Boot exception 2.0"
  29157. ],
  29158. "WxWindows-exception-3.1": [
  29159. "WxWindows Library Exception 3.1"
  29160. ]
  29161. }{
  29162. "0BSD": [
  29163. "BSD Zero Clause License",
  29164. false,
  29165. false
  29166. ],
  29167. "AAL": [
  29168. "Attribution Assurance License",
  29169. true,
  29170. false
  29171. ],
  29172. "Abstyles": [
  29173. "Abstyles License",
  29174. false,
  29175. false
  29176. ],
  29177. "Adobe-2006": [
  29178. "Adobe Systems Incorporated Source Code License Agreement",
  29179. false,
  29180. false
  29181. ],
  29182. "Adobe-Glyph": [
  29183. "Adobe Glyph List License",
  29184. false,
  29185. false
  29186. ],
  29187. "ADSL": [
  29188. "Amazon Digital Services License",
  29189. false,
  29190. false
  29191. ],
  29192. "AFL-1.1": [
  29193. "Academic Free License v1.1",
  29194. true,
  29195. false
  29196. ],
  29197. "AFL-1.2": [
  29198. "Academic Free License v1.2",
  29199. true,
  29200. false
  29201. ],
  29202. "AFL-2.0": [
  29203. "Academic Free License v2.0",
  29204. true,
  29205. false
  29206. ],
  29207. "AFL-2.1": [
  29208. "Academic Free License v2.1",
  29209. true,
  29210. false
  29211. ],
  29212. "AFL-3.0": [
  29213. "Academic Free License v3.0",
  29214. true,
  29215. false
  29216. ],
  29217. "Afmparse": [
  29218. "Afmparse License",
  29219. false,
  29220. false
  29221. ],
  29222. "AGPL-1.0": [
  29223. "Affero General Public License v1.0",
  29224. false,
  29225. true
  29226. ],
  29227. "AGPL-1.0-only": [
  29228. "Affero General Public License v1.0 only",
  29229. false,
  29230. false
  29231. ],
  29232. "AGPL-1.0-or-later": [
  29233. "Affero General Public License v1.0 or later",
  29234. false,
  29235. false
  29236. ],
  29237. "AGPL-3.0": [
  29238. "GNU Affero General Public License v3.0",
  29239. true,
  29240. true
  29241. ],
  29242. "AGPL-3.0-only": [
  29243. "GNU Affero General Public License v3.0 only",
  29244. true,
  29245. false
  29246. ],
  29247. "AGPL-3.0-or-later": [
  29248. "GNU Affero General Public License v3.0 or later",
  29249. true,
  29250. false
  29251. ],
  29252. "Aladdin": [
  29253. "Aladdin Free Public License",
  29254. false,
  29255. false
  29256. ],
  29257. "AMDPLPA": [
  29258. "AMD's plpa_map.c License",
  29259. false,
  29260. false
  29261. ],
  29262. "AML": [
  29263. "Apple MIT License",
  29264. false,
  29265. false
  29266. ],
  29267. "AMPAS": [
  29268. "Academy of Motion Picture Arts and Sciences BSD",
  29269. false,
  29270. false
  29271. ],
  29272. "ANTLR-PD": [
  29273. "ANTLR Software Rights Notice",
  29274. false,
  29275. false
  29276. ],
  29277. "Apache-1.0": [
  29278. "Apache License 1.0",
  29279. false,
  29280. false
  29281. ],
  29282. "Apache-1.1": [
  29283. "Apache License 1.1",
  29284. true,
  29285. false
  29286. ],
  29287. "Apache-2.0": [
  29288. "Apache License 2.0",
  29289. true,
  29290. false
  29291. ],
  29292. "APAFML": [
  29293. "Adobe Postscript AFM License",
  29294. false,
  29295. false
  29296. ],
  29297. "APL-1.0": [
  29298. "Adaptive Public License 1.0",
  29299. true,
  29300. false
  29301. ],
  29302. "APSL-1.0": [
  29303. "Apple Public Source License 1.0",
  29304. true,
  29305. false
  29306. ],
  29307. "APSL-1.1": [
  29308. "Apple Public Source License 1.1",
  29309. true,
  29310. false
  29311. ],
  29312. "APSL-1.2": [
  29313. "Apple Public Source License 1.2",
  29314. true,
  29315. false
  29316. ],
  29317. "APSL-2.0": [
  29318. "Apple Public Source License 2.0",
  29319. true,
  29320. false
  29321. ],
  29322. "Artistic-1.0": [
  29323. "Artistic License 1.0",
  29324. true,
  29325. false
  29326. ],
  29327. "Artistic-1.0-cl8": [
  29328. "Artistic License 1.0 w/clause 8",
  29329. true,
  29330. false
  29331. ],
  29332. "Artistic-1.0-Perl": [
  29333. "Artistic License 1.0 (Perl)",
  29334. true,
  29335. false
  29336. ],
  29337. "Artistic-2.0": [
  29338. "Artistic License 2.0",
  29339. true,
  29340. false
  29341. ],
  29342. "Bahyph": [
  29343. "Bahyph License",
  29344. false,
  29345. false
  29346. ],
  29347. "Barr": [
  29348. "Barr License",
  29349. false,
  29350. false
  29351. ],
  29352. "Beerware": [
  29353. "Beerware License",
  29354. false,
  29355. false
  29356. ],
  29357. "BitTorrent-1.0": [
  29358. "BitTorrent Open Source License v1.0",
  29359. false,
  29360. false
  29361. ],
  29362. "BitTorrent-1.1": [
  29363. "BitTorrent Open Source License v1.1",
  29364. false,
  29365. false
  29366. ],
  29367. "Borceux": [
  29368. "Borceux license",
  29369. false,
  29370. false
  29371. ],
  29372. "BSD-1-Clause": [
  29373. "BSD 1-Clause License",
  29374. false,
  29375. false
  29376. ],
  29377. "BSD-2-Clause": [
  29378. "BSD 2-Clause \"Simplified\" License",
  29379. true,
  29380. false
  29381. ],
  29382. "BSD-2-Clause-FreeBSD": [
  29383. "BSD 2-Clause FreeBSD License",
  29384. false,
  29385. false
  29386. ],
  29387. "BSD-2-Clause-NetBSD": [
  29388. "BSD 2-Clause NetBSD License",
  29389. false,
  29390. false
  29391. ],
  29392. "BSD-2-Clause-Patent": [
  29393. "BSD-2-Clause Plus Patent License",
  29394. true,
  29395. false
  29396. ],
  29397. "BSD-3-Clause": [
  29398. "BSD 3-Clause \"New\" or \"Revised\" License",
  29399. true,
  29400. false
  29401. ],
  29402. "BSD-3-Clause-Attribution": [
  29403. "BSD with attribution",
  29404. false,
  29405. false
  29406. ],
  29407. "BSD-3-Clause-Clear": [
  29408. "BSD 3-Clause Clear License",
  29409. false,
  29410. false
  29411. ],
  29412. "BSD-3-Clause-LBNL": [
  29413. "Lawrence Berkeley National Labs BSD variant license",
  29414. false,
  29415. false
  29416. ],
  29417. "BSD-3-Clause-No-Nuclear-License": [
  29418. "BSD 3-Clause No Nuclear License",
  29419. false,
  29420. false
  29421. ],
  29422. "BSD-3-Clause-No-Nuclear-License-2014": [
  29423. "BSD 3-Clause No Nuclear License 2014",
  29424. false,
  29425. false
  29426. ],
  29427. "BSD-3-Clause-No-Nuclear-Warranty": [
  29428. "BSD 3-Clause No Nuclear Warranty",
  29429. false,
  29430. false
  29431. ],
  29432. "BSD-4-Clause": [
  29433. "BSD 4-Clause \"Original\" or \"Old\" License",
  29434. false,
  29435. false
  29436. ],
  29437. "BSD-4-Clause-UC": [
  29438. "BSD-4-Clause (University of California-Specific)",
  29439. false,
  29440. false
  29441. ],
  29442. "BSD-Protection": [
  29443. "BSD Protection License",
  29444. false,
  29445. false
  29446. ],
  29447. "BSD-Source-Code": [
  29448. "BSD Source Code Attribution",
  29449. false,
  29450. false
  29451. ],
  29452. "BSL-1.0": [
  29453. "Boost Software License 1.0",
  29454. true,
  29455. false
  29456. ],
  29457. "bzip2-1.0.5": [
  29458. "bzip2 and libbzip2 License v1.0.5",
  29459. false,
  29460. false
  29461. ],
  29462. "bzip2-1.0.6": [
  29463. "bzip2 and libbzip2 License v1.0.6",
  29464. false,
  29465. false
  29466. ],
  29467. "Caldera": [
  29468. "Caldera License",
  29469. false,
  29470. false
  29471. ],
  29472. "CATOSL-1.1": [
  29473. "Computer Associates Trusted Open Source License 1.1",
  29474. true,
  29475. false
  29476. ],
  29477. "CC-BY-1.0": [
  29478. "Creative Commons Attribution 1.0 Generic",
  29479. false,
  29480. false
  29481. ],
  29482. "CC-BY-2.0": [
  29483. "Creative Commons Attribution 2.0 Generic",
  29484. false,
  29485. false
  29486. ],
  29487. "CC-BY-2.5": [
  29488. "Creative Commons Attribution 2.5 Generic",
  29489. false,
  29490. false
  29491. ],
  29492. "CC-BY-3.0": [
  29493. "Creative Commons Attribution 3.0 Unported",
  29494. false,
  29495. false
  29496. ],
  29497. "CC-BY-4.0": [
  29498. "Creative Commons Attribution 4.0 International",
  29499. false,
  29500. false
  29501. ],
  29502. "CC-BY-NC-1.0": [
  29503. "Creative Commons Attribution Non Commercial 1.0 Generic",
  29504. false,
  29505. false
  29506. ],
  29507. "CC-BY-NC-2.0": [
  29508. "Creative Commons Attribution Non Commercial 2.0 Generic",
  29509. false,
  29510. false
  29511. ],
  29512. "CC-BY-NC-2.5": [
  29513. "Creative Commons Attribution Non Commercial 2.5 Generic",
  29514. false,
  29515. false
  29516. ],
  29517. "CC-BY-NC-3.0": [
  29518. "Creative Commons Attribution Non Commercial 3.0 Unported",
  29519. false,
  29520. false
  29521. ],
  29522. "CC-BY-NC-4.0": [
  29523. "Creative Commons Attribution Non Commercial 4.0 International",
  29524. false,
  29525. false
  29526. ],
  29527. "CC-BY-NC-ND-1.0": [
  29528. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  29529. false,
  29530. false
  29531. ],
  29532. "CC-BY-NC-ND-2.0": [
  29533. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  29534. false,
  29535. false
  29536. ],
  29537. "CC-BY-NC-ND-2.5": [
  29538. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  29539. false,
  29540. false
  29541. ],
  29542. "CC-BY-NC-ND-3.0": [
  29543. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  29544. false,
  29545. false
  29546. ],
  29547. "CC-BY-NC-ND-4.0": [
  29548. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  29549. false,
  29550. false
  29551. ],
  29552. "CC-BY-NC-SA-1.0": [
  29553. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  29554. false,
  29555. false
  29556. ],
  29557. "CC-BY-NC-SA-2.0": [
  29558. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  29559. false,
  29560. false
  29561. ],
  29562. "CC-BY-NC-SA-2.5": [
  29563. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  29564. false,
  29565. false
  29566. ],
  29567. "CC-BY-NC-SA-3.0": [
  29568. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  29569. false,
  29570. false
  29571. ],
  29572. "CC-BY-NC-SA-4.0": [
  29573. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  29574. false,
  29575. false
  29576. ],
  29577. "CC-BY-ND-1.0": [
  29578. "Creative Commons Attribution No Derivatives 1.0 Generic",
  29579. false,
  29580. false
  29581. ],
  29582. "CC-BY-ND-2.0": [
  29583. "Creative Commons Attribution No Derivatives 2.0 Generic",
  29584. false,
  29585. false
  29586. ],
  29587. "CC-BY-ND-2.5": [
  29588. "Creative Commons Attribution No Derivatives 2.5 Generic",
  29589. false,
  29590. false
  29591. ],
  29592. "CC-BY-ND-3.0": [
  29593. "Creative Commons Attribution No Derivatives 3.0 Unported",
  29594. false,
  29595. false
  29596. ],
  29597. "CC-BY-ND-4.0": [
  29598. "Creative Commons Attribution No Derivatives 4.0 International",
  29599. false,
  29600. false
  29601. ],
  29602. "CC-BY-SA-1.0": [
  29603. "Creative Commons Attribution Share Alike 1.0 Generic",
  29604. false,
  29605. false
  29606. ],
  29607. "CC-BY-SA-2.0": [
  29608. "Creative Commons Attribution Share Alike 2.0 Generic",
  29609. false,
  29610. false
  29611. ],
  29612. "CC-BY-SA-2.5": [
  29613. "Creative Commons Attribution Share Alike 2.5 Generic",
  29614. false,
  29615. false
  29616. ],
  29617. "CC-BY-SA-3.0": [
  29618. "Creative Commons Attribution Share Alike 3.0 Unported",
  29619. false,
  29620. false
  29621. ],
  29622. "CC-BY-SA-4.0": [
  29623. "Creative Commons Attribution Share Alike 4.0 International",
  29624. false,
  29625. false
  29626. ],
  29627. "CC0-1.0": [
  29628. "Creative Commons Zero v1.0 Universal",
  29629. false,
  29630. false
  29631. ],
  29632. "CDDL-1.0": [
  29633. "Common Development and Distribution License 1.0",
  29634. true,
  29635. false
  29636. ],
  29637. "CDDL-1.1": [
  29638. "Common Development and Distribution License 1.1",
  29639. false,
  29640. false
  29641. ],
  29642. "CDLA-Permissive-1.0": [
  29643. "Community Data License Agreement Permissive 1.0",
  29644. false,
  29645. false
  29646. ],
  29647. "CDLA-Sharing-1.0": [
  29648. "Community Data License Agreement Sharing 1.0",
  29649. false,
  29650. false
  29651. ],
  29652. "CECILL-1.0": [
  29653. "CeCILL Free Software License Agreement v1.0",
  29654. false,
  29655. false
  29656. ],
  29657. "CECILL-1.1": [
  29658. "CeCILL Free Software License Agreement v1.1",
  29659. false,
  29660. false
  29661. ],
  29662. "CECILL-2.0": [
  29663. "CeCILL Free Software License Agreement v2.0",
  29664. false,
  29665. false
  29666. ],
  29667. "CECILL-2.1": [
  29668. "CeCILL Free Software License Agreement v2.1",
  29669. true,
  29670. false
  29671. ],
  29672. "CECILL-B": [
  29673. "CeCILL-B Free Software License Agreement",
  29674. false,
  29675. false
  29676. ],
  29677. "CECILL-C": [
  29678. "CeCILL-C Free Software License Agreement",
  29679. false,
  29680. false
  29681. ],
  29682. "ClArtistic": [
  29683. "Clarified Artistic License",
  29684. false,
  29685. false
  29686. ],
  29687. "CNRI-Jython": [
  29688. "CNRI Jython License",
  29689. false,
  29690. false
  29691. ],
  29692. "CNRI-Python": [
  29693. "CNRI Python License",
  29694. true,
  29695. false
  29696. ],
  29697. "CNRI-Python-GPL-Compatible": [
  29698. "CNRI Python Open Source GPL Compatible License Agreement",
  29699. false,
  29700. false
  29701. ],
  29702. "Condor-1.1": [
  29703. "Condor Public License v1.1",
  29704. false,
  29705. false
  29706. ],
  29707. "copyleft-next-0.3.1": [
  29708. "copyleft-next 0.3.1",
  29709. false,
  29710. false
  29711. ],
  29712. "CPAL-1.0": [
  29713. "Common Public Attribution License 1.0",
  29714. true,
  29715. false
  29716. ],
  29717. "CPL-1.0": [
  29718. "Common Public License 1.0",
  29719. true,
  29720. false
  29721. ],
  29722. "CPOL-1.02": [
  29723. "Code Project Open License 1.02",
  29724. false,
  29725. false
  29726. ],
  29727. "Crossword": [
  29728. "Crossword License",
  29729. false,
  29730. false
  29731. ],
  29732. "CrystalStacker": [
  29733. "CrystalStacker License",
  29734. false,
  29735. false
  29736. ],
  29737. "CUA-OPL-1.0": [
  29738. "CUA Office Public License v1.0",
  29739. true,
  29740. false
  29741. ],
  29742. "Cube": [
  29743. "Cube License",
  29744. false,
  29745. false
  29746. ],
  29747. "curl": [
  29748. "curl License",
  29749. false,
  29750. false
  29751. ],
  29752. "D-FSL-1.0": [
  29753. "Deutsche Freie Software Lizenz",
  29754. false,
  29755. false
  29756. ],
  29757. "diffmark": [
  29758. "diffmark license",
  29759. false,
  29760. false
  29761. ],
  29762. "DOC": [
  29763. "DOC License",
  29764. false,
  29765. false
  29766. ],
  29767. "Dotseqn": [
  29768. "Dotseqn License",
  29769. false,
  29770. false
  29771. ],
  29772. "DSDP": [
  29773. "DSDP License",
  29774. false,
  29775. false
  29776. ],
  29777. "dvipdfm": [
  29778. "dvipdfm License",
  29779. false,
  29780. false
  29781. ],
  29782. "ECL-1.0": [
  29783. "Educational Community License v1.0",
  29784. true,
  29785. false
  29786. ],
  29787. "ECL-2.0": [
  29788. "Educational Community License v2.0",
  29789. true,
  29790. false
  29791. ],
  29792. "eCos-2.0": [
  29793. "eCos license version 2.0",
  29794. false,
  29795. true
  29796. ],
  29797. "EFL-1.0": [
  29798. "Eiffel Forum License v1.0",
  29799. true,
  29800. false
  29801. ],
  29802. "EFL-2.0": [
  29803. "Eiffel Forum License v2.0",
  29804. true,
  29805. false
  29806. ],
  29807. "eGenix": [
  29808. "eGenix.com Public License 1.1.0",
  29809. false,
  29810. false
  29811. ],
  29812. "Entessa": [
  29813. "Entessa Public License v1.0",
  29814. true,
  29815. false
  29816. ],
  29817. "EPL-1.0": [
  29818. "Eclipse Public License 1.0",
  29819. true,
  29820. false
  29821. ],
  29822. "EPL-2.0": [
  29823. "Eclipse Public License 2.0",
  29824. true,
  29825. false
  29826. ],
  29827. "ErlPL-1.1": [
  29828. "Erlang Public License v1.1",
  29829. false,
  29830. false
  29831. ],
  29832. "EUDatagrid": [
  29833. "EU DataGrid Software License",
  29834. true,
  29835. false
  29836. ],
  29837. "EUPL-1.0": [
  29838. "European Union Public License 1.0",
  29839. false,
  29840. false
  29841. ],
  29842. "EUPL-1.1": [
  29843. "European Union Public License 1.1",
  29844. true,
  29845. false
  29846. ],
  29847. "EUPL-1.2": [
  29848. "European Union Public License 1.2",
  29849. true,
  29850. false
  29851. ],
  29852. "Eurosym": [
  29853. "Eurosym License",
  29854. false,
  29855. false
  29856. ],
  29857. "Fair": [
  29858. "Fair License",
  29859. true,
  29860. false
  29861. ],
  29862. "Frameworx-1.0": [
  29863. "Frameworx Open License 1.0",
  29864. true,
  29865. false
  29866. ],
  29867. "FreeImage": [
  29868. "FreeImage Public License v1.0",
  29869. false,
  29870. false
  29871. ],
  29872. "FSFAP": [
  29873. "FSF All Permissive License",
  29874. false,
  29875. false
  29876. ],
  29877. "FSFUL": [
  29878. "FSF Unlimited License",
  29879. false,
  29880. false
  29881. ],
  29882. "FSFULLR": [
  29883. "FSF Unlimited License (with License Retention)",
  29884. false,
  29885. false
  29886. ],
  29887. "FTL": [
  29888. "Freetype Project License",
  29889. false,
  29890. false
  29891. ],
  29892. "GFDL-1.1": [
  29893. "GNU Free Documentation License v1.1",
  29894. false,
  29895. true
  29896. ],
  29897. "GFDL-1.1-only": [
  29898. "GNU Free Documentation License v1.1 only",
  29899. false,
  29900. false
  29901. ],
  29902. "GFDL-1.1-or-later": [
  29903. "GNU Free Documentation License v1.1 or later",
  29904. false,
  29905. false
  29906. ],
  29907. "GFDL-1.2": [
  29908. "GNU Free Documentation License v1.2",
  29909. false,
  29910. true
  29911. ],
  29912. "GFDL-1.2-only": [
  29913. "GNU Free Documentation License v1.2 only",
  29914. false,
  29915. false
  29916. ],
  29917. "GFDL-1.2-or-later": [
  29918. "GNU Free Documentation License v1.2 or later",
  29919. false,
  29920. false
  29921. ],
  29922. "GFDL-1.3": [
  29923. "GNU Free Documentation License v1.3",
  29924. false,
  29925. true
  29926. ],
  29927. "GFDL-1.3-only": [
  29928. "GNU Free Documentation License v1.3 only",
  29929. false,
  29930. false
  29931. ],
  29932. "GFDL-1.3-or-later": [
  29933. "GNU Free Documentation License v1.3 or later",
  29934. false,
  29935. false
  29936. ],
  29937. "Giftware": [
  29938. "Giftware License",
  29939. false,
  29940. false
  29941. ],
  29942. "GL2PS": [
  29943. "GL2PS License",
  29944. false,
  29945. false
  29946. ],
  29947. "Glide": [
  29948. "3dfx Glide License",
  29949. false,
  29950. false
  29951. ],
  29952. "Glulxe": [
  29953. "Glulxe License",
  29954. false,
  29955. false
  29956. ],
  29957. "gnuplot": [
  29958. "gnuplot License",
  29959. false,
  29960. false
  29961. ],
  29962. "GPL-1.0": [
  29963. "GNU General Public License v1.0 only",
  29964. false,
  29965. true
  29966. ],
  29967. "GPL-1.0+": [
  29968. "GNU General Public License v1.0 or later",
  29969. false,
  29970. true
  29971. ],
  29972. "GPL-1.0-only": [
  29973. "GNU General Public License v1.0 only",
  29974. false,
  29975. false
  29976. ],
  29977. "GPL-1.0-or-later": [
  29978. "GNU General Public License v1.0 or later",
  29979. false,
  29980. false
  29981. ],
  29982. "GPL-2.0": [
  29983. "GNU General Public License v2.0 only",
  29984. true,
  29985. true
  29986. ],
  29987. "GPL-2.0+": [
  29988. "GNU General Public License v2.0 or later",
  29989. true,
  29990. true
  29991. ],
  29992. "GPL-2.0-only": [
  29993. "GNU General Public License v2.0 only",
  29994. true,
  29995. false
  29996. ],
  29997. "GPL-2.0-or-later": [
  29998. "GNU General Public License v2.0 or later",
  29999. true,
  30000. false
  30001. ],
  30002. "GPL-2.0-with-autoconf-exception": [
  30003. "GNU General Public License v2.0 w/Autoconf exception",
  30004. false,
  30005. true
  30006. ],
  30007. "GPL-2.0-with-bison-exception": [
  30008. "GNU General Public License v2.0 w/Bison exception",
  30009. false,
  30010. true
  30011. ],
  30012. "GPL-2.0-with-classpath-exception": [
  30013. "GNU General Public License v2.0 w/Classpath exception",
  30014. false,
  30015. true
  30016. ],
  30017. "GPL-2.0-with-font-exception": [
  30018. "GNU General Public License v2.0 w/Font exception",
  30019. false,
  30020. true
  30021. ],
  30022. "GPL-2.0-with-GCC-exception": [
  30023. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  30024. false,
  30025. true
  30026. ],
  30027. "GPL-3.0": [
  30028. "GNU General Public License v3.0 only",
  30029. true,
  30030. true
  30031. ],
  30032. "GPL-3.0+": [
  30033. "GNU General Public License v3.0 or later",
  30034. true,
  30035. true
  30036. ],
  30037. "GPL-3.0-only": [
  30038. "GNU General Public License v3.0 only",
  30039. true,
  30040. false
  30041. ],
  30042. "GPL-3.0-or-later": [
  30043. "GNU General Public License v3.0 or later",
  30044. true,
  30045. false
  30046. ],
  30047. "GPL-3.0-with-autoconf-exception": [
  30048. "GNU General Public License v3.0 w/Autoconf exception",
  30049. false,
  30050. true
  30051. ],
  30052. "GPL-3.0-with-GCC-exception": [
  30053. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  30054. true,
  30055. true
  30056. ],
  30057. "gSOAP-1.3b": [
  30058. "gSOAP Public License v1.3b",
  30059. false,
  30060. false
  30061. ],
  30062. "HaskellReport": [
  30063. "Haskell Language Report License",
  30064. false,
  30065. false
  30066. ],
  30067. "HPND": [
  30068. "Historical Permission Notice and Disclaimer",
  30069. true,
  30070. false
  30071. ],
  30072. "IBM-pibs": [
  30073. "IBM PowerPC Initialization and Boot Software",
  30074. false,
  30075. false
  30076. ],
  30077. "ICU": [
  30078. "ICU License",
  30079. false,
  30080. false
  30081. ],
  30082. "IJG": [
  30083. "Independent JPEG Group License",
  30084. false,
  30085. false
  30086. ],
  30087. "ImageMagick": [
  30088. "ImageMagick License",
  30089. false,
  30090. false
  30091. ],
  30092. "iMatix": [
  30093. "iMatix Standard Function Library Agreement",
  30094. false,
  30095. false
  30096. ],
  30097. "Imlib2": [
  30098. "Imlib2 License",
  30099. false,
  30100. false
  30101. ],
  30102. "Info-ZIP": [
  30103. "Info-ZIP License",
  30104. false,
  30105. false
  30106. ],
  30107. "Intel": [
  30108. "Intel Open Source License",
  30109. true,
  30110. false
  30111. ],
  30112. "Intel-ACPI": [
  30113. "Intel ACPI Software License Agreement",
  30114. false,
  30115. false
  30116. ],
  30117. "Interbase-1.0": [
  30118. "Interbase Public License v1.0",
  30119. false,
  30120. false
  30121. ],
  30122. "IPA": [
  30123. "IPA Font License",
  30124. true,
  30125. false
  30126. ],
  30127. "IPL-1.0": [
  30128. "IBM Public License v1.0",
  30129. true,
  30130. false
  30131. ],
  30132. "ISC": [
  30133. "ISC License",
  30134. true,
  30135. false
  30136. ],
  30137. "JasPer-2.0": [
  30138. "JasPer License",
  30139. false,
  30140. false
  30141. ],
  30142. "JSON": [
  30143. "JSON License",
  30144. false,
  30145. false
  30146. ],
  30147. "LAL-1.2": [
  30148. "Licence Art Libre 1.2",
  30149. false,
  30150. false
  30151. ],
  30152. "LAL-1.3": [
  30153. "Licence Art Libre 1.3",
  30154. false,
  30155. false
  30156. ],
  30157. "Latex2e": [
  30158. "Latex2e License",
  30159. false,
  30160. false
  30161. ],
  30162. "Leptonica": [
  30163. "Leptonica License",
  30164. false,
  30165. false
  30166. ],
  30167. "LGPL-2.0": [
  30168. "GNU Library General Public License v2 only",
  30169. true,
  30170. true
  30171. ],
  30172. "LGPL-2.0+": [
  30173. "GNU Library General Public License v2 or later",
  30174. true,
  30175. true
  30176. ],
  30177. "LGPL-2.0-only": [
  30178. "GNU Library General Public License v2 only",
  30179. true,
  30180. false
  30181. ],
  30182. "LGPL-2.0-or-later": [
  30183. "GNU Library General Public License v2 or later",
  30184. true,
  30185. false
  30186. ],
  30187. "LGPL-2.1": [
  30188. "GNU Lesser General Public License v2.1 only",
  30189. true,
  30190. true
  30191. ],
  30192. "LGPL-2.1+": [
  30193. "GNU Library General Public License v2.1 or later",
  30194. true,
  30195. true
  30196. ],
  30197. "LGPL-2.1-only": [
  30198. "GNU Lesser General Public License v2.1 only",
  30199. true,
  30200. false
  30201. ],
  30202. "LGPL-2.1-or-later": [
  30203. "GNU Lesser General Public License v2.1 or later",
  30204. true,
  30205. false
  30206. ],
  30207. "LGPL-3.0": [
  30208. "GNU Lesser General Public License v3.0 only",
  30209. true,
  30210. true
  30211. ],
  30212. "LGPL-3.0+": [
  30213. "GNU Lesser General Public License v3.0 or later",
  30214. true,
  30215. true
  30216. ],
  30217. "LGPL-3.0-only": [
  30218. "GNU Lesser General Public License v3.0 only",
  30219. true,
  30220. false
  30221. ],
  30222. "LGPL-3.0-or-later": [
  30223. "GNU Lesser General Public License v3.0 or later",
  30224. true,
  30225. false
  30226. ],
  30227. "LGPLLR": [
  30228. "Lesser General Public License For Linguistic Resources",
  30229. false,
  30230. false
  30231. ],
  30232. "Libpng": [
  30233. "libpng License",
  30234. false,
  30235. false
  30236. ],
  30237. "libtiff": [
  30238. "libtiff License",
  30239. false,
  30240. false
  30241. ],
  30242. "LiLiQ-P-1.1": [
  30243. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  30244. true,
  30245. false
  30246. ],
  30247. "LiLiQ-R-1.1": [
  30248. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  30249. true,
  30250. false
  30251. ],
  30252. "LiLiQ-Rplus-1.1": [
  30253. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  30254. true,
  30255. false
  30256. ],
  30257. "Linux-OpenIB": [
  30258. "Linux Kernel Variant of OpenIB.org license",
  30259. false,
  30260. false
  30261. ],
  30262. "LPL-1.0": [
  30263. "Lucent Public License Version 1.0",
  30264. true,
  30265. false
  30266. ],
  30267. "LPL-1.02": [
  30268. "Lucent Public License v1.02",
  30269. true,
  30270. false
  30271. ],
  30272. "LPPL-1.0": [
  30273. "LaTeX Project Public License v1.0",
  30274. false,
  30275. false
  30276. ],
  30277. "LPPL-1.1": [
  30278. "LaTeX Project Public License v1.1",
  30279. false,
  30280. false
  30281. ],
  30282. "LPPL-1.2": [
  30283. "LaTeX Project Public License v1.2",
  30284. false,
  30285. false
  30286. ],
  30287. "LPPL-1.3a": [
  30288. "LaTeX Project Public License v1.3a",
  30289. false,
  30290. false
  30291. ],
  30292. "LPPL-1.3c": [
  30293. "LaTeX Project Public License v1.3c",
  30294. true,
  30295. false
  30296. ],
  30297. "MakeIndex": [
  30298. "MakeIndex License",
  30299. false,
  30300. false
  30301. ],
  30302. "MirOS": [
  30303. "MirOS License",
  30304. true,
  30305. false
  30306. ],
  30307. "MIT": [
  30308. "MIT License",
  30309. true,
  30310. false
  30311. ],
  30312. "MIT-0": [
  30313. "MIT No Attribution",
  30314. true,
  30315. false
  30316. ],
  30317. "MIT-advertising": [
  30318. "Enlightenment License (e16)",
  30319. false,
  30320. false
  30321. ],
  30322. "MIT-CMU": [
  30323. "CMU License",
  30324. false,
  30325. false
  30326. ],
  30327. "MIT-enna": [
  30328. "enna License",
  30329. false,
  30330. false
  30331. ],
  30332. "MIT-feh": [
  30333. "feh License",
  30334. false,
  30335. false
  30336. ],
  30337. "MITNFA": [
  30338. "MIT +no-false-attribs license",
  30339. false,
  30340. false
  30341. ],
  30342. "Motosoto": [
  30343. "Motosoto License",
  30344. true,
  30345. false
  30346. ],
  30347. "mpich2": [
  30348. "mpich2 License",
  30349. false,
  30350. false
  30351. ],
  30352. "MPL-1.0": [
  30353. "Mozilla Public License 1.0",
  30354. true,
  30355. false
  30356. ],
  30357. "MPL-1.1": [
  30358. "Mozilla Public License 1.1",
  30359. true,
  30360. false
  30361. ],
  30362. "MPL-2.0": [
  30363. "Mozilla Public License 2.0",
  30364. true,
  30365. false
  30366. ],
  30367. "MPL-2.0-no-copyleft-exception": [
  30368. "Mozilla Public License 2.0 (no copyleft exception)",
  30369. true,
  30370. false
  30371. ],
  30372. "MS-PL": [
  30373. "Microsoft Public License",
  30374. true,
  30375. false
  30376. ],
  30377. "MS-RL": [
  30378. "Microsoft Reciprocal License",
  30379. true,
  30380. false
  30381. ],
  30382. "MTLL": [
  30383. "Matrix Template Library License",
  30384. false,
  30385. false
  30386. ],
  30387. "Multics": [
  30388. "Multics License",
  30389. true,
  30390. false
  30391. ],
  30392. "Mup": [
  30393. "Mup License",
  30394. false,
  30395. false
  30396. ],
  30397. "NASA-1.3": [
  30398. "NASA Open Source Agreement 1.3",
  30399. true,
  30400. false
  30401. ],
  30402. "Naumen": [
  30403. "Naumen Public License",
  30404. true,
  30405. false
  30406. ],
  30407. "NBPL-1.0": [
  30408. "Net Boolean Public License v1",
  30409. false,
  30410. false
  30411. ],
  30412. "NCSA": [
  30413. "University of Illinois/NCSA Open Source License",
  30414. true,
  30415. false
  30416. ],
  30417. "Net-SNMP": [
  30418. "Net-SNMP License",
  30419. false,
  30420. false
  30421. ],
  30422. "NetCDF": [
  30423. "NetCDF license",
  30424. false,
  30425. false
  30426. ],
  30427. "Newsletr": [
  30428. "Newsletr License",
  30429. false,
  30430. false
  30431. ],
  30432. "NGPL": [
  30433. "Nethack General Public License",
  30434. true,
  30435. false
  30436. ],
  30437. "NLOD-1.0": [
  30438. "Norwegian Licence for Open Government Data",
  30439. false,
  30440. false
  30441. ],
  30442. "NLPL": [
  30443. "No Limit Public License",
  30444. false,
  30445. false
  30446. ],
  30447. "Nokia": [
  30448. "Nokia Open Source License",
  30449. true,
  30450. false
  30451. ],
  30452. "NOSL": [
  30453. "Netizen Open Source License",
  30454. false,
  30455. false
  30456. ],
  30457. "Noweb": [
  30458. "Noweb License",
  30459. false,
  30460. false
  30461. ],
  30462. "NPL-1.0": [
  30463. "Netscape Public License v1.0",
  30464. false,
  30465. false
  30466. ],
  30467. "NPL-1.1": [
  30468. "Netscape Public License v1.1",
  30469. false,
  30470. false
  30471. ],
  30472. "NPOSL-3.0": [
  30473. "Non-Profit Open Software License 3.0",
  30474. true,
  30475. false
  30476. ],
  30477. "NRL": [
  30478. "NRL License",
  30479. false,
  30480. false
  30481. ],
  30482. "NTP": [
  30483. "NTP License",
  30484. true,
  30485. false
  30486. ],
  30487. "Nunit": [
  30488. "Nunit License",
  30489. false,
  30490. true
  30491. ],
  30492. "OCCT-PL": [
  30493. "Open CASCADE Technology Public License",
  30494. false,
  30495. false
  30496. ],
  30497. "OCLC-2.0": [
  30498. "OCLC Research Public License 2.0",
  30499. true,
  30500. false
  30501. ],
  30502. "ODbL-1.0": [
  30503. "ODC Open Database License v1.0",
  30504. false,
  30505. false
  30506. ],
  30507. "ODC-By-1.0": [
  30508. "Open Data Commons Attribution License v1.0",
  30509. false,
  30510. false
  30511. ],
  30512. "OFL-1.0": [
  30513. "SIL Open Font License 1.0",
  30514. false,
  30515. false
  30516. ],
  30517. "OFL-1.1": [
  30518. "SIL Open Font License 1.1",
  30519. true,
  30520. false
  30521. ],
  30522. "OGL-UK-1.0": [
  30523. "Open Government Licence v1.0",
  30524. false,
  30525. false
  30526. ],
  30527. "OGL-UK-2.0": [
  30528. "Open Government Licence v2.0",
  30529. false,
  30530. false
  30531. ],
  30532. "OGL-UK-3.0": [
  30533. "Open Government Licence v3.0",
  30534. false,
  30535. false
  30536. ],
  30537. "OGTSL": [
  30538. "Open Group Test Suite License",
  30539. true,
  30540. false
  30541. ],
  30542. "OLDAP-1.1": [
  30543. "Open LDAP Public License v1.1",
  30544. false,
  30545. false
  30546. ],
  30547. "OLDAP-1.2": [
  30548. "Open LDAP Public License v1.2",
  30549. false,
  30550. false
  30551. ],
  30552. "OLDAP-1.3": [
  30553. "Open LDAP Public License v1.3",
  30554. false,
  30555. false
  30556. ],
  30557. "OLDAP-1.4": [
  30558. "Open LDAP Public License v1.4",
  30559. false,
  30560. false
  30561. ],
  30562. "OLDAP-2.0": [
  30563. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  30564. false,
  30565. false
  30566. ],
  30567. "OLDAP-2.0.1": [
  30568. "Open LDAP Public License v2.0.1",
  30569. false,
  30570. false
  30571. ],
  30572. "OLDAP-2.1": [
  30573. "Open LDAP Public License v2.1",
  30574. false,
  30575. false
  30576. ],
  30577. "OLDAP-2.2": [
  30578. "Open LDAP Public License v2.2",
  30579. false,
  30580. false
  30581. ],
  30582. "OLDAP-2.2.1": [
  30583. "Open LDAP Public License v2.2.1",
  30584. false,
  30585. false
  30586. ],
  30587. "OLDAP-2.2.2": [
  30588. "Open LDAP Public License 2.2.2",
  30589. false,
  30590. false
  30591. ],
  30592. "OLDAP-2.3": [
  30593. "Open LDAP Public License v2.3",
  30594. false,
  30595. false
  30596. ],
  30597. "OLDAP-2.4": [
  30598. "Open LDAP Public License v2.4",
  30599. false,
  30600. false
  30601. ],
  30602. "OLDAP-2.5": [
  30603. "Open LDAP Public License v2.5",
  30604. false,
  30605. false
  30606. ],
  30607. "OLDAP-2.6": [
  30608. "Open LDAP Public License v2.6",
  30609. false,
  30610. false
  30611. ],
  30612. "OLDAP-2.7": [
  30613. "Open LDAP Public License v2.7",
  30614. false,
  30615. false
  30616. ],
  30617. "OLDAP-2.8": [
  30618. "Open LDAP Public License v2.8",
  30619. false,
  30620. false
  30621. ],
  30622. "OML": [
  30623. "Open Market License",
  30624. false,
  30625. false
  30626. ],
  30627. "OpenSSL": [
  30628. "OpenSSL License",
  30629. false,
  30630. false
  30631. ],
  30632. "OPL-1.0": [
  30633. "Open Public License v1.0",
  30634. false,
  30635. false
  30636. ],
  30637. "OSET-PL-2.1": [
  30638. "OSET Public License version 2.1",
  30639. true,
  30640. false
  30641. ],
  30642. "OSL-1.0": [
  30643. "Open Software License 1.0",
  30644. true,
  30645. false
  30646. ],
  30647. "OSL-1.1": [
  30648. "Open Software License 1.1",
  30649. false,
  30650. false
  30651. ],
  30652. "OSL-2.0": [
  30653. "Open Software License 2.0",
  30654. true,
  30655. false
  30656. ],
  30657. "OSL-2.1": [
  30658. "Open Software License 2.1",
  30659. true,
  30660. false
  30661. ],
  30662. "OSL-3.0": [
  30663. "Open Software License 3.0",
  30664. true,
  30665. false
  30666. ],
  30667. "PDDL-1.0": [
  30668. "ODC Public Domain Dedication & License 1.0",
  30669. false,
  30670. false
  30671. ],
  30672. "PHP-3.0": [
  30673. "PHP License v3.0",
  30674. true,
  30675. false
  30676. ],
  30677. "PHP-3.01": [
  30678. "PHP License v3.01",
  30679. false,
  30680. false
  30681. ],
  30682. "Plexus": [
  30683. "Plexus Classworlds License",
  30684. false,
  30685. false
  30686. ],
  30687. "PostgreSQL": [
  30688. "PostgreSQL License",
  30689. true,
  30690. false
  30691. ],
  30692. "psfrag": [
  30693. "psfrag License",
  30694. false,
  30695. false
  30696. ],
  30697. "psutils": [
  30698. "psutils License",
  30699. false,
  30700. false
  30701. ],
  30702. "Python-2.0": [
  30703. "Python License 2.0",
  30704. true,
  30705. false
  30706. ],
  30707. "Qhull": [
  30708. "Qhull License",
  30709. false,
  30710. false
  30711. ],
  30712. "QPL-1.0": [
  30713. "Q Public License 1.0",
  30714. true,
  30715. false
  30716. ],
  30717. "Rdisc": [
  30718. "Rdisc License",
  30719. false,
  30720. false
  30721. ],
  30722. "RHeCos-1.1": [
  30723. "Red Hat eCos Public License v1.1",
  30724. false,
  30725. false
  30726. ],
  30727. "RPL-1.1": [
  30728. "Reciprocal Public License 1.1",
  30729. true,
  30730. false
  30731. ],
  30732. "RPL-1.5": [
  30733. "Reciprocal Public License 1.5",
  30734. true,
  30735. false
  30736. ],
  30737. "RPSL-1.0": [
  30738. "RealNetworks Public Source License v1.0",
  30739. true,
  30740. false
  30741. ],
  30742. "RSA-MD": [
  30743. "RSA Message-Digest License",
  30744. false,
  30745. false
  30746. ],
  30747. "RSCPL": [
  30748. "Ricoh Source Code Public License",
  30749. true,
  30750. false
  30751. ],
  30752. "Ruby": [
  30753. "Ruby License",
  30754. false,
  30755. false
  30756. ],
  30757. "SAX-PD": [
  30758. "Sax Public Domain Notice",
  30759. false,
  30760. false
  30761. ],
  30762. "Saxpath": [
  30763. "Saxpath License",
  30764. false,
  30765. false
  30766. ],
  30767. "SCEA": [
  30768. "SCEA Shared Source License",
  30769. false,
  30770. false
  30771. ],
  30772. "Sendmail": [
  30773. "Sendmail License",
  30774. false,
  30775. false
  30776. ],
  30777. "Sendmail-8.23": [
  30778. "Sendmail License 8.23",
  30779. false,
  30780. false
  30781. ],
  30782. "SGI-B-1.0": [
  30783. "SGI Free Software License B v1.0",
  30784. false,
  30785. false
  30786. ],
  30787. "SGI-B-1.1": [
  30788. "SGI Free Software License B v1.1",
  30789. false,
  30790. false
  30791. ],
  30792. "SGI-B-2.0": [
  30793. "SGI Free Software License B v2.0",
  30794. false,
  30795. false
  30796. ],
  30797. "SimPL-2.0": [
  30798. "Simple Public License 2.0",
  30799. true,
  30800. false
  30801. ],
  30802. "SISSL": [
  30803. "Sun Industry Standards Source License v1.1",
  30804. true,
  30805. false
  30806. ],
  30807. "SISSL-1.2": [
  30808. "Sun Industry Standards Source License v1.2",
  30809. false,
  30810. false
  30811. ],
  30812. "Sleepycat": [
  30813. "Sleepycat License",
  30814. true,
  30815. false
  30816. ],
  30817. "SMLNJ": [
  30818. "Standard ML of New Jersey License",
  30819. false,
  30820. false
  30821. ],
  30822. "SMPPL": [
  30823. "Secure Messaging Protocol Public License",
  30824. false,
  30825. false
  30826. ],
  30827. "SNIA": [
  30828. "SNIA Public License 1.1",
  30829. false,
  30830. false
  30831. ],
  30832. "Spencer-86": [
  30833. "Spencer License 86",
  30834. false,
  30835. false
  30836. ],
  30837. "Spencer-94": [
  30838. "Spencer License 94",
  30839. false,
  30840. false
  30841. ],
  30842. "Spencer-99": [
  30843. "Spencer License 99",
  30844. false,
  30845. false
  30846. ],
  30847. "SPL-1.0": [
  30848. "Sun Public License v1.0",
  30849. true,
  30850. false
  30851. ],
  30852. "StandardML-NJ": [
  30853. "Standard ML of New Jersey License",
  30854. false,
  30855. true
  30856. ],
  30857. "SugarCRM-1.1.3": [
  30858. "SugarCRM Public License v1.1.3",
  30859. false,
  30860. false
  30861. ],
  30862. "SWL": [
  30863. "Scheme Widget Library (SWL) Software License Agreement",
  30864. false,
  30865. false
  30866. ],
  30867. "TCL": [
  30868. "TCL/TK License",
  30869. false,
  30870. false
  30871. ],
  30872. "TCP-wrappers": [
  30873. "TCP Wrappers License",
  30874. false,
  30875. false
  30876. ],
  30877. "TMate": [
  30878. "TMate Open Source License",
  30879. false,
  30880. false
  30881. ],
  30882. "TORQUE-1.1": [
  30883. "TORQUE v2.5+ Software License v1.1",
  30884. false,
  30885. false
  30886. ],
  30887. "TOSL": [
  30888. "Trusster Open Source License",
  30889. false,
  30890. false
  30891. ],
  30892. "TU-Berlin-1.0": [
  30893. "Technische Universitaet Berlin License 1.0",
  30894. false,
  30895. false
  30896. ],
  30897. "TU-Berlin-2.0": [
  30898. "Technische Universitaet Berlin License 2.0",
  30899. false,
  30900. false
  30901. ],
  30902. "Unicode-DFS-2015": [
  30903. "Unicode License Agreement - Data Files and Software (2015)",
  30904. false,
  30905. false
  30906. ],
  30907. "Unicode-DFS-2016": [
  30908. "Unicode License Agreement - Data Files and Software (2016)",
  30909. false,
  30910. false
  30911. ],
  30912. "Unicode-TOU": [
  30913. "Unicode Terms of Use",
  30914. false,
  30915. false
  30916. ],
  30917. "Unlicense": [
  30918. "The Unlicense",
  30919. false,
  30920. false
  30921. ],
  30922. "UPL-1.0": [
  30923. "Universal Permissive License v1.0",
  30924. true,
  30925. false
  30926. ],
  30927. "Vim": [
  30928. "Vim License",
  30929. false,
  30930. false
  30931. ],
  30932. "VOSTROM": [
  30933. "VOSTROM Public License for Open Source",
  30934. false,
  30935. false
  30936. ],
  30937. "VSL-1.0": [
  30938. "Vovida Software License v1.0",
  30939. true,
  30940. false
  30941. ],
  30942. "W3C": [
  30943. "W3C Software Notice and License (2002-12-31)",
  30944. true,
  30945. false
  30946. ],
  30947. "W3C-19980720": [
  30948. "W3C Software Notice and License (1998-07-20)",
  30949. false,
  30950. false
  30951. ],
  30952. "W3C-20150513": [
  30953. "W3C Software Notice and Document License (2015-05-13)",
  30954. false,
  30955. false
  30956. ],
  30957. "Watcom-1.0": [
  30958. "Sybase Open Watcom Public License 1.0",
  30959. true,
  30960. false
  30961. ],
  30962. "Wsuipa": [
  30963. "Wsuipa License",
  30964. false,
  30965. false
  30966. ],
  30967. "WTFPL": [
  30968. "Do What The F*ck You Want To Public License",
  30969. false,
  30970. false
  30971. ],
  30972. "wxWindows": [
  30973. "wxWindows Library License",
  30974. false,
  30975. true
  30976. ],
  30977. "X11": [
  30978. "X11 License",
  30979. false,
  30980. false
  30981. ],
  30982. "Xerox": [
  30983. "Xerox License",
  30984. false,
  30985. false
  30986. ],
  30987. "XFree86-1.1": [
  30988. "XFree86 License 1.1",
  30989. false,
  30990. false
  30991. ],
  30992. "xinetd": [
  30993. "xinetd License",
  30994. false,
  30995. false
  30996. ],
  30997. "Xnet": [
  30998. "X.Net License",
  30999. true,
  31000. false
  31001. ],
  31002. "xpp": [
  31003. "XPP License",
  31004. false,
  31005. false
  31006. ],
  31007. "XSkat": [
  31008. "XSkat License",
  31009. false,
  31010. false
  31011. ],
  31012. "YPL-1.0": [
  31013. "Yahoo! Public License v1.0",
  31014. false,
  31015. false
  31016. ],
  31017. "YPL-1.1": [
  31018. "Yahoo! Public License v1.1",
  31019. false,
  31020. false
  31021. ],
  31022. "Zed": [
  31023. "Zed License",
  31024. false,
  31025. false
  31026. ],
  31027. "Zend-2.0": [
  31028. "Zend License v2.0",
  31029. false,
  31030. false
  31031. ],
  31032. "Zimbra-1.3": [
  31033. "Zimbra Public License v1.3",
  31034. false,
  31035. false
  31036. ],
  31037. "Zimbra-1.4": [
  31038. "Zimbra Public License v1.4",
  31039. false,
  31040. false
  31041. ],
  31042. "Zlib": [
  31043. "zlib License",
  31044. true,
  31045. false
  31046. ],
  31047. "zlib-acknowledgement": [
  31048. "zlib/libpng License with Acknowledgement",
  31049. false,
  31050. false
  31051. ],
  31052. "ZPL-1.1": [
  31053. "Zope Public License 1.1",
  31054. false,
  31055. false
  31056. ],
  31057. "ZPL-2.0": [
  31058. "Zope Public License 2.0",
  31059. true,
  31060. false
  31061. ],
  31062. "ZPL-2.1": [
  31063. "Zope Public License 2.1",
  31064. false,
  31065. false
  31066. ]
  31067. }MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  31068. $�������Æ,Í;§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��������à�  ��
  31069. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  31070. ����������������� ��`.rdata����� ���
  31071. �����������������@��@.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
  31072. 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
  31073. 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
  31074. 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">
  31075. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  31076. <security>
  31077. <requestedPrivileges>
  31078. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  31079. </requestedPrivileges>
  31080. </security>
  31081. </trustInfo>
  31082. <dependency>
  31083. <dependentAssembly>
  31084. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  31085. </dependentAssembly>
  31086. </dependency>
  31087. </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
  31088. namespace Symfony\Component\Console;
  31089. use Symfony\Component\Console\Command\Command;
  31090. use Symfony\Component\Console\Command\HelpCommand;
  31091. use Symfony\Component\Console\Command\ListCommand;
  31092. use Symfony\Component\Console\Descriptor\TextDescriptor;
  31093. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  31094. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  31095. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  31096. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  31097. use Symfony\Component\Console\Exception\CommandNotFoundException;
  31098. use Symfony\Component\Console\Exception\ExceptionInterface;
  31099. use Symfony\Component\Console\Exception\LogicException;
  31100. use Symfony\Component\Console\Formatter\OutputFormatter;
  31101. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  31102. use Symfony\Component\Console\Helper\DialogHelper;
  31103. use Symfony\Component\Console\Helper\FormatterHelper;
  31104. use Symfony\Component\Console\Helper\Helper;
  31105. use Symfony\Component\Console\Helper\HelperSet;
  31106. use Symfony\Component\Console\Helper\ProcessHelper;
  31107. use Symfony\Component\Console\Helper\ProgressHelper;
  31108. use Symfony\Component\Console\Helper\QuestionHelper;
  31109. use Symfony\Component\Console\Helper\TableHelper;
  31110. use Symfony\Component\Console\Input\ArgvInput;
  31111. use Symfony\Component\Console\Input\ArrayInput;
  31112. use Symfony\Component\Console\Input\InputArgument;
  31113. use Symfony\Component\Console\Input\InputAwareInterface;
  31114. use Symfony\Component\Console\Input\InputDefinition;
  31115. use Symfony\Component\Console\Input\InputInterface;
  31116. use Symfony\Component\Console\Input\InputOption;
  31117. use Symfony\Component\Console\Output\BufferedOutput;
  31118. use Symfony\Component\Console\Output\ConsoleOutput;
  31119. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  31120. use Symfony\Component\Console\Output\OutputInterface;
  31121. use Symfony\Component\Debug\Exception\FatalThrowableError;
  31122. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  31123. class Application
  31124. {
  31125. private $commands = array();
  31126. private $wantHelps = false;
  31127. private $runningCommand;
  31128. private $name;
  31129. private $version;
  31130. private $catchExceptions = true;
  31131. private $autoExit = true;
  31132. private $definition;
  31133. private $helperSet;
  31134. private $dispatcher;
  31135. private $terminalDimensions;
  31136. private $defaultCommand;
  31137. private $initialized;
  31138. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  31139. {
  31140. $this->name = $name;
  31141. $this->version = $version;
  31142. $this->defaultCommand = 'list';
  31143. }
  31144. public function setDispatcher(EventDispatcherInterface $dispatcher)
  31145. {
  31146. $this->dispatcher = $dispatcher;
  31147. }
  31148. public function run(InputInterface $input = null, OutputInterface $output = null)
  31149. {
  31150. if (null === $input) {
  31151. $input = new ArgvInput();
  31152. }
  31153. if (null === $output) {
  31154. $output = new ConsoleOutput();
  31155. }
  31156. $this->configureIO($input, $output);
  31157. try {
  31158. $e = null;
  31159. $exitCode = $this->doRun($input, $output);
  31160. } catch (\Exception $e) {
  31161. }
  31162. if (null !== $e) {
  31163. if (!$this->catchExceptions) {
  31164. throw $e;
  31165. }
  31166. if ($output instanceof ConsoleOutputInterface) {
  31167. $this->renderException($e, $output->getErrorOutput());
  31168. } else {
  31169. $this->renderException($e, $output);
  31170. }
  31171. $exitCode = $this->getExitCodeForThrowable($e);
  31172. }
  31173. if ($this->autoExit) {
  31174. if ($exitCode > 255) {
  31175. $exitCode = 255;
  31176. }
  31177. exit($exitCode);
  31178. }
  31179. return $exitCode;
  31180. }
  31181. public function doRun(InputInterface $input, OutputInterface $output)
  31182. {
  31183. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  31184. $output->writeln($this->getLongVersion());
  31185. return 0;
  31186. }
  31187. $name = $this->getCommandName($input);
  31188. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  31189. if (!$name) {
  31190. $name = 'help';
  31191. $input = new ArrayInput(array('command' => 'help'));
  31192. } else {
  31193. $this->wantHelps = true;
  31194. }
  31195. }
  31196. if (!$name) {
  31197. $name = $this->defaultCommand;
  31198. $definition = $this->getDefinition();
  31199. $definition->setArguments(array_merge(
  31200. $definition->getArguments(),
  31201. array(
  31202. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  31203. )
  31204. ));
  31205. }
  31206. $this->runningCommand = null;
  31207. $command = $this->find($name);
  31208. $this->runningCommand = $command;
  31209. $exitCode = $this->doRunCommand($command, $input, $output);
  31210. $this->runningCommand = null;
  31211. return $exitCode;
  31212. }
  31213. public function setHelperSet(HelperSet $helperSet)
  31214. {
  31215. $this->helperSet = $helperSet;
  31216. }
  31217. public function getHelperSet()
  31218. {
  31219. if (!$this->helperSet) {
  31220. $this->helperSet = $this->getDefaultHelperSet();
  31221. }
  31222. return $this->helperSet;
  31223. }
  31224. public function setDefinition(InputDefinition $definition)
  31225. {
  31226. $this->definition = $definition;
  31227. }
  31228. public function getDefinition()
  31229. {
  31230. if (!$this->definition) {
  31231. $this->definition = $this->getDefaultInputDefinition();
  31232. }
  31233. return $this->definition;
  31234. }
  31235. public function getHelp()
  31236. {
  31237. return $this->getLongVersion();
  31238. }
  31239. public function setCatchExceptions($boolean)
  31240. {
  31241. $this->catchExceptions = (bool) $boolean;
  31242. }
  31243. public function setAutoExit($boolean)
  31244. {
  31245. $this->autoExit = (bool) $boolean;
  31246. }
  31247. public function getName()
  31248. {
  31249. return $this->name;
  31250. }
  31251. public function setName($name)
  31252. {
  31253. $this->name = $name;
  31254. }
  31255. public function getVersion()
  31256. {
  31257. return $this->version;
  31258. }
  31259. public function setVersion($version)
  31260. {
  31261. $this->version = $version;
  31262. }
  31263. public function getLongVersion()
  31264. {
  31265. if ('UNKNOWN' !== $this->getName()) {
  31266. if ('UNKNOWN' !== $this->getVersion()) {
  31267. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  31268. }
  31269. return sprintf('<info>%s</info>', $this->getName());
  31270. }
  31271. return '<info>Console Tool</info>';
  31272. }
  31273. public function register($name)
  31274. {
  31275. return $this->add(new Command($name));
  31276. }
  31277. public function addCommands(array $commands)
  31278. {
  31279. foreach ($commands as $command) {
  31280. $this->add($command);
  31281. }
  31282. }
  31283. public function add(Command $command)
  31284. {
  31285. $this->init();
  31286. $command->setApplication($this);
  31287. if (!$command->isEnabled()) {
  31288. $command->setApplication(null);
  31289. return;
  31290. }
  31291. if (null === $command->getDefinition()) {
  31292. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  31293. }
  31294. $this->commands[$command->getName()] = $command;
  31295. foreach ($command->getAliases() as $alias) {
  31296. $this->commands[$alias] = $command;
  31297. }
  31298. return $command;
  31299. }
  31300. public function get($name)
  31301. {
  31302. $this->init();
  31303. if (!isset($this->commands[$name])) {
  31304. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  31305. }
  31306. $command = $this->commands[$name];
  31307. if ($this->wantHelps) {
  31308. $this->wantHelps = false;
  31309. $helpCommand = $this->get('help');
  31310. $helpCommand->setCommand($command);
  31311. return $helpCommand;
  31312. }
  31313. return $command;
  31314. }
  31315. public function has($name)
  31316. {
  31317. $this->init();
  31318. return isset($this->commands[$name]);
  31319. }
  31320. public function getNamespaces()
  31321. {
  31322. $namespaces = array();
  31323. foreach ($this->all() as $command) {
  31324. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  31325. foreach ($command->getAliases() as $alias) {
  31326. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  31327. }
  31328. }
  31329. return array_values(array_unique(array_filter($namespaces)));
  31330. }
  31331. public function findNamespace($namespace)
  31332. {
  31333. $allNamespaces = $this->getNamespaces();
  31334. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  31335. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  31336. if (empty($namespaces)) {
  31337. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  31338. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  31339. if (1 == \count($alternatives)) {
  31340. $message .= "\n\nDid you mean this?\n ";
  31341. } else {
  31342. $message .= "\n\nDid you mean one of these?\n ";
  31343. }
  31344. $message .= implode("\n ", $alternatives);
  31345. }
  31346. throw new CommandNotFoundException($message, $alternatives);
  31347. }
  31348. $exact = \in_array($namespace, $namespaces, true);
  31349. if (\count($namespaces) > 1 && !$exact) {
  31350. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  31351. }
  31352. return $exact ? $namespace : reset($namespaces);
  31353. }
  31354. public function find($name)
  31355. {
  31356. $this->init();
  31357. $aliases = array();
  31358. $allCommands = array_keys($this->commands);
  31359. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  31360. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  31361. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  31362. if (false !== $pos = strrpos($name, ':')) {
  31363. $this->findNamespace(substr($name, 0, $pos));
  31364. }
  31365. $message = sprintf('Command "%s" is not defined.', $name);
  31366. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  31367. if (1 == \count($alternatives)) {
  31368. $message .= "\n\nDid you mean this?\n ";
  31369. } else {
  31370. $message .= "\n\nDid you mean one of these?\n ";
  31371. }
  31372. $message .= implode("\n ", $alternatives);
  31373. }
  31374. throw new CommandNotFoundException($message, $alternatives);
  31375. }
  31376. if (\count($commands) > 1) {
  31377. $commandList = $this->commands;
  31378. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  31379. $commandName = $commandList[$nameOrAlias]->getName();
  31380. $aliases[$nameOrAlias] = $commandName;
  31381. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  31382. });
  31383. }
  31384. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  31385. if (!$exact && \count($commands) > 1) {
  31386. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  31387. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  31388. }
  31389. return $this->get($exact ? $name : reset($commands));
  31390. }
  31391. public function all($namespace = null)
  31392. {
  31393. $this->init();
  31394. if (null === $namespace) {
  31395. return $this->commands;
  31396. }
  31397. $commands = array();
  31398. foreach ($this->commands as $name => $command) {
  31399. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  31400. $commands[$name] = $command;
  31401. }
  31402. }
  31403. return $commands;
  31404. }
  31405. public static function getAbbreviations($names)
  31406. {
  31407. $abbrevs = array();
  31408. foreach ($names as $name) {
  31409. for ($len = \strlen($name); $len > 0; --$len) {
  31410. $abbrev = substr($name, 0, $len);
  31411. $abbrevs[$abbrev][] = $name;
  31412. }
  31413. }
  31414. return $abbrevs;
  31415. }
  31416. public function asText($namespace = null, $raw = false)
  31417. {
  31418. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  31419. $descriptor = new TextDescriptor();
  31420. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  31421. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  31422. return $output->fetch();
  31423. }
  31424. public function asXml($namespace = null, $asDom = false)
  31425. {
  31426. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  31427. $descriptor = new XmlDescriptor();
  31428. if ($asDom) {
  31429. return $descriptor->getApplicationDocument($this, $namespace);
  31430. }
  31431. $output = new BufferedOutput();
  31432. $descriptor->describe($output, $this, array('namespace' => $namespace));
  31433. return $output->fetch();
  31434. }
  31435. public function renderException($e, $output)
  31436. {
  31437. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  31438. do {
  31439. $title = sprintf(' [%s] ', \get_class($e));
  31440. $len = Helper::strlen($title);
  31441. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  31442. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  31443. $width = 1 << 31;
  31444. }
  31445. $lines = array();
  31446. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  31447. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  31448. $lineLength = Helper::strlen($line) + 4;
  31449. $lines[] = array($line, $lineLength);
  31450. $len = max($lineLength, $len);
  31451. }
  31452. }
  31453. $messages = array();
  31454. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  31455. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  31456. foreach ($lines as $line) {
  31457. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  31458. }
  31459. $messages[] = $emptyLine;
  31460. $messages[] = '';
  31461. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  31462. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  31463. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  31464. $trace = $e->getTrace();
  31465. array_unshift($trace, array(
  31466. 'function' => '',
  31467. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  31468. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  31469. 'args' => array(),
  31470. ));
  31471. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  31472. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  31473. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  31474. $function = $trace[$i]['function'];
  31475. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  31476. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  31477. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  31478. }
  31479. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  31480. }
  31481. } while ($e = $e->getPrevious());
  31482. if (null !== $this->runningCommand) {
  31483. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  31484. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  31485. }
  31486. }
  31487. protected function getTerminalWidth()
  31488. {
  31489. $dimensions = $this->getTerminalDimensions();
  31490. return $dimensions[0];
  31491. }
  31492. protected function getTerminalHeight()
  31493. {
  31494. $dimensions = $this->getTerminalDimensions();
  31495. return $dimensions[1];
  31496. }
  31497. public function getTerminalDimensions()
  31498. {
  31499. if ($this->terminalDimensions) {
  31500. return $this->terminalDimensions;
  31501. }
  31502. if ('\\' === \DIRECTORY_SEPARATOR) {
  31503. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  31504. return array((int) $matches[1], (int) $matches[2]);
  31505. }
  31506. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  31507. return array((int) $matches[1], (int) $matches[2]);
  31508. }
  31509. }
  31510. if ($sttyString = $this->getSttyColumns()) {
  31511. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  31512. return array((int) $matches[2], (int) $matches[1]);
  31513. }
  31514. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  31515. return array((int) $matches[2], (int) $matches[1]);
  31516. }
  31517. }
  31518. return array(null, null);
  31519. }
  31520. public function setTerminalDimensions($width, $height)
  31521. {
  31522. $this->terminalDimensions = array($width, $height);
  31523. return $this;
  31524. }
  31525. protected function configureIO(InputInterface $input, OutputInterface $output)
  31526. {
  31527. if (true === $input->hasParameterOption(array('--ansi'))) {
  31528. $output->setDecorated(true);
  31529. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  31530. $output->setDecorated(false);
  31531. }
  31532. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  31533. $input->setInteractive(false);
  31534. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  31535. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  31536. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  31537. $input->setInteractive(false);
  31538. }
  31539. }
  31540. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  31541. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  31542. $input->setInteractive(false);
  31543. } else {
  31544. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  31545. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  31546. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  31547. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  31548. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  31549. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  31550. }
  31551. }
  31552. }
  31553. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  31554. {
  31555. foreach ($command->getHelperSet() as $helper) {
  31556. if ($helper instanceof InputAwareInterface) {
  31557. $helper->setInput($input);
  31558. }
  31559. }
  31560. if (null === $this->dispatcher) {
  31561. return $command->run($input, $output);
  31562. }
  31563. try {
  31564. $command->mergeApplicationDefinition();
  31565. $input->bind($command->getDefinition());
  31566. } catch (ExceptionInterface $e) {
  31567. }
  31568. $event = new ConsoleCommandEvent($command, $input, $output);
  31569. $e = null;
  31570. try {
  31571. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  31572. if ($event->commandShouldRun()) {
  31573. $exitCode = $command->run($input, $output);
  31574. } else {
  31575. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  31576. }
  31577. } catch (\Exception $e) {
  31578. } catch (\Throwable $e) {
  31579. }
  31580. if (null !== $e) {
  31581. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  31582. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  31583. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  31584. if ($x !== $event->getException()) {
  31585. $e = $event->getException();
  31586. }
  31587. $exitCode = $this->getExitCodeForThrowable($e);
  31588. }
  31589. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  31590. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  31591. if (null !== $e) {
  31592. throw $e;
  31593. }
  31594. return $event->getExitCode();
  31595. }
  31596. protected function getCommandName(InputInterface $input)
  31597. {
  31598. return $input->getFirstArgument();
  31599. }
  31600. protected function getDefaultInputDefinition()
  31601. {
  31602. return new InputDefinition(array(
  31603. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  31604. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  31605. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  31606. 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'),
  31607. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  31608. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  31609. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  31610. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  31611. ));
  31612. }
  31613. protected function getDefaultCommands()
  31614. {
  31615. return array(new HelpCommand(), new ListCommand());
  31616. }
  31617. protected function getDefaultHelperSet()
  31618. {
  31619. return new HelperSet(array(
  31620. new FormatterHelper(),
  31621. new DialogHelper(false),
  31622. new ProgressHelper(false),
  31623. new TableHelper(false),
  31624. new DebugFormatterHelper(),
  31625. new ProcessHelper(),
  31626. new QuestionHelper(),
  31627. ));
  31628. }
  31629. private function getSttyColumns()
  31630. {
  31631. if (!\function_exists('proc_open')) {
  31632. return;
  31633. }
  31634. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  31635. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  31636. if (\is_resource($process)) {
  31637. $info = stream_get_contents($pipes[1]);
  31638. fclose($pipes[1]);
  31639. fclose($pipes[2]);
  31640. proc_close($process);
  31641. return $info;
  31642. }
  31643. }
  31644. private function getConsoleMode()
  31645. {
  31646. if (!\function_exists('proc_open')) {
  31647. return;
  31648. }
  31649. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  31650. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  31651. if (\is_resource($process)) {
  31652. $info = stream_get_contents($pipes[1]);
  31653. fclose($pipes[1]);
  31654. fclose($pipes[2]);
  31655. proc_close($process);
  31656. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  31657. return $matches[2].'x'.$matches[1];
  31658. }
  31659. }
  31660. }
  31661. private function getAbbreviationSuggestions($abbrevs)
  31662. {
  31663. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  31664. }
  31665. public function extractNamespace($name, $limit = null)
  31666. {
  31667. $parts = explode(':', $name);
  31668. array_pop($parts);
  31669. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  31670. }
  31671. private function findAlternatives($name, $collection)
  31672. {
  31673. $threshold = 1e3;
  31674. $alternatives = array();
  31675. $collectionParts = array();
  31676. foreach ($collection as $item) {
  31677. $collectionParts[$item] = explode(':', $item);
  31678. }
  31679. foreach (explode(':', $name) as $i => $subname) {
  31680. foreach ($collectionParts as $collectionName => $parts) {
  31681. $exists = isset($alternatives[$collectionName]);
  31682. if (!isset($parts[$i]) && $exists) {
  31683. $alternatives[$collectionName] += $threshold;
  31684. continue;
  31685. } elseif (!isset($parts[$i])) {
  31686. continue;
  31687. }
  31688. $lev = levenshtein($subname, $parts[$i]);
  31689. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  31690. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  31691. } elseif ($exists) {
  31692. $alternatives[$collectionName] += $threshold;
  31693. }
  31694. }
  31695. }
  31696. foreach ($collection as $item) {
  31697. $lev = levenshtein($name, $item);
  31698. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  31699. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  31700. }
  31701. }
  31702. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  31703. asort($alternatives);
  31704. return array_keys($alternatives);
  31705. }
  31706. public function setDefaultCommand($commandName)
  31707. {
  31708. $this->defaultCommand = $commandName;
  31709. }
  31710. private function splitStringByWidth($string, $width)
  31711. {
  31712. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  31713. return str_split($string, $width);
  31714. }
  31715. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  31716. $lines = array();
  31717. $line = '';
  31718. foreach (preg_split('//u', $utf8String) as $char) {
  31719. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  31720. $line .= $char;
  31721. continue;
  31722. }
  31723. $lines[] = str_pad($line, $width);
  31724. $line = $char;
  31725. }
  31726. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  31727. mb_convert_variables($encoding, 'utf8', $lines);
  31728. return $lines;
  31729. }
  31730. private function extractAllNamespaces($name)
  31731. {
  31732. $parts = explode(':', $name, -1);
  31733. $namespaces = array();
  31734. foreach ($parts as $part) {
  31735. if (\count($namespaces)) {
  31736. $namespaces[] = end($namespaces).':'.$part;
  31737. } else {
  31738. $namespaces[] = $part;
  31739. }
  31740. }
  31741. return $namespaces;
  31742. }
  31743. private function init()
  31744. {
  31745. if ($this->initialized) {
  31746. return;
  31747. }
  31748. $this->initialized = true;
  31749. foreach ($this->getDefaultCommands() as $command) {
  31750. $this->add($command);
  31751. }
  31752. }
  31753. private function getExitCodeForThrowable($throwable)
  31754. {
  31755. $exitCode = $throwable->getCode();
  31756. if (is_numeric($exitCode)) {
  31757. $exitCode = (int) $exitCode;
  31758. if (0 === $exitCode) {
  31759. $exitCode = 1;
  31760. }
  31761. } else {
  31762. $exitCode = 1;
  31763. }
  31764. return $exitCode;
  31765. }
  31766. }
  31767. <?php
  31768. namespace Symfony\Component\Console\Command;
  31769. use Symfony\Component\Console\Application;
  31770. use Symfony\Component\Console\Descriptor\TextDescriptor;
  31771. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  31772. use Symfony\Component\Console\Exception\ExceptionInterface;
  31773. use Symfony\Component\Console\Exception\InvalidArgumentException;
  31774. use Symfony\Component\Console\Exception\LogicException;
  31775. use Symfony\Component\Console\Helper\HelperSet;
  31776. use Symfony\Component\Console\Input\InputArgument;
  31777. use Symfony\Component\Console\Input\InputDefinition;
  31778. use Symfony\Component\Console\Input\InputInterface;
  31779. use Symfony\Component\Console\Input\InputOption;
  31780. use Symfony\Component\Console\Output\BufferedOutput;
  31781. use Symfony\Component\Console\Output\OutputInterface;
  31782. class Command
  31783. {
  31784. private $application;
  31785. private $name;
  31786. private $processTitle;
  31787. private $aliases = array();
  31788. private $definition;
  31789. private $help;
  31790. private $description;
  31791. private $ignoreValidationErrors = false;
  31792. private $applicationDefinitionMerged = false;
  31793. private $applicationDefinitionMergedWithArgs = false;
  31794. private $code;
  31795. private $synopsis = array();
  31796. private $usages = array();
  31797. private $helperSet;
  31798. public function __construct($name = null)
  31799. {
  31800. $this->definition = new InputDefinition();
  31801. if (null !== $name) {
  31802. $this->setName($name);
  31803. }
  31804. $this->configure();
  31805. if (!$this->name) {
  31806. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  31807. }
  31808. }
  31809. public function ignoreValidationErrors()
  31810. {
  31811. $this->ignoreValidationErrors = true;
  31812. }
  31813. public function setApplication(Application $application = null)
  31814. {
  31815. $this->application = $application;
  31816. if ($application) {
  31817. $this->setHelperSet($application->getHelperSet());
  31818. } else {
  31819. $this->helperSet = null;
  31820. }
  31821. }
  31822. public function setHelperSet(HelperSet $helperSet)
  31823. {
  31824. $this->helperSet = $helperSet;
  31825. }
  31826. public function getHelperSet()
  31827. {
  31828. return $this->helperSet;
  31829. }
  31830. public function getApplication()
  31831. {
  31832. return $this->application;
  31833. }
  31834. public function isEnabled()
  31835. {
  31836. return true;
  31837. }
  31838. protected function configure()
  31839. {
  31840. }
  31841. protected function execute(InputInterface $input, OutputInterface $output)
  31842. {
  31843. throw new LogicException('You must override the execute() method in the concrete command class.');
  31844. }
  31845. protected function interact(InputInterface $input, OutputInterface $output)
  31846. {
  31847. }
  31848. protected function initialize(InputInterface $input, OutputInterface $output)
  31849. {
  31850. }
  31851. public function run(InputInterface $input, OutputInterface $output)
  31852. {
  31853. $this->getSynopsis(true);
  31854. $this->getSynopsis(false);
  31855. $this->mergeApplicationDefinition();
  31856. try {
  31857. $input->bind($this->definition);
  31858. } catch (ExceptionInterface $e) {
  31859. if (!$this->ignoreValidationErrors) {
  31860. throw $e;
  31861. }
  31862. }
  31863. $this->initialize($input, $output);
  31864. if (null !== $this->processTitle) {
  31865. if (\function_exists('cli_set_process_title')) {
  31866. if (!@cli_set_process_title($this->processTitle)) {
  31867. if ('Darwin' === PHP_OS) {
  31868. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  31869. } else {
  31870. cli_set_process_title($this->processTitle);
  31871. }
  31872. }
  31873. } elseif (\function_exists('setproctitle')) {
  31874. setproctitle($this->processTitle);
  31875. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  31876. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  31877. }
  31878. }
  31879. if ($input->isInteractive()) {
  31880. $this->interact($input, $output);
  31881. }
  31882. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  31883. $input->setArgument('command', $this->getName());
  31884. }
  31885. $input->validate();
  31886. if ($this->code) {
  31887. $statusCode = \call_user_func($this->code, $input, $output);
  31888. } else {
  31889. $statusCode = $this->execute($input, $output);
  31890. }
  31891. return is_numeric($statusCode) ? (int) $statusCode : 0;
  31892. }
  31893. public function setCode($code)
  31894. {
  31895. if (!\is_callable($code)) {
  31896. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  31897. }
  31898. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  31899. $r = new \ReflectionFunction($code);
  31900. if (null === $r->getClosureThis()) {
  31901. if (\PHP_VERSION_ID < 70000) {
  31902. $code = @\Closure::bind($code, $this);
  31903. } else {
  31904. $code = \Closure::bind($code, $this);
  31905. }
  31906. }
  31907. }
  31908. $this->code = $code;
  31909. return $this;
  31910. }
  31911. public function mergeApplicationDefinition($mergeArgs = true)
  31912. {
  31913. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  31914. return;
  31915. }
  31916. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  31917. $this->applicationDefinitionMerged = true;
  31918. if ($mergeArgs) {
  31919. $currentArguments = $this->definition->getArguments();
  31920. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  31921. $this->definition->addArguments($currentArguments);
  31922. $this->applicationDefinitionMergedWithArgs = true;
  31923. }
  31924. }
  31925. public function setDefinition($definition)
  31926. {
  31927. if ($definition instanceof InputDefinition) {
  31928. $this->definition = $definition;
  31929. } else {
  31930. $this->definition->setDefinition($definition);
  31931. }
  31932. $this->applicationDefinitionMerged = false;
  31933. return $this;
  31934. }
  31935. public function getDefinition()
  31936. {
  31937. return $this->definition;
  31938. }
  31939. public function getNativeDefinition()
  31940. {
  31941. return $this->getDefinition();
  31942. }
  31943. public function addArgument($name, $mode = null, $description = '', $default = null)
  31944. {
  31945. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  31946. return $this;
  31947. }
  31948. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  31949. {
  31950. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  31951. return $this;
  31952. }
  31953. public function setName($name)
  31954. {
  31955. $this->validateName($name);
  31956. $this->name = $name;
  31957. return $this;
  31958. }
  31959. public function setProcessTitle($title)
  31960. {
  31961. $this->processTitle = $title;
  31962. return $this;
  31963. }
  31964. public function getName()
  31965. {
  31966. return $this->name;
  31967. }
  31968. public function setDescription($description)
  31969. {
  31970. $this->description = $description;
  31971. return $this;
  31972. }
  31973. public function getDescription()
  31974. {
  31975. return $this->description;
  31976. }
  31977. public function setHelp($help)
  31978. {
  31979. $this->help = $help;
  31980. return $this;
  31981. }
  31982. public function getHelp()
  31983. {
  31984. return $this->help;
  31985. }
  31986. public function getProcessedHelp()
  31987. {
  31988. $name = $this->name;
  31989. $placeholders = array(
  31990. '%command.name%',
  31991. '%command.full_name%',
  31992. );
  31993. $replacements = array(
  31994. $name,
  31995. $_SERVER['PHP_SELF'].' '.$name,
  31996. );
  31997. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  31998. }
  31999. public function setAliases($aliases)
  32000. {
  32001. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  32002. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  32003. }
  32004. foreach ($aliases as $alias) {
  32005. $this->validateName($alias);
  32006. }
  32007. $this->aliases = $aliases;
  32008. return $this;
  32009. }
  32010. public function getAliases()
  32011. {
  32012. return $this->aliases;
  32013. }
  32014. public function getSynopsis($short = false)
  32015. {
  32016. $key = $short ? 'short' : 'long';
  32017. if (!isset($this->synopsis[$key])) {
  32018. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  32019. }
  32020. return $this->synopsis[$key];
  32021. }
  32022. public function addUsage($usage)
  32023. {
  32024. if (0 !== strpos($usage, $this->name)) {
  32025. $usage = sprintf('%s %s', $this->name, $usage);
  32026. }
  32027. $this->usages[] = $usage;
  32028. return $this;
  32029. }
  32030. public function getUsages()
  32031. {
  32032. return $this->usages;
  32033. }
  32034. public function getHelper($name)
  32035. {
  32036. if (null === $this->helperSet) {
  32037. 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));
  32038. }
  32039. return $this->helperSet->get($name);
  32040. }
  32041. public function asText()
  32042. {
  32043. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  32044. $descriptor = new TextDescriptor();
  32045. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  32046. $descriptor->describe($output, $this, array('raw_output' => true));
  32047. return $output->fetch();
  32048. }
  32049. public function asXml($asDom = false)
  32050. {
  32051. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  32052. $descriptor = new XmlDescriptor();
  32053. if ($asDom) {
  32054. return $descriptor->getCommandDocument($this);
  32055. }
  32056. $output = new BufferedOutput();
  32057. $descriptor->describe($output, $this);
  32058. return $output->fetch();
  32059. }
  32060. private function validateName($name)
  32061. {
  32062. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  32063. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  32064. }
  32065. }
  32066. }
  32067. <?php
  32068. namespace Symfony\Component\Console\Command;
  32069. use Symfony\Component\Console\Helper\DescriptorHelper;
  32070. use Symfony\Component\Console\Input\InputArgument;
  32071. use Symfony\Component\Console\Input\InputInterface;
  32072. use Symfony\Component\Console\Input\InputOption;
  32073. use Symfony\Component\Console\Output\OutputInterface;
  32074. class HelpCommand extends Command
  32075. {
  32076. private $command;
  32077. protected function configure()
  32078. {
  32079. $this->ignoreValidationErrors();
  32080. $this
  32081. ->setName('help')
  32082. ->setDefinition(array(
  32083. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  32084. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  32085. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  32086. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  32087. ))
  32088. ->setDescription('Displays help for a command')
  32089. ->setHelp(<<<'EOF'
  32090. The <info>%command.name%</info> command displays help for a given command:
  32091. <info>php %command.full_name% list</info>
  32092. You can also output the help in other formats by using the <comment>--format</comment> option:
  32093. <info>php %command.full_name% --format=xml list</info>
  32094. To display the list of available commands, please use the <info>list</info> command.
  32095. EOF
  32096. )
  32097. ;
  32098. }
  32099. public function setCommand(Command $command)
  32100. {
  32101. $this->command = $command;
  32102. }
  32103. protected function execute(InputInterface $input, OutputInterface $output)
  32104. {
  32105. if (null === $this->command) {
  32106. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  32107. }
  32108. if ($input->getOption('xml')) {
  32109. @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);
  32110. $input->setOption('format', 'xml');
  32111. }
  32112. $helper = new DescriptorHelper();
  32113. $helper->describe($output, $this->command, array(
  32114. 'format' => $input->getOption('format'),
  32115. 'raw_text' => $input->getOption('raw'),
  32116. ));
  32117. $this->command = null;
  32118. }
  32119. }
  32120. <?php
  32121. namespace Symfony\Component\Console\Command;
  32122. use Symfony\Component\Console\Helper\DescriptorHelper;
  32123. use Symfony\Component\Console\Input\InputArgument;
  32124. use Symfony\Component\Console\Input\InputDefinition;
  32125. use Symfony\Component\Console\Input\InputInterface;
  32126. use Symfony\Component\Console\Input\InputOption;
  32127. use Symfony\Component\Console\Output\OutputInterface;
  32128. class ListCommand extends Command
  32129. {
  32130. protected function configure()
  32131. {
  32132. $this
  32133. ->setName('list')
  32134. ->setDefinition($this->createDefinition())
  32135. ->setDescription('Lists commands')
  32136. ->setHelp(<<<'EOF'
  32137. The <info>%command.name%</info> command lists all commands:
  32138. <info>php %command.full_name%</info>
  32139. You can also display the commands for a specific namespace:
  32140. <info>php %command.full_name% test</info>
  32141. You can also output the information in other formats by using the <comment>--format</comment> option:
  32142. <info>php %command.full_name% --format=xml</info>
  32143. It's also possible to get raw list of commands (useful for embedding command runner):
  32144. <info>php %command.full_name% --raw</info>
  32145. EOF
  32146. )
  32147. ;
  32148. }
  32149. public function getNativeDefinition()
  32150. {
  32151. return $this->createDefinition();
  32152. }
  32153. protected function execute(InputInterface $input, OutputInterface $output)
  32154. {
  32155. if ($input->getOption('xml')) {
  32156. @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);
  32157. $input->setOption('format', 'xml');
  32158. }
  32159. $helper = new DescriptorHelper();
  32160. $helper->describe($output, $this->getApplication(), array(
  32161. 'format' => $input->getOption('format'),
  32162. 'raw_text' => $input->getOption('raw'),
  32163. 'namespace' => $input->getArgument('namespace'),
  32164. ));
  32165. }
  32166. private function createDefinition()
  32167. {
  32168. return new InputDefinition(array(
  32169. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  32170. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  32171. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  32172. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  32173. ));
  32174. }
  32175. }
  32176. <?php
  32177. namespace Symfony\Component\Console;
  32178. final class ConsoleEvents
  32179. {
  32180. const COMMAND = 'console.command';
  32181. const TERMINATE = 'console.terminate';
  32182. const EXCEPTION = 'console.exception';
  32183. }
  32184. <?php
  32185. namespace Symfony\Component\Console\Descriptor;
  32186. use Symfony\Component\Console\Application;
  32187. use Symfony\Component\Console\Command\Command;
  32188. use Symfony\Component\Console\Exception\CommandNotFoundException;
  32189. class ApplicationDescription
  32190. {
  32191. const GLOBAL_NAMESPACE = '_global';
  32192. private $application;
  32193. private $namespace;
  32194. private $namespaces;
  32195. private $commands;
  32196. private $aliases;
  32197. public function __construct(Application $application, $namespace = null)
  32198. {
  32199. $this->application = $application;
  32200. $this->namespace = $namespace;
  32201. }
  32202. public function getNamespaces()
  32203. {
  32204. if (null === $this->namespaces) {
  32205. $this->inspectApplication();
  32206. }
  32207. return $this->namespaces;
  32208. }
  32209. public function getCommands()
  32210. {
  32211. if (null === $this->commands) {
  32212. $this->inspectApplication();
  32213. }
  32214. return $this->commands;
  32215. }
  32216. public function getCommand($name)
  32217. {
  32218. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  32219. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  32220. }
  32221. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  32222. }
  32223. private function inspectApplication()
  32224. {
  32225. $this->commands = array();
  32226. $this->namespaces = array();
  32227. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  32228. foreach ($this->sortCommands($all) as $namespace => $commands) {
  32229. $names = array();
  32230. foreach ($commands as $name => $command) {
  32231. if (!$command->getName()) {
  32232. continue;
  32233. }
  32234. if ($command->getName() === $name) {
  32235. $this->commands[$name] = $command;
  32236. } else {
  32237. $this->aliases[$name] = $command;
  32238. }
  32239. $names[] = $name;
  32240. }
  32241. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  32242. }
  32243. }
  32244. private function sortCommands(array $commands)
  32245. {
  32246. $namespacedCommands = array();
  32247. $globalCommands = array();
  32248. foreach ($commands as $name => $command) {
  32249. $key = $this->application->extractNamespace($name, 1);
  32250. if (!$key) {
  32251. $globalCommands['_global'][$name] = $command;
  32252. } else {
  32253. $namespacedCommands[$key][$name] = $command;
  32254. }
  32255. }
  32256. ksort($namespacedCommands);
  32257. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  32258. foreach ($namespacedCommands as &$commandsSet) {
  32259. ksort($commandsSet);
  32260. }
  32261. unset($commandsSet);
  32262. return $namespacedCommands;
  32263. }
  32264. }
  32265. <?php
  32266. namespace Symfony\Component\Console\Descriptor;
  32267. use Symfony\Component\Console\Application;
  32268. use Symfony\Component\Console\Command\Command;
  32269. use Symfony\Component\Console\Exception\InvalidArgumentException;
  32270. use Symfony\Component\Console\Input\InputArgument;
  32271. use Symfony\Component\Console\Input\InputDefinition;
  32272. use Symfony\Component\Console\Input\InputOption;
  32273. use Symfony\Component\Console\Output\OutputInterface;
  32274. abstract class Descriptor implements DescriptorInterface
  32275. {
  32276. private $output;
  32277. public function describe(OutputInterface $output, $object, array $options = array())
  32278. {
  32279. $this->output = $output;
  32280. switch (true) {
  32281. case $object instanceof InputArgument:
  32282. $this->describeInputArgument($object, $options);
  32283. break;
  32284. case $object instanceof InputOption:
  32285. $this->describeInputOption($object, $options);
  32286. break;
  32287. case $object instanceof InputDefinition:
  32288. $this->describeInputDefinition($object, $options);
  32289. break;
  32290. case $object instanceof Command:
  32291. $this->describeCommand($object, $options);
  32292. break;
  32293. case $object instanceof Application:
  32294. $this->describeApplication($object, $options);
  32295. break;
  32296. default:
  32297. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  32298. }
  32299. }
  32300. protected function write($content, $decorated = false)
  32301. {
  32302. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  32303. }
  32304. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  32305. abstract protected function describeInputOption(InputOption $option, array $options = array());
  32306. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  32307. abstract protected function describeCommand(Command $command, array $options = array());
  32308. abstract protected function describeApplication(Application $application, array $options = array());
  32309. }
  32310. <?php
  32311. namespace Symfony\Component\Console\Descriptor;
  32312. use Symfony\Component\Console\Output\OutputInterface;
  32313. interface DescriptorInterface
  32314. {
  32315. public function describe(OutputInterface $output, $object, array $options = array());
  32316. }
  32317. <?php
  32318. namespace Symfony\Component\Console\Descriptor;
  32319. use Symfony\Component\Console\Application;
  32320. use Symfony\Component\Console\Command\Command;
  32321. use Symfony\Component\Console\Input\InputArgument;
  32322. use Symfony\Component\Console\Input\InputDefinition;
  32323. use Symfony\Component\Console\Input\InputOption;
  32324. class JsonDescriptor extends Descriptor
  32325. {
  32326. protected function describeInputArgument(InputArgument $argument, array $options = array())
  32327. {
  32328. $this->writeData($this->getInputArgumentData($argument), $options);
  32329. }
  32330. protected function describeInputOption(InputOption $option, array $options = array())
  32331. {
  32332. $this->writeData($this->getInputOptionData($option), $options);
  32333. }
  32334. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  32335. {
  32336. $this->writeData($this->getInputDefinitionData($definition), $options);
  32337. }
  32338. protected function describeCommand(Command $command, array $options = array())
  32339. {
  32340. $this->writeData($this->getCommandData($command), $options);
  32341. }
  32342. protected function describeApplication(Application $application, array $options = array())
  32343. {
  32344. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  32345. $description = new ApplicationDescription($application, $describedNamespace);
  32346. $commands = array();
  32347. foreach ($description->getCommands() as $command) {
  32348. $commands[] = $this->getCommandData($command);
  32349. }
  32350. $data = $describedNamespace
  32351. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  32352. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  32353. $this->writeData($data, $options);
  32354. }
  32355. private function writeData(array $data, array $options)
  32356. {
  32357. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  32358. }
  32359. private function getInputArgumentData(InputArgument $argument)
  32360. {
  32361. return array(
  32362. 'name' => $argument->getName(),
  32363. 'is_required' => $argument->isRequired(),
  32364. 'is_array' => $argument->isArray(),
  32365. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  32366. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  32367. );
  32368. }
  32369. private function getInputOptionData(InputOption $option)
  32370. {
  32371. return array(
  32372. 'name' => '--'.$option->getName(),
  32373. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  32374. 'accept_value' => $option->acceptValue(),
  32375. 'is_value_required' => $option->isValueRequired(),
  32376. 'is_multiple' => $option->isArray(),
  32377. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  32378. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  32379. );
  32380. }
  32381. private function getInputDefinitionData(InputDefinition $definition)
  32382. {
  32383. $inputArguments = array();
  32384. foreach ($definition->getArguments() as $name => $argument) {
  32385. $inputArguments[$name] = $this->getInputArgumentData($argument);
  32386. }
  32387. $inputOptions = array();
  32388. foreach ($definition->getOptions() as $name => $option) {
  32389. $inputOptions[$name] = $this->getInputOptionData($option);
  32390. }
  32391. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  32392. }
  32393. private function getCommandData(Command $command)
  32394. {
  32395. $command->getSynopsis();
  32396. $command->mergeApplicationDefinition(false);
  32397. return array(
  32398. 'name' => $command->getName(),
  32399. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  32400. 'description' => $command->getDescription(),
  32401. 'help' => $command->getProcessedHelp(),
  32402. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  32403. );
  32404. }
  32405. }
  32406. <?php
  32407. namespace Symfony\Component\Console\Descriptor;
  32408. use Symfony\Component\Console\Application;
  32409. use Symfony\Component\Console\Command\Command;
  32410. use Symfony\Component\Console\Helper\Helper;
  32411. use Symfony\Component\Console\Input\InputArgument;
  32412. use Symfony\Component\Console\Input\InputDefinition;
  32413. use Symfony\Component\Console\Input\InputOption;
  32414. class MarkdownDescriptor extends Descriptor
  32415. {
  32416. protected function describeInputArgument(InputArgument $argument, array $options = array())
  32417. {
  32418. $this->write(
  32419. '**'.$argument->getName().':**'."\n\n"
  32420. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  32421. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  32422. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  32423. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  32424. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  32425. );
  32426. }
  32427. protected function describeInputOption(InputOption $option, array $options = array())
  32428. {
  32429. $this->write(
  32430. '**'.$option->getName().':**'."\n\n"
  32431. .'* Name: `--'.$option->getName().'`'."\n"
  32432. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  32433. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  32434. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  32435. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  32436. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  32437. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  32438. );
  32439. }
  32440. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  32441. {
  32442. if ($showArguments = \count($definition->getArguments()) > 0) {
  32443. $this->write('### Arguments:');
  32444. foreach ($definition->getArguments() as $argument) {
  32445. $this->write("\n\n");
  32446. $this->write($this->describeInputArgument($argument));
  32447. }
  32448. }
  32449. if (\count($definition->getOptions()) > 0) {
  32450. if ($showArguments) {
  32451. $this->write("\n\n");
  32452. }
  32453. $this->write('### Options:');
  32454. foreach ($definition->getOptions() as $option) {
  32455. $this->write("\n\n");
  32456. $this->write($this->describeInputOption($option));
  32457. }
  32458. }
  32459. }
  32460. protected function describeCommand(Command $command, array $options = array())
  32461. {
  32462. $command->getSynopsis();
  32463. $command->mergeApplicationDefinition(false);
  32464. $this->write(
  32465. $command->getName()."\n"
  32466. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  32467. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  32468. .'* Usage:'."\n\n"
  32469. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  32470. return $carry.' * `'.$usage.'`'."\n";
  32471. })
  32472. );
  32473. if ($help = $command->getProcessedHelp()) {
  32474. $this->write("\n");
  32475. $this->write($help);
  32476. }
  32477. if ($command->getNativeDefinition()) {
  32478. $this->write("\n\n");
  32479. $this->describeInputDefinition($command->getNativeDefinition());
  32480. }
  32481. }
  32482. protected function describeApplication(Application $application, array $options = array())
  32483. {
  32484. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  32485. $description = new ApplicationDescription($application, $describedNamespace);
  32486. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  32487. foreach ($description->getNamespaces() as $namespace) {
  32488. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  32489. $this->write("\n\n");
  32490. $this->write('**'.$namespace['id'].':**');
  32491. }
  32492. $this->write("\n\n");
  32493. $this->write(implode("\n", array_map(function ($commandName) {
  32494. return '* '.$commandName;
  32495. }, $namespace['commands'])));
  32496. }
  32497. foreach ($description->getCommands() as $command) {
  32498. $this->write("\n\n");
  32499. $this->write($this->describeCommand($command));
  32500. }
  32501. }
  32502. }
  32503. <?php
  32504. namespace Symfony\Component\Console\Descriptor;
  32505. use Symfony\Component\Console\Application;
  32506. use Symfony\Component\Console\Command\Command;
  32507. use Symfony\Component\Console\Formatter\OutputFormatter;
  32508. use Symfony\Component\Console\Helper\Helper;
  32509. use Symfony\Component\Console\Input\InputArgument;
  32510. use Symfony\Component\Console\Input\InputDefinition;
  32511. use Symfony\Component\Console\Input\InputOption;
  32512. class TextDescriptor extends Descriptor
  32513. {
  32514. protected function describeInputArgument(InputArgument $argument, array $options = array())
  32515. {
  32516. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  32517. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  32518. } else {
  32519. $default = '';
  32520. }
  32521. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  32522. $spacingWidth = $totalWidth - \strlen($argument->getName());
  32523. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  32524. $argument->getName(),
  32525. str_repeat(' ', $spacingWidth),
  32526. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  32527. $default
  32528. ), $options);
  32529. }
  32530. protected function describeInputOption(InputOption $option, array $options = array())
  32531. {
  32532. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  32533. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  32534. } else {
  32535. $default = '';
  32536. }
  32537. $value = '';
  32538. if ($option->acceptValue()) {
  32539. $value = '='.strtoupper($option->getName());
  32540. if ($option->isValueOptional()) {
  32541. $value = '['.$value.']';
  32542. }
  32543. }
  32544. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  32545. $synopsis = sprintf('%s%s',
  32546. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  32547. sprintf('--%s%s', $option->getName(), $value)
  32548. );
  32549. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  32550. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  32551. $synopsis,
  32552. str_repeat(' ', $spacingWidth),
  32553. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  32554. $default,
  32555. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  32556. ), $options);
  32557. }
  32558. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  32559. {
  32560. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  32561. foreach ($definition->getArguments() as $argument) {
  32562. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  32563. }
  32564. if ($definition->getArguments()) {
  32565. $this->writeText('<comment>Arguments:</comment>', $options);
  32566. $this->writeText("\n");
  32567. foreach ($definition->getArguments() as $argument) {
  32568. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  32569. $this->writeText("\n");
  32570. }
  32571. }
  32572. if ($definition->getArguments() && $definition->getOptions()) {
  32573. $this->writeText("\n");
  32574. }
  32575. if ($definition->getOptions()) {
  32576. $laterOptions = array();
  32577. $this->writeText('<comment>Options:</comment>', $options);
  32578. foreach ($definition->getOptions() as $option) {
  32579. if (\strlen($option->getShortcut()) > 1) {
  32580. $laterOptions[] = $option;
  32581. continue;
  32582. }
  32583. $this->writeText("\n");
  32584. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  32585. }
  32586. foreach ($laterOptions as $option) {
  32587. $this->writeText("\n");
  32588. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  32589. }
  32590. }
  32591. }
  32592. protected function describeCommand(Command $command, array $options = array())
  32593. {
  32594. $command->getSynopsis(true);
  32595. $command->getSynopsis(false);
  32596. $command->mergeApplicationDefinition(false);
  32597. $this->writeText('<comment>Usage:</comment>', $options);
  32598. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  32599. $this->writeText("\n");
  32600. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  32601. }
  32602. $this->writeText("\n");
  32603. $definition = $command->getNativeDefinition();
  32604. if ($definition->getOptions() || $definition->getArguments()) {
  32605. $this->writeText("\n");
  32606. $this->describeInputDefinition($definition, $options);
  32607. $this->writeText("\n");
  32608. }
  32609. if ($help = $command->getProcessedHelp()) {
  32610. $this->writeText("\n");
  32611. $this->writeText('<comment>Help:</comment>', $options);
  32612. $this->writeText("\n");
  32613. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  32614. $this->writeText("\n");
  32615. }
  32616. }
  32617. protected function describeApplication(Application $application, array $options = array())
  32618. {
  32619. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  32620. $description = new ApplicationDescription($application, $describedNamespace);
  32621. if (isset($options['raw_text']) && $options['raw_text']) {
  32622. $width = $this->getColumnWidth($description->getCommands());
  32623. foreach ($description->getCommands() as $command) {
  32624. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  32625. $this->writeText("\n");
  32626. }
  32627. } else {
  32628. if ('' != $help = $application->getHelp()) {
  32629. $this->writeText("$help\n\n", $options);
  32630. }
  32631. $this->writeText("<comment>Usage:</comment>\n", $options);
  32632. $this->writeText(" command [options] [arguments]\n\n", $options);
  32633. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  32634. $this->writeText("\n");
  32635. $this->writeText("\n");
  32636. $width = $this->getColumnWidth($description->getCommands());
  32637. if ($describedNamespace) {
  32638. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  32639. } else {
  32640. $this->writeText('<comment>Available commands:</comment>', $options);
  32641. }
  32642. foreach ($description->getNamespaces() as $namespace) {
  32643. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  32644. $this->writeText("\n");
  32645. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  32646. }
  32647. foreach ($namespace['commands'] as $name) {
  32648. $this->writeText("\n");
  32649. $spacingWidth = $width - Helper::strlen($name);
  32650. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  32651. }
  32652. }
  32653. $this->writeText("\n");
  32654. }
  32655. }
  32656. private function writeText($content, array $options = array())
  32657. {
  32658. $this->write(
  32659. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  32660. isset($options['raw_output']) ? !$options['raw_output'] : true
  32661. );
  32662. }
  32663. private function formatDefaultValue($default)
  32664. {
  32665. if (INF === $default) {
  32666. return 'INF';
  32667. }
  32668. if (\is_string($default)) {
  32669. $default = OutputFormatter::escape($default);
  32670. } elseif (\is_array($default)) {
  32671. foreach ($default as $key => $value) {
  32672. if (\is_string($value)) {
  32673. $default[$key] = OutputFormatter::escape($value);
  32674. }
  32675. }
  32676. }
  32677. if (\PHP_VERSION_ID < 50400) {
  32678. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  32679. }
  32680. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  32681. }
  32682. private function getColumnWidth(array $commands)
  32683. {
  32684. $widths = array();
  32685. foreach ($commands as $command) {
  32686. $widths[] = Helper::strlen($command->getName());
  32687. foreach ($command->getAliases() as $alias) {
  32688. $widths[] = Helper::strlen($alias);
  32689. }
  32690. }
  32691. return max($widths) + 2;
  32692. }
  32693. private function calculateTotalWidthForOptions(array $options)
  32694. {
  32695. $totalWidth = 0;
  32696. foreach ($options as $option) {
  32697. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  32698. if ($option->acceptValue()) {
  32699. $valueLength = 1 + Helper::strlen($option->getName());
  32700. $valueLength += $option->isValueOptional() ? 2 : 0;
  32701. $nameLength += $valueLength;
  32702. }
  32703. $totalWidth = max($totalWidth, $nameLength);
  32704. }
  32705. return $totalWidth;
  32706. }
  32707. }
  32708. <?php
  32709. namespace Symfony\Component\Console\Descriptor;
  32710. use Symfony\Component\Console\Application;
  32711. use Symfony\Component\Console\Command\Command;
  32712. use Symfony\Component\Console\Input\InputArgument;
  32713. use Symfony\Component\Console\Input\InputDefinition;
  32714. use Symfony\Component\Console\Input\InputOption;
  32715. class XmlDescriptor extends Descriptor
  32716. {
  32717. public function getInputDefinitionDocument(InputDefinition $definition)
  32718. {
  32719. $dom = new \DOMDocument('1.0', 'UTF-8');
  32720. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  32721. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  32722. foreach ($definition->getArguments() as $argument) {
  32723. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  32724. }
  32725. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  32726. foreach ($definition->getOptions() as $option) {
  32727. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  32728. }
  32729. return $dom;
  32730. }
  32731. public function getCommandDocument(Command $command)
  32732. {
  32733. $dom = new \DOMDocument('1.0', 'UTF-8');
  32734. $dom->appendChild($commandXML = $dom->createElement('command'));
  32735. $command->getSynopsis();
  32736. $command->mergeApplicationDefinition(false);
  32737. $commandXML->setAttribute('id', $command->getName());
  32738. $commandXML->setAttribute('name', $command->getName());
  32739. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  32740. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  32741. $usagesXML->appendChild($dom->createElement('usage', $usage));
  32742. }
  32743. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  32744. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  32745. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  32746. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  32747. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  32748. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  32749. return $dom;
  32750. }
  32751. public function getApplicationDocument(Application $application, $namespace = null)
  32752. {
  32753. $dom = new \DOMDocument('1.0', 'UTF-8');
  32754. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  32755. if ('UNKNOWN' !== $application->getName()) {
  32756. $rootXml->setAttribute('name', $application->getName());
  32757. if ('UNKNOWN' !== $application->getVersion()) {
  32758. $rootXml->setAttribute('version', $application->getVersion());
  32759. }
  32760. }
  32761. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  32762. $description = new ApplicationDescription($application, $namespace);
  32763. if ($namespace) {
  32764. $commandsXML->setAttribute('namespace', $namespace);
  32765. }
  32766. foreach ($description->getCommands() as $command) {
  32767. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  32768. }
  32769. if (!$namespace) {
  32770. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  32771. foreach ($description->getNamespaces() as $namespaceDescription) {
  32772. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  32773. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  32774. foreach ($namespaceDescription['commands'] as $name) {
  32775. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  32776. $commandXML->appendChild($dom->createTextNode($name));
  32777. }
  32778. }
  32779. }
  32780. return $dom;
  32781. }
  32782. protected function describeInputArgument(InputArgument $argument, array $options = array())
  32783. {
  32784. $this->writeDocument($this->getInputArgumentDocument($argument));
  32785. }
  32786. protected function describeInputOption(InputOption $option, array $options = array())
  32787. {
  32788. $this->writeDocument($this->getInputOptionDocument($option));
  32789. }
  32790. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  32791. {
  32792. $this->writeDocument($this->getInputDefinitionDocument($definition));
  32793. }
  32794. protected function describeCommand(Command $command, array $options = array())
  32795. {
  32796. $this->writeDocument($this->getCommandDocument($command));
  32797. }
  32798. protected function describeApplication(Application $application, array $options = array())
  32799. {
  32800. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  32801. }
  32802. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  32803. {
  32804. foreach ($importedParent->childNodes as $childNode) {
  32805. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  32806. }
  32807. }
  32808. private function writeDocument(\DOMDocument $dom)
  32809. {
  32810. $dom->formatOutput = true;
  32811. $this->write($dom->saveXML());
  32812. }
  32813. private function getInputArgumentDocument(InputArgument $argument)
  32814. {
  32815. $dom = new \DOMDocument('1.0', 'UTF-8');
  32816. $dom->appendChild($objectXML = $dom->createElement('argument'));
  32817. $objectXML->setAttribute('name', $argument->getName());
  32818. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  32819. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  32820. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  32821. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  32822. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  32823. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  32824. foreach ($defaults as $default) {
  32825. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  32826. $defaultXML->appendChild($dom->createTextNode($default));
  32827. }
  32828. return $dom;
  32829. }
  32830. private function getInputOptionDocument(InputOption $option)
  32831. {
  32832. $dom = new \DOMDocument('1.0', 'UTF-8');
  32833. $dom->appendChild($objectXML = $dom->createElement('option'));
  32834. $objectXML->setAttribute('name', '--'.$option->getName());
  32835. $pos = strpos($option->getShortcut(), '|');
  32836. if (false !== $pos) {
  32837. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  32838. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  32839. } else {
  32840. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  32841. }
  32842. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  32843. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  32844. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  32845. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  32846. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  32847. if ($option->acceptValue()) {
  32848. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  32849. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  32850. if (!empty($defaults)) {
  32851. foreach ($defaults as $default) {
  32852. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  32853. $defaultXML->appendChild($dom->createTextNode($default));
  32854. }
  32855. }
  32856. }
  32857. return $dom;
  32858. }
  32859. }
  32860. <?php
  32861. namespace Symfony\Component\Console\Event;
  32862. class ConsoleCommandEvent extends ConsoleEvent
  32863. {
  32864. const RETURN_CODE_DISABLED = 113;
  32865. private $commandShouldRun = true;
  32866. public function disableCommand()
  32867. {
  32868. return $this->commandShouldRun = false;
  32869. }
  32870. public function enableCommand()
  32871. {
  32872. return $this->commandShouldRun = true;
  32873. }
  32874. public function commandShouldRun()
  32875. {
  32876. return $this->commandShouldRun;
  32877. }
  32878. }
  32879. <?php
  32880. namespace Symfony\Component\Console\Event;
  32881. use Symfony\Component\Console\Command\Command;
  32882. use Symfony\Component\Console\Input\InputInterface;
  32883. use Symfony\Component\Console\Output\OutputInterface;
  32884. use Symfony\Component\EventDispatcher\Event;
  32885. class ConsoleEvent extends Event
  32886. {
  32887. protected $command;
  32888. private $input;
  32889. private $output;
  32890. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  32891. {
  32892. $this->command = $command;
  32893. $this->input = $input;
  32894. $this->output = $output;
  32895. }
  32896. public function getCommand()
  32897. {
  32898. return $this->command;
  32899. }
  32900. public function getInput()
  32901. {
  32902. return $this->input;
  32903. }
  32904. public function getOutput()
  32905. {
  32906. return $this->output;
  32907. }
  32908. }
  32909. <?php
  32910. namespace Symfony\Component\Console\Event;
  32911. use Symfony\Component\Console\Command\Command;
  32912. use Symfony\Component\Console\Input\InputInterface;
  32913. use Symfony\Component\Console\Output\OutputInterface;
  32914. class ConsoleExceptionEvent extends ConsoleEvent
  32915. {
  32916. private $exception;
  32917. private $exitCode;
  32918. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  32919. {
  32920. parent::__construct($command, $input, $output);
  32921. $this->setException($exception);
  32922. $this->exitCode = (int) $exitCode;
  32923. }
  32924. public function getException()
  32925. {
  32926. return $this->exception;
  32927. }
  32928. public function setException(\Exception $exception)
  32929. {
  32930. $this->exception = $exception;
  32931. }
  32932. public function getExitCode()
  32933. {
  32934. return $this->exitCode;
  32935. }
  32936. }
  32937. <?php
  32938. namespace Symfony\Component\Console\Event;
  32939. use Symfony\Component\Console\Command\Command;
  32940. use Symfony\Component\Console\Input\InputInterface;
  32941. use Symfony\Component\Console\Output\OutputInterface;
  32942. class ConsoleTerminateEvent extends ConsoleEvent
  32943. {
  32944. private $exitCode;
  32945. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  32946. {
  32947. parent::__construct($command, $input, $output);
  32948. $this->setExitCode($exitCode);
  32949. }
  32950. public function setExitCode($exitCode)
  32951. {
  32952. $this->exitCode = (int) $exitCode;
  32953. }
  32954. public function getExitCode()
  32955. {
  32956. return $this->exitCode;
  32957. }
  32958. }
  32959. <?php
  32960. namespace Symfony\Component\Console\Exception;
  32961. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  32962. {
  32963. private $alternatives;
  32964. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  32965. {
  32966. parent::__construct($message, $code, $previous);
  32967. $this->alternatives = $alternatives;
  32968. }
  32969. public function getAlternatives()
  32970. {
  32971. return $this->alternatives;
  32972. }
  32973. }
  32974. <?php
  32975. namespace Symfony\Component\Console\Exception;
  32976. interface ExceptionInterface
  32977. {
  32978. }
  32979. <?php
  32980. namespace Symfony\Component\Console\Exception;
  32981. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  32982. {
  32983. }
  32984. <?php
  32985. namespace Symfony\Component\Console\Exception;
  32986. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  32987. {
  32988. }
  32989. <?php
  32990. namespace Symfony\Component\Console\Exception;
  32991. class LogicException extends \LogicException implements ExceptionInterface
  32992. {
  32993. }
  32994. <?php
  32995. namespace Symfony\Component\Console\Exception;
  32996. class RuntimeException extends \RuntimeException implements ExceptionInterface
  32997. {
  32998. }
  32999. <?php
  33000. namespace Symfony\Component\Console\Formatter;
  33001. use Symfony\Component\Console\Exception\InvalidArgumentException;
  33002. class OutputFormatter implements OutputFormatterInterface
  33003. {
  33004. private $decorated;
  33005. private $styles = array();
  33006. private $styleStack;
  33007. public static function escape($text)
  33008. {
  33009. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  33010. return self::escapeTrailingBackslash($text);
  33011. }
  33012. public static function escapeTrailingBackslash($text)
  33013. {
  33014. if ('\\' === substr($text, -1)) {
  33015. $len = \strlen($text);
  33016. $text = rtrim($text, '\\');
  33017. $text = str_replace("\0", '', $text);
  33018. $text .= str_repeat("\0", $len - \strlen($text));
  33019. }
  33020. return $text;
  33021. }
  33022. public function __construct($decorated = false, array $styles = array())
  33023. {
  33024. $this->decorated = (bool) $decorated;
  33025. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  33026. $this->setStyle('info', new OutputFormatterStyle('green'));
  33027. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  33028. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  33029. foreach ($styles as $name => $style) {
  33030. $this->setStyle($name, $style);
  33031. }
  33032. $this->styleStack = new OutputFormatterStyleStack();
  33033. }
  33034. public function setDecorated($decorated)
  33035. {
  33036. $this->decorated = (bool) $decorated;
  33037. }
  33038. public function isDecorated()
  33039. {
  33040. return $this->decorated;
  33041. }
  33042. public function setStyle($name, OutputFormatterStyleInterface $style)
  33043. {
  33044. $this->styles[strtolower($name)] = $style;
  33045. }
  33046. public function hasStyle($name)
  33047. {
  33048. return isset($this->styles[strtolower($name)]);
  33049. }
  33050. public function getStyle($name)
  33051. {
  33052. if (!$this->hasStyle($name)) {
  33053. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  33054. }
  33055. return $this->styles[strtolower($name)];
  33056. }
  33057. public function format($message)
  33058. {
  33059. $message = (string) $message;
  33060. $offset = 0;
  33061. $output = '';
  33062. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  33063. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  33064. foreach ($matches[0] as $i => $match) {
  33065. $pos = $match[1];
  33066. $text = $match[0];
  33067. if (0 != $pos && '\\' == $message[$pos - 1]) {
  33068. continue;
  33069. }
  33070. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  33071. $offset = $pos + \strlen($text);
  33072. if ($open = '/' != $text[1]) {
  33073. $tag = $matches[1][$i][0];
  33074. } else {
  33075. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  33076. }
  33077. if (!$open && !$tag) {
  33078. $this->styleStack->pop();
  33079. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  33080. $output .= $this->applyCurrentStyle($text);
  33081. } elseif ($open) {
  33082. $this->styleStack->push($style);
  33083. } else {
  33084. $this->styleStack->pop($style);
  33085. }
  33086. }
  33087. $output .= $this->applyCurrentStyle(substr($message, $offset));
  33088. if (false !== strpos($output, "\0")) {
  33089. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  33090. }
  33091. return str_replace('\\<', '<', $output);
  33092. }
  33093. public function getStyleStack()
  33094. {
  33095. return $this->styleStack;
  33096. }
  33097. private function createStyleFromString($string)
  33098. {
  33099. if (isset($this->styles[$string])) {
  33100. return $this->styles[$string];
  33101. }
  33102. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  33103. return false;
  33104. }
  33105. $style = new OutputFormatterStyle();
  33106. foreach ($matches as $match) {
  33107. array_shift($match);
  33108. if ('fg' == $match[0]) {
  33109. $style->setForeground($match[1]);
  33110. } elseif ('bg' == $match[0]) {
  33111. $style->setBackground($match[1]);
  33112. } else {
  33113. try {
  33114. $style->setOption($match[1]);
  33115. } catch (\InvalidArgumentException $e) {
  33116. return false;
  33117. }
  33118. }
  33119. }
  33120. return $style;
  33121. }
  33122. private function applyCurrentStyle($text)
  33123. {
  33124. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  33125. }
  33126. }
  33127. <?php
  33128. namespace Symfony\Component\Console\Formatter;
  33129. interface OutputFormatterInterface
  33130. {
  33131. public function setDecorated($decorated);
  33132. public function isDecorated();
  33133. public function setStyle($name, OutputFormatterStyleInterface $style);
  33134. public function hasStyle($name);
  33135. public function getStyle($name);
  33136. public function format($message);
  33137. }
  33138. <?php
  33139. namespace Symfony\Component\Console\Formatter;
  33140. use Symfony\Component\Console\Exception\InvalidArgumentException;
  33141. class OutputFormatterStyle implements OutputFormatterStyleInterface
  33142. {
  33143. private static $availableForegroundColors = array(
  33144. 'black' => array('set' => 30, 'unset' => 39),
  33145. 'red' => array('set' => 31, 'unset' => 39),
  33146. 'green' => array('set' => 32, 'unset' => 39),
  33147. 'yellow' => array('set' => 33, 'unset' => 39),
  33148. 'blue' => array('set' => 34, 'unset' => 39),
  33149. 'magenta' => array('set' => 35, 'unset' => 39),
  33150. 'cyan' => array('set' => 36, 'unset' => 39),
  33151. 'white' => array('set' => 37, 'unset' => 39),
  33152. 'default' => array('set' => 39, 'unset' => 39),
  33153. );
  33154. private static $availableBackgroundColors = array(
  33155. 'black' => array('set' => 40, 'unset' => 49),
  33156. 'red' => array('set' => 41, 'unset' => 49),
  33157. 'green' => array('set' => 42, 'unset' => 49),
  33158. 'yellow' => array('set' => 43, 'unset' => 49),
  33159. 'blue' => array('set' => 44, 'unset' => 49),
  33160. 'magenta' => array('set' => 45, 'unset' => 49),
  33161. 'cyan' => array('set' => 46, 'unset' => 49),
  33162. 'white' => array('set' => 47, 'unset' => 49),
  33163. 'default' => array('set' => 49, 'unset' => 49),
  33164. );
  33165. private static $availableOptions = array(
  33166. 'bold' => array('set' => 1, 'unset' => 22),
  33167. 'underscore' => array('set' => 4, 'unset' => 24),
  33168. 'blink' => array('set' => 5, 'unset' => 25),
  33169. 'reverse' => array('set' => 7, 'unset' => 27),
  33170. 'conceal' => array('set' => 8, 'unset' => 28),
  33171. );
  33172. private $foreground;
  33173. private $background;
  33174. private $options = array();
  33175. public function __construct($foreground = null, $background = null, array $options = array())
  33176. {
  33177. if (null !== $foreground) {
  33178. $this->setForeground($foreground);
  33179. }
  33180. if (null !== $background) {
  33181. $this->setBackground($background);
  33182. }
  33183. if (\count($options)) {
  33184. $this->setOptions($options);
  33185. }
  33186. }
  33187. public function setForeground($color = null)
  33188. {
  33189. if (null === $color) {
  33190. $this->foreground = null;
  33191. return;
  33192. }
  33193. if (!isset(static::$availableForegroundColors[$color])) {
  33194. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  33195. }
  33196. $this->foreground = static::$availableForegroundColors[$color];
  33197. }
  33198. public function setBackground($color = null)
  33199. {
  33200. if (null === $color) {
  33201. $this->background = null;
  33202. return;
  33203. }
  33204. if (!isset(static::$availableBackgroundColors[$color])) {
  33205. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  33206. }
  33207. $this->background = static::$availableBackgroundColors[$color];
  33208. }
  33209. public function setOption($option)
  33210. {
  33211. if (!isset(static::$availableOptions[$option])) {
  33212. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  33213. }
  33214. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  33215. $this->options[] = static::$availableOptions[$option];
  33216. }
  33217. }
  33218. public function unsetOption($option)
  33219. {
  33220. if (!isset(static::$availableOptions[$option])) {
  33221. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  33222. }
  33223. $pos = array_search(static::$availableOptions[$option], $this->options);
  33224. if (false !== $pos) {
  33225. unset($this->options[$pos]);
  33226. }
  33227. }
  33228. public function setOptions(array $options)
  33229. {
  33230. $this->options = array();
  33231. foreach ($options as $option) {
  33232. $this->setOption($option);
  33233. }
  33234. }
  33235. public function apply($text)
  33236. {
  33237. $setCodes = array();
  33238. $unsetCodes = array();
  33239. if (null !== $this->foreground) {
  33240. $setCodes[] = $this->foreground['set'];
  33241. $unsetCodes[] = $this->foreground['unset'];
  33242. }
  33243. if (null !== $this->background) {
  33244. $setCodes[] = $this->background['set'];
  33245. $unsetCodes[] = $this->background['unset'];
  33246. }
  33247. if (\count($this->options)) {
  33248. foreach ($this->options as $option) {
  33249. $setCodes[] = $option['set'];
  33250. $unsetCodes[] = $option['unset'];
  33251. }
  33252. }
  33253. if (0 === \count($setCodes)) {
  33254. return $text;
  33255. }
  33256. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  33257. }
  33258. }
  33259. <?php
  33260. namespace Symfony\Component\Console\Formatter;
  33261. interface OutputFormatterStyleInterface
  33262. {
  33263. public function setForeground($color = null);
  33264. public function setBackground($color = null);
  33265. public function setOption($option);
  33266. public function unsetOption($option);
  33267. public function setOptions(array $options);
  33268. public function apply($text);
  33269. }
  33270. <?php
  33271. namespace Symfony\Component\Console\Formatter;
  33272. use Symfony\Component\Console\Exception\InvalidArgumentException;
  33273. class OutputFormatterStyleStack
  33274. {
  33275. private $styles;
  33276. private $emptyStyle;
  33277. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  33278. {
  33279. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  33280. $this->reset();
  33281. }
  33282. public function reset()
  33283. {
  33284. $this->styles = array();
  33285. }
  33286. public function push(OutputFormatterStyleInterface $style)
  33287. {
  33288. $this->styles[] = $style;
  33289. }
  33290. public function pop(OutputFormatterStyleInterface $style = null)
  33291. {
  33292. if (empty($this->styles)) {
  33293. return $this->emptyStyle;
  33294. }
  33295. if (null === $style) {
  33296. return array_pop($this->styles);
  33297. }
  33298. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  33299. if ($style->apply('') === $stackedStyle->apply('')) {
  33300. $this->styles = \array_slice($this->styles, 0, $index);
  33301. return $stackedStyle;
  33302. }
  33303. }
  33304. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  33305. }
  33306. public function getCurrent()
  33307. {
  33308. if (empty($this->styles)) {
  33309. return $this->emptyStyle;
  33310. }
  33311. return $this->styles[\count($this->styles) - 1];
  33312. }
  33313. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  33314. {
  33315. $this->emptyStyle = $emptyStyle;
  33316. return $this;
  33317. }
  33318. public function getEmptyStyle()
  33319. {
  33320. return $this->emptyStyle;
  33321. }
  33322. }
  33323. <?php
  33324. namespace Symfony\Component\Console\Helper;
  33325. class DebugFormatterHelper extends Helper
  33326. {
  33327. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  33328. private $started = array();
  33329. private $count = -1;
  33330. public function start($id, $message, $prefix = 'RUN')
  33331. {
  33332. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  33333. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  33334. }
  33335. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  33336. {
  33337. $message = '';
  33338. if ($error) {
  33339. if (isset($this->started[$id]['out'])) {
  33340. $message .= "\n";
  33341. unset($this->started[$id]['out']);
  33342. }
  33343. if (!isset($this->started[$id]['err'])) {
  33344. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  33345. $this->started[$id]['err'] = true;
  33346. }
  33347. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  33348. } else {
  33349. if (isset($this->started[$id]['err'])) {
  33350. $message .= "\n";
  33351. unset($this->started[$id]['err']);
  33352. }
  33353. if (!isset($this->started[$id]['out'])) {
  33354. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  33355. $this->started[$id]['out'] = true;
  33356. }
  33357. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  33358. }
  33359. return $message;
  33360. }
  33361. public function stop($id, $message, $successful, $prefix = 'RES')
  33362. {
  33363. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  33364. if ($successful) {
  33365. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  33366. }
  33367. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  33368. unset($this->started[$id]['out'], $this->started[$id]['err']);
  33369. return $message;
  33370. }
  33371. private function getBorder($id)
  33372. {
  33373. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  33374. }
  33375. public function getName()
  33376. {
  33377. return 'debug_formatter';
  33378. }
  33379. }
  33380. <?php
  33381. namespace Symfony\Component\Console\Helper;
  33382. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  33383. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  33384. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  33385. use Symfony\Component\Console\Descriptor\TextDescriptor;
  33386. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  33387. use Symfony\Component\Console\Exception\InvalidArgumentException;
  33388. use Symfony\Component\Console\Output\OutputInterface;
  33389. class DescriptorHelper extends Helper
  33390. {
  33391. private $descriptors = array();
  33392. public function __construct()
  33393. {
  33394. $this
  33395. ->register('txt', new TextDescriptor())
  33396. ->register('xml', new XmlDescriptor())
  33397. ->register('json', new JsonDescriptor())
  33398. ->register('md', new MarkdownDescriptor())
  33399. ;
  33400. }
  33401. public function describe(OutputInterface $output, $object, array $options = array())
  33402. {
  33403. $options = array_merge(array(
  33404. 'raw_text' => false,
  33405. 'format' => 'txt',
  33406. ), $options);
  33407. if (!isset($this->descriptors[$options['format']])) {
  33408. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  33409. }
  33410. $descriptor = $this->descriptors[$options['format']];
  33411. $descriptor->describe($output, $object, $options);
  33412. }
  33413. public function register($format, DescriptorInterface $descriptor)
  33414. {
  33415. $this->descriptors[$format] = $descriptor;
  33416. return $this;
  33417. }
  33418. public function getName()
  33419. {
  33420. return 'descriptor';
  33421. }
  33422. }
  33423. <?php
  33424. namespace Symfony\Component\Console\Helper;
  33425. use Symfony\Component\Console\Exception\InvalidArgumentException;
  33426. use Symfony\Component\Console\Exception\RuntimeException;
  33427. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  33428. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  33429. use Symfony\Component\Console\Output\OutputInterface;
  33430. class DialogHelper extends InputAwareHelper
  33431. {
  33432. private $inputStream;
  33433. private static $shell;
  33434. private static $stty;
  33435. public function __construct($triggerDeprecationError = true)
  33436. {
  33437. if ($triggerDeprecationError) {
  33438. @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);
  33439. }
  33440. }
  33441. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  33442. {
  33443. if ($output instanceof ConsoleOutputInterface) {
  33444. $output = $output->getErrorOutput();
  33445. }
  33446. $width = max(array_map('strlen', array_keys($choices)));
  33447. $messages = (array) $question;
  33448. foreach ($choices as $key => $value) {
  33449. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  33450. }
  33451. $output->writeln($messages);
  33452. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  33453. $selectedChoices = str_replace(' ', '', $picked);
  33454. if ($multiselect) {
  33455. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  33456. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  33457. }
  33458. $selectedChoices = explode(',', $selectedChoices);
  33459. } else {
  33460. $selectedChoices = array($picked);
  33461. }
  33462. $multiselectChoices = array();
  33463. foreach ($selectedChoices as $value) {
  33464. if (empty($choices[$value])) {
  33465. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  33466. }
  33467. $multiselectChoices[] = $value;
  33468. }
  33469. if ($multiselect) {
  33470. return $multiselectChoices;
  33471. }
  33472. return $picked;
  33473. }, $attempts, $default);
  33474. return $result;
  33475. }
  33476. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  33477. {
  33478. if ($this->input && !$this->input->isInteractive()) {
  33479. return $default;
  33480. }
  33481. if ($output instanceof ConsoleOutputInterface) {
  33482. $output = $output->getErrorOutput();
  33483. }
  33484. $output->write($question);
  33485. $inputStream = $this->inputStream ?: STDIN;
  33486. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  33487. $ret = fgets($inputStream, 4096);
  33488. if (false === $ret) {
  33489. throw new RuntimeException('Aborted');
  33490. }
  33491. $ret = trim($ret);
  33492. } else {
  33493. $ret = '';
  33494. $i = 0;
  33495. $ofs = -1;
  33496. $matches = $autocomplete;
  33497. $numMatches = \count($matches);
  33498. $sttyMode = shell_exec('stty -g');
  33499. shell_exec('stty -icanon -echo');
  33500. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  33501. while (!feof($inputStream)) {
  33502. $c = fread($inputStream, 1);
  33503. if ("\177" === $c) {
  33504. if (0 === $numMatches && 0 !== $i) {
  33505. --$i;
  33506. $output->write("\033[1D");
  33507. }
  33508. if (0 === $i) {
  33509. $ofs = -1;
  33510. $matches = $autocomplete;
  33511. $numMatches = \count($matches);
  33512. } else {
  33513. $numMatches = 0;
  33514. }
  33515. $ret = substr($ret, 0, $i);
  33516. } elseif ("\033" === $c) {
  33517. $c .= fread($inputStream, 2);
  33518. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  33519. if ('A' === $c[2] && -1 === $ofs) {
  33520. $ofs = 0;
  33521. }
  33522. if (0 === $numMatches) {
  33523. continue;
  33524. }
  33525. $ofs += ('A' === $c[2]) ? -1 : 1;
  33526. $ofs = ($numMatches + $ofs) % $numMatches;
  33527. }
  33528. } elseif (\ord($c) < 32) {
  33529. if ("\t" === $c || "\n" === $c) {
  33530. if ($numMatches > 0 && -1 !== $ofs) {
  33531. $ret = $matches[$ofs];
  33532. $output->write(substr($ret, $i));
  33533. $i = \strlen($ret);
  33534. }
  33535. if ("\n" === $c) {
  33536. $output->write($c);
  33537. break;
  33538. }
  33539. $numMatches = 0;
  33540. }
  33541. continue;
  33542. } else {
  33543. $output->write($c);
  33544. $ret .= $c;
  33545. ++$i;
  33546. $numMatches = 0;
  33547. $ofs = 0;
  33548. foreach ($autocomplete as $value) {
  33549. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  33550. $matches[$numMatches++] = $value;
  33551. }
  33552. }
  33553. }
  33554. $output->write("\033[K");
  33555. if ($numMatches > 0 && -1 !== $ofs) {
  33556. $output->write("\0337");
  33557. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  33558. $output->write("\0338");
  33559. }
  33560. }
  33561. shell_exec(sprintf('stty %s', $sttyMode));
  33562. }
  33563. return \strlen($ret) > 0 ? $ret : $default;
  33564. }
  33565. public function askConfirmation(OutputInterface $output, $question, $default = true)
  33566. {
  33567. $answer = 'z';
  33568. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  33569. $answer = $this->ask($output, $question);
  33570. }
  33571. if (false === $default) {
  33572. return $answer && 'y' == strtolower($answer[0]);
  33573. }
  33574. return !$answer || 'y' == strtolower($answer[0]);
  33575. }
  33576. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  33577. {
  33578. if ($output instanceof ConsoleOutputInterface) {
  33579. $output = $output->getErrorOutput();
  33580. }
  33581. if ('\\' === \DIRECTORY_SEPARATOR) {
  33582. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  33583. if ('phar:' === substr(__FILE__, 0, 5)) {
  33584. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  33585. copy($exe, $tmpExe);
  33586. $exe = $tmpExe;
  33587. }
  33588. $output->write($question);
  33589. $value = rtrim(shell_exec($exe));
  33590. $output->writeln('');
  33591. if (isset($tmpExe)) {
  33592. unlink($tmpExe);
  33593. }
  33594. return $value;
  33595. }
  33596. if ($this->hasSttyAvailable()) {
  33597. $output->write($question);
  33598. $sttyMode = shell_exec('stty -g');
  33599. shell_exec('stty -echo');
  33600. $value = fgets($this->inputStream ?: STDIN, 4096);
  33601. shell_exec(sprintf('stty %s', $sttyMode));
  33602. if (false === $value) {
  33603. throw new RuntimeException('Aborted');
  33604. }
  33605. $value = trim($value);
  33606. $output->writeln('');
  33607. return $value;
  33608. }
  33609. if (false !== $shell = $this->getShell()) {
  33610. $output->write($question);
  33611. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  33612. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  33613. $value = rtrim(shell_exec($command));
  33614. $output->writeln('');
  33615. return $value;
  33616. }
  33617. if ($fallback) {
  33618. return $this->ask($output, $question);
  33619. }
  33620. throw new RuntimeException('Unable to hide the response');
  33621. }
  33622. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  33623. {
  33624. $that = $this;
  33625. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  33626. return $that->ask($output, $question, $default, $autocomplete);
  33627. };
  33628. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  33629. }
  33630. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  33631. {
  33632. $that = $this;
  33633. $interviewer = function () use ($output, $question, $fallback, $that) {
  33634. return $that->askHiddenResponse($output, $question, $fallback);
  33635. };
  33636. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  33637. }
  33638. public function setInputStream($stream)
  33639. {
  33640. $this->inputStream = $stream;
  33641. }
  33642. public function getInputStream()
  33643. {
  33644. return $this->inputStream;
  33645. }
  33646. public function getName()
  33647. {
  33648. return 'dialog';
  33649. }
  33650. private function getShell()
  33651. {
  33652. if (null !== self::$shell) {
  33653. return self::$shell;
  33654. }
  33655. self::$shell = false;
  33656. if (file_exists('/usr/bin/env')) {
  33657. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  33658. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  33659. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  33660. self::$shell = $sh;
  33661. break;
  33662. }
  33663. }
  33664. }
  33665. return self::$shell;
  33666. }
  33667. private function hasSttyAvailable()
  33668. {
  33669. if (null !== self::$stty) {
  33670. return self::$stty;
  33671. }
  33672. exec('stty 2>&1', $output, $exitcode);
  33673. return self::$stty = 0 === $exitcode;
  33674. }
  33675. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  33676. {
  33677. if ($output instanceof ConsoleOutputInterface) {
  33678. $output = $output->getErrorOutput();
  33679. }
  33680. $e = null;
  33681. while (false === $attempts || $attempts--) {
  33682. if (null !== $e) {
  33683. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  33684. }
  33685. try {
  33686. return \call_user_func($validator, $interviewer());
  33687. } catch (\Exception $e) {
  33688. }
  33689. }
  33690. throw $e;
  33691. }
  33692. }
  33693. <?php
  33694. namespace Symfony\Component\Console\Helper;
  33695. use Symfony\Component\Console\Formatter\OutputFormatter;
  33696. class FormatterHelper extends Helper
  33697. {
  33698. public function formatSection($section, $message, $style = 'info')
  33699. {
  33700. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  33701. }
  33702. public function formatBlock($messages, $style, $large = false)
  33703. {
  33704. if (!\is_array($messages)) {
  33705. $messages = array($messages);
  33706. }
  33707. $len = 0;
  33708. $lines = array();
  33709. foreach ($messages as $message) {
  33710. $message = OutputFormatter::escape($message);
  33711. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  33712. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  33713. }
  33714. $messages = $large ? array(str_repeat(' ', $len)) : array();
  33715. for ($i = 0; isset($lines[$i]); ++$i) {
  33716. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  33717. }
  33718. if ($large) {
  33719. $messages[] = str_repeat(' ', $len);
  33720. }
  33721. for ($i = 0; isset($messages[$i]); ++$i) {
  33722. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  33723. }
  33724. return implode("\n", $messages);
  33725. }
  33726. public function getName()
  33727. {
  33728. return 'formatter';
  33729. }
  33730. }
  33731. <?php
  33732. namespace Symfony\Component\Console\Helper;
  33733. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  33734. abstract class Helper implements HelperInterface
  33735. {
  33736. protected $helperSet = null;
  33737. public function setHelperSet(HelperSet $helperSet = null)
  33738. {
  33739. $this->helperSet = $helperSet;
  33740. }
  33741. public function getHelperSet()
  33742. {
  33743. return $this->helperSet;
  33744. }
  33745. public static function strlen($string)
  33746. {
  33747. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  33748. return \strlen($string);
  33749. }
  33750. return mb_strwidth($string, $encoding);
  33751. }
  33752. public static function formatTime($secs)
  33753. {
  33754. static $timeFormats = array(
  33755. array(0, '< 1 sec'),
  33756. array(1, '1 sec'),
  33757. array(2, 'secs', 1),
  33758. array(60, '1 min'),
  33759. array(120, 'mins', 60),
  33760. array(3600, '1 hr'),
  33761. array(7200, 'hrs', 3600),
  33762. array(86400, '1 day'),
  33763. array(172800, 'days', 86400),
  33764. );
  33765. foreach ($timeFormats as $index => $format) {
  33766. if ($secs >= $format[0]) {
  33767. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  33768. || $index == \count($timeFormats) - 1
  33769. ) {
  33770. if (2 == \count($format)) {
  33771. return $format[1];
  33772. }
  33773. return floor($secs / $format[2]).' '.$format[1];
  33774. }
  33775. }
  33776. }
  33777. }
  33778. public static function formatMemory($memory)
  33779. {
  33780. if ($memory >= 1024 * 1024 * 1024) {
  33781. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  33782. }
  33783. if ($memory >= 1024 * 1024) {
  33784. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  33785. }
  33786. if ($memory >= 1024) {
  33787. return sprintf('%d KiB', $memory / 1024);
  33788. }
  33789. return sprintf('%d B', $memory);
  33790. }
  33791. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  33792. {
  33793. return self::strlen(self::removeDecoration($formatter, $string));
  33794. }
  33795. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  33796. {
  33797. $isDecorated = $formatter->isDecorated();
  33798. $formatter->setDecorated(false);
  33799. $string = $formatter->format($string);
  33800. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  33801. $formatter->setDecorated($isDecorated);
  33802. return $string;
  33803. }
  33804. }
  33805. <?php
  33806. namespace Symfony\Component\Console\Helper;
  33807. interface HelperInterface
  33808. {
  33809. public function setHelperSet(HelperSet $helperSet = null);
  33810. public function getHelperSet();
  33811. public function getName();
  33812. }
  33813. <?php
  33814. namespace Symfony\Component\Console\Helper;
  33815. use Symfony\Component\Console\Command\Command;
  33816. use Symfony\Component\Console\Exception\InvalidArgumentException;
  33817. class HelperSet implements \IteratorAggregate
  33818. {
  33819. private $helpers = array();
  33820. private $command;
  33821. public function __construct(array $helpers = array())
  33822. {
  33823. foreach ($helpers as $alias => $helper) {
  33824. $this->set($helper, \is_int($alias) ? null : $alias);
  33825. }
  33826. }
  33827. public function set(HelperInterface $helper, $alias = null)
  33828. {
  33829. $this->helpers[$helper->getName()] = $helper;
  33830. if (null !== $alias) {
  33831. $this->helpers[$alias] = $helper;
  33832. }
  33833. $helper->setHelperSet($this);
  33834. }
  33835. public function has($name)
  33836. {
  33837. return isset($this->helpers[$name]);
  33838. }
  33839. public function get($name)
  33840. {
  33841. if (!$this->has($name)) {
  33842. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  33843. }
  33844. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  33845. @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);
  33846. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  33847. @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);
  33848. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  33849. @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);
  33850. }
  33851. return $this->helpers[$name];
  33852. }
  33853. public function setCommand(Command $command = null)
  33854. {
  33855. $this->command = $command;
  33856. }
  33857. public function getCommand()
  33858. {
  33859. return $this->command;
  33860. }
  33861. public function getIterator()
  33862. {
  33863. return new \ArrayIterator($this->helpers);
  33864. }
  33865. }
  33866. <?php
  33867. namespace Symfony\Component\Console\Helper;
  33868. use Symfony\Component\Console\Input\InputAwareInterface;
  33869. use Symfony\Component\Console\Input\InputInterface;
  33870. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  33871. {
  33872. protected $input;
  33873. public function setInput(InputInterface $input)
  33874. {
  33875. $this->input = $input;
  33876. }
  33877. }
  33878. <?php
  33879. namespace Symfony\Component\Console\Helper;
  33880. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  33881. use Symfony\Component\Console\Output\OutputInterface;
  33882. use Symfony\Component\Process\Exception\ProcessFailedException;
  33883. use Symfony\Component\Process\Process;
  33884. use Symfony\Component\Process\ProcessBuilder;
  33885. class ProcessHelper extends Helper
  33886. {
  33887. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  33888. {
  33889. if ($output instanceof ConsoleOutputInterface) {
  33890. $output = $output->getErrorOutput();
  33891. }
  33892. $formatter = $this->getHelperSet()->get('debug_formatter');
  33893. if (\is_array($cmd)) {
  33894. $process = ProcessBuilder::create($cmd)->getProcess();
  33895. } elseif ($cmd instanceof Process) {
  33896. $process = $cmd;
  33897. } else {
  33898. $process = new Process($cmd);
  33899. }
  33900. if ($verbosity <= $output->getVerbosity()) {
  33901. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  33902. }
  33903. if ($output->isDebug()) {
  33904. $callback = $this->wrapCallback($output, $process, $callback);
  33905. }
  33906. $process->run($callback);
  33907. if ($verbosity <= $output->getVerbosity()) {
  33908. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  33909. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  33910. }
  33911. if (!$process->isSuccessful() && null !== $error) {
  33912. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  33913. }
  33914. return $process;
  33915. }
  33916. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  33917. {
  33918. $process = $this->run($output, $cmd, $error, $callback);
  33919. if (!$process->isSuccessful()) {
  33920. throw new ProcessFailedException($process);
  33921. }
  33922. return $process;
  33923. }
  33924. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  33925. {
  33926. if ($output instanceof ConsoleOutputInterface) {
  33927. $output = $output->getErrorOutput();
  33928. }
  33929. $formatter = $this->getHelperSet()->get('debug_formatter');
  33930. $that = $this;
  33931. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  33932. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  33933. if (null !== $callback) {
  33934. \call_user_func($callback, $type, $buffer);
  33935. }
  33936. };
  33937. }
  33938. public function escapeString($str)
  33939. {
  33940. return str_replace('<', '\\<', $str);
  33941. }
  33942. public function getName()
  33943. {
  33944. return 'process';
  33945. }
  33946. }
  33947. <?php
  33948. namespace Symfony\Component\Console\Helper;
  33949. use Symfony\Component\Console\Exception\LogicException;
  33950. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  33951. use Symfony\Component\Console\Output\OutputInterface;
  33952. class ProgressBar
  33953. {
  33954. private $barWidth = 28;
  33955. private $barChar;
  33956. private $emptyBarChar = '-';
  33957. private $progressChar = '>';
  33958. private $format;
  33959. private $internalFormat;
  33960. private $redrawFreq = 1;
  33961. private $output;
  33962. private $step = 0;
  33963. private $max;
  33964. private $startTime;
  33965. private $stepWidth;
  33966. private $percent = 0.0;
  33967. private $formatLineCount;
  33968. private $messages = array();
  33969. private $overwrite = true;
  33970. private $firstRun = true;
  33971. private static $formatters;
  33972. private static $formats;
  33973. public function __construct(OutputInterface $output, $max = 0)
  33974. {
  33975. if ($output instanceof ConsoleOutputInterface) {
  33976. $output = $output->getErrorOutput();
  33977. }
  33978. $this->output = $output;
  33979. $this->setMaxSteps($max);
  33980. if (!$this->output->isDecorated()) {
  33981. $this->overwrite = false;
  33982. $this->setRedrawFrequency($max / 10);
  33983. }
  33984. $this->startTime = time();
  33985. }
  33986. public static function setPlaceholderFormatterDefinition($name, $callable)
  33987. {
  33988. if (!self::$formatters) {
  33989. self::$formatters = self::initPlaceholderFormatters();
  33990. }
  33991. self::$formatters[$name] = $callable;
  33992. }
  33993. public static function getPlaceholderFormatterDefinition($name)
  33994. {
  33995. if (!self::$formatters) {
  33996. self::$formatters = self::initPlaceholderFormatters();
  33997. }
  33998. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  33999. }
  34000. public static function setFormatDefinition($name, $format)
  34001. {
  34002. if (!self::$formats) {
  34003. self::$formats = self::initFormats();
  34004. }
  34005. self::$formats[$name] = $format;
  34006. }
  34007. public static function getFormatDefinition($name)
  34008. {
  34009. if (!self::$formats) {
  34010. self::$formats = self::initFormats();
  34011. }
  34012. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  34013. }
  34014. public function setMessage($message, $name = 'message')
  34015. {
  34016. $this->messages[$name] = $message;
  34017. }
  34018. public function getMessage($name = 'message')
  34019. {
  34020. return $this->messages[$name];
  34021. }
  34022. public function getStartTime()
  34023. {
  34024. return $this->startTime;
  34025. }
  34026. public function getMaxSteps()
  34027. {
  34028. return $this->max;
  34029. }
  34030. public function getStep()
  34031. {
  34032. @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);
  34033. return $this->getProgress();
  34034. }
  34035. public function getProgress()
  34036. {
  34037. return $this->step;
  34038. }
  34039. public function getStepWidth()
  34040. {
  34041. return $this->stepWidth;
  34042. }
  34043. public function getProgressPercent()
  34044. {
  34045. return $this->percent;
  34046. }
  34047. public function setBarWidth($size)
  34048. {
  34049. $this->barWidth = (int) $size;
  34050. }
  34051. public function getBarWidth()
  34052. {
  34053. return $this->barWidth;
  34054. }
  34055. public function setBarCharacter($char)
  34056. {
  34057. $this->barChar = $char;
  34058. }
  34059. public function getBarCharacter()
  34060. {
  34061. if (null === $this->barChar) {
  34062. return $this->max ? '=' : $this->emptyBarChar;
  34063. }
  34064. return $this->barChar;
  34065. }
  34066. public function setEmptyBarCharacter($char)
  34067. {
  34068. $this->emptyBarChar = $char;
  34069. }
  34070. public function getEmptyBarCharacter()
  34071. {
  34072. return $this->emptyBarChar;
  34073. }
  34074. public function setProgressCharacter($char)
  34075. {
  34076. $this->progressChar = $char;
  34077. }
  34078. public function getProgressCharacter()
  34079. {
  34080. return $this->progressChar;
  34081. }
  34082. public function setFormat($format)
  34083. {
  34084. $this->format = null;
  34085. $this->internalFormat = $format;
  34086. }
  34087. public function setRedrawFrequency($freq)
  34088. {
  34089. $this->redrawFreq = max((int) $freq, 1);
  34090. }
  34091. public function start($max = null)
  34092. {
  34093. $this->startTime = time();
  34094. $this->step = 0;
  34095. $this->percent = 0.0;
  34096. if (null !== $max) {
  34097. $this->setMaxSteps($max);
  34098. }
  34099. $this->display();
  34100. }
  34101. public function advance($step = 1)
  34102. {
  34103. $this->setProgress($this->step + $step);
  34104. }
  34105. public function setCurrent($step)
  34106. {
  34107. @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);
  34108. $this->setProgress($step);
  34109. }
  34110. public function setOverwrite($overwrite)
  34111. {
  34112. $this->overwrite = (bool) $overwrite;
  34113. }
  34114. public function setProgress($step)
  34115. {
  34116. $step = (int) $step;
  34117. if ($step < $this->step) {
  34118. throw new LogicException('You can\'t regress the progress bar.');
  34119. }
  34120. if ($this->max && $step > $this->max) {
  34121. $this->max = $step;
  34122. }
  34123. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  34124. $currPeriod = (int) ($step / $this->redrawFreq);
  34125. $this->step = $step;
  34126. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  34127. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  34128. $this->display();
  34129. }
  34130. }
  34131. public function finish()
  34132. {
  34133. if (!$this->max) {
  34134. $this->max = $this->step;
  34135. }
  34136. if ($this->step === $this->max && !$this->overwrite) {
  34137. return;
  34138. }
  34139. $this->setProgress($this->max);
  34140. }
  34141. public function display()
  34142. {
  34143. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  34144. return;
  34145. }
  34146. if (null === $this->format) {
  34147. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  34148. }
  34149. $self = $this;
  34150. $output = $this->output;
  34151. $messages = $this->messages;
  34152. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  34153. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  34154. $text = \call_user_func($formatter, $self, $output);
  34155. } elseif (isset($messages[$matches[1]])) {
  34156. $text = $messages[$matches[1]];
  34157. } else {
  34158. return $matches[0];
  34159. }
  34160. if (isset($matches[2])) {
  34161. $text = sprintf('%'.$matches[2], $text);
  34162. }
  34163. return $text;
  34164. }, $this->format));
  34165. }
  34166. public function clear()
  34167. {
  34168. if (!$this->overwrite) {
  34169. return;
  34170. }
  34171. if (null === $this->format) {
  34172. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  34173. }
  34174. $this->overwrite('');
  34175. }
  34176. private function setRealFormat($format)
  34177. {
  34178. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  34179. $this->format = self::getFormatDefinition($format.'_nomax');
  34180. } elseif (null !== self::getFormatDefinition($format)) {
  34181. $this->format = self::getFormatDefinition($format);
  34182. } else {
  34183. $this->format = $format;
  34184. }
  34185. $this->formatLineCount = substr_count($this->format, "\n");
  34186. }
  34187. private function setMaxSteps($max)
  34188. {
  34189. $this->max = max(0, (int) $max);
  34190. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  34191. }
  34192. private function overwrite($message)
  34193. {
  34194. if ($this->overwrite) {
  34195. if (!$this->firstRun) {
  34196. $this->output->write("\x0D");
  34197. $this->output->write("\x1B[2K");
  34198. if ($this->formatLineCount > 0) {
  34199. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  34200. }
  34201. }
  34202. } elseif ($this->step > 0) {
  34203. $this->output->writeln('');
  34204. }
  34205. $this->firstRun = false;
  34206. $this->output->write($message);
  34207. }
  34208. private function determineBestFormat()
  34209. {
  34210. switch ($this->output->getVerbosity()) {
  34211. case OutputInterface::VERBOSITY_VERBOSE:
  34212. return $this->max ? 'verbose' : 'verbose_nomax';
  34213. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  34214. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  34215. case OutputInterface::VERBOSITY_DEBUG:
  34216. return $this->max ? 'debug' : 'debug_nomax';
  34217. default:
  34218. return $this->max ? 'normal' : 'normal_nomax';
  34219. }
  34220. }
  34221. private static function initPlaceholderFormatters()
  34222. {
  34223. return array(
  34224. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  34225. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  34226. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  34227. if ($completeBars < $bar->getBarWidth()) {
  34228. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  34229. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  34230. }
  34231. return $display;
  34232. },
  34233. 'elapsed' => function (ProgressBar $bar) {
  34234. return Helper::formatTime(time() - $bar->getStartTime());
  34235. },
  34236. 'remaining' => function (ProgressBar $bar) {
  34237. if (!$bar->getMaxSteps()) {
  34238. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  34239. }
  34240. if (!$bar->getProgress()) {
  34241. $remaining = 0;
  34242. } else {
  34243. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  34244. }
  34245. return Helper::formatTime($remaining);
  34246. },
  34247. 'estimated' => function (ProgressBar $bar) {
  34248. if (!$bar->getMaxSteps()) {
  34249. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  34250. }
  34251. if (!$bar->getProgress()) {
  34252. $estimated = 0;
  34253. } else {
  34254. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  34255. }
  34256. return Helper::formatTime($estimated);
  34257. },
  34258. 'memory' => function (ProgressBar $bar) {
  34259. return Helper::formatMemory(memory_get_usage(true));
  34260. },
  34261. 'current' => function (ProgressBar $bar) {
  34262. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  34263. },
  34264. 'max' => function (ProgressBar $bar) {
  34265. return $bar->getMaxSteps();
  34266. },
  34267. 'percent' => function (ProgressBar $bar) {
  34268. return floor($bar->getProgressPercent() * 100);
  34269. },
  34270. );
  34271. }
  34272. private static function initFormats()
  34273. {
  34274. return array(
  34275. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  34276. 'normal_nomax' => ' %current% [%bar%]',
  34277. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  34278. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  34279. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  34280. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  34281. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  34282. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  34283. );
  34284. }
  34285. }
  34286. <?php
  34287. namespace Symfony\Component\Console\Helper;
  34288. use Symfony\Component\Console\Exception\LogicException;
  34289. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  34290. use Symfony\Component\Console\Output\NullOutput;
  34291. use Symfony\Component\Console\Output\OutputInterface;
  34292. class ProgressHelper extends Helper
  34293. {
  34294. const FORMAT_QUIET = ' %percent%%';
  34295. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  34296. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  34297. const FORMAT_QUIET_NOMAX = ' %current%';
  34298. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  34299. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  34300. private $barWidth = 28;
  34301. private $barChar = '=';
  34302. private $emptyBarChar = '-';
  34303. private $progressChar = '>';
  34304. private $format = null;
  34305. private $redrawFreq = 1;
  34306. private $lastMessagesLength;
  34307. private $barCharOriginal;
  34308. private $output;
  34309. private $current;
  34310. private $max;
  34311. private $startTime;
  34312. private $defaultFormatVars = array(
  34313. 'current',
  34314. 'max',
  34315. 'bar',
  34316. 'percent',
  34317. 'elapsed',
  34318. );
  34319. private $formatVars;
  34320. private $widths = array(
  34321. 'current' => 4,
  34322. 'max' => 4,
  34323. 'percent' => 3,
  34324. 'elapsed' => 6,
  34325. );
  34326. private $timeFormats = array(
  34327. array(0, '???'),
  34328. array(2, '1 sec'),
  34329. array(59, 'secs', 1),
  34330. array(60, '1 min'),
  34331. array(3600, 'mins', 60),
  34332. array(5400, '1 hr'),
  34333. array(86400, 'hrs', 3600),
  34334. array(129600, '1 day'),
  34335. array(604800, 'days', 86400),
  34336. );
  34337. public function __construct($triggerDeprecationError = true)
  34338. {
  34339. if ($triggerDeprecationError) {
  34340. @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);
  34341. }
  34342. }
  34343. public function setBarWidth($size)
  34344. {
  34345. $this->barWidth = (int) $size;
  34346. }
  34347. public function setBarCharacter($char)
  34348. {
  34349. $this->barChar = $char;
  34350. }
  34351. public function setEmptyBarCharacter($char)
  34352. {
  34353. $this->emptyBarChar = $char;
  34354. }
  34355. public function setProgressCharacter($char)
  34356. {
  34357. $this->progressChar = $char;
  34358. }
  34359. public function setFormat($format)
  34360. {
  34361. $this->format = $format;
  34362. }
  34363. public function setRedrawFrequency($freq)
  34364. {
  34365. $this->redrawFreq = (int) $freq;
  34366. }
  34367. public function start(OutputInterface $output, $max = null)
  34368. {
  34369. if ($output instanceof ConsoleOutputInterface) {
  34370. $output = $output->getErrorOutput();
  34371. }
  34372. $this->startTime = time();
  34373. $this->current = 0;
  34374. $this->max = (int) $max;
  34375. $this->output = $output->isDecorated() ? $output : new NullOutput();
  34376. $this->lastMessagesLength = 0;
  34377. $this->barCharOriginal = '';
  34378. if (null === $this->format) {
  34379. switch ($output->getVerbosity()) {
  34380. case OutputInterface::VERBOSITY_QUIET:
  34381. $this->format = self::FORMAT_QUIET_NOMAX;
  34382. if ($this->max > 0) {
  34383. $this->format = self::FORMAT_QUIET;
  34384. }
  34385. break;
  34386. case OutputInterface::VERBOSITY_VERBOSE:
  34387. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  34388. case OutputInterface::VERBOSITY_DEBUG:
  34389. $this->format = self::FORMAT_VERBOSE_NOMAX;
  34390. if ($this->max > 0) {
  34391. $this->format = self::FORMAT_VERBOSE;
  34392. }
  34393. break;
  34394. default:
  34395. $this->format = self::FORMAT_NORMAL_NOMAX;
  34396. if ($this->max > 0) {
  34397. $this->format = self::FORMAT_NORMAL;
  34398. }
  34399. break;
  34400. }
  34401. }
  34402. $this->initialize();
  34403. }
  34404. public function advance($step = 1, $redraw = false)
  34405. {
  34406. $this->setCurrent($this->current + $step, $redraw);
  34407. }
  34408. public function setCurrent($current, $redraw = false)
  34409. {
  34410. if (null === $this->startTime) {
  34411. throw new LogicException('You must start the progress bar before calling setCurrent().');
  34412. }
  34413. $current = (int) $current;
  34414. if ($current < $this->current) {
  34415. throw new LogicException('You can\'t regress the progress bar');
  34416. }
  34417. if (0 === $this->current) {
  34418. $redraw = true;
  34419. }
  34420. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  34421. $this->current = $current;
  34422. $currPeriod = (int) ($this->current / $this->redrawFreq);
  34423. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  34424. $this->display();
  34425. }
  34426. }
  34427. public function display($finish = false)
  34428. {
  34429. if (null === $this->startTime) {
  34430. throw new LogicException('You must start the progress bar before calling display().');
  34431. }
  34432. $message = $this->format;
  34433. foreach ($this->generate($finish) as $name => $value) {
  34434. $message = str_replace("%{$name}%", $value, $message);
  34435. }
  34436. $this->overwrite($this->output, $message);
  34437. }
  34438. public function clear()
  34439. {
  34440. $this->overwrite($this->output, '');
  34441. }
  34442. public function finish()
  34443. {
  34444. if (null === $this->startTime) {
  34445. throw new LogicException('You must start the progress bar before calling finish().');
  34446. }
  34447. if (null !== $this->startTime) {
  34448. if (!$this->max) {
  34449. $this->barChar = $this->barCharOriginal;
  34450. $this->display(true);
  34451. }
  34452. $this->startTime = null;
  34453. $this->output->writeln('');
  34454. $this->output = null;
  34455. }
  34456. }
  34457. private function initialize()
  34458. {
  34459. $this->formatVars = array();
  34460. foreach ($this->defaultFormatVars as $var) {
  34461. if (false !== strpos($this->format, "%{$var}%")) {
  34462. $this->formatVars[$var] = true;
  34463. }
  34464. }
  34465. if ($this->max > 0) {
  34466. $this->widths['max'] = $this->strlen($this->max);
  34467. $this->widths['current'] = $this->widths['max'];
  34468. } else {
  34469. $this->barCharOriginal = $this->barChar;
  34470. $this->barChar = $this->emptyBarChar;
  34471. }
  34472. }
  34473. private function generate($finish = false)
  34474. {
  34475. $vars = array();
  34476. $percent = 0;
  34477. if ($this->max > 0) {
  34478. $percent = (float) $this->current / $this->max;
  34479. }
  34480. if (isset($this->formatVars['bar'])) {
  34481. if ($this->max > 0) {
  34482. $completeBars = floor($percent * $this->barWidth);
  34483. } else {
  34484. if (!$finish) {
  34485. $completeBars = floor($this->current % $this->barWidth);
  34486. } else {
  34487. $completeBars = $this->barWidth;
  34488. }
  34489. }
  34490. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  34491. $bar = str_repeat($this->barChar, $completeBars);
  34492. if ($completeBars < $this->barWidth) {
  34493. $bar .= $this->progressChar;
  34494. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  34495. }
  34496. $vars['bar'] = $bar;
  34497. }
  34498. if (isset($this->formatVars['elapsed'])) {
  34499. $elapsed = time() - $this->startTime;
  34500. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  34501. }
  34502. if (isset($this->formatVars['current'])) {
  34503. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  34504. }
  34505. if (isset($this->formatVars['max'])) {
  34506. $vars['max'] = $this->max;
  34507. }
  34508. if (isset($this->formatVars['percent'])) {
  34509. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  34510. }
  34511. return $vars;
  34512. }
  34513. private function humaneTime($secs)
  34514. {
  34515. $text = '';
  34516. foreach ($this->timeFormats as $format) {
  34517. if ($secs < $format[0]) {
  34518. if (2 == \count($format)) {
  34519. $text = $format[1];
  34520. break;
  34521. } else {
  34522. $text = ceil($secs / $format[2]).' '.$format[1];
  34523. break;
  34524. }
  34525. }
  34526. }
  34527. return $text;
  34528. }
  34529. private function overwrite(OutputInterface $output, $message)
  34530. {
  34531. $length = $this->strlen($message);
  34532. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  34533. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  34534. }
  34535. $output->write("\x0D");
  34536. $output->write($message);
  34537. $this->lastMessagesLength = $this->strlen($message);
  34538. }
  34539. public function getName()
  34540. {
  34541. return 'progress';
  34542. }
  34543. }
  34544. <?php
  34545. namespace Symfony\Component\Console\Helper;
  34546. use Symfony\Component\Console\Exception\InvalidArgumentException;
  34547. use Symfony\Component\Console\Exception\LogicException;
  34548. use Symfony\Component\Console\Output\OutputInterface;
  34549. class ProgressIndicator
  34550. {
  34551. private $output;
  34552. private $startTime;
  34553. private $format;
  34554. private $message;
  34555. private $indicatorValues;
  34556. private $indicatorCurrent;
  34557. private $indicatorChangeInterval;
  34558. private $indicatorUpdateTime;
  34559. private $started = false;
  34560. private static $formatters;
  34561. private static $formats;
  34562. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  34563. {
  34564. $this->output = $output;
  34565. if (null === $format) {
  34566. $format = $this->determineBestFormat();
  34567. }
  34568. if (null === $indicatorValues) {
  34569. $indicatorValues = array('-', '\\', '|', '/');
  34570. }
  34571. $indicatorValues = array_values($indicatorValues);
  34572. if (2 > \count($indicatorValues)) {
  34573. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  34574. }
  34575. $this->format = self::getFormatDefinition($format);
  34576. $this->indicatorChangeInterval = $indicatorChangeInterval;
  34577. $this->indicatorValues = $indicatorValues;
  34578. $this->startTime = time();
  34579. }
  34580. public function setMessage($message)
  34581. {
  34582. $this->message = $message;
  34583. $this->display();
  34584. }
  34585. public function getMessage()
  34586. {
  34587. return $this->message;
  34588. }
  34589. public function getStartTime()
  34590. {
  34591. return $this->startTime;
  34592. }
  34593. public function getCurrentValue()
  34594. {
  34595. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  34596. }
  34597. public function start($message)
  34598. {
  34599. if ($this->started) {
  34600. throw new LogicException('Progress indicator already started.');
  34601. }
  34602. $this->message = $message;
  34603. $this->started = true;
  34604. $this->startTime = time();
  34605. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  34606. $this->indicatorCurrent = 0;
  34607. $this->display();
  34608. }
  34609. public function advance()
  34610. {
  34611. if (!$this->started) {
  34612. throw new LogicException('Progress indicator has not yet been started.');
  34613. }
  34614. if (!$this->output->isDecorated()) {
  34615. return;
  34616. }
  34617. $currentTime = $this->getCurrentTimeInMilliseconds();
  34618. if ($currentTime < $this->indicatorUpdateTime) {
  34619. return;
  34620. }
  34621. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  34622. ++$this->indicatorCurrent;
  34623. $this->display();
  34624. }
  34625. public function finish($message)
  34626. {
  34627. if (!$this->started) {
  34628. throw new LogicException('Progress indicator has not yet been started.');
  34629. }
  34630. $this->message = $message;
  34631. $this->display();
  34632. $this->output->writeln('');
  34633. $this->started = false;
  34634. }
  34635. public static function getFormatDefinition($name)
  34636. {
  34637. if (!self::$formats) {
  34638. self::$formats = self::initFormats();
  34639. }
  34640. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  34641. }
  34642. public static function setPlaceholderFormatterDefinition($name, $callable)
  34643. {
  34644. if (!self::$formatters) {
  34645. self::$formatters = self::initPlaceholderFormatters();
  34646. }
  34647. self::$formatters[$name] = $callable;
  34648. }
  34649. public static function getPlaceholderFormatterDefinition($name)
  34650. {
  34651. if (!self::$formatters) {
  34652. self::$formatters = self::initPlaceholderFormatters();
  34653. }
  34654. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  34655. }
  34656. private function display()
  34657. {
  34658. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  34659. return;
  34660. }
  34661. $self = $this;
  34662. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  34663. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  34664. return \call_user_func($formatter, $self);
  34665. }
  34666. return $matches[0];
  34667. }, $this->format));
  34668. }
  34669. private function determineBestFormat()
  34670. {
  34671. switch ($this->output->getVerbosity()) {
  34672. case OutputInterface::VERBOSITY_VERBOSE:
  34673. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  34674. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  34675. case OutputInterface::VERBOSITY_DEBUG:
  34676. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  34677. default:
  34678. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  34679. }
  34680. }
  34681. private function overwrite($message)
  34682. {
  34683. if ($this->output->isDecorated()) {
  34684. $this->output->write("\x0D\x1B[2K");
  34685. $this->output->write($message);
  34686. } else {
  34687. $this->output->writeln($message);
  34688. }
  34689. }
  34690. private function getCurrentTimeInMilliseconds()
  34691. {
  34692. return round(microtime(true) * 1000);
  34693. }
  34694. private static function initPlaceholderFormatters()
  34695. {
  34696. return array(
  34697. 'indicator' => function (ProgressIndicator $indicator) {
  34698. return $indicator->getCurrentValue();
  34699. },
  34700. 'message' => function (ProgressIndicator $indicator) {
  34701. return $indicator->getMessage();
  34702. },
  34703. 'elapsed' => function (ProgressIndicator $indicator) {
  34704. return Helper::formatTime(time() - $indicator->getStartTime());
  34705. },
  34706. 'memory' => function () {
  34707. return Helper::formatMemory(memory_get_usage(true));
  34708. },
  34709. );
  34710. }
  34711. private static function initFormats()
  34712. {
  34713. return array(
  34714. 'normal' => ' %indicator% %message%',
  34715. 'normal_no_ansi' => ' %message%',
  34716. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  34717. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  34718. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  34719. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  34720. );
  34721. }
  34722. }
  34723. <?php
  34724. namespace Symfony\Component\Console\Helper;
  34725. use Symfony\Component\Console\Exception\InvalidArgumentException;
  34726. use Symfony\Component\Console\Exception\RuntimeException;
  34727. use Symfony\Component\Console\Formatter\OutputFormatter;
  34728. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  34729. use Symfony\Component\Console\Input\InputInterface;
  34730. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  34731. use Symfony\Component\Console\Output\OutputInterface;
  34732. use Symfony\Component\Console\Question\ChoiceQuestion;
  34733. use Symfony\Component\Console\Question\Question;
  34734. class QuestionHelper extends Helper
  34735. {
  34736. private $inputStream;
  34737. private static $shell;
  34738. private static $stty;
  34739. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  34740. {
  34741. if ($output instanceof ConsoleOutputInterface) {
  34742. $output = $output->getErrorOutput();
  34743. }
  34744. if (!$input->isInteractive()) {
  34745. $default = $question->getDefault();
  34746. if (null !== $default && $question instanceof ChoiceQuestion) {
  34747. $choices = $question->getChoices();
  34748. if (!$question->isMultiselect()) {
  34749. return isset($choices[$default]) ? $choices[$default] : $default;
  34750. }
  34751. $default = explode(',', $default);
  34752. foreach ($default as $k => $v) {
  34753. $v = trim($v);
  34754. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  34755. }
  34756. }
  34757. return $default;
  34758. }
  34759. if (!$question->getValidator()) {
  34760. return $this->doAsk($output, $question);
  34761. }
  34762. $that = $this;
  34763. $interviewer = function () use ($output, $question, $that) {
  34764. return $that->doAsk($output, $question);
  34765. };
  34766. return $this->validateAttempts($interviewer, $output, $question);
  34767. }
  34768. public function setInputStream($stream)
  34769. {
  34770. if (!\is_resource($stream)) {
  34771. throw new InvalidArgumentException('Input stream must be a valid resource.');
  34772. }
  34773. $this->inputStream = $stream;
  34774. }
  34775. public function getInputStream()
  34776. {
  34777. return $this->inputStream;
  34778. }
  34779. public function getName()
  34780. {
  34781. return 'question';
  34782. }
  34783. public function doAsk(OutputInterface $output, Question $question)
  34784. {
  34785. $this->writePrompt($output, $question);
  34786. $inputStream = $this->inputStream ?: STDIN;
  34787. $autocomplete = $question->getAutocompleterValues();
  34788. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  34789. $ret = false;
  34790. if ($question->isHidden()) {
  34791. try {
  34792. $ret = trim($this->getHiddenResponse($output, $inputStream));
  34793. } catch (RuntimeException $e) {
  34794. if (!$question->isHiddenFallback()) {
  34795. throw $e;
  34796. }
  34797. }
  34798. }
  34799. if (false === $ret) {
  34800. $ret = fgets($inputStream, 4096);
  34801. if (false === $ret) {
  34802. throw new RuntimeException('Aborted');
  34803. }
  34804. $ret = trim($ret);
  34805. }
  34806. } else {
  34807. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  34808. }
  34809. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  34810. if ($normalizer = $question->getNormalizer()) {
  34811. return $normalizer($ret);
  34812. }
  34813. return $ret;
  34814. }
  34815. protected function writePrompt(OutputInterface $output, Question $question)
  34816. {
  34817. $message = $question->getQuestion();
  34818. if ($question instanceof ChoiceQuestion) {
  34819. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  34820. $messages = (array) $question->getQuestion();
  34821. foreach ($question->getChoices() as $key => $value) {
  34822. $width = $maxWidth - $this->strlen($key);
  34823. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  34824. }
  34825. $output->writeln($messages);
  34826. $message = $question->getPrompt();
  34827. }
  34828. $output->write($message);
  34829. }
  34830. protected function writeError(OutputInterface $output, \Exception $error)
  34831. {
  34832. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  34833. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  34834. } else {
  34835. $message = '<error>'.$error->getMessage().'</error>';
  34836. }
  34837. $output->writeln($message);
  34838. }
  34839. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  34840. {
  34841. $ret = '';
  34842. $i = 0;
  34843. $ofs = -1;
  34844. $matches = $autocomplete;
  34845. $numMatches = \count($matches);
  34846. $sttyMode = shell_exec('stty -g');
  34847. shell_exec('stty -icanon -echo');
  34848. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  34849. while (!feof($inputStream)) {
  34850. $c = fread($inputStream, 1);
  34851. if ("\177" === $c) {
  34852. if (0 === $numMatches && 0 !== $i) {
  34853. --$i;
  34854. $output->write("\033[1D");
  34855. }
  34856. if (0 === $i) {
  34857. $ofs = -1;
  34858. $matches = $autocomplete;
  34859. $numMatches = \count($matches);
  34860. } else {
  34861. $numMatches = 0;
  34862. }
  34863. $ret = substr($ret, 0, $i);
  34864. } elseif ("\033" === $c) {
  34865. $c .= fread($inputStream, 2);
  34866. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  34867. if ('A' === $c[2] && -1 === $ofs) {
  34868. $ofs = 0;
  34869. }
  34870. if (0 === $numMatches) {
  34871. continue;
  34872. }
  34873. $ofs += ('A' === $c[2]) ? -1 : 1;
  34874. $ofs = ($numMatches + $ofs) % $numMatches;
  34875. }
  34876. } elseif (\ord($c) < 32) {
  34877. if ("\t" === $c || "\n" === $c) {
  34878. if ($numMatches > 0 && -1 !== $ofs) {
  34879. $ret = $matches[$ofs];
  34880. $output->write(substr($ret, $i));
  34881. $i = \strlen($ret);
  34882. }
  34883. if ("\n" === $c) {
  34884. $output->write($c);
  34885. break;
  34886. }
  34887. $numMatches = 0;
  34888. }
  34889. continue;
  34890. } else {
  34891. $output->write($c);
  34892. $ret .= $c;
  34893. ++$i;
  34894. $numMatches = 0;
  34895. $ofs = 0;
  34896. foreach ($autocomplete as $value) {
  34897. if (0 === strpos($value, $ret)) {
  34898. $matches[$numMatches++] = $value;
  34899. }
  34900. }
  34901. }
  34902. $output->write("\033[K");
  34903. if ($numMatches > 0 && -1 !== $ofs) {
  34904. $output->write("\0337");
  34905. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  34906. $output->write("\0338");
  34907. }
  34908. }
  34909. shell_exec(sprintf('stty %s', $sttyMode));
  34910. return $ret;
  34911. }
  34912. private function getHiddenResponse(OutputInterface $output, $inputStream)
  34913. {
  34914. if ('\\' === \DIRECTORY_SEPARATOR) {
  34915. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  34916. if ('phar:' === substr(__FILE__, 0, 5)) {
  34917. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  34918. copy($exe, $tmpExe);
  34919. $exe = $tmpExe;
  34920. }
  34921. $value = rtrim(shell_exec($exe));
  34922. $output->writeln('');
  34923. if (isset($tmpExe)) {
  34924. unlink($tmpExe);
  34925. }
  34926. return $value;
  34927. }
  34928. if ($this->hasSttyAvailable()) {
  34929. $sttyMode = shell_exec('stty -g');
  34930. shell_exec('stty -echo');
  34931. $value = fgets($inputStream, 4096);
  34932. shell_exec(sprintf('stty %s', $sttyMode));
  34933. if (false === $value) {
  34934. throw new RuntimeException('Aborted');
  34935. }
  34936. $value = trim($value);
  34937. $output->writeln('');
  34938. return $value;
  34939. }
  34940. if (false !== $shell = $this->getShell()) {
  34941. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  34942. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  34943. $value = rtrim(shell_exec($command));
  34944. $output->writeln('');
  34945. return $value;
  34946. }
  34947. throw new RuntimeException('Unable to hide the response.');
  34948. }
  34949. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  34950. {
  34951. $error = null;
  34952. $attempts = $question->getMaxAttempts();
  34953. while (null === $attempts || $attempts--) {
  34954. if (null !== $error) {
  34955. $this->writeError($output, $error);
  34956. }
  34957. try {
  34958. return \call_user_func($question->getValidator(), $interviewer());
  34959. } catch (RuntimeException $e) {
  34960. throw $e;
  34961. } catch (\Exception $error) {
  34962. }
  34963. }
  34964. throw $error;
  34965. }
  34966. private function getShell()
  34967. {
  34968. if (null !== self::$shell) {
  34969. return self::$shell;
  34970. }
  34971. self::$shell = false;
  34972. if (file_exists('/usr/bin/env')) {
  34973. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  34974. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  34975. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  34976. self::$shell = $sh;
  34977. break;
  34978. }
  34979. }
  34980. }
  34981. return self::$shell;
  34982. }
  34983. private function hasSttyAvailable()
  34984. {
  34985. if (null !== self::$stty) {
  34986. return self::$stty;
  34987. }
  34988. exec('stty 2>&1', $output, $exitcode);
  34989. return self::$stty = 0 === $exitcode;
  34990. }
  34991. }
  34992. <?php
  34993. namespace Symfony\Component\Console\Helper;
  34994. use Symfony\Component\Console\Exception\LogicException;
  34995. use Symfony\Component\Console\Formatter\OutputFormatter;
  34996. use Symfony\Component\Console\Input\InputInterface;
  34997. use Symfony\Component\Console\Output\OutputInterface;
  34998. use Symfony\Component\Console\Question\ChoiceQuestion;
  34999. use Symfony\Component\Console\Question\ConfirmationQuestion;
  35000. use Symfony\Component\Console\Question\Question;
  35001. use Symfony\Component\Console\Style\SymfonyStyle;
  35002. class SymfonyQuestionHelper extends QuestionHelper
  35003. {
  35004. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  35005. {
  35006. $validator = $question->getValidator();
  35007. $question->setValidator(function ($value) use ($validator) {
  35008. if (null !== $validator) {
  35009. $value = $validator($value);
  35010. } else {
  35011. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  35012. throw new LogicException('A value is required.');
  35013. }
  35014. }
  35015. return $value;
  35016. });
  35017. return parent::ask($input, $output, $question);
  35018. }
  35019. protected function writePrompt(OutputInterface $output, Question $question)
  35020. {
  35021. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  35022. $default = $question->getDefault();
  35023. switch (true) {
  35024. case null === $default:
  35025. $text = sprintf(' <info>%s</info>:', $text);
  35026. break;
  35027. case $question instanceof ConfirmationQuestion:
  35028. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  35029. break;
  35030. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  35031. $choices = $question->getChoices();
  35032. $default = explode(',', $default);
  35033. foreach ($default as $key => $value) {
  35034. $default[$key] = $choices[trim($value)];
  35035. }
  35036. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  35037. break;
  35038. case $question instanceof ChoiceQuestion:
  35039. $choices = $question->getChoices();
  35040. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  35041. break;
  35042. default:
  35043. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  35044. }
  35045. $output->writeln($text);
  35046. if ($question instanceof ChoiceQuestion) {
  35047. $width = max(array_map('strlen', array_keys($question->getChoices())));
  35048. foreach ($question->getChoices() as $key => $value) {
  35049. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  35050. }
  35051. }
  35052. $output->write(' > ');
  35053. }
  35054. protected function writeError(OutputInterface $output, \Exception $error)
  35055. {
  35056. if ($output instanceof SymfonyStyle) {
  35057. $output->newLine();
  35058. $output->error($error->getMessage());
  35059. return;
  35060. }
  35061. parent::writeError($output, $error);
  35062. }
  35063. }
  35064. <?php
  35065. namespace Symfony\Component\Console\Helper;
  35066. use Symfony\Component\Console\Exception\InvalidArgumentException;
  35067. use Symfony\Component\Console\Output\OutputInterface;
  35068. class Table
  35069. {
  35070. private $headers = array();
  35071. private $rows = array();
  35072. private $columnWidths = array();
  35073. private $numberOfColumns;
  35074. private $output;
  35075. private $style;
  35076. private $columnStyles = array();
  35077. private static $styles;
  35078. public function __construct(OutputInterface $output)
  35079. {
  35080. $this->output = $output;
  35081. if (!self::$styles) {
  35082. self::$styles = self::initStyles();
  35083. }
  35084. $this->setStyle('default');
  35085. }
  35086. public static function setStyleDefinition($name, TableStyle $style)
  35087. {
  35088. if (!self::$styles) {
  35089. self::$styles = self::initStyles();
  35090. }
  35091. self::$styles[$name] = $style;
  35092. }
  35093. public static function getStyleDefinition($name)
  35094. {
  35095. if (!self::$styles) {
  35096. self::$styles = self::initStyles();
  35097. }
  35098. if (isset(self::$styles[$name])) {
  35099. return self::$styles[$name];
  35100. }
  35101. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  35102. }
  35103. public function setStyle($name)
  35104. {
  35105. $this->style = $this->resolveStyle($name);
  35106. return $this;
  35107. }
  35108. public function getStyle()
  35109. {
  35110. return $this->style;
  35111. }
  35112. public function setColumnStyle($columnIndex, $name)
  35113. {
  35114. $columnIndex = (int) $columnIndex;
  35115. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  35116. return $this;
  35117. }
  35118. public function getColumnStyle($columnIndex)
  35119. {
  35120. if (isset($this->columnStyles[$columnIndex])) {
  35121. return $this->columnStyles[$columnIndex];
  35122. }
  35123. return $this->getStyle();
  35124. }
  35125. public function setHeaders(array $headers)
  35126. {
  35127. $headers = array_values($headers);
  35128. if (!empty($headers) && !\is_array($headers[0])) {
  35129. $headers = array($headers);
  35130. }
  35131. $this->headers = $headers;
  35132. return $this;
  35133. }
  35134. public function setRows(array $rows)
  35135. {
  35136. $this->rows = array();
  35137. return $this->addRows($rows);
  35138. }
  35139. public function addRows(array $rows)
  35140. {
  35141. foreach ($rows as $row) {
  35142. $this->addRow($row);
  35143. }
  35144. return $this;
  35145. }
  35146. public function addRow($row)
  35147. {
  35148. if ($row instanceof TableSeparator) {
  35149. $this->rows[] = $row;
  35150. return $this;
  35151. }
  35152. if (!\is_array($row)) {
  35153. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  35154. }
  35155. $this->rows[] = array_values($row);
  35156. return $this;
  35157. }
  35158. public function setRow($column, array $row)
  35159. {
  35160. $this->rows[$column] = $row;
  35161. return $this;
  35162. }
  35163. public function render()
  35164. {
  35165. $this->calculateNumberOfColumns();
  35166. $rows = $this->buildTableRows($this->rows);
  35167. $headers = $this->buildTableRows($this->headers);
  35168. $this->calculateColumnsWidth(array_merge($headers, $rows));
  35169. $this->renderRowSeparator();
  35170. if (!empty($headers)) {
  35171. foreach ($headers as $header) {
  35172. $this->renderRow($header, $this->style->getCellHeaderFormat());
  35173. $this->renderRowSeparator();
  35174. }
  35175. }
  35176. foreach ($rows as $row) {
  35177. if ($row instanceof TableSeparator) {
  35178. $this->renderRowSeparator();
  35179. } else {
  35180. $this->renderRow($row, $this->style->getCellRowFormat());
  35181. }
  35182. }
  35183. if (!empty($rows)) {
  35184. $this->renderRowSeparator();
  35185. }
  35186. $this->cleanup();
  35187. }
  35188. private function renderRowSeparator()
  35189. {
  35190. if (0 === $count = $this->numberOfColumns) {
  35191. return;
  35192. }
  35193. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  35194. return;
  35195. }
  35196. $markup = $this->style->getCrossingChar();
  35197. for ($column = 0; $column < $count; ++$column) {
  35198. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  35199. }
  35200. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  35201. }
  35202. private function renderColumnSeparator()
  35203. {
  35204. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  35205. }
  35206. private function renderRow(array $row, $cellFormat)
  35207. {
  35208. if (empty($row)) {
  35209. return;
  35210. }
  35211. $rowContent = $this->renderColumnSeparator();
  35212. foreach ($this->getRowColumns($row) as $column) {
  35213. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  35214. $rowContent .= $this->renderColumnSeparator();
  35215. }
  35216. $this->output->writeln($rowContent);
  35217. }
  35218. private function renderCell(array $row, $column, $cellFormat)
  35219. {
  35220. $cell = isset($row[$column]) ? $row[$column] : '';
  35221. $width = $this->columnWidths[$column];
  35222. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  35223. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  35224. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  35225. }
  35226. }
  35227. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  35228. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  35229. }
  35230. $style = $this->getColumnStyle($column);
  35231. if ($cell instanceof TableSeparator) {
  35232. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  35233. }
  35234. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  35235. $content = sprintf($style->getCellRowContentFormat(), $cell);
  35236. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  35237. }
  35238. private function calculateNumberOfColumns()
  35239. {
  35240. if (null !== $this->numberOfColumns) {
  35241. return;
  35242. }
  35243. $columns = array(0);
  35244. foreach (array_merge($this->headers, $this->rows) as $row) {
  35245. if ($row instanceof TableSeparator) {
  35246. continue;
  35247. }
  35248. $columns[] = $this->getNumberOfColumns($row);
  35249. }
  35250. $this->numberOfColumns = max($columns);
  35251. }
  35252. private function buildTableRows($rows)
  35253. {
  35254. $unmergedRows = array();
  35255. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  35256. $rows = $this->fillNextRows($rows, $rowKey);
  35257. foreach ($rows[$rowKey] as $column => $cell) {
  35258. if (!strstr($cell, "\n")) {
  35259. continue;
  35260. }
  35261. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  35262. foreach ($lines as $lineKey => $line) {
  35263. if ($cell instanceof TableCell) {
  35264. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  35265. }
  35266. if (0 === $lineKey) {
  35267. $rows[$rowKey][$column] = $line;
  35268. } else {
  35269. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  35270. }
  35271. }
  35272. }
  35273. }
  35274. $tableRows = array();
  35275. foreach ($rows as $rowKey => $row) {
  35276. $tableRows[] = $this->fillCells($row);
  35277. if (isset($unmergedRows[$rowKey])) {
  35278. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  35279. }
  35280. }
  35281. return $tableRows;
  35282. }
  35283. private function fillNextRows(array $rows, $line)
  35284. {
  35285. $unmergedRows = array();
  35286. foreach ($rows[$line] as $column => $cell) {
  35287. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  35288. $nbLines = $cell->getRowspan() - 1;
  35289. $lines = array($cell);
  35290. if (strstr($cell, "\n")) {
  35291. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  35292. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  35293. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  35294. unset($lines[0]);
  35295. }
  35296. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  35297. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  35298. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  35299. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  35300. if ($nbLines === $unmergedRowKey - $line) {
  35301. break;
  35302. }
  35303. }
  35304. }
  35305. }
  35306. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  35307. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  35308. foreach ($unmergedRow as $cellKey => $cell) {
  35309. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  35310. }
  35311. } else {
  35312. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  35313. foreach ($unmergedRow as $column => $cell) {
  35314. if (!empty($cell)) {
  35315. $row[$column] = $unmergedRow[$column];
  35316. }
  35317. }
  35318. array_splice($rows, $unmergedRowKey, 0, array($row));
  35319. }
  35320. }
  35321. return $rows;
  35322. }
  35323. private function fillCells($row)
  35324. {
  35325. $newRow = array();
  35326. foreach ($row as $column => $cell) {
  35327. $newRow[] = $cell;
  35328. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  35329. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  35330. $newRow[] = '';
  35331. }
  35332. }
  35333. }
  35334. return $newRow ?: $row;
  35335. }
  35336. private function copyRow(array $rows, $line)
  35337. {
  35338. $row = $rows[$line];
  35339. foreach ($row as $cellKey => $cellValue) {
  35340. $row[$cellKey] = '';
  35341. if ($cellValue instanceof TableCell) {
  35342. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  35343. }
  35344. }
  35345. return $row;
  35346. }
  35347. private function getNumberOfColumns(array $row)
  35348. {
  35349. $columns = \count($row);
  35350. foreach ($row as $column) {
  35351. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  35352. }
  35353. return $columns;
  35354. }
  35355. private function getRowColumns(array $row)
  35356. {
  35357. $columns = range(0, $this->numberOfColumns - 1);
  35358. foreach ($row as $cellKey => $cell) {
  35359. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  35360. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  35361. }
  35362. }
  35363. return $columns;
  35364. }
  35365. private function calculateColumnsWidth($rows)
  35366. {
  35367. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  35368. $lengths = array();
  35369. foreach ($rows as $row) {
  35370. if ($row instanceof TableSeparator) {
  35371. continue;
  35372. }
  35373. foreach ($row as $i => $cell) {
  35374. if ($cell instanceof TableCell) {
  35375. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  35376. $textLength = Helper::strlen($textContent);
  35377. if ($textLength > 0) {
  35378. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  35379. foreach ($contentColumns as $position => $content) {
  35380. $row[$i + $position] = $content;
  35381. }
  35382. }
  35383. }
  35384. }
  35385. $lengths[] = $this->getCellWidth($row, $column);
  35386. }
  35387. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  35388. }
  35389. }
  35390. private function getColumnSeparatorWidth()
  35391. {
  35392. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  35393. }
  35394. private function getCellWidth(array $row, $column)
  35395. {
  35396. if (isset($row[$column])) {
  35397. $cell = $row[$column];
  35398. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  35399. return $cellWidth;
  35400. }
  35401. return 0;
  35402. }
  35403. private function cleanup()
  35404. {
  35405. $this->columnWidths = array();
  35406. $this->numberOfColumns = null;
  35407. }
  35408. private static function initStyles()
  35409. {
  35410. $borderless = new TableStyle();
  35411. $borderless
  35412. ->setHorizontalBorderChar('=')
  35413. ->setVerticalBorderChar(' ')
  35414. ->setCrossingChar(' ')
  35415. ;
  35416. $compact = new TableStyle();
  35417. $compact
  35418. ->setHorizontalBorderChar('')
  35419. ->setVerticalBorderChar(' ')
  35420. ->setCrossingChar('')
  35421. ->setCellRowContentFormat('%s')
  35422. ;
  35423. $styleGuide = new TableStyle();
  35424. $styleGuide
  35425. ->setHorizontalBorderChar('-')
  35426. ->setVerticalBorderChar(' ')
  35427. ->setCrossingChar(' ')
  35428. ->setCellHeaderFormat('%s')
  35429. ;
  35430. return array(
  35431. 'default' => new TableStyle(),
  35432. 'borderless' => $borderless,
  35433. 'compact' => $compact,
  35434. 'symfony-style-guide' => $styleGuide,
  35435. );
  35436. }
  35437. private function resolveStyle($name)
  35438. {
  35439. if ($name instanceof TableStyle) {
  35440. return $name;
  35441. }
  35442. if (isset(self::$styles[$name])) {
  35443. return self::$styles[$name];
  35444. }
  35445. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  35446. }
  35447. }
  35448. <?php
  35449. namespace Symfony\Component\Console\Helper;
  35450. use Symfony\Component\Console\Exception\InvalidArgumentException;
  35451. class TableCell
  35452. {
  35453. private $value;
  35454. private $options = array(
  35455. 'rowspan' => 1,
  35456. 'colspan' => 1,
  35457. );
  35458. public function __construct($value = '', array $options = array())
  35459. {
  35460. if (is_numeric($value) && !\is_string($value)) {
  35461. $value = (string) $value;
  35462. }
  35463. $this->value = $value;
  35464. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  35465. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  35466. }
  35467. $this->options = array_merge($this->options, $options);
  35468. }
  35469. public function __toString()
  35470. {
  35471. return $this->value;
  35472. }
  35473. public function getColspan()
  35474. {
  35475. return (int) $this->options['colspan'];
  35476. }
  35477. public function getRowspan()
  35478. {
  35479. return (int) $this->options['rowspan'];
  35480. }
  35481. }
  35482. <?php
  35483. namespace Symfony\Component\Console\Helper;
  35484. use Symfony\Component\Console\Exception\InvalidArgumentException;
  35485. use Symfony\Component\Console\Output\NullOutput;
  35486. use Symfony\Component\Console\Output\OutputInterface;
  35487. class TableHelper extends Helper
  35488. {
  35489. const LAYOUT_DEFAULT = 0;
  35490. const LAYOUT_BORDERLESS = 1;
  35491. const LAYOUT_COMPACT = 2;
  35492. private $table;
  35493. public function __construct($triggerDeprecationError = true)
  35494. {
  35495. if ($triggerDeprecationError) {
  35496. @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);
  35497. }
  35498. $this->table = new Table(new NullOutput());
  35499. }
  35500. public function setLayout($layout)
  35501. {
  35502. switch ($layout) {
  35503. case self::LAYOUT_BORDERLESS:
  35504. $this->table->setStyle('borderless');
  35505. break;
  35506. case self::LAYOUT_COMPACT:
  35507. $this->table->setStyle('compact');
  35508. break;
  35509. case self::LAYOUT_DEFAULT:
  35510. $this->table->setStyle('default');
  35511. break;
  35512. default:
  35513. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  35514. }
  35515. return $this;
  35516. }
  35517. public function setHeaders(array $headers)
  35518. {
  35519. $this->table->setHeaders($headers);
  35520. return $this;
  35521. }
  35522. public function setRows(array $rows)
  35523. {
  35524. $this->table->setRows($rows);
  35525. return $this;
  35526. }
  35527. public function addRows(array $rows)
  35528. {
  35529. $this->table->addRows($rows);
  35530. return $this;
  35531. }
  35532. public function addRow(array $row)
  35533. {
  35534. $this->table->addRow($row);
  35535. return $this;
  35536. }
  35537. public function setRow($column, array $row)
  35538. {
  35539. $this->table->setRow($column, $row);
  35540. return $this;
  35541. }
  35542. public function setPaddingChar($paddingChar)
  35543. {
  35544. $this->table->getStyle()->setPaddingChar($paddingChar);
  35545. return $this;
  35546. }
  35547. public function setHorizontalBorderChar($horizontalBorderChar)
  35548. {
  35549. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  35550. return $this;
  35551. }
  35552. public function setVerticalBorderChar($verticalBorderChar)
  35553. {
  35554. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  35555. return $this;
  35556. }
  35557. public function setCrossingChar($crossingChar)
  35558. {
  35559. $this->table->getStyle()->setCrossingChar($crossingChar);
  35560. return $this;
  35561. }
  35562. public function setCellHeaderFormat($cellHeaderFormat)
  35563. {
  35564. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  35565. return $this;
  35566. }
  35567. public function setCellRowFormat($cellRowFormat)
  35568. {
  35569. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  35570. return $this;
  35571. }
  35572. public function setCellRowContentFormat($cellRowContentFormat)
  35573. {
  35574. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  35575. return $this;
  35576. }
  35577. public function setBorderFormat($borderFormat)
  35578. {
  35579. $this->table->getStyle()->setBorderFormat($borderFormat);
  35580. return $this;
  35581. }
  35582. public function setPadType($padType)
  35583. {
  35584. $this->table->getStyle()->setPadType($padType);
  35585. return $this;
  35586. }
  35587. public function render(OutputInterface $output)
  35588. {
  35589. $p = new \ReflectionProperty($this->table, 'output');
  35590. $p->setAccessible(true);
  35591. $p->setValue($this->table, $output);
  35592. $this->table->render();
  35593. }
  35594. public function getName()
  35595. {
  35596. return 'table';
  35597. }
  35598. }
  35599. <?php
  35600. namespace Symfony\Component\Console\Helper;
  35601. class TableSeparator extends TableCell
  35602. {
  35603. public function __construct(array $options = array())
  35604. {
  35605. parent::__construct('', $options);
  35606. }
  35607. }
  35608. <?php
  35609. namespace Symfony\Component\Console\Helper;
  35610. use Symfony\Component\Console\Exception\InvalidArgumentException;
  35611. use Symfony\Component\Console\Exception\LogicException;
  35612. class TableStyle
  35613. {
  35614. private $paddingChar = ' ';
  35615. private $horizontalBorderChar = '-';
  35616. private $verticalBorderChar = '|';
  35617. private $crossingChar = '+';
  35618. private $cellHeaderFormat = '<info>%s</info>';
  35619. private $cellRowFormat = '%s';
  35620. private $cellRowContentFormat = ' %s ';
  35621. private $borderFormat = '%s';
  35622. private $padType = STR_PAD_RIGHT;
  35623. public function setPaddingChar($paddingChar)
  35624. {
  35625. if (!$paddingChar) {
  35626. throw new LogicException('The padding char must not be empty');
  35627. }
  35628. $this->paddingChar = $paddingChar;
  35629. return $this;
  35630. }
  35631. public function getPaddingChar()
  35632. {
  35633. return $this->paddingChar;
  35634. }
  35635. public function setHorizontalBorderChar($horizontalBorderChar)
  35636. {
  35637. $this->horizontalBorderChar = $horizontalBorderChar;
  35638. return $this;
  35639. }
  35640. public function getHorizontalBorderChar()
  35641. {
  35642. return $this->horizontalBorderChar;
  35643. }
  35644. public function setVerticalBorderChar($verticalBorderChar)
  35645. {
  35646. $this->verticalBorderChar = $verticalBorderChar;
  35647. return $this;
  35648. }
  35649. public function getVerticalBorderChar()
  35650. {
  35651. return $this->verticalBorderChar;
  35652. }
  35653. public function setCrossingChar($crossingChar)
  35654. {
  35655. $this->crossingChar = $crossingChar;
  35656. return $this;
  35657. }
  35658. public function getCrossingChar()
  35659. {
  35660. return $this->crossingChar;
  35661. }
  35662. public function setCellHeaderFormat($cellHeaderFormat)
  35663. {
  35664. $this->cellHeaderFormat = $cellHeaderFormat;
  35665. return $this;
  35666. }
  35667. public function getCellHeaderFormat()
  35668. {
  35669. return $this->cellHeaderFormat;
  35670. }
  35671. public function setCellRowFormat($cellRowFormat)
  35672. {
  35673. $this->cellRowFormat = $cellRowFormat;
  35674. return $this;
  35675. }
  35676. public function getCellRowFormat()
  35677. {
  35678. return $this->cellRowFormat;
  35679. }
  35680. public function setCellRowContentFormat($cellRowContentFormat)
  35681. {
  35682. $this->cellRowContentFormat = $cellRowContentFormat;
  35683. return $this;
  35684. }
  35685. public function getCellRowContentFormat()
  35686. {
  35687. return $this->cellRowContentFormat;
  35688. }
  35689. public function setBorderFormat($borderFormat)
  35690. {
  35691. $this->borderFormat = $borderFormat;
  35692. return $this;
  35693. }
  35694. public function getBorderFormat()
  35695. {
  35696. return $this->borderFormat;
  35697. }
  35698. public function setPadType($padType)
  35699. {
  35700. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  35701. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  35702. }
  35703. $this->padType = $padType;
  35704. return $this;
  35705. }
  35706. public function getPadType()
  35707. {
  35708. return $this->padType;
  35709. }
  35710. }
  35711. <?php
  35712. namespace Symfony\Component\Console\Input;
  35713. use Symfony\Component\Console\Exception\RuntimeException;
  35714. class ArgvInput extends Input
  35715. {
  35716. private $tokens;
  35717. private $parsed;
  35718. public function __construct(array $argv = null, InputDefinition $definition = null)
  35719. {
  35720. if (null === $argv) {
  35721. $argv = $_SERVER['argv'];
  35722. }
  35723. array_shift($argv);
  35724. $this->tokens = $argv;
  35725. parent::__construct($definition);
  35726. }
  35727. protected function setTokens(array $tokens)
  35728. {
  35729. $this->tokens = $tokens;
  35730. }
  35731. protected function parse()
  35732. {
  35733. $parseOptions = true;
  35734. $this->parsed = $this->tokens;
  35735. while (null !== $token = array_shift($this->parsed)) {
  35736. if ($parseOptions && '' == $token) {
  35737. $this->parseArgument($token);
  35738. } elseif ($parseOptions && '--' == $token) {
  35739. $parseOptions = false;
  35740. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  35741. $this->parseLongOption($token);
  35742. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  35743. $this->parseShortOption($token);
  35744. } else {
  35745. $this->parseArgument($token);
  35746. }
  35747. }
  35748. }
  35749. private function parseShortOption($token)
  35750. {
  35751. $name = substr($token, 1);
  35752. if (\strlen($name) > 1) {
  35753. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  35754. $this->addShortOption($name[0], substr($name, 1));
  35755. } else {
  35756. $this->parseShortOptionSet($name);
  35757. }
  35758. } else {
  35759. $this->addShortOption($name, null);
  35760. }
  35761. }
  35762. private function parseShortOptionSet($name)
  35763. {
  35764. $len = \strlen($name);
  35765. for ($i = 0; $i < $len; ++$i) {
  35766. if (!$this->definition->hasShortcut($name[$i])) {
  35767. $encoding = mb_detect_encoding($name, null, true);
  35768. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  35769. }
  35770. $option = $this->definition->getOptionForShortcut($name[$i]);
  35771. if ($option->acceptValue()) {
  35772. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  35773. break;
  35774. } else {
  35775. $this->addLongOption($option->getName(), null);
  35776. }
  35777. }
  35778. }
  35779. private function parseLongOption($token)
  35780. {
  35781. $name = substr($token, 2);
  35782. if (false !== $pos = strpos($name, '=')) {
  35783. if (0 === \strlen($value = substr($name, $pos + 1))) {
  35784. array_unshift($this->parsed, null);
  35785. }
  35786. $this->addLongOption(substr($name, 0, $pos), $value);
  35787. } else {
  35788. $this->addLongOption($name, null);
  35789. }
  35790. }
  35791. private function parseArgument($token)
  35792. {
  35793. $c = \count($this->arguments);
  35794. if ($this->definition->hasArgument($c)) {
  35795. $arg = $this->definition->getArgument($c);
  35796. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  35797. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  35798. $arg = $this->definition->getArgument($c - 1);
  35799. $this->arguments[$arg->getName()][] = $token;
  35800. } else {
  35801. $all = $this->definition->getArguments();
  35802. if (\count($all)) {
  35803. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  35804. }
  35805. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  35806. }
  35807. }
  35808. private function addShortOption($shortcut, $value)
  35809. {
  35810. if (!$this->definition->hasShortcut($shortcut)) {
  35811. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  35812. }
  35813. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  35814. }
  35815. private function addLongOption($name, $value)
  35816. {
  35817. if (!$this->definition->hasOption($name)) {
  35818. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  35819. }
  35820. $option = $this->definition->getOption($name);
  35821. if (!isset($value[0])) {
  35822. $value = null;
  35823. }
  35824. if (null !== $value && !$option->acceptValue()) {
  35825. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  35826. }
  35827. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  35828. $next = array_shift($this->parsed);
  35829. if (isset($next[0]) && '-' !== $next[0]) {
  35830. $value = $next;
  35831. } elseif (empty($next)) {
  35832. $value = null;
  35833. } else {
  35834. array_unshift($this->parsed, $next);
  35835. }
  35836. }
  35837. if (null === $value) {
  35838. if ($option->isValueRequired()) {
  35839. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  35840. }
  35841. if (!$option->isArray()) {
  35842. $value = $option->isValueOptional() ? $option->getDefault() : true;
  35843. }
  35844. }
  35845. if ($option->isArray()) {
  35846. $this->options[$name][] = $value;
  35847. } else {
  35848. $this->options[$name] = $value;
  35849. }
  35850. }
  35851. public function getFirstArgument()
  35852. {
  35853. foreach ($this->tokens as $token) {
  35854. if ($token && '-' === $token[0]) {
  35855. continue;
  35856. }
  35857. return $token;
  35858. }
  35859. }
  35860. public function hasParameterOption($values)
  35861. {
  35862. $values = (array) $values;
  35863. foreach ($this->tokens as $token) {
  35864. foreach ($values as $value) {
  35865. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  35866. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  35867. return true;
  35868. }
  35869. }
  35870. }
  35871. return false;
  35872. }
  35873. public function getParameterOption($values, $default = false)
  35874. {
  35875. $values = (array) $values;
  35876. $tokens = $this->tokens;
  35877. while (0 < \count($tokens)) {
  35878. $token = array_shift($tokens);
  35879. foreach ($values as $value) {
  35880. if ($token === $value) {
  35881. return array_shift($tokens);
  35882. }
  35883. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  35884. if ('' !== $leading && 0 === strpos($token, $leading)) {
  35885. return substr($token, \strlen($leading));
  35886. }
  35887. }
  35888. }
  35889. return $default;
  35890. }
  35891. public function __toString()
  35892. {
  35893. $self = $this;
  35894. $tokens = array_map(function ($token) use ($self) {
  35895. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  35896. return $match[1].$self->escapeToken($match[2]);
  35897. }
  35898. if ($token && '-' !== $token[0]) {
  35899. return $self->escapeToken($token);
  35900. }
  35901. return $token;
  35902. }, $this->tokens);
  35903. return implode(' ', $tokens);
  35904. }
  35905. }
  35906. <?php
  35907. namespace Symfony\Component\Console\Input;
  35908. use Symfony\Component\Console\Exception\InvalidArgumentException;
  35909. use Symfony\Component\Console\Exception\InvalidOptionException;
  35910. class ArrayInput extends Input
  35911. {
  35912. private $parameters;
  35913. public function __construct(array $parameters, InputDefinition $definition = null)
  35914. {
  35915. $this->parameters = $parameters;
  35916. parent::__construct($definition);
  35917. }
  35918. public function getFirstArgument()
  35919. {
  35920. foreach ($this->parameters as $key => $value) {
  35921. if ($key && '-' === $key[0]) {
  35922. continue;
  35923. }
  35924. return $value;
  35925. }
  35926. }
  35927. public function hasParameterOption($values)
  35928. {
  35929. $values = (array) $values;
  35930. foreach ($this->parameters as $k => $v) {
  35931. if (!\is_int($k)) {
  35932. $v = $k;
  35933. }
  35934. if (\in_array($v, $values)) {
  35935. return true;
  35936. }
  35937. }
  35938. return false;
  35939. }
  35940. public function getParameterOption($values, $default = false)
  35941. {
  35942. $values = (array) $values;
  35943. foreach ($this->parameters as $k => $v) {
  35944. if (\is_int($k)) {
  35945. if (\in_array($v, $values)) {
  35946. return true;
  35947. }
  35948. } elseif (\in_array($k, $values)) {
  35949. return $v;
  35950. }
  35951. }
  35952. return $default;
  35953. }
  35954. public function __toString()
  35955. {
  35956. $params = array();
  35957. foreach ($this->parameters as $param => $val) {
  35958. if ($param && '-' === $param[0]) {
  35959. if (\is_array($val)) {
  35960. foreach ($val as $v) {
  35961. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  35962. }
  35963. } else {
  35964. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  35965. }
  35966. } else {
  35967. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  35968. }
  35969. }
  35970. return implode(' ', $params);
  35971. }
  35972. protected function parse()
  35973. {
  35974. foreach ($this->parameters as $key => $value) {
  35975. if (0 === strpos($key, '--')) {
  35976. $this->addLongOption(substr($key, 2), $value);
  35977. } elseif ('-' === $key[0]) {
  35978. $this->addShortOption(substr($key, 1), $value);
  35979. } else {
  35980. $this->addArgument($key, $value);
  35981. }
  35982. }
  35983. }
  35984. private function addShortOption($shortcut, $value)
  35985. {
  35986. if (!$this->definition->hasShortcut($shortcut)) {
  35987. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  35988. }
  35989. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  35990. }
  35991. private function addLongOption($name, $value)
  35992. {
  35993. if (!$this->definition->hasOption($name)) {
  35994. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  35995. }
  35996. $option = $this->definition->getOption($name);
  35997. if (null === $value) {
  35998. if ($option->isValueRequired()) {
  35999. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  36000. }
  36001. $value = $option->isValueOptional() ? $option->getDefault() : true;
  36002. }
  36003. $this->options[$name] = $value;
  36004. }
  36005. private function addArgument($name, $value)
  36006. {
  36007. if (!$this->definition->hasArgument($name)) {
  36008. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  36009. }
  36010. $this->arguments[$name] = $value;
  36011. }
  36012. }
  36013. <?php
  36014. namespace Symfony\Component\Console\Input;
  36015. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36016. use Symfony\Component\Console\Exception\RuntimeException;
  36017. abstract class Input implements InputInterface
  36018. {
  36019. protected $definition;
  36020. protected $options = array();
  36021. protected $arguments = array();
  36022. protected $interactive = true;
  36023. public function __construct(InputDefinition $definition = null)
  36024. {
  36025. if (null === $definition) {
  36026. $this->definition = new InputDefinition();
  36027. } else {
  36028. $this->bind($definition);
  36029. $this->validate();
  36030. }
  36031. }
  36032. public function bind(InputDefinition $definition)
  36033. {
  36034. $this->arguments = array();
  36035. $this->options = array();
  36036. $this->definition = $definition;
  36037. $this->parse();
  36038. }
  36039. abstract protected function parse();
  36040. public function validate()
  36041. {
  36042. $definition = $this->definition;
  36043. $givenArguments = $this->arguments;
  36044. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  36045. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  36046. });
  36047. if (\count($missingArguments) > 0) {
  36048. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  36049. }
  36050. }
  36051. public function isInteractive()
  36052. {
  36053. return $this->interactive;
  36054. }
  36055. public function setInteractive($interactive)
  36056. {
  36057. $this->interactive = (bool) $interactive;
  36058. }
  36059. public function getArguments()
  36060. {
  36061. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  36062. }
  36063. public function getArgument($name)
  36064. {
  36065. if (!$this->definition->hasArgument($name)) {
  36066. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  36067. }
  36068. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  36069. }
  36070. public function setArgument($name, $value)
  36071. {
  36072. if (!$this->definition->hasArgument($name)) {
  36073. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  36074. }
  36075. $this->arguments[$name] = $value;
  36076. }
  36077. public function hasArgument($name)
  36078. {
  36079. return $this->definition->hasArgument($name);
  36080. }
  36081. public function getOptions()
  36082. {
  36083. return array_merge($this->definition->getOptionDefaults(), $this->options);
  36084. }
  36085. public function getOption($name)
  36086. {
  36087. if (!$this->definition->hasOption($name)) {
  36088. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  36089. }
  36090. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  36091. }
  36092. public function setOption($name, $value)
  36093. {
  36094. if (!$this->definition->hasOption($name)) {
  36095. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  36096. }
  36097. $this->options[$name] = $value;
  36098. }
  36099. public function hasOption($name)
  36100. {
  36101. return $this->definition->hasOption($name);
  36102. }
  36103. public function escapeToken($token)
  36104. {
  36105. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  36106. }
  36107. }
  36108. <?php
  36109. namespace Symfony\Component\Console\Input;
  36110. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36111. use Symfony\Component\Console\Exception\LogicException;
  36112. class InputArgument
  36113. {
  36114. const REQUIRED = 1;
  36115. const OPTIONAL = 2;
  36116. const IS_ARRAY = 4;
  36117. private $name;
  36118. private $mode;
  36119. private $default;
  36120. private $description;
  36121. public function __construct($name, $mode = null, $description = '', $default = null)
  36122. {
  36123. if (null === $mode) {
  36124. $mode = self::OPTIONAL;
  36125. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  36126. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  36127. }
  36128. $this->name = $name;
  36129. $this->mode = $mode;
  36130. $this->description = $description;
  36131. $this->setDefault($default);
  36132. }
  36133. public function getName()
  36134. {
  36135. return $this->name;
  36136. }
  36137. public function isRequired()
  36138. {
  36139. return self::REQUIRED === (self::REQUIRED & $this->mode);
  36140. }
  36141. public function isArray()
  36142. {
  36143. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  36144. }
  36145. public function setDefault($default = null)
  36146. {
  36147. if (self::REQUIRED === $this->mode && null !== $default) {
  36148. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  36149. }
  36150. if ($this->isArray()) {
  36151. if (null === $default) {
  36152. $default = array();
  36153. } elseif (!\is_array($default)) {
  36154. throw new LogicException('A default value for an array argument must be an array.');
  36155. }
  36156. }
  36157. $this->default = $default;
  36158. }
  36159. public function getDefault()
  36160. {
  36161. return $this->default;
  36162. }
  36163. public function getDescription()
  36164. {
  36165. return $this->description;
  36166. }
  36167. }
  36168. <?php
  36169. namespace Symfony\Component\Console\Input;
  36170. interface InputAwareInterface
  36171. {
  36172. public function setInput(InputInterface $input);
  36173. }
  36174. <?php
  36175. namespace Symfony\Component\Console\Input;
  36176. use Symfony\Component\Console\Descriptor\TextDescriptor;
  36177. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  36178. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36179. use Symfony\Component\Console\Exception\LogicException;
  36180. use Symfony\Component\Console\Output\BufferedOutput;
  36181. class InputDefinition
  36182. {
  36183. private $arguments;
  36184. private $requiredCount;
  36185. private $hasAnArrayArgument = false;
  36186. private $hasOptional;
  36187. private $options;
  36188. private $shortcuts;
  36189. public function __construct(array $definition = array())
  36190. {
  36191. $this->setDefinition($definition);
  36192. }
  36193. public function setDefinition(array $definition)
  36194. {
  36195. $arguments = array();
  36196. $options = array();
  36197. foreach ($definition as $item) {
  36198. if ($item instanceof InputOption) {
  36199. $options[] = $item;
  36200. } else {
  36201. $arguments[] = $item;
  36202. }
  36203. }
  36204. $this->setArguments($arguments);
  36205. $this->setOptions($options);
  36206. }
  36207. public function setArguments($arguments = array())
  36208. {
  36209. $this->arguments = array();
  36210. $this->requiredCount = 0;
  36211. $this->hasOptional = false;
  36212. $this->hasAnArrayArgument = false;
  36213. $this->addArguments($arguments);
  36214. }
  36215. public function addArguments($arguments = array())
  36216. {
  36217. if (null !== $arguments) {
  36218. foreach ($arguments as $argument) {
  36219. $this->addArgument($argument);
  36220. }
  36221. }
  36222. }
  36223. public function addArgument(InputArgument $argument)
  36224. {
  36225. if (isset($this->arguments[$argument->getName()])) {
  36226. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  36227. }
  36228. if ($this->hasAnArrayArgument) {
  36229. throw new LogicException('Cannot add an argument after an array argument.');
  36230. }
  36231. if ($argument->isRequired() && $this->hasOptional) {
  36232. throw new LogicException('Cannot add a required argument after an optional one.');
  36233. }
  36234. if ($argument->isArray()) {
  36235. $this->hasAnArrayArgument = true;
  36236. }
  36237. if ($argument->isRequired()) {
  36238. ++$this->requiredCount;
  36239. } else {
  36240. $this->hasOptional = true;
  36241. }
  36242. $this->arguments[$argument->getName()] = $argument;
  36243. }
  36244. public function getArgument($name)
  36245. {
  36246. if (!$this->hasArgument($name)) {
  36247. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  36248. }
  36249. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  36250. return $arguments[$name];
  36251. }
  36252. public function hasArgument($name)
  36253. {
  36254. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  36255. return isset($arguments[$name]);
  36256. }
  36257. public function getArguments()
  36258. {
  36259. return $this->arguments;
  36260. }
  36261. public function getArgumentCount()
  36262. {
  36263. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  36264. }
  36265. public function getArgumentRequiredCount()
  36266. {
  36267. return $this->requiredCount;
  36268. }
  36269. public function getArgumentDefaults()
  36270. {
  36271. $values = array();
  36272. foreach ($this->arguments as $argument) {
  36273. $values[$argument->getName()] = $argument->getDefault();
  36274. }
  36275. return $values;
  36276. }
  36277. public function setOptions($options = array())
  36278. {
  36279. $this->options = array();
  36280. $this->shortcuts = array();
  36281. $this->addOptions($options);
  36282. }
  36283. public function addOptions($options = array())
  36284. {
  36285. foreach ($options as $option) {
  36286. $this->addOption($option);
  36287. }
  36288. }
  36289. public function addOption(InputOption $option)
  36290. {
  36291. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  36292. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  36293. }
  36294. if ($option->getShortcut()) {
  36295. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  36296. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  36297. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  36298. }
  36299. }
  36300. }
  36301. $this->options[$option->getName()] = $option;
  36302. if ($option->getShortcut()) {
  36303. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  36304. $this->shortcuts[$shortcut] = $option->getName();
  36305. }
  36306. }
  36307. }
  36308. public function getOption($name)
  36309. {
  36310. if (!$this->hasOption($name)) {
  36311. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  36312. }
  36313. return $this->options[$name];
  36314. }
  36315. public function hasOption($name)
  36316. {
  36317. return isset($this->options[$name]);
  36318. }
  36319. public function getOptions()
  36320. {
  36321. return $this->options;
  36322. }
  36323. public function hasShortcut($name)
  36324. {
  36325. return isset($this->shortcuts[$name]);
  36326. }
  36327. public function getOptionForShortcut($shortcut)
  36328. {
  36329. return $this->getOption($this->shortcutToName($shortcut));
  36330. }
  36331. public function getOptionDefaults()
  36332. {
  36333. $values = array();
  36334. foreach ($this->options as $option) {
  36335. $values[$option->getName()] = $option->getDefault();
  36336. }
  36337. return $values;
  36338. }
  36339. private function shortcutToName($shortcut)
  36340. {
  36341. if (!isset($this->shortcuts[$shortcut])) {
  36342. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  36343. }
  36344. return $this->shortcuts[$shortcut];
  36345. }
  36346. public function getSynopsis($short = false)
  36347. {
  36348. $elements = array();
  36349. if ($short && $this->getOptions()) {
  36350. $elements[] = '[options]';
  36351. } elseif (!$short) {
  36352. foreach ($this->getOptions() as $option) {
  36353. $value = '';
  36354. if ($option->acceptValue()) {
  36355. $value = sprintf(
  36356. ' %s%s%s',
  36357. $option->isValueOptional() ? '[' : '',
  36358. strtoupper($option->getName()),
  36359. $option->isValueOptional() ? ']' : ''
  36360. );
  36361. }
  36362. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  36363. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  36364. }
  36365. }
  36366. if (\count($elements) && $this->getArguments()) {
  36367. $elements[] = '[--]';
  36368. }
  36369. foreach ($this->getArguments() as $argument) {
  36370. $element = '<'.$argument->getName().'>';
  36371. if (!$argument->isRequired()) {
  36372. $element = '['.$element.']';
  36373. } elseif ($argument->isArray()) {
  36374. $element .= ' ('.$element.')';
  36375. }
  36376. if ($argument->isArray()) {
  36377. $element .= '...';
  36378. }
  36379. $elements[] = $element;
  36380. }
  36381. return implode(' ', $elements);
  36382. }
  36383. public function asText()
  36384. {
  36385. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  36386. $descriptor = new TextDescriptor();
  36387. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  36388. $descriptor->describe($output, $this, array('raw_output' => true));
  36389. return $output->fetch();
  36390. }
  36391. public function asXml($asDom = false)
  36392. {
  36393. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  36394. $descriptor = new XmlDescriptor();
  36395. if ($asDom) {
  36396. return $descriptor->getInputDefinitionDocument($this);
  36397. }
  36398. $output = new BufferedOutput();
  36399. $descriptor->describe($output, $this);
  36400. return $output->fetch();
  36401. }
  36402. }
  36403. <?php
  36404. namespace Symfony\Component\Console\Input;
  36405. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36406. use Symfony\Component\Console\Exception\RuntimeException;
  36407. interface InputInterface
  36408. {
  36409. public function getFirstArgument();
  36410. public function hasParameterOption($values);
  36411. public function getParameterOption($values, $default = false);
  36412. public function bind(InputDefinition $definition);
  36413. public function validate();
  36414. public function getArguments();
  36415. public function getArgument($name);
  36416. public function setArgument($name, $value);
  36417. public function hasArgument($name);
  36418. public function getOptions();
  36419. public function getOption($name);
  36420. public function setOption($name, $value);
  36421. public function hasOption($name);
  36422. public function isInteractive();
  36423. public function setInteractive($interactive);
  36424. }
  36425. <?php
  36426. namespace Symfony\Component\Console\Input;
  36427. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36428. use Symfony\Component\Console\Exception\LogicException;
  36429. class InputOption
  36430. {
  36431. const VALUE_NONE = 1;
  36432. const VALUE_REQUIRED = 2;
  36433. const VALUE_OPTIONAL = 4;
  36434. const VALUE_IS_ARRAY = 8;
  36435. private $name;
  36436. private $shortcut;
  36437. private $mode;
  36438. private $default;
  36439. private $description;
  36440. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  36441. {
  36442. if (0 === strpos($name, '--')) {
  36443. $name = substr($name, 2);
  36444. }
  36445. if (empty($name)) {
  36446. throw new InvalidArgumentException('An option name cannot be empty.');
  36447. }
  36448. if (empty($shortcut)) {
  36449. $shortcut = null;
  36450. }
  36451. if (null !== $shortcut) {
  36452. if (\is_array($shortcut)) {
  36453. $shortcut = implode('|', $shortcut);
  36454. }
  36455. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  36456. $shortcuts = array_filter($shortcuts);
  36457. $shortcut = implode('|', $shortcuts);
  36458. if (empty($shortcut)) {
  36459. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  36460. }
  36461. }
  36462. if (null === $mode) {
  36463. $mode = self::VALUE_NONE;
  36464. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  36465. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  36466. }
  36467. $this->name = $name;
  36468. $this->shortcut = $shortcut;
  36469. $this->mode = $mode;
  36470. $this->description = $description;
  36471. if ($this->isArray() && !$this->acceptValue()) {
  36472. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  36473. }
  36474. $this->setDefault($default);
  36475. }
  36476. public function getShortcut()
  36477. {
  36478. return $this->shortcut;
  36479. }
  36480. public function getName()
  36481. {
  36482. return $this->name;
  36483. }
  36484. public function acceptValue()
  36485. {
  36486. return $this->isValueRequired() || $this->isValueOptional();
  36487. }
  36488. public function isValueRequired()
  36489. {
  36490. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  36491. }
  36492. public function isValueOptional()
  36493. {
  36494. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  36495. }
  36496. public function isArray()
  36497. {
  36498. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  36499. }
  36500. public function setDefault($default = null)
  36501. {
  36502. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  36503. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  36504. }
  36505. if ($this->isArray()) {
  36506. if (null === $default) {
  36507. $default = array();
  36508. } elseif (!\is_array($default)) {
  36509. throw new LogicException('A default value for an array option must be an array.');
  36510. }
  36511. }
  36512. $this->default = $this->acceptValue() ? $default : false;
  36513. }
  36514. public function getDefault()
  36515. {
  36516. return $this->default;
  36517. }
  36518. public function getDescription()
  36519. {
  36520. return $this->description;
  36521. }
  36522. public function equals(self $option)
  36523. {
  36524. return $option->getName() === $this->getName()
  36525. && $option->getShortcut() === $this->getShortcut()
  36526. && $option->getDefault() === $this->getDefault()
  36527. && $option->isArray() === $this->isArray()
  36528. && $option->isValueRequired() === $this->isValueRequired()
  36529. && $option->isValueOptional() === $this->isValueOptional()
  36530. ;
  36531. }
  36532. }
  36533. <?php
  36534. namespace Symfony\Component\Console\Input;
  36535. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36536. class StringInput extends ArgvInput
  36537. {
  36538. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  36539. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  36540. public function __construct($input, InputDefinition $definition = null)
  36541. {
  36542. if ($definition) {
  36543. @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);
  36544. }
  36545. parent::__construct(array(), null);
  36546. $this->setTokens($this->tokenize($input));
  36547. if (null !== $definition) {
  36548. $this->bind($definition);
  36549. }
  36550. }
  36551. private function tokenize($input)
  36552. {
  36553. $tokens = array();
  36554. $length = \strlen($input);
  36555. $cursor = 0;
  36556. while ($cursor < $length) {
  36557. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  36558. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  36559. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  36560. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  36561. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  36562. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  36563. $tokens[] = stripcslashes($match[1]);
  36564. } else {
  36565. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  36566. }
  36567. $cursor += \strlen($match[0]);
  36568. }
  36569. return $tokens;
  36570. }
  36571. }
  36572. Copyright (c) 2004-2018 Fabien Potencier
  36573. Permission is hereby granted, free of charge, to any person obtaining a copy
  36574. of this software and associated documentation files (the "Software"), to deal
  36575. in the Software without restriction, including without limitation the rights
  36576. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  36577. copies of the Software, and to permit persons to whom the Software is furnished
  36578. to do so, subject to the following conditions:
  36579. The above copyright notice and this permission notice shall be included in all
  36580. copies or substantial portions of the Software.
  36581. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  36582. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  36583. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  36584. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  36585. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  36586. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  36587. THE SOFTWARE.
  36588. <?php
  36589. namespace Symfony\Component\Console\Logger;
  36590. use Psr\Log\AbstractLogger;
  36591. use Psr\Log\InvalidArgumentException;
  36592. use Psr\Log\LogLevel;
  36593. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  36594. use Symfony\Component\Console\Output\OutputInterface;
  36595. class ConsoleLogger extends AbstractLogger
  36596. {
  36597. const INFO = 'info';
  36598. const ERROR = 'error';
  36599. private $output;
  36600. private $verbosityLevelMap = array(
  36601. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  36602. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  36603. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  36604. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  36605. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  36606. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  36607. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  36608. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  36609. );
  36610. private $formatLevelMap = array(
  36611. LogLevel::EMERGENCY => self::ERROR,
  36612. LogLevel::ALERT => self::ERROR,
  36613. LogLevel::CRITICAL => self::ERROR,
  36614. LogLevel::ERROR => self::ERROR,
  36615. LogLevel::WARNING => self::INFO,
  36616. LogLevel::NOTICE => self::INFO,
  36617. LogLevel::INFO => self::INFO,
  36618. LogLevel::DEBUG => self::INFO,
  36619. );
  36620. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  36621. {
  36622. $this->output = $output;
  36623. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  36624. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  36625. }
  36626. public function log($level, $message, array $context = array())
  36627. {
  36628. if (!isset($this->verbosityLevelMap[$level])) {
  36629. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  36630. }
  36631. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  36632. $output = $this->output->getErrorOutput();
  36633. } else {
  36634. $output = $this->output;
  36635. }
  36636. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  36637. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  36638. }
  36639. }
  36640. private function interpolate($message, array $context)
  36641. {
  36642. $replace = array();
  36643. foreach ($context as $key => $val) {
  36644. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  36645. $replace[sprintf('{%s}', $key)] = $val;
  36646. }
  36647. }
  36648. return strtr($message, $replace);
  36649. }
  36650. }
  36651. <?php
  36652. namespace Symfony\Component\Console\Output;
  36653. class BufferedOutput extends Output
  36654. {
  36655. private $buffer = '';
  36656. public function fetch()
  36657. {
  36658. $content = $this->buffer;
  36659. $this->buffer = '';
  36660. return $content;
  36661. }
  36662. protected function doWrite($message, $newline)
  36663. {
  36664. $this->buffer .= $message;
  36665. if ($newline) {
  36666. $this->buffer .= PHP_EOL;
  36667. }
  36668. }
  36669. }
  36670. <?php
  36671. namespace Symfony\Component\Console\Output;
  36672. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  36673. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  36674. {
  36675. private $stderr;
  36676. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  36677. {
  36678. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  36679. $actualDecorated = $this->isDecorated();
  36680. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  36681. if (null === $decorated) {
  36682. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  36683. }
  36684. }
  36685. public function setDecorated($decorated)
  36686. {
  36687. parent::setDecorated($decorated);
  36688. $this->stderr->setDecorated($decorated);
  36689. }
  36690. public function setFormatter(OutputFormatterInterface $formatter)
  36691. {
  36692. parent::setFormatter($formatter);
  36693. $this->stderr->setFormatter($formatter);
  36694. }
  36695. public function setVerbosity($level)
  36696. {
  36697. parent::setVerbosity($level);
  36698. $this->stderr->setVerbosity($level);
  36699. }
  36700. public function getErrorOutput()
  36701. {
  36702. return $this->stderr;
  36703. }
  36704. public function setErrorOutput(OutputInterface $error)
  36705. {
  36706. $this->stderr = $error;
  36707. }
  36708. protected function hasStdoutSupport()
  36709. {
  36710. return false === $this->isRunningOS400();
  36711. }
  36712. protected function hasStderrSupport()
  36713. {
  36714. return false === $this->isRunningOS400();
  36715. }
  36716. private function isRunningOS400()
  36717. {
  36718. $checks = array(
  36719. \function_exists('php_uname') ? php_uname('s') : '',
  36720. getenv('OSTYPE'),
  36721. PHP_OS,
  36722. );
  36723. return false !== stripos(implode(';', $checks), 'OS400');
  36724. }
  36725. private function openOutputStream()
  36726. {
  36727. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  36728. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  36729. }
  36730. private function openErrorStream()
  36731. {
  36732. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  36733. return fopen($errorStream, 'w');
  36734. }
  36735. }
  36736. <?php
  36737. namespace Symfony\Component\Console\Output;
  36738. interface ConsoleOutputInterface extends OutputInterface
  36739. {
  36740. public function getErrorOutput();
  36741. public function setErrorOutput(OutputInterface $error);
  36742. }
  36743. <?php
  36744. namespace Symfony\Component\Console\Output;
  36745. use Symfony\Component\Console\Formatter\OutputFormatter;
  36746. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  36747. class NullOutput implements OutputInterface
  36748. {
  36749. public function setFormatter(OutputFormatterInterface $formatter)
  36750. {
  36751. }
  36752. public function getFormatter()
  36753. {
  36754. return new OutputFormatter();
  36755. }
  36756. public function setDecorated($decorated)
  36757. {
  36758. }
  36759. public function isDecorated()
  36760. {
  36761. return false;
  36762. }
  36763. public function setVerbosity($level)
  36764. {
  36765. }
  36766. public function getVerbosity()
  36767. {
  36768. return self::VERBOSITY_QUIET;
  36769. }
  36770. public function isQuiet()
  36771. {
  36772. return true;
  36773. }
  36774. public function isVerbose()
  36775. {
  36776. return false;
  36777. }
  36778. public function isVeryVerbose()
  36779. {
  36780. return false;
  36781. }
  36782. public function isDebug()
  36783. {
  36784. return false;
  36785. }
  36786. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  36787. {
  36788. }
  36789. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  36790. {
  36791. }
  36792. }
  36793. <?php
  36794. namespace Symfony\Component\Console\Output;
  36795. use Symfony\Component\Console\Formatter\OutputFormatter;
  36796. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  36797. abstract class Output implements OutputInterface
  36798. {
  36799. private $verbosity;
  36800. private $formatter;
  36801. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  36802. {
  36803. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  36804. $this->formatter = $formatter ?: new OutputFormatter();
  36805. $this->formatter->setDecorated($decorated);
  36806. }
  36807. public function setFormatter(OutputFormatterInterface $formatter)
  36808. {
  36809. $this->formatter = $formatter;
  36810. }
  36811. public function getFormatter()
  36812. {
  36813. return $this->formatter;
  36814. }
  36815. public function setDecorated($decorated)
  36816. {
  36817. $this->formatter->setDecorated($decorated);
  36818. }
  36819. public function isDecorated()
  36820. {
  36821. return $this->formatter->isDecorated();
  36822. }
  36823. public function setVerbosity($level)
  36824. {
  36825. $this->verbosity = (int) $level;
  36826. }
  36827. public function getVerbosity()
  36828. {
  36829. return $this->verbosity;
  36830. }
  36831. public function isQuiet()
  36832. {
  36833. return self::VERBOSITY_QUIET === $this->verbosity;
  36834. }
  36835. public function isVerbose()
  36836. {
  36837. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  36838. }
  36839. public function isVeryVerbose()
  36840. {
  36841. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  36842. }
  36843. public function isDebug()
  36844. {
  36845. return self::VERBOSITY_DEBUG <= $this->verbosity;
  36846. }
  36847. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  36848. {
  36849. $this->write($messages, true, $options);
  36850. }
  36851. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  36852. {
  36853. $messages = (array) $messages;
  36854. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  36855. $type = $types & $options ?: self::OUTPUT_NORMAL;
  36856. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  36857. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  36858. if ($verbosity > $this->getVerbosity()) {
  36859. return;
  36860. }
  36861. foreach ($messages as $message) {
  36862. switch ($type) {
  36863. case OutputInterface::OUTPUT_NORMAL:
  36864. $message = $this->formatter->format($message);
  36865. break;
  36866. case OutputInterface::OUTPUT_RAW:
  36867. break;
  36868. case OutputInterface::OUTPUT_PLAIN:
  36869. $message = strip_tags($this->formatter->format($message));
  36870. break;
  36871. }
  36872. $this->doWrite($message, $newline);
  36873. }
  36874. }
  36875. abstract protected function doWrite($message, $newline);
  36876. }
  36877. <?php
  36878. namespace Symfony\Component\Console\Output;
  36879. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  36880. interface OutputInterface
  36881. {
  36882. const VERBOSITY_QUIET = 16;
  36883. const VERBOSITY_NORMAL = 32;
  36884. const VERBOSITY_VERBOSE = 64;
  36885. const VERBOSITY_VERY_VERBOSE = 128;
  36886. const VERBOSITY_DEBUG = 256;
  36887. const OUTPUT_NORMAL = 1;
  36888. const OUTPUT_RAW = 2;
  36889. const OUTPUT_PLAIN = 4;
  36890. public function write($messages, $newline = false, $options = 0);
  36891. public function writeln($messages, $options = 0);
  36892. public function setVerbosity($level);
  36893. public function getVerbosity();
  36894. public function setDecorated($decorated);
  36895. public function isDecorated();
  36896. public function setFormatter(OutputFormatterInterface $formatter);
  36897. public function getFormatter();
  36898. }
  36899. <?php
  36900. namespace Symfony\Component\Console\Output;
  36901. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36902. use Symfony\Component\Console\Exception\RuntimeException;
  36903. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  36904. class StreamOutput extends Output
  36905. {
  36906. private $stream;
  36907. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  36908. {
  36909. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  36910. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  36911. }
  36912. $this->stream = $stream;
  36913. if (null === $decorated) {
  36914. $decorated = $this->hasColorSupport();
  36915. }
  36916. parent::__construct($verbosity, $decorated, $formatter);
  36917. }
  36918. public function getStream()
  36919. {
  36920. return $this->stream;
  36921. }
  36922. protected function doWrite($message, $newline)
  36923. {
  36924. if ($newline) {
  36925. $message .= PHP_EOL;
  36926. }
  36927. if (false === @fwrite($this->stream, $message)) {
  36928. throw new RuntimeException('Unable to write output.');
  36929. }
  36930. fflush($this->stream);
  36931. }
  36932. protected function hasColorSupport()
  36933. {
  36934. if ('Hyper' === getenv('TERM_PROGRAM')) {
  36935. return true;
  36936. }
  36937. if (\DIRECTORY_SEPARATOR === '\\') {
  36938. return (\function_exists('sapi_windows_vt100_support')
  36939. && @sapi_windows_vt100_support($this->stream))
  36940. || false !== getenv('ANSICON')
  36941. || 'ON' === getenv('ConEmuANSI')
  36942. || 'xterm' === getenv('TERM');
  36943. }
  36944. if (\function_exists('stream_isatty')) {
  36945. return @stream_isatty($this->stream);
  36946. }
  36947. if (\function_exists('posix_isatty')) {
  36948. return @posix_isatty($this->stream);
  36949. }
  36950. $stat = @fstat($this->stream);
  36951. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  36952. }
  36953. }
  36954. <?php
  36955. namespace Symfony\Component\Console\Question;
  36956. use Symfony\Component\Console\Exception\InvalidArgumentException;
  36957. class ChoiceQuestion extends Question
  36958. {
  36959. private $choices;
  36960. private $multiselect = false;
  36961. private $prompt = ' > ';
  36962. private $errorMessage = 'Value "%s" is invalid';
  36963. public function __construct($question, array $choices, $default = null)
  36964. {
  36965. if (!$choices) {
  36966. throw new \LogicException('Choice question must have at least 1 choice available.');
  36967. }
  36968. parent::__construct($question, $default);
  36969. $this->choices = $choices;
  36970. $this->setValidator($this->getDefaultValidator());
  36971. $this->setAutocompleterValues($choices);
  36972. }
  36973. public function getChoices()
  36974. {
  36975. return $this->choices;
  36976. }
  36977. public function setMultiselect($multiselect)
  36978. {
  36979. $this->multiselect = $multiselect;
  36980. $this->setValidator($this->getDefaultValidator());
  36981. return $this;
  36982. }
  36983. public function isMultiselect()
  36984. {
  36985. return $this->multiselect;
  36986. }
  36987. public function getPrompt()
  36988. {
  36989. return $this->prompt;
  36990. }
  36991. public function setPrompt($prompt)
  36992. {
  36993. $this->prompt = $prompt;
  36994. return $this;
  36995. }
  36996. public function setErrorMessage($errorMessage)
  36997. {
  36998. $this->errorMessage = $errorMessage;
  36999. $this->setValidator($this->getDefaultValidator());
  37000. return $this;
  37001. }
  37002. private function getDefaultValidator()
  37003. {
  37004. $choices = $this->choices;
  37005. $errorMessage = $this->errorMessage;
  37006. $multiselect = $this->multiselect;
  37007. $isAssoc = $this->isAssoc($choices);
  37008. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  37009. $selectedChoices = str_replace(' ', '', $selected);
  37010. if ($multiselect) {
  37011. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  37012. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  37013. }
  37014. $selectedChoices = explode(',', $selectedChoices);
  37015. } else {
  37016. $selectedChoices = array($selected);
  37017. }
  37018. $multiselectChoices = array();
  37019. foreach ($selectedChoices as $value) {
  37020. $results = array();
  37021. foreach ($choices as $key => $choice) {
  37022. if ($choice === $value) {
  37023. $results[] = $key;
  37024. }
  37025. }
  37026. if (\count($results) > 1) {
  37027. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  37028. }
  37029. $result = array_search($value, $choices);
  37030. if (!$isAssoc) {
  37031. if (false !== $result) {
  37032. $result = $choices[$result];
  37033. } elseif (isset($choices[$value])) {
  37034. $result = $choices[$value];
  37035. }
  37036. } elseif (false === $result && isset($choices[$value])) {
  37037. $result = $value;
  37038. }
  37039. if (false === $result) {
  37040. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  37041. }
  37042. $multiselectChoices[] = (string) $result;
  37043. }
  37044. if ($multiselect) {
  37045. return $multiselectChoices;
  37046. }
  37047. return current($multiselectChoices);
  37048. };
  37049. }
  37050. }
  37051. <?php
  37052. namespace Symfony\Component\Console\Question;
  37053. class ConfirmationQuestion extends Question
  37054. {
  37055. private $trueAnswerRegex;
  37056. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  37057. {
  37058. parent::__construct($question, (bool) $default);
  37059. $this->trueAnswerRegex = $trueAnswerRegex;
  37060. $this->setNormalizer($this->getDefaultNormalizer());
  37061. }
  37062. private function getDefaultNormalizer()
  37063. {
  37064. $default = $this->getDefault();
  37065. $regex = $this->trueAnswerRegex;
  37066. return function ($answer) use ($default, $regex) {
  37067. if (\is_bool($answer)) {
  37068. return $answer;
  37069. }
  37070. $answerIsTrue = (bool) preg_match($regex, $answer);
  37071. if (false === $default) {
  37072. return $answer && $answerIsTrue;
  37073. }
  37074. return !$answer || $answerIsTrue;
  37075. };
  37076. }
  37077. }
  37078. <?php
  37079. namespace Symfony\Component\Console\Question;
  37080. use Symfony\Component\Console\Exception\InvalidArgumentException;
  37081. use Symfony\Component\Console\Exception\LogicException;
  37082. class Question
  37083. {
  37084. private $question;
  37085. private $attempts;
  37086. private $hidden = false;
  37087. private $hiddenFallback = true;
  37088. private $autocompleterValues;
  37089. private $validator;
  37090. private $default;
  37091. private $normalizer;
  37092. public function __construct($question, $default = null)
  37093. {
  37094. $this->question = $question;
  37095. $this->default = $default;
  37096. }
  37097. public function getQuestion()
  37098. {
  37099. return $this->question;
  37100. }
  37101. public function getDefault()
  37102. {
  37103. return $this->default;
  37104. }
  37105. public function isHidden()
  37106. {
  37107. return $this->hidden;
  37108. }
  37109. public function setHidden($hidden)
  37110. {
  37111. if ($this->autocompleterValues) {
  37112. throw new LogicException('A hidden question cannot use the autocompleter.');
  37113. }
  37114. $this->hidden = (bool) $hidden;
  37115. return $this;
  37116. }
  37117. public function isHiddenFallback()
  37118. {
  37119. return $this->hiddenFallback;
  37120. }
  37121. public function setHiddenFallback($fallback)
  37122. {
  37123. $this->hiddenFallback = (bool) $fallback;
  37124. return $this;
  37125. }
  37126. public function getAutocompleterValues()
  37127. {
  37128. return $this->autocompleterValues;
  37129. }
  37130. public function setAutocompleterValues($values)
  37131. {
  37132. if (\is_array($values)) {
  37133. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  37134. }
  37135. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  37136. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  37137. }
  37138. if ($this->hidden) {
  37139. throw new LogicException('A hidden question cannot use the autocompleter.');
  37140. }
  37141. $this->autocompleterValues = $values;
  37142. return $this;
  37143. }
  37144. public function setValidator($validator)
  37145. {
  37146. $this->validator = $validator;
  37147. return $this;
  37148. }
  37149. public function getValidator()
  37150. {
  37151. return $this->validator;
  37152. }
  37153. public function setMaxAttempts($attempts)
  37154. {
  37155. if (null !== $attempts && $attempts < 1) {
  37156. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  37157. }
  37158. $this->attempts = $attempts;
  37159. return $this;
  37160. }
  37161. public function getMaxAttempts()
  37162. {
  37163. return $this->attempts;
  37164. }
  37165. public function setNormalizer($normalizer)
  37166. {
  37167. $this->normalizer = $normalizer;
  37168. return $this;
  37169. }
  37170. public function getNormalizer()
  37171. {
  37172. return $this->normalizer;
  37173. }
  37174. protected function isAssoc($array)
  37175. {
  37176. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  37177. }
  37178. }
  37179. <?php
  37180. namespace Symfony\Component\Console;
  37181. use Symfony\Component\Console\Exception\RuntimeException;
  37182. use Symfony\Component\Console\Input\StringInput;
  37183. use Symfony\Component\Console\Output\ConsoleOutput;
  37184. use Symfony\Component\Process\PhpExecutableFinder;
  37185. use Symfony\Component\Process\ProcessBuilder;
  37186. class Shell
  37187. {
  37188. private $application;
  37189. private $history;
  37190. private $output;
  37191. private $hasReadline;
  37192. private $processIsolation = false;
  37193. public function __construct(Application $application)
  37194. {
  37195. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  37196. $this->hasReadline = \function_exists('readline');
  37197. $this->application = $application;
  37198. $this->history = getenv('HOME').'/.history_'.$application->getName();
  37199. $this->output = new ConsoleOutput();
  37200. }
  37201. public function run()
  37202. {
  37203. $this->application->setAutoExit(false);
  37204. $this->application->setCatchExceptions(true);
  37205. if ($this->hasReadline) {
  37206. readline_read_history($this->history);
  37207. readline_completion_function(array($this, 'autocompleter'));
  37208. }
  37209. $this->output->writeln($this->getHeader());
  37210. $php = null;
  37211. if ($this->processIsolation) {
  37212. $finder = new PhpExecutableFinder();
  37213. $php = $finder->find();
  37214. $this->output->writeln(<<<'EOF'
  37215. <info>Running with process isolation, you should consider this:</info>
  37216. * each command is executed as separate process,
  37217. * commands don't support interactivity, all params must be passed explicitly,
  37218. * commands output is not colorized.
  37219. EOF
  37220. );
  37221. }
  37222. while (true) {
  37223. $command = $this->readline();
  37224. if (false === $command) {
  37225. $this->output->writeln("\n");
  37226. break;
  37227. }
  37228. if ($this->hasReadline) {
  37229. readline_add_history($command);
  37230. readline_write_history($this->history);
  37231. }
  37232. if ($this->processIsolation) {
  37233. $pb = new ProcessBuilder();
  37234. $process = $pb
  37235. ->add($php)
  37236. ->add($_SERVER['argv'][0])
  37237. ->add($command)
  37238. ->inheritEnvironmentVariables(true)
  37239. ->getProcess()
  37240. ;
  37241. $output = $this->output;
  37242. $process->run(function ($type, $data) use ($output) {
  37243. $output->writeln($data);
  37244. });
  37245. $ret = $process->getExitCode();
  37246. } else {
  37247. $ret = $this->application->run(new StringInput($command), $this->output);
  37248. }
  37249. if (0 !== $ret) {
  37250. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  37251. }
  37252. }
  37253. }
  37254. protected function getHeader()
  37255. {
  37256. return <<<EOF
  37257. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  37258. At the prompt, type <comment>help</comment> for some help,
  37259. or <comment>list</comment> to get a list of available commands.
  37260. To exit the shell, type <comment>^D</comment>.
  37261. EOF;
  37262. }
  37263. protected function getPrompt()
  37264. {
  37265. return $this->output->getFormatter()->format($this->application->getName().' > ');
  37266. }
  37267. protected function getOutput()
  37268. {
  37269. return $this->output;
  37270. }
  37271. protected function getApplication()
  37272. {
  37273. return $this->application;
  37274. }
  37275. private function autocompleter($text)
  37276. {
  37277. $info = readline_info();
  37278. $text = substr($info['line_buffer'], 0, $info['end']);
  37279. if ($info['point'] !== $info['end']) {
  37280. return true;
  37281. }
  37282. if (false === strpos($text, ' ') || !$text) {
  37283. return array_keys($this->application->all());
  37284. }
  37285. try {
  37286. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  37287. } catch (\Exception $e) {
  37288. return true;
  37289. }
  37290. $list = array('--help');
  37291. foreach ($command->getDefinition()->getOptions() as $option) {
  37292. $list[] = '--'.$option->getName();
  37293. }
  37294. return $list;
  37295. }
  37296. private function readline()
  37297. {
  37298. if ($this->hasReadline) {
  37299. $line = readline($this->getPrompt());
  37300. } else {
  37301. $this->output->write($this->getPrompt());
  37302. $line = fgets(STDIN, 1024);
  37303. $line = (false === $line || '' === $line) ? false : rtrim($line);
  37304. }
  37305. return $line;
  37306. }
  37307. public function getProcessIsolation()
  37308. {
  37309. return $this->processIsolation;
  37310. }
  37311. public function setProcessIsolation($processIsolation)
  37312. {
  37313. $this->processIsolation = (bool) $processIsolation;
  37314. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  37315. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  37316. }
  37317. }
  37318. }
  37319. <?php
  37320. namespace Symfony\Component\Console\Style;
  37321. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  37322. use Symfony\Component\Console\Helper\ProgressBar;
  37323. use Symfony\Component\Console\Output\OutputInterface;
  37324. abstract class OutputStyle implements OutputInterface, StyleInterface
  37325. {
  37326. private $output;
  37327. public function __construct(OutputInterface $output)
  37328. {
  37329. $this->output = $output;
  37330. }
  37331. public function newLine($count = 1)
  37332. {
  37333. $this->output->write(str_repeat(PHP_EOL, $count));
  37334. }
  37335. public function createProgressBar($max = 0)
  37336. {
  37337. return new ProgressBar($this->output, $max);
  37338. }
  37339. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  37340. {
  37341. $this->output->write($messages, $newline, $type);
  37342. }
  37343. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  37344. {
  37345. $this->output->writeln($messages, $type);
  37346. }
  37347. public function setVerbosity($level)
  37348. {
  37349. $this->output->setVerbosity($level);
  37350. }
  37351. public function getVerbosity()
  37352. {
  37353. return $this->output->getVerbosity();
  37354. }
  37355. public function setDecorated($decorated)
  37356. {
  37357. $this->output->setDecorated($decorated);
  37358. }
  37359. public function isDecorated()
  37360. {
  37361. return $this->output->isDecorated();
  37362. }
  37363. public function setFormatter(OutputFormatterInterface $formatter)
  37364. {
  37365. $this->output->setFormatter($formatter);
  37366. }
  37367. public function getFormatter()
  37368. {
  37369. return $this->output->getFormatter();
  37370. }
  37371. }
  37372. <?php
  37373. namespace Symfony\Component\Console\Style;
  37374. interface StyleInterface
  37375. {
  37376. public function title($message);
  37377. public function section($message);
  37378. public function listing(array $elements);
  37379. public function text($message);
  37380. public function success($message);
  37381. public function error($message);
  37382. public function warning($message);
  37383. public function note($message);
  37384. public function caution($message);
  37385. public function table(array $headers, array $rows);
  37386. public function ask($question, $default = null, $validator = null);
  37387. public function askHidden($question, $validator = null);
  37388. public function confirm($question, $default = true);
  37389. public function choice($question, array $choices, $default = null);
  37390. public function newLine($count = 1);
  37391. public function progressStart($max = 0);
  37392. public function progressAdvance($step = 1);
  37393. public function progressFinish();
  37394. }
  37395. <?php
  37396. namespace Symfony\Component\Console\Style;
  37397. use Symfony\Component\Console\Application;
  37398. use Symfony\Component\Console\Exception\RuntimeException;
  37399. use Symfony\Component\Console\Formatter\OutputFormatter;
  37400. use Symfony\Component\Console\Helper\Helper;
  37401. use Symfony\Component\Console\Helper\ProgressBar;
  37402. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  37403. use Symfony\Component\Console\Helper\Table;
  37404. use Symfony\Component\Console\Input\InputInterface;
  37405. use Symfony\Component\Console\Output\BufferedOutput;
  37406. use Symfony\Component\Console\Output\OutputInterface;
  37407. use Symfony\Component\Console\Question\ChoiceQuestion;
  37408. use Symfony\Component\Console\Question\ConfirmationQuestion;
  37409. use Symfony\Component\Console\Question\Question;
  37410. class SymfonyStyle extends OutputStyle
  37411. {
  37412. const MAX_LINE_LENGTH = 120;
  37413. private $input;
  37414. private $questionHelper;
  37415. private $progressBar;
  37416. private $lineLength;
  37417. private $bufferedOutput;
  37418. public function __construct(InputInterface $input, OutputInterface $output)
  37419. {
  37420. $this->input = $input;
  37421. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  37422. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  37423. parent::__construct($output);
  37424. }
  37425. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  37426. {
  37427. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  37428. $this->autoPrependBlock();
  37429. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  37430. $this->newLine();
  37431. }
  37432. public function title($message)
  37433. {
  37434. $this->autoPrependBlock();
  37435. $this->writeln(array(
  37436. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  37437. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  37438. ));
  37439. $this->newLine();
  37440. }
  37441. public function section($message)
  37442. {
  37443. $this->autoPrependBlock();
  37444. $this->writeln(array(
  37445. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  37446. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  37447. ));
  37448. $this->newLine();
  37449. }
  37450. public function listing(array $elements)
  37451. {
  37452. $this->autoPrependText();
  37453. $elements = array_map(function ($element) {
  37454. return sprintf(' * %s', $element);
  37455. }, $elements);
  37456. $this->writeln($elements);
  37457. $this->newLine();
  37458. }
  37459. public function text($message)
  37460. {
  37461. $this->autoPrependText();
  37462. $messages = \is_array($message) ? array_values($message) : array($message);
  37463. foreach ($messages as $message) {
  37464. $this->writeln(sprintf(' %s', $message));
  37465. }
  37466. }
  37467. public function comment($message)
  37468. {
  37469. $messages = \is_array($message) ? array_values($message) : array($message);
  37470. $this->autoPrependBlock();
  37471. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  37472. $this->newLine();
  37473. }
  37474. public function success($message)
  37475. {
  37476. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  37477. }
  37478. public function error($message)
  37479. {
  37480. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  37481. }
  37482. public function warning($message)
  37483. {
  37484. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  37485. }
  37486. public function note($message)
  37487. {
  37488. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  37489. }
  37490. public function caution($message)
  37491. {
  37492. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  37493. }
  37494. public function table(array $headers, array $rows)
  37495. {
  37496. $style = clone Table::getStyleDefinition('symfony-style-guide');
  37497. $style->setCellHeaderFormat('<info>%s</info>');
  37498. $table = new Table($this);
  37499. $table->setHeaders($headers);
  37500. $table->setRows($rows);
  37501. $table->setStyle($style);
  37502. $table->render();
  37503. $this->newLine();
  37504. }
  37505. public function ask($question, $default = null, $validator = null)
  37506. {
  37507. $question = new Question($question, $default);
  37508. $question->setValidator($validator);
  37509. return $this->askQuestion($question);
  37510. }
  37511. public function askHidden($question, $validator = null)
  37512. {
  37513. $question = new Question($question);
  37514. $question->setHidden(true);
  37515. $question->setValidator($validator);
  37516. return $this->askQuestion($question);
  37517. }
  37518. public function confirm($question, $default = true)
  37519. {
  37520. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  37521. }
  37522. public function choice($question, array $choices, $default = null)
  37523. {
  37524. if (null !== $default) {
  37525. $values = array_flip($choices);
  37526. $default = $values[$default];
  37527. }
  37528. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  37529. }
  37530. public function progressStart($max = 0)
  37531. {
  37532. $this->progressBar = $this->createProgressBar($max);
  37533. $this->progressBar->start();
  37534. }
  37535. public function progressAdvance($step = 1)
  37536. {
  37537. $this->getProgressBar()->advance($step);
  37538. }
  37539. public function progressFinish()
  37540. {
  37541. $this->getProgressBar()->finish();
  37542. $this->newLine(2);
  37543. $this->progressBar = null;
  37544. }
  37545. public function createProgressBar($max = 0)
  37546. {
  37547. $progressBar = parent::createProgressBar($max);
  37548. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  37549. $progressBar->setEmptyBarCharacter('â–‘');
  37550. $progressBar->setProgressCharacter('');
  37551. $progressBar->setBarCharacter('â–“');
  37552. }
  37553. return $progressBar;
  37554. }
  37555. public function askQuestion(Question $question)
  37556. {
  37557. if ($this->input->isInteractive()) {
  37558. $this->autoPrependBlock();
  37559. }
  37560. if (!$this->questionHelper) {
  37561. $this->questionHelper = new SymfonyQuestionHelper();
  37562. }
  37563. $answer = $this->questionHelper->ask($this->input, $this, $question);
  37564. if ($this->input->isInteractive()) {
  37565. $this->newLine();
  37566. $this->bufferedOutput->write("\n");
  37567. }
  37568. return $answer;
  37569. }
  37570. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  37571. {
  37572. parent::writeln($messages, $type);
  37573. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  37574. }
  37575. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  37576. {
  37577. parent::write($messages, $newline, $type);
  37578. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  37579. }
  37580. public function newLine($count = 1)
  37581. {
  37582. parent::newLine($count);
  37583. $this->bufferedOutput->write(str_repeat("\n", $count));
  37584. }
  37585. private function getProgressBar()
  37586. {
  37587. if (!$this->progressBar) {
  37588. throw new RuntimeException('The ProgressBar is not started.');
  37589. }
  37590. return $this->progressBar;
  37591. }
  37592. private function getTerminalWidth()
  37593. {
  37594. $application = new Application();
  37595. $dimensions = $application->getTerminalDimensions();
  37596. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  37597. }
  37598. private function autoPrependBlock()
  37599. {
  37600. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  37601. if (!isset($chars[0])) {
  37602. return $this->newLine();
  37603. }
  37604. $this->newLine(2 - substr_count($chars, "\n"));
  37605. }
  37606. private function autoPrependText()
  37607. {
  37608. $fetched = $this->bufferedOutput->fetch();
  37609. if ("\n" !== substr($fetched, -1)) {
  37610. $this->newLine();
  37611. }
  37612. }
  37613. private function reduceBuffer($messages)
  37614. {
  37615. return array_map(function ($value) {
  37616. return substr($value, -4);
  37617. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  37618. }
  37619. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  37620. {
  37621. $indentLength = 0;
  37622. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  37623. $lines = array();
  37624. if (null !== $type) {
  37625. $type = sprintf('[%s] ', $type);
  37626. $indentLength = \strlen($type);
  37627. $lineIndentation = str_repeat(' ', $indentLength);
  37628. }
  37629. foreach ($messages as $key => $message) {
  37630. if ($escape) {
  37631. $message = OutputFormatter::escape($message);
  37632. }
  37633. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  37634. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  37635. $lines[] = '';
  37636. }
  37637. }
  37638. $firstLineIndex = 0;
  37639. if ($padding && $this->isDecorated()) {
  37640. $firstLineIndex = 1;
  37641. array_unshift($lines, '');
  37642. $lines[] = '';
  37643. }
  37644. foreach ($lines as $i => &$line) {
  37645. if (null !== $type) {
  37646. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  37647. }
  37648. $line = $prefix.$line;
  37649. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  37650. if ($style) {
  37651. $line = sprintf('<%s>%s</>', $style, $line);
  37652. }
  37653. }
  37654. return $lines;
  37655. }
  37656. }
  37657. <?php
  37658. namespace Symfony\Component\Console\Tester;
  37659. use Symfony\Component\Console\Application;
  37660. use Symfony\Component\Console\Input\ArrayInput;
  37661. use Symfony\Component\Console\Input\InputInterface;
  37662. use Symfony\Component\Console\Output\OutputInterface;
  37663. use Symfony\Component\Console\Output\StreamOutput;
  37664. class ApplicationTester
  37665. {
  37666. private $application;
  37667. private $input;
  37668. private $output;
  37669. private $statusCode;
  37670. public function __construct(Application $application)
  37671. {
  37672. $this->application = $application;
  37673. }
  37674. public function run(array $input, $options = array())
  37675. {
  37676. $this->input = new ArrayInput($input);
  37677. if (isset($options['interactive'])) {
  37678. $this->input->setInteractive($options['interactive']);
  37679. }
  37680. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  37681. if (isset($options['decorated'])) {
  37682. $this->output->setDecorated($options['decorated']);
  37683. }
  37684. if (isset($options['verbosity'])) {
  37685. $this->output->setVerbosity($options['verbosity']);
  37686. }
  37687. return $this->statusCode = $this->application->run($this->input, $this->output);
  37688. }
  37689. public function getDisplay($normalize = false)
  37690. {
  37691. rewind($this->output->getStream());
  37692. $display = stream_get_contents($this->output->getStream());
  37693. if ($normalize) {
  37694. $display = str_replace(PHP_EOL, "\n", $display);
  37695. }
  37696. return $display;
  37697. }
  37698. public function getInput()
  37699. {
  37700. return $this->input;
  37701. }
  37702. public function getOutput()
  37703. {
  37704. return $this->output;
  37705. }
  37706. public function getStatusCode()
  37707. {
  37708. return $this->statusCode;
  37709. }
  37710. }
  37711. <?php
  37712. namespace Symfony\Component\Console\Tester;
  37713. use Symfony\Component\Console\Command\Command;
  37714. use Symfony\Component\Console\Input\ArrayInput;
  37715. use Symfony\Component\Console\Input\InputInterface;
  37716. use Symfony\Component\Console\Output\OutputInterface;
  37717. use Symfony\Component\Console\Output\StreamOutput;
  37718. class CommandTester
  37719. {
  37720. private $command;
  37721. private $input;
  37722. private $output;
  37723. private $statusCode;
  37724. public function __construct(Command $command)
  37725. {
  37726. $this->command = $command;
  37727. }
  37728. public function execute(array $input, array $options = array())
  37729. {
  37730. if (!isset($input['command'])
  37731. && (null !== $application = $this->command->getApplication())
  37732. && $application->getDefinition()->hasArgument('command')
  37733. ) {
  37734. $input = array_merge(array('command' => $this->command->getName()), $input);
  37735. }
  37736. $this->input = new ArrayInput($input);
  37737. if (isset($options['interactive'])) {
  37738. $this->input->setInteractive($options['interactive']);
  37739. }
  37740. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  37741. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  37742. if (isset($options['verbosity'])) {
  37743. $this->output->setVerbosity($options['verbosity']);
  37744. }
  37745. return $this->statusCode = $this->command->run($this->input, $this->output);
  37746. }
  37747. public function getDisplay($normalize = false)
  37748. {
  37749. rewind($this->output->getStream());
  37750. $display = stream_get_contents($this->output->getStream());
  37751. if ($normalize) {
  37752. $display = str_replace(PHP_EOL, "\n", $display);
  37753. }
  37754. return $display;
  37755. }
  37756. public function getInput()
  37757. {
  37758. return $this->input;
  37759. }
  37760. public function getOutput()
  37761. {
  37762. return $this->output;
  37763. }
  37764. public function getStatusCode()
  37765. {
  37766. return $this->statusCode;
  37767. }
  37768. }
  37769. <?php
  37770. namespace Symfony\Component\Debug;
  37771. use Psr\Log\AbstractLogger;
  37772. class BufferingLogger extends AbstractLogger
  37773. {
  37774. private $logs = array();
  37775. public function log($level, $message, array $context = array())
  37776. {
  37777. $this->logs[] = array($level, $message, $context);
  37778. }
  37779. public function cleanLogs()
  37780. {
  37781. $logs = $this->logs;
  37782. $this->logs = array();
  37783. return $logs;
  37784. }
  37785. }
  37786. <?php
  37787. namespace Symfony\Component\Debug;
  37788. class Debug
  37789. {
  37790. private static $enabled = false;
  37791. public static function enable($errorReportingLevel = null, $displayErrors = true)
  37792. {
  37793. if (static::$enabled) {
  37794. return;
  37795. }
  37796. static::$enabled = true;
  37797. if (null !== $errorReportingLevel) {
  37798. error_reporting($errorReportingLevel);
  37799. } else {
  37800. error_reporting(-1);
  37801. }
  37802. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  37803. ini_set('display_errors', 0);
  37804. ExceptionHandler::register();
  37805. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  37806. ini_set('display_errors', 1);
  37807. }
  37808. if ($displayErrors) {
  37809. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  37810. } else {
  37811. ErrorHandler::register()->throwAt(0, true);
  37812. }
  37813. DebugClassLoader::enable();
  37814. }
  37815. }
  37816. <?php
  37817. namespace Symfony\Component\Debug;
  37818. class DebugClassLoader
  37819. {
  37820. private $classLoader;
  37821. private $isFinder;
  37822. private $loaded = array();
  37823. private $wasFinder;
  37824. private static $caseCheck;
  37825. private static $deprecated = array();
  37826. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  37827. private static $darwinCache = array('/' => array('/', array()));
  37828. public function __construct($classLoader)
  37829. {
  37830. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  37831. if ($this->wasFinder) {
  37832. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  37833. $this->classLoader = array($classLoader, 'loadClass');
  37834. $this->isFinder = true;
  37835. } else {
  37836. $this->classLoader = $classLoader;
  37837. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  37838. }
  37839. if (!isset(self::$caseCheck)) {
  37840. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  37841. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  37842. $dir = substr($file, 0, 1 + $i);
  37843. $file = substr($file, 1 + $i);
  37844. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  37845. $test = realpath($dir.$test);
  37846. if (false === $test || false === $i) {
  37847. self::$caseCheck = 0;
  37848. } elseif (substr($test, -\strlen($file)) === $file) {
  37849. self::$caseCheck = 1;
  37850. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  37851. self::$caseCheck = 2;
  37852. } else {
  37853. self::$caseCheck = 0;
  37854. }
  37855. }
  37856. }
  37857. public function getClassLoader()
  37858. {
  37859. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  37860. }
  37861. public static function enable()
  37862. {
  37863. class_exists('Symfony\Component\Debug\ErrorHandler');
  37864. class_exists('Psr\Log\LogLevel');
  37865. if (!\is_array($functions = spl_autoload_functions())) {
  37866. return;
  37867. }
  37868. foreach ($functions as $function) {
  37869. spl_autoload_unregister($function);
  37870. }
  37871. foreach ($functions as $function) {
  37872. if (!\is_array($function) || !$function[0] instanceof self) {
  37873. $function = array(new static($function), 'loadClass');
  37874. }
  37875. spl_autoload_register($function);
  37876. }
  37877. }
  37878. public static function disable()
  37879. {
  37880. if (!\is_array($functions = spl_autoload_functions())) {
  37881. return;
  37882. }
  37883. foreach ($functions as $function) {
  37884. spl_autoload_unregister($function);
  37885. }
  37886. foreach ($functions as $function) {
  37887. if (\is_array($function) && $function[0] instanceof self) {
  37888. $function = $function[0]->getClassLoader();
  37889. }
  37890. spl_autoload_register($function);
  37891. }
  37892. }
  37893. public function findFile($class)
  37894. {
  37895. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  37896. if ($this->wasFinder) {
  37897. return $this->classLoader[0]->findFile($class);
  37898. }
  37899. }
  37900. public function loadClass($class)
  37901. {
  37902. ErrorHandler::stackErrors();
  37903. try {
  37904. if ($this->isFinder && !isset($this->loaded[$class])) {
  37905. $this->loaded[$class] = true;
  37906. if ($file = $this->classLoader[0]->findFile($class)) {
  37907. require $file;
  37908. }
  37909. } else {
  37910. \call_user_func($this->classLoader, $class);
  37911. $file = false;
  37912. }
  37913. } catch (\Exception $e) {
  37914. ErrorHandler::unstackErrors();
  37915. throw $e;
  37916. } catch (\Throwable $e) {
  37917. ErrorHandler::unstackErrors();
  37918. throw $e;
  37919. }
  37920. ErrorHandler::unstackErrors();
  37921. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  37922. if ($class && '\\' === $class[0]) {
  37923. $class = substr($class, 1);
  37924. }
  37925. if ($exists) {
  37926. $refl = new \ReflectionClass($class);
  37927. $name = $refl->getName();
  37928. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  37929. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  37930. }
  37931. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  37932. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  37933. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  37934. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  37935. } else {
  37936. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  37937. $len = 0;
  37938. $ns = '';
  37939. } else {
  37940. $ns = substr($name, 0, $len);
  37941. }
  37942. $parent = get_parent_class($class);
  37943. if (!$parent || strncmp($ns, $parent, $len)) {
  37944. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  37945. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  37946. }
  37947. $parentInterfaces = array();
  37948. $deprecatedInterfaces = array();
  37949. if ($parent) {
  37950. foreach (class_implements($parent) as $interface) {
  37951. $parentInterfaces[$interface] = 1;
  37952. }
  37953. }
  37954. foreach ($refl->getInterfaceNames() as $interface) {
  37955. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  37956. $deprecatedInterfaces[] = $interface;
  37957. }
  37958. foreach (class_implements($interface) as $interface) {
  37959. $parentInterfaces[$interface] = 1;
  37960. }
  37961. }
  37962. foreach ($deprecatedInterfaces as $interface) {
  37963. if (!isset($parentInterfaces[$interface])) {
  37964. @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);
  37965. }
  37966. }
  37967. }
  37968. }
  37969. }
  37970. if ($file) {
  37971. if (!$exists) {
  37972. if (false !== strpos($class, '/')) {
  37973. 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));
  37974. }
  37975. 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));
  37976. }
  37977. if (self::$caseCheck) {
  37978. $real = explode('\\', $class.strrchr($file, '.'));
  37979. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  37980. $i = \count($tail) - 1;
  37981. $j = \count($real) - 1;
  37982. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  37983. --$i;
  37984. --$j;
  37985. }
  37986. array_splice($tail, 0, $i + 1);
  37987. }
  37988. if (self::$caseCheck && $tail) {
  37989. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  37990. $tailLen = \strlen($tail);
  37991. $real = $refl->getFileName();
  37992. if (2 === self::$caseCheck) {
  37993. $i = 1 + strrpos($real, '/');
  37994. $file = substr($real, $i);
  37995. $real = substr($real, 0, $i);
  37996. if (isset(self::$darwinCache[$real])) {
  37997. $kDir = $real;
  37998. } else {
  37999. $kDir = strtolower($real);
  38000. if (isset(self::$darwinCache[$kDir])) {
  38001. $real = self::$darwinCache[$kDir][0];
  38002. } else {
  38003. $dir = getcwd();
  38004. chdir($real);
  38005. $real = getcwd().'/';
  38006. chdir($dir);
  38007. $dir = $real;
  38008. $k = $kDir;
  38009. $i = \strlen($dir) - 1;
  38010. while (!isset(self::$darwinCache[$k])) {
  38011. self::$darwinCache[$k] = array($dir, array());
  38012. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  38013. while ('/' !== $dir[--$i]) {
  38014. }
  38015. $k = substr($k, 0, ++$i);
  38016. $dir = substr($dir, 0, $i--);
  38017. }
  38018. }
  38019. }
  38020. $dirFiles = self::$darwinCache[$kDir][1];
  38021. if (isset($dirFiles[$file])) {
  38022. $kFile = $file;
  38023. } else {
  38024. $kFile = strtolower($file);
  38025. if (!isset($dirFiles[$kFile])) {
  38026. foreach (scandir($real, 2) as $f) {
  38027. if ('.' !== $f[0]) {
  38028. $dirFiles[$f] = $f;
  38029. if ($f === $file) {
  38030. $kFile = $k = $file;
  38031. } elseif ($f !== $k = strtolower($f)) {
  38032. $dirFiles[$k] = $f;
  38033. }
  38034. }
  38035. }
  38036. self::$darwinCache[$kDir][1] = $dirFiles;
  38037. }
  38038. }
  38039. $real .= $dirFiles[$kFile];
  38040. }
  38041. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  38042. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  38043. ) {
  38044. 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)));
  38045. }
  38046. }
  38047. return true;
  38048. }
  38049. }
  38050. }
  38051. <?php
  38052. namespace Symfony\Component\Debug;
  38053. use Psr\Log\LoggerInterface;
  38054. use Psr\Log\LogLevel;
  38055. use Symfony\Component\Debug\Exception\ContextErrorException;
  38056. use Symfony\Component\Debug\Exception\FatalErrorException;
  38057. use Symfony\Component\Debug\Exception\FatalThrowableError;
  38058. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  38059. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  38060. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  38061. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  38062. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  38063. class ErrorHandler
  38064. {
  38065. const TYPE_DEPRECATION = -100;
  38066. private $levels = array(
  38067. E_DEPRECATED => 'Deprecated',
  38068. E_USER_DEPRECATED => 'User Deprecated',
  38069. E_NOTICE => 'Notice',
  38070. E_USER_NOTICE => 'User Notice',
  38071. E_STRICT => 'Runtime Notice',
  38072. E_WARNING => 'Warning',
  38073. E_USER_WARNING => 'User Warning',
  38074. E_COMPILE_WARNING => 'Compile Warning',
  38075. E_CORE_WARNING => 'Core Warning',
  38076. E_USER_ERROR => 'User Error',
  38077. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  38078. E_COMPILE_ERROR => 'Compile Error',
  38079. E_PARSE => 'Parse Error',
  38080. E_ERROR => 'Error',
  38081. E_CORE_ERROR => 'Core Error',
  38082. );
  38083. private $loggers = array(
  38084. E_DEPRECATED => array(null, LogLevel::INFO),
  38085. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  38086. E_NOTICE => array(null, LogLevel::WARNING),
  38087. E_USER_NOTICE => array(null, LogLevel::WARNING),
  38088. E_STRICT => array(null, LogLevel::WARNING),
  38089. E_WARNING => array(null, LogLevel::WARNING),
  38090. E_USER_WARNING => array(null, LogLevel::WARNING),
  38091. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  38092. E_CORE_WARNING => array(null, LogLevel::WARNING),
  38093. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  38094. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  38095. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  38096. E_PARSE => array(null, LogLevel::CRITICAL),
  38097. E_ERROR => array(null, LogLevel::CRITICAL),
  38098. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  38099. );
  38100. private $thrownErrors = 0x1FFF;
  38101. private $scopedErrors = 0x1FFF;
  38102. private $tracedErrors = 0x77FB;
  38103. private $screamedErrors = 0x55;
  38104. private $loggedErrors = 0;
  38105. private $loggedTraces = array();
  38106. private $isRecursive = 0;
  38107. private $isRoot = false;
  38108. private $exceptionHandler;
  38109. private $bootstrappingLogger;
  38110. private static $reservedMemory;
  38111. private static $stackedErrors = array();
  38112. private static $stackedErrorLevels = array();
  38113. private static $toStringException = null;
  38114. private static $exitCode = 0;
  38115. private $displayErrors = 0x1FFF;
  38116. public static function register($handler = null, $replace = true)
  38117. {
  38118. if (null === self::$reservedMemory) {
  38119. self::$reservedMemory = str_repeat('x', 10240);
  38120. register_shutdown_function(__CLASS__.'::handleFatalError');
  38121. }
  38122. $levels = -1;
  38123. if ($handlerIsNew = !$handler instanceof self) {
  38124. if (null !== $handler) {
  38125. $levels = $replace ? $handler : 0;
  38126. $replace = true;
  38127. }
  38128. $handler = new static();
  38129. }
  38130. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  38131. restore_error_handler();
  38132. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  38133. $handler->isRoot = true;
  38134. }
  38135. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  38136. $handler = $prev[0];
  38137. $replace = false;
  38138. }
  38139. if (!$replace && $prev) {
  38140. restore_error_handler();
  38141. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  38142. } else {
  38143. $handlerIsRegistered = true;
  38144. }
  38145. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  38146. restore_exception_handler();
  38147. if (!$handlerIsRegistered) {
  38148. $handler = $prev[0];
  38149. } elseif ($handler !== $prev[0] && $replace) {
  38150. set_exception_handler(array($handler, 'handleException'));
  38151. $p = $prev[0]->setExceptionHandler(null);
  38152. $handler->setExceptionHandler($p);
  38153. $prev[0]->setExceptionHandler($p);
  38154. }
  38155. } else {
  38156. $handler->setExceptionHandler($prev);
  38157. }
  38158. $handler->throwAt($levels & $handler->thrownErrors, true);
  38159. return $handler;
  38160. }
  38161. public function __construct(BufferingLogger $bootstrappingLogger = null)
  38162. {
  38163. if ($bootstrappingLogger) {
  38164. $this->bootstrappingLogger = $bootstrappingLogger;
  38165. $this->setDefaultLogger($bootstrappingLogger);
  38166. }
  38167. }
  38168. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  38169. {
  38170. $loggers = array();
  38171. if (\is_array($levels)) {
  38172. foreach ($levels as $type => $logLevel) {
  38173. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  38174. $loggers[$type] = array($logger, $logLevel);
  38175. }
  38176. }
  38177. } else {
  38178. if (null === $levels) {
  38179. $levels = E_ALL | E_STRICT;
  38180. }
  38181. foreach ($this->loggers as $type => $log) {
  38182. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  38183. $log[0] = $logger;
  38184. $loggers[$type] = $log;
  38185. }
  38186. }
  38187. }
  38188. $this->setLoggers($loggers);
  38189. }
  38190. public function setLoggers(array $loggers)
  38191. {
  38192. $prevLogged = $this->loggedErrors;
  38193. $prev = $this->loggers;
  38194. $flush = array();
  38195. foreach ($loggers as $type => $log) {
  38196. if (!isset($prev[$type])) {
  38197. throw new \InvalidArgumentException('Unknown error type: '.$type);
  38198. }
  38199. if (!\is_array($log)) {
  38200. $log = array($log);
  38201. } elseif (!array_key_exists(0, $log)) {
  38202. throw new \InvalidArgumentException('No logger provided');
  38203. }
  38204. if (null === $log[0]) {
  38205. $this->loggedErrors &= ~$type;
  38206. } elseif ($log[0] instanceof LoggerInterface) {
  38207. $this->loggedErrors |= $type;
  38208. } else {
  38209. throw new \InvalidArgumentException('Invalid logger provided');
  38210. }
  38211. $this->loggers[$type] = $log + $prev[$type];
  38212. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  38213. $flush[$type] = $type;
  38214. }
  38215. }
  38216. $this->reRegister($prevLogged | $this->thrownErrors);
  38217. if ($flush) {
  38218. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  38219. $type = $log[2]['type'];
  38220. if (!isset($flush[$type])) {
  38221. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  38222. } elseif ($this->loggers[$type][0]) {
  38223. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  38224. }
  38225. }
  38226. }
  38227. return $prev;
  38228. }
  38229. public function setExceptionHandler($handler)
  38230. {
  38231. if (null !== $handler && !\is_callable($handler)) {
  38232. throw new \LogicException('The exception handler must be a valid PHP callable.');
  38233. }
  38234. $prev = $this->exceptionHandler;
  38235. $this->exceptionHandler = $handler;
  38236. return $prev;
  38237. }
  38238. public function throwAt($levels, $replace = false)
  38239. {
  38240. $prev = $this->thrownErrors;
  38241. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  38242. if (!$replace) {
  38243. $this->thrownErrors |= $prev;
  38244. }
  38245. $this->reRegister($prev | $this->loggedErrors);
  38246. $this->displayErrors = $this->thrownErrors;
  38247. return $prev;
  38248. }
  38249. public function scopeAt($levels, $replace = false)
  38250. {
  38251. $prev = $this->scopedErrors;
  38252. $this->scopedErrors = (int) $levels;
  38253. if (!$replace) {
  38254. $this->scopedErrors |= $prev;
  38255. }
  38256. return $prev;
  38257. }
  38258. public function traceAt($levels, $replace = false)
  38259. {
  38260. $prev = $this->tracedErrors;
  38261. $this->tracedErrors = (int) $levels;
  38262. if (!$replace) {
  38263. $this->tracedErrors |= $prev;
  38264. }
  38265. return $prev;
  38266. }
  38267. public function screamAt($levels, $replace = false)
  38268. {
  38269. $prev = $this->screamedErrors;
  38270. $this->screamedErrors = (int) $levels;
  38271. if (!$replace) {
  38272. $this->screamedErrors |= $prev;
  38273. }
  38274. return $prev;
  38275. }
  38276. private function reRegister($prev)
  38277. {
  38278. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  38279. $handler = set_error_handler('var_dump');
  38280. $handler = \is_array($handler) ? $handler[0] : null;
  38281. restore_error_handler();
  38282. if ($handler === $this) {
  38283. restore_error_handler();
  38284. if ($this->isRoot) {
  38285. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  38286. } else {
  38287. set_error_handler(array($this, 'handleError'));
  38288. }
  38289. }
  38290. }
  38291. }
  38292. public function handleError($type, $message, $file, $line)
  38293. {
  38294. $level = error_reporting();
  38295. $silenced = 0 === ($level & $type);
  38296. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  38297. $log = $this->loggedErrors & $type;
  38298. $throw = $this->thrownErrors & $type & $level;
  38299. $type &= $level | $this->screamedErrors;
  38300. if (!$type || (!$log && !$throw)) {
  38301. return !$silenced && $type && $log;
  38302. }
  38303. $scope = $this->scopedErrors & $type;
  38304. if (4 < $numArgs = \func_num_args()) {
  38305. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  38306. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  38307. } else {
  38308. $context = array();
  38309. $backtrace = null;
  38310. }
  38311. if (isset($context['GLOBALS']) && $scope) {
  38312. $e = $context;
  38313. unset($e['GLOBALS'], $context);
  38314. $context = $e;
  38315. }
  38316. if (null !== $backtrace && $type & E_ERROR) {
  38317. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  38318. return true;
  38319. }
  38320. if ($throw) {
  38321. if (null !== self::$toStringException) {
  38322. $throw = self::$toStringException;
  38323. self::$toStringException = null;
  38324. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  38325. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  38326. } else {
  38327. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  38328. }
  38329. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  38330. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  38331. }
  38332. if (E_USER_ERROR & $type) {
  38333. $backtrace = $backtrace ?: $throw->getTrace();
  38334. for ($i = 1; isset($backtrace[$i]); ++$i) {
  38335. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  38336. && '__toString' === $backtrace[$i]['function']
  38337. && '->' === $backtrace[$i]['type']
  38338. && !isset($backtrace[$i - 1]['class'])
  38339. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  38340. ) {
  38341. foreach ($context as $e) {
  38342. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  38343. if (1 === $i) {
  38344. $throw = $e;
  38345. break;
  38346. }
  38347. self::$toStringException = $e;
  38348. return true;
  38349. }
  38350. }
  38351. if (1 < $i) {
  38352. $this->handleException($throw);
  38353. return false;
  38354. }
  38355. }
  38356. }
  38357. }
  38358. throw $throw;
  38359. }
  38360. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  38361. $trace = true;
  38362. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  38363. $trace = false;
  38364. } else {
  38365. $this->loggedTraces[$e] = 1;
  38366. }
  38367. $e = compact('type', 'file', 'line', 'level');
  38368. if ($type & $level) {
  38369. if ($scope) {
  38370. $e['scope_vars'] = $context;
  38371. if ($trace) {
  38372. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  38373. }
  38374. } elseif ($trace) {
  38375. if (null === $backtrace) {
  38376. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  38377. } else {
  38378. foreach ($backtrace as &$frame) {
  38379. unset($frame['args'], $frame);
  38380. }
  38381. $e['stack'] = $backtrace;
  38382. }
  38383. }
  38384. }
  38385. if ($this->isRecursive) {
  38386. $log = 0;
  38387. } elseif (self::$stackedErrorLevels) {
  38388. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  38389. } else {
  38390. try {
  38391. $this->isRecursive = true;
  38392. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  38393. $this->isRecursive = false;
  38394. } catch (\Exception $e) {
  38395. $this->isRecursive = false;
  38396. throw $e;
  38397. } catch (\Throwable $e) {
  38398. $this->isRecursive = false;
  38399. throw $e;
  38400. }
  38401. }
  38402. return !$silenced && $type && $log;
  38403. }
  38404. public function handleException($exception, array $error = null)
  38405. {
  38406. if (null === $error) {
  38407. self::$exitCode = 255;
  38408. }
  38409. if (!$exception instanceof \Exception) {
  38410. $exception = new FatalThrowableError($exception);
  38411. }
  38412. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  38413. $handlerException = null;
  38414. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  38415. $e = array(
  38416. 'type' => $type,
  38417. 'file' => $exception->getFile(),
  38418. 'line' => $exception->getLine(),
  38419. 'level' => error_reporting(),
  38420. 'stack' => $exception->getTrace(),
  38421. );
  38422. if ($exception instanceof FatalErrorException) {
  38423. if ($exception instanceof FatalThrowableError) {
  38424. $error = array(
  38425. 'type' => $type,
  38426. 'message' => $message = $exception->getMessage(),
  38427. 'file' => $e['file'],
  38428. 'line' => $e['line'],
  38429. );
  38430. } else {
  38431. $message = 'Fatal '.$exception->getMessage();
  38432. }
  38433. } elseif ($exception instanceof \ErrorException) {
  38434. $message = 'Uncaught '.$exception->getMessage();
  38435. if ($exception instanceof ContextErrorException) {
  38436. $e['context'] = $exception->getContext();
  38437. }
  38438. } else {
  38439. $message = 'Uncaught Exception: '.$exception->getMessage();
  38440. }
  38441. }
  38442. if ($this->loggedErrors & $type) {
  38443. try {
  38444. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  38445. } catch (\Exception $handlerException) {
  38446. } catch (\Throwable $handlerException) {
  38447. }
  38448. }
  38449. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  38450. foreach ($this->getFatalErrorHandlers() as $handler) {
  38451. if ($e = $handler->handleError($error, $exception)) {
  38452. $exception = $e;
  38453. break;
  38454. }
  38455. }
  38456. }
  38457. $exceptionHandler = $this->exceptionHandler;
  38458. $this->exceptionHandler = null;
  38459. try {
  38460. if (null !== $exceptionHandler) {
  38461. return \call_user_func($exceptionHandler, $exception);
  38462. }
  38463. $handlerException = $handlerException ?: $exception;
  38464. } catch (\Exception $handlerException) {
  38465. } catch (\Throwable $handlerException) {
  38466. }
  38467. if ($exception === $handlerException) {
  38468. self::$reservedMemory = null;
  38469. throw $exception;
  38470. }
  38471. $this->handleException($handlerException);
  38472. }
  38473. public static function handleFatalError(array $error = null)
  38474. {
  38475. if (null === self::$reservedMemory) {
  38476. return;
  38477. }
  38478. $handler = self::$reservedMemory = null;
  38479. $handlers = array();
  38480. $previousHandler = null;
  38481. $sameHandlerLimit = 10;
  38482. while (!\is_array($handler) || !$handler[0] instanceof self) {
  38483. $handler = set_exception_handler('var_dump');
  38484. restore_exception_handler();
  38485. if (!$handler) {
  38486. break;
  38487. }
  38488. restore_exception_handler();
  38489. if ($handler !== $previousHandler) {
  38490. array_unshift($handlers, $handler);
  38491. $previousHandler = $handler;
  38492. } elseif (0 === --$sameHandlerLimit) {
  38493. $handler = null;
  38494. break;
  38495. }
  38496. }
  38497. foreach ($handlers as $h) {
  38498. set_exception_handler($h);
  38499. }
  38500. if (!$handler) {
  38501. return;
  38502. }
  38503. if ($handler !== $h) {
  38504. $handler[0]->setExceptionHandler($h);
  38505. }
  38506. $handler = $handler[0];
  38507. $handlers = array();
  38508. if ($exit = null === $error) {
  38509. $error = error_get_last();
  38510. }
  38511. try {
  38512. while (self::$stackedErrorLevels) {
  38513. static::unstackErrors();
  38514. }
  38515. } catch (\Exception $exception) {
  38516. } catch (\Throwable $exception) {
  38517. }
  38518. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  38519. $handler->throwAt(0, true);
  38520. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  38521. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  38522. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  38523. } else {
  38524. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  38525. }
  38526. }
  38527. try {
  38528. if (isset($exception)) {
  38529. self::$exitCode = 255;
  38530. $handler->handleException($exception, $error);
  38531. }
  38532. } catch (FatalErrorException $e) {
  38533. }
  38534. if ($exit && self::$exitCode) {
  38535. $exitCode = self::$exitCode;
  38536. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  38537. }
  38538. }
  38539. public static function stackErrors()
  38540. {
  38541. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  38542. }
  38543. public static function unstackErrors()
  38544. {
  38545. $level = array_pop(self::$stackedErrorLevels);
  38546. if (null !== $level) {
  38547. $e = error_reporting($level);
  38548. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  38549. error_reporting($e);
  38550. }
  38551. }
  38552. if (empty(self::$stackedErrorLevels)) {
  38553. $errors = self::$stackedErrors;
  38554. self::$stackedErrors = array();
  38555. foreach ($errors as $e) {
  38556. $e[0]->log($e[1], $e[2], $e[3]);
  38557. }
  38558. }
  38559. }
  38560. protected function getFatalErrorHandlers()
  38561. {
  38562. return array(
  38563. new UndefinedFunctionFatalErrorHandler(),
  38564. new UndefinedMethodFatalErrorHandler(),
  38565. new ClassNotFoundFatalErrorHandler(),
  38566. );
  38567. }
  38568. public function setLevel($level)
  38569. {
  38570. @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);
  38571. $level = null === $level ? error_reporting() : $level;
  38572. $this->throwAt($level, true);
  38573. }
  38574. public function setDisplayErrors($displayErrors)
  38575. {
  38576. @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);
  38577. if ($displayErrors) {
  38578. $this->throwAt($this->displayErrors, true);
  38579. } else {
  38580. $displayErrors = $this->displayErrors;
  38581. $this->throwAt(0, true);
  38582. $this->displayErrors = $displayErrors;
  38583. }
  38584. }
  38585. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  38586. {
  38587. @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);
  38588. $handler = set_error_handler('var_dump');
  38589. $handler = \is_array($handler) ? $handler[0] : null;
  38590. restore_error_handler();
  38591. if (!$handler instanceof self) {
  38592. return;
  38593. }
  38594. if ('deprecation' === $channel) {
  38595. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  38596. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  38597. } elseif ('scream' === $channel) {
  38598. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  38599. $handler->screamAt(E_ALL | E_STRICT);
  38600. } elseif ('emergency' === $channel) {
  38601. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  38602. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  38603. }
  38604. }
  38605. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  38606. {
  38607. $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());
  38608. return $this->handleError($level, $message, $file, $line, (array) $context);
  38609. }
  38610. public function handleFatal()
  38611. {
  38612. @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);
  38613. static::handleFatalError();
  38614. }
  38615. }
  38616. class ErrorHandlerCanary
  38617. {
  38618. private static $displayErrors = null;
  38619. public function __construct()
  38620. {
  38621. if (null === self::$displayErrors) {
  38622. self::$displayErrors = ini_set('display_errors', 1);
  38623. }
  38624. }
  38625. public function __destruct()
  38626. {
  38627. if (null !== self::$displayErrors) {
  38628. ini_set('display_errors', self::$displayErrors);
  38629. self::$displayErrors = null;
  38630. }
  38631. }
  38632. }
  38633. <?php
  38634. namespace Symfony\Component\Debug\Exception;
  38635. class ClassNotFoundException extends FatalErrorException
  38636. {
  38637. public function __construct($message, \ErrorException $previous)
  38638. {
  38639. parent::__construct(
  38640. $message,
  38641. $previous->getCode(),
  38642. $previous->getSeverity(),
  38643. $previous->getFile(),
  38644. $previous->getLine(),
  38645. null,
  38646. true,
  38647. null,
  38648. $previous->getPrevious()
  38649. );
  38650. $this->setTrace($previous->getTrace());
  38651. }
  38652. }
  38653. <?php
  38654. namespace Symfony\Component\Debug\Exception;
  38655. class ContextErrorException extends \ErrorException
  38656. {
  38657. private $context = array();
  38658. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  38659. {
  38660. parent::__construct($message, $code, $severity, $filename, $lineno);
  38661. $this->context = $context;
  38662. }
  38663. public function getContext()
  38664. {
  38665. return $this->context;
  38666. }
  38667. }
  38668. <?php
  38669. namespace Symfony\Component\Debug\Exception;
  38670. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  38671. class DummyException extends \ErrorException
  38672. {
  38673. }
  38674. <?php
  38675. namespace Symfony\Component\HttpKernel\Exception;
  38676. class FatalErrorException extends \ErrorException
  38677. {
  38678. }
  38679. namespace Symfony\Component\Debug\Exception;
  38680. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  38681. class FatalErrorException extends LegacyFatalErrorException
  38682. {
  38683. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  38684. {
  38685. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  38686. if (null !== $trace) {
  38687. if (!$traceArgs) {
  38688. foreach ($trace as &$frame) {
  38689. unset($frame['args'], $frame['this'], $frame);
  38690. }
  38691. }
  38692. $this->setTrace($trace);
  38693. } elseif (null !== $traceOffset) {
  38694. if (\function_exists('xdebug_get_function_stack')) {
  38695. $trace = xdebug_get_function_stack();
  38696. if (0 < $traceOffset) {
  38697. array_splice($trace, -$traceOffset);
  38698. }
  38699. foreach ($trace as &$frame) {
  38700. if (!isset($frame['type'])) {
  38701. if (isset($frame['class'])) {
  38702. $frame['type'] = '::';
  38703. }
  38704. } elseif ('dynamic' === $frame['type']) {
  38705. $frame['type'] = '->';
  38706. } elseif ('static' === $frame['type']) {
  38707. $frame['type'] = '::';
  38708. }
  38709. if (!$traceArgs) {
  38710. unset($frame['params'], $frame['args']);
  38711. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  38712. $frame['args'] = $frame['params'];
  38713. unset($frame['params']);
  38714. }
  38715. }
  38716. unset($frame);
  38717. $trace = array_reverse($trace);
  38718. } elseif (\function_exists('symfony_debug_backtrace')) {
  38719. $trace = symfony_debug_backtrace();
  38720. if (0 < $traceOffset) {
  38721. array_splice($trace, 0, $traceOffset);
  38722. }
  38723. } else {
  38724. $trace = array();
  38725. }
  38726. $this->setTrace($trace);
  38727. }
  38728. }
  38729. protected function setTrace($trace)
  38730. {
  38731. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  38732. $traceReflector->setAccessible(true);
  38733. $traceReflector->setValue($this, $trace);
  38734. }
  38735. }
  38736. <?php
  38737. namespace Symfony\Component\Debug\Exception;
  38738. class FatalThrowableError extends FatalErrorException
  38739. {
  38740. public function __construct(\Throwable $e)
  38741. {
  38742. if ($e instanceof \ParseError) {
  38743. $message = 'Parse error: '.$e->getMessage();
  38744. $severity = E_PARSE;
  38745. } elseif ($e instanceof \TypeError) {
  38746. $message = 'Type error: '.$e->getMessage();
  38747. $severity = E_RECOVERABLE_ERROR;
  38748. } else {
  38749. $message = $e->getMessage();
  38750. $severity = E_ERROR;
  38751. }
  38752. \ErrorException::__construct(
  38753. $message,
  38754. $e->getCode(),
  38755. $severity,
  38756. $e->getFile(),
  38757. $e->getLine(),
  38758. $e->getPrevious()
  38759. );
  38760. $this->setTrace($e->getTrace());
  38761. }
  38762. }
  38763. <?php
  38764. namespace Symfony\Component\HttpKernel\Exception;
  38765. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  38766. class FlattenException
  38767. {
  38768. private $handler;
  38769. public static function __callStatic($method, $args)
  38770. {
  38771. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  38772. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  38773. }
  38774. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  38775. }
  38776. public function __call($method, $args)
  38777. {
  38778. if (!isset($this->handler)) {
  38779. $this->handler = new DebugFlattenException();
  38780. }
  38781. if (!method_exists($this->handler, $method)) {
  38782. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  38783. }
  38784. return \call_user_func_array(array($this->handler, $method), $args);
  38785. }
  38786. }
  38787. namespace Symfony\Component\Debug\Exception;
  38788. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  38789. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  38790. class FlattenException extends LegacyFlattenException
  38791. {
  38792. private $message;
  38793. private $code;
  38794. private $previous;
  38795. private $trace;
  38796. private $class;
  38797. private $statusCode;
  38798. private $headers;
  38799. private $file;
  38800. private $line;
  38801. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  38802. {
  38803. $e = new static();
  38804. $e->setMessage($exception->getMessage());
  38805. $e->setCode($exception->getCode());
  38806. if ($exception instanceof HttpExceptionInterface) {
  38807. $statusCode = $exception->getStatusCode();
  38808. $headers = array_merge($headers, $exception->getHeaders());
  38809. }
  38810. if (null === $statusCode) {
  38811. $statusCode = 500;
  38812. }
  38813. $e->setStatusCode($statusCode);
  38814. $e->setHeaders($headers);
  38815. $e->setTraceFromException($exception);
  38816. $e->setClass(\get_class($exception));
  38817. $e->setFile($exception->getFile());
  38818. $e->setLine($exception->getLine());
  38819. $previous = $exception->getPrevious();
  38820. if ($previous instanceof \Exception) {
  38821. $e->setPrevious(static::create($previous));
  38822. } elseif ($previous instanceof \Throwable) {
  38823. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  38824. }
  38825. return $e;
  38826. }
  38827. public function toArray()
  38828. {
  38829. $exceptions = array();
  38830. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  38831. $exceptions[] = array(
  38832. 'message' => $exception->getMessage(),
  38833. 'class' => $exception->getClass(),
  38834. 'trace' => $exception->getTrace(),
  38835. );
  38836. }
  38837. return $exceptions;
  38838. }
  38839. public function getStatusCode()
  38840. {
  38841. return $this->statusCode;
  38842. }
  38843. public function setStatusCode($code)
  38844. {
  38845. $this->statusCode = $code;
  38846. }
  38847. public function getHeaders()
  38848. {
  38849. return $this->headers;
  38850. }
  38851. public function setHeaders(array $headers)
  38852. {
  38853. $this->headers = $headers;
  38854. }
  38855. public function getClass()
  38856. {
  38857. return $this->class;
  38858. }
  38859. public function setClass($class)
  38860. {
  38861. $this->class = $class;
  38862. }
  38863. public function getFile()
  38864. {
  38865. return $this->file;
  38866. }
  38867. public function setFile($file)
  38868. {
  38869. $this->file = $file;
  38870. }
  38871. public function getLine()
  38872. {
  38873. return $this->line;
  38874. }
  38875. public function setLine($line)
  38876. {
  38877. $this->line = $line;
  38878. }
  38879. public function getMessage()
  38880. {
  38881. return $this->message;
  38882. }
  38883. public function setMessage($message)
  38884. {
  38885. $this->message = $message;
  38886. }
  38887. public function getCode()
  38888. {
  38889. return $this->code;
  38890. }
  38891. public function setCode($code)
  38892. {
  38893. $this->code = $code;
  38894. }
  38895. public function getPrevious()
  38896. {
  38897. return $this->previous;
  38898. }
  38899. public function setPrevious(FlattenException $previous)
  38900. {
  38901. $this->previous = $previous;
  38902. }
  38903. public function getAllPrevious()
  38904. {
  38905. $exceptions = array();
  38906. $e = $this;
  38907. while ($e = $e->getPrevious()) {
  38908. $exceptions[] = $e;
  38909. }
  38910. return $exceptions;
  38911. }
  38912. public function getTrace()
  38913. {
  38914. return $this->trace;
  38915. }
  38916. public function setTraceFromException(\Exception $exception)
  38917. {
  38918. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  38919. }
  38920. public function setTrace($trace, $file, $line)
  38921. {
  38922. $this->trace = array();
  38923. $this->trace[] = array(
  38924. 'namespace' => '',
  38925. 'short_class' => '',
  38926. 'class' => '',
  38927. 'type' => '',
  38928. 'function' => '',
  38929. 'file' => $file,
  38930. 'line' => $line,
  38931. 'args' => array(),
  38932. );
  38933. foreach ($trace as $entry) {
  38934. $class = '';
  38935. $namespace = '';
  38936. if (isset($entry['class'])) {
  38937. $parts = explode('\\', $entry['class']);
  38938. $class = array_pop($parts);
  38939. $namespace = implode('\\', $parts);
  38940. }
  38941. $this->trace[] = array(
  38942. 'namespace' => $namespace,
  38943. 'short_class' => $class,
  38944. 'class' => isset($entry['class']) ? $entry['class'] : '',
  38945. 'type' => isset($entry['type']) ? $entry['type'] : '',
  38946. 'function' => isset($entry['function']) ? $entry['function'] : null,
  38947. 'file' => isset($entry['file']) ? $entry['file'] : null,
  38948. 'line' => isset($entry['line']) ? $entry['line'] : null,
  38949. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  38950. );
  38951. }
  38952. }
  38953. private function flattenArgs($args, $level = 0, &$count = 0)
  38954. {
  38955. $result = array();
  38956. foreach ($args as $key => $value) {
  38957. if (++$count > 1e4) {
  38958. return array('array', '*SKIPPED over 10000 entries*');
  38959. }
  38960. if ($value instanceof \__PHP_Incomplete_Class) {
  38961. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  38962. } elseif (\is_object($value)) {
  38963. $result[$key] = array('object', \get_class($value));
  38964. } elseif (\is_array($value)) {
  38965. if ($level > 10) {
  38966. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  38967. } else {
  38968. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  38969. }
  38970. } elseif (null === $value) {
  38971. $result[$key] = array('null', null);
  38972. } elseif (\is_bool($value)) {
  38973. $result[$key] = array('boolean', $value);
  38974. } elseif (\is_resource($value)) {
  38975. $result[$key] = array('resource', get_resource_type($value));
  38976. } else {
  38977. $result[$key] = array('string', (string) $value);
  38978. }
  38979. }
  38980. return $result;
  38981. }
  38982. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  38983. {
  38984. $array = new \ArrayObject($value);
  38985. return $array['__PHP_Incomplete_Class_Name'];
  38986. }
  38987. }
  38988. <?php
  38989. namespace Symfony\Component\Debug\Exception;
  38990. class OutOfMemoryException extends FatalErrorException
  38991. {
  38992. }
  38993. <?php
  38994. namespace Symfony\Component\Debug\Exception;
  38995. class UndefinedFunctionException extends FatalErrorException
  38996. {
  38997. public function __construct($message, \ErrorException $previous)
  38998. {
  38999. parent::__construct(
  39000. $message,
  39001. $previous->getCode(),
  39002. $previous->getSeverity(),
  39003. $previous->getFile(),
  39004. $previous->getLine(),
  39005. null,
  39006. true,
  39007. null,
  39008. $previous->getPrevious()
  39009. );
  39010. $this->setTrace($previous->getTrace());
  39011. }
  39012. }
  39013. <?php
  39014. namespace Symfony\Component\Debug\Exception;
  39015. class UndefinedMethodException extends FatalErrorException
  39016. {
  39017. public function __construct($message, \ErrorException $previous)
  39018. {
  39019. parent::__construct(
  39020. $message,
  39021. $previous->getCode(),
  39022. $previous->getSeverity(),
  39023. $previous->getFile(),
  39024. $previous->getLine(),
  39025. null,
  39026. true,
  39027. null,
  39028. $previous->getPrevious()
  39029. );
  39030. $this->setTrace($previous->getTrace());
  39031. }
  39032. }
  39033. <?php
  39034. namespace Symfony\Component\Debug;
  39035. use Symfony\Component\Debug\Exception\FlattenException;
  39036. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  39037. use Symfony\Component\HttpFoundation\Response;
  39038. class ExceptionHandler
  39039. {
  39040. private $debug;
  39041. private $charset;
  39042. private $handler;
  39043. private $caughtBuffer;
  39044. private $caughtLength;
  39045. private $fileLinkFormat;
  39046. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  39047. {
  39048. if (false !== strpos($charset, '%')) {
  39049. @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);
  39050. $pivot = $fileLinkFormat;
  39051. $fileLinkFormat = $charset;
  39052. $charset = $pivot;
  39053. }
  39054. $this->debug = $debug;
  39055. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  39056. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  39057. }
  39058. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  39059. {
  39060. $handler = new static($debug, $charset, $fileLinkFormat);
  39061. $prev = set_exception_handler(array($handler, 'handle'));
  39062. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  39063. restore_exception_handler();
  39064. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  39065. }
  39066. return $handler;
  39067. }
  39068. public function setHandler($handler)
  39069. {
  39070. if (null !== $handler && !\is_callable($handler)) {
  39071. throw new \LogicException('The exception handler must be a valid PHP callable.');
  39072. }
  39073. $old = $this->handler;
  39074. $this->handler = $handler;
  39075. return $old;
  39076. }
  39077. public function setFileLinkFormat($format)
  39078. {
  39079. $old = $this->fileLinkFormat;
  39080. $this->fileLinkFormat = $format;
  39081. return $old;
  39082. }
  39083. public function handle(\Exception $exception)
  39084. {
  39085. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  39086. $this->failSafeHandle($exception);
  39087. return;
  39088. }
  39089. $caughtLength = $this->caughtLength = 0;
  39090. ob_start(array($this, 'catchOutput'));
  39091. $this->failSafeHandle($exception);
  39092. while (null === $this->caughtBuffer && ob_end_flush()) {
  39093. }
  39094. if (isset($this->caughtBuffer[0])) {
  39095. ob_start(array($this, 'cleanOutput'));
  39096. echo $this->caughtBuffer;
  39097. $caughtLength = ob_get_length();
  39098. }
  39099. $this->caughtBuffer = null;
  39100. try {
  39101. \call_user_func($this->handler, $exception);
  39102. $this->caughtLength = $caughtLength;
  39103. } catch (\Exception $e) {
  39104. if (!$caughtLength) {
  39105. throw $exception;
  39106. }
  39107. }
  39108. }
  39109. private function failSafeHandle(\Exception $exception)
  39110. {
  39111. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  39112. && __CLASS__ !== \get_class($this)
  39113. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  39114. && __CLASS__ !== $reflector->class
  39115. ) {
  39116. $response = $this->createResponse($exception);
  39117. $response->sendHeaders();
  39118. $response->sendContent();
  39119. @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);
  39120. return;
  39121. }
  39122. $this->sendPhpResponse($exception);
  39123. }
  39124. public function sendPhpResponse($exception)
  39125. {
  39126. if (!$exception instanceof FlattenException) {
  39127. $exception = FlattenException::create($exception);
  39128. }
  39129. if (!headers_sent()) {
  39130. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  39131. foreach ($exception->getHeaders() as $name => $value) {
  39132. header($name.': '.$value, false);
  39133. }
  39134. header('Content-Type: text/html; charset='.$this->charset);
  39135. }
  39136. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  39137. }
  39138. public function createResponse($exception)
  39139. {
  39140. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  39141. if (!$exception instanceof FlattenException) {
  39142. $exception = FlattenException::create($exception);
  39143. }
  39144. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  39145. }
  39146. public function getHtml($exception)
  39147. {
  39148. if (!$exception instanceof FlattenException) {
  39149. $exception = FlattenException::create($exception);
  39150. }
  39151. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  39152. }
  39153. public function getContent(FlattenException $exception)
  39154. {
  39155. switch ($exception->getStatusCode()) {
  39156. case 404:
  39157. $title = 'Sorry, the page you are looking for could not be found.';
  39158. break;
  39159. default:
  39160. $title = 'Whoops, looks like something went wrong.';
  39161. }
  39162. $content = '';
  39163. if ($this->debug) {
  39164. try {
  39165. $count = \count($exception->getAllPrevious());
  39166. $total = $count + 1;
  39167. foreach ($exception->toArray() as $position => $e) {
  39168. $ind = $count - $position + 1;
  39169. $class = $this->formatClass($e['class']);
  39170. $message = nl2br($this->escapeHtml($e['message']));
  39171. $content .= sprintf(<<<'EOF'
  39172. <h2 class="block_exception clear_fix">
  39173. <span class="exception_counter">%d/%d</span>
  39174. <span class="exception_title">%s%s:</span>
  39175. <span class="exception_message">%s</span>
  39176. </h2>
  39177. <div class="block">
  39178. <ol class="traces list_exception">
  39179. EOF
  39180. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  39181. foreach ($e['trace'] as $trace) {
  39182. $content .= ' <li>';
  39183. if ($trace['function']) {
  39184. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  39185. }
  39186. if (isset($trace['file']) && isset($trace['line'])) {
  39187. $content .= $this->formatPath($trace['file'], $trace['line']);
  39188. }
  39189. $content .= "</li>\n";
  39190. }
  39191. $content .= " </ol>\n</div>\n";
  39192. }
  39193. } catch (\Exception $e) {
  39194. if ($this->debug) {
  39195. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  39196. } else {
  39197. $title = 'Whoops, looks like something went wrong.';
  39198. }
  39199. }
  39200. }
  39201. return <<<EOF
  39202. <div id="sf-resetcontent" class="sf-reset">
  39203. <h1>$title</h1>
  39204. $content
  39205. </div>
  39206. EOF;
  39207. }
  39208. public function getStylesheet(FlattenException $exception)
  39209. {
  39210. return <<<'EOF'
  39211. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  39212. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  39213. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  39214. .sf-reset .clear_fix { display:inline-block; }
  39215. .sf-reset * html .clear_fix { height:1%; }
  39216. .sf-reset .clear_fix { display:block; }
  39217. .sf-reset, .sf-reset .block { margin: auto }
  39218. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  39219. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  39220. .sf-reset strong { font-weight:bold; }
  39221. .sf-reset a { color:#6c6159; cursor: default; }
  39222. .sf-reset a img { border:none; }
  39223. .sf-reset a:hover { text-decoration:underline; }
  39224. .sf-reset em { font-style:italic; }
  39225. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  39226. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  39227. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  39228. .sf-reset .exception_message { margin-left: 3em; display: block; }
  39229. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  39230. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  39231. -webkit-border-bottom-right-radius: 16px;
  39232. -webkit-border-bottom-left-radius: 16px;
  39233. -moz-border-radius-bottomright: 16px;
  39234. -moz-border-radius-bottomleft: 16px;
  39235. border-bottom-right-radius: 16px;
  39236. border-bottom-left-radius: 16px;
  39237. border-bottom:1px solid #ccc;
  39238. border-right:1px solid #ccc;
  39239. border-left:1px solid #ccc;
  39240. word-wrap: break-word;
  39241. }
  39242. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  39243. -webkit-border-top-left-radius: 16px;
  39244. -webkit-border-top-right-radius: 16px;
  39245. -moz-border-radius-topleft: 16px;
  39246. -moz-border-radius-topright: 16px;
  39247. border-top-left-radius: 16px;
  39248. border-top-right-radius: 16px;
  39249. border-top:1px solid #ccc;
  39250. border-right:1px solid #ccc;
  39251. border-left:1px solid #ccc;
  39252. overflow: hidden;
  39253. word-wrap: break-word;
  39254. }
  39255. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  39256. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  39257. .sf-reset ol { padding: 10px 0; }
  39258. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  39259. -webkit-border-radius: 10px;
  39260. -moz-border-radius: 10px;
  39261. border-radius: 10px;
  39262. border: 1px solid #ccc;
  39263. }
  39264. EOF;
  39265. }
  39266. private function decorate($content, $css)
  39267. {
  39268. return <<<EOF
  39269. <!DOCTYPE html>
  39270. <html>
  39271. <head>
  39272. <meta charset="{$this->charset}" />
  39273. <meta name="robots" content="noindex,nofollow" />
  39274. <style>
  39275. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  39276. 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;}
  39277. html { background: #eee; padding: 10px }
  39278. img { border: 0; }
  39279. #sf-resetcontent { width:970px; margin:0 auto; }
  39280. $css
  39281. </style>
  39282. </head>
  39283. <body>
  39284. $content
  39285. </body>
  39286. </html>
  39287. EOF;
  39288. }
  39289. private function formatClass($class)
  39290. {
  39291. $parts = explode('\\', $class);
  39292. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  39293. }
  39294. private function formatPath($path, $line)
  39295. {
  39296. $path = $this->escapeHtml($path);
  39297. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  39298. if ($linkFormat = $this->fileLinkFormat) {
  39299. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  39300. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  39301. }
  39302. 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);
  39303. }
  39304. private function formatArgs(array $args)
  39305. {
  39306. $result = array();
  39307. foreach ($args as $key => $item) {
  39308. if ('object' === $item[0]) {
  39309. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  39310. } elseif ('array' === $item[0]) {
  39311. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  39312. } elseif ('string' === $item[0]) {
  39313. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  39314. } elseif ('null' === $item[0]) {
  39315. $formattedValue = '<em>null</em>';
  39316. } elseif ('boolean' === $item[0]) {
  39317. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  39318. } elseif ('resource' === $item[0]) {
  39319. $formattedValue = '<em>resource</em>';
  39320. } else {
  39321. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  39322. }
  39323. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  39324. }
  39325. return implode(', ', $result);
  39326. }
  39327. protected static function utf8Htmlize($str)
  39328. {
  39329. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  39330. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  39331. }
  39332. private function escapeHtml($str)
  39333. {
  39334. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  39335. }
  39336. public function catchOutput($buffer)
  39337. {
  39338. $this->caughtBuffer = $buffer;
  39339. return '';
  39340. }
  39341. public function cleanOutput($buffer)
  39342. {
  39343. if ($this->caughtLength) {
  39344. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  39345. if (isset($cleanBuffer[0])) {
  39346. $buffer = $cleanBuffer;
  39347. }
  39348. }
  39349. return $buffer;
  39350. }
  39351. }
  39352. <?php
  39353. namespace Symfony\Component\Debug\FatalErrorHandler;
  39354. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  39355. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  39356. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  39357. use Symfony\Component\Debug\DebugClassLoader;
  39358. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  39359. use Symfony\Component\Debug\Exception\FatalErrorException;
  39360. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  39361. {
  39362. public function handleError(array $error, FatalErrorException $exception)
  39363. {
  39364. $messageLen = \strlen($error['message']);
  39365. $notFoundSuffix = '\' not found';
  39366. $notFoundSuffixLen = \strlen($notFoundSuffix);
  39367. if ($notFoundSuffixLen > $messageLen) {
  39368. return;
  39369. }
  39370. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  39371. return;
  39372. }
  39373. foreach (array('class', 'interface', 'trait') as $typeName) {
  39374. $prefix = ucfirst($typeName).' \'';
  39375. $prefixLen = \strlen($prefix);
  39376. if (0 !== strpos($error['message'], $prefix)) {
  39377. continue;
  39378. }
  39379. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  39380. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  39381. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  39382. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  39383. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  39384. $tail = ' for another namespace?';
  39385. } else {
  39386. $className = $fullyQualifiedClassName;
  39387. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  39388. $tail = '?';
  39389. }
  39390. if ($candidates = $this->getClassCandidates($className)) {
  39391. $tail = array_pop($candidates).'"?';
  39392. if ($candidates) {
  39393. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  39394. } else {
  39395. $tail = ' for "'.$tail;
  39396. }
  39397. }
  39398. $message .= "\nDid you forget a \"use\" statement".$tail;
  39399. return new ClassNotFoundException($message, $exception);
  39400. }
  39401. }
  39402. private function getClassCandidates($class)
  39403. {
  39404. if (!\is_array($functions = spl_autoload_functions())) {
  39405. return array();
  39406. }
  39407. $classes = array();
  39408. foreach ($functions as $function) {
  39409. if (!\is_array($function)) {
  39410. continue;
  39411. }
  39412. if ($function[0] instanceof DebugClassLoader) {
  39413. $function = $function[0]->getClassLoader();
  39414. if (\is_object($function)) {
  39415. $function = array($function);
  39416. }
  39417. if (!\is_array($function)) {
  39418. continue;
  39419. }
  39420. }
  39421. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  39422. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  39423. foreach ($paths as $path) {
  39424. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  39425. }
  39426. }
  39427. }
  39428. if ($function[0] instanceof ComposerClassLoader) {
  39429. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  39430. foreach ($paths as $path) {
  39431. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  39432. }
  39433. }
  39434. }
  39435. }
  39436. return array_unique($classes);
  39437. }
  39438. private function findClassInPath($path, $class, $prefix)
  39439. {
  39440. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  39441. return array();
  39442. }
  39443. $classes = array();
  39444. $filename = $class.'.php';
  39445. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  39446. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  39447. $classes[] = $class;
  39448. }
  39449. }
  39450. return $classes;
  39451. }
  39452. private function convertFileToClass($path, $file, $prefix)
  39453. {
  39454. $candidates = array(
  39455. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  39456. $prefix.$namespacedClass,
  39457. $prefix.'\\'.$namespacedClass,
  39458. str_replace('\\', '_', $namespacedClass),
  39459. str_replace('\\', '_', $prefix.$namespacedClass),
  39460. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  39461. );
  39462. if ($prefix) {
  39463. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  39464. }
  39465. foreach ($candidates as $candidate) {
  39466. if ($this->classExists($candidate)) {
  39467. return $candidate;
  39468. }
  39469. }
  39470. require_once $file;
  39471. foreach ($candidates as $candidate) {
  39472. if ($this->classExists($candidate)) {
  39473. return $candidate;
  39474. }
  39475. }
  39476. }
  39477. private function classExists($class)
  39478. {
  39479. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  39480. }
  39481. }
  39482. <?php
  39483. namespace Symfony\Component\Debug\FatalErrorHandler;
  39484. use Symfony\Component\Debug\Exception\FatalErrorException;
  39485. interface FatalErrorHandlerInterface
  39486. {
  39487. public function handleError(array $error, FatalErrorException $exception);
  39488. }
  39489. <?php
  39490. namespace Symfony\Component\Debug\FatalErrorHandler;
  39491. use Symfony\Component\Debug\Exception\FatalErrorException;
  39492. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  39493. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  39494. {
  39495. public function handleError(array $error, FatalErrorException $exception)
  39496. {
  39497. $messageLen = \strlen($error['message']);
  39498. $notFoundSuffix = '()';
  39499. $notFoundSuffixLen = \strlen($notFoundSuffix);
  39500. if ($notFoundSuffixLen > $messageLen) {
  39501. return;
  39502. }
  39503. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  39504. return;
  39505. }
  39506. $prefix = 'Call to undefined function ';
  39507. $prefixLen = \strlen($prefix);
  39508. if (0 !== strpos($error['message'], $prefix)) {
  39509. return;
  39510. }
  39511. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  39512. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  39513. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  39514. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  39515. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  39516. } else {
  39517. $functionName = $fullyQualifiedFunctionName;
  39518. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  39519. }
  39520. $candidates = array();
  39521. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  39522. foreach ($definedFunctionNames as $definedFunctionName) {
  39523. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  39524. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  39525. } else {
  39526. $definedFunctionNameBasename = $definedFunctionName;
  39527. }
  39528. if ($definedFunctionNameBasename === $functionName) {
  39529. $candidates[] = '\\'.$definedFunctionName;
  39530. }
  39531. }
  39532. }
  39533. if ($candidates) {
  39534. sort($candidates);
  39535. $last = array_pop($candidates).'"?';
  39536. if ($candidates) {
  39537. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  39538. } else {
  39539. $candidates = '"'.$last;
  39540. }
  39541. $message .= "\nDid you mean to call ".$candidates;
  39542. }
  39543. return new UndefinedFunctionException($message, $exception);
  39544. }
  39545. }
  39546. <?php
  39547. namespace Symfony\Component\Debug\FatalErrorHandler;
  39548. use Symfony\Component\Debug\Exception\FatalErrorException;
  39549. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  39550. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  39551. {
  39552. public function handleError(array $error, FatalErrorException $exception)
  39553. {
  39554. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  39555. if (!$matches) {
  39556. return;
  39557. }
  39558. $className = $matches[1];
  39559. $methodName = $matches[2];
  39560. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  39561. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  39562. return new UndefinedMethodException($message, $exception);
  39563. }
  39564. $candidates = array();
  39565. foreach ($methods as $definedMethodName) {
  39566. $lev = levenshtein($methodName, $definedMethodName);
  39567. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  39568. $candidates[] = $definedMethodName;
  39569. }
  39570. }
  39571. if ($candidates) {
  39572. sort($candidates);
  39573. $last = array_pop($candidates).'"?';
  39574. if ($candidates) {
  39575. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  39576. } else {
  39577. $candidates = '"'.$last;
  39578. }
  39579. $message .= "\nDid you mean to call ".$candidates;
  39580. }
  39581. return new UndefinedMethodException($message, $exception);
  39582. }
  39583. }
  39584. Copyright (c) 2004-2018 Fabien Potencier
  39585. Permission is hereby granted, free of charge, to any person obtaining a copy
  39586. of this software and associated documentation files (the "Software"), to deal
  39587. in the Software without restriction, including without limitation the rights
  39588. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  39589. copies of the Software, and to permit persons to whom the Software is furnished
  39590. to do so, subject to the following conditions:
  39591. The above copyright notice and this permission notice shall be included in all
  39592. copies or substantial portions of the Software.
  39593. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39594. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  39595. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  39596. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39597. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39598. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  39599. THE SOFTWARE.
  39600. <?php
  39601. namespace Symfony\Component\Filesystem\Exception;
  39602. interface ExceptionInterface
  39603. {
  39604. }
  39605. <?php
  39606. namespace Symfony\Component\Filesystem\Exception;
  39607. class FileNotFoundException extends IOException
  39608. {
  39609. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  39610. {
  39611. if (null === $message) {
  39612. if (null === $path) {
  39613. $message = 'File could not be found.';
  39614. } else {
  39615. $message = sprintf('File "%s" could not be found.', $path);
  39616. }
  39617. }
  39618. parent::__construct($message, $code, $previous, $path);
  39619. }
  39620. }
  39621. <?php
  39622. namespace Symfony\Component\Filesystem\Exception;
  39623. class IOException extends \RuntimeException implements IOExceptionInterface
  39624. {
  39625. private $path;
  39626. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  39627. {
  39628. $this->path = $path;
  39629. parent::__construct($message, $code, $previous);
  39630. }
  39631. public function getPath()
  39632. {
  39633. return $this->path;
  39634. }
  39635. }
  39636. <?php
  39637. namespace Symfony\Component\Filesystem\Exception;
  39638. interface IOExceptionInterface extends ExceptionInterface
  39639. {
  39640. public function getPath();
  39641. }
  39642. <?php
  39643. namespace Symfony\Component\Filesystem;
  39644. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  39645. use Symfony\Component\Filesystem\Exception\IOException;
  39646. class Filesystem
  39647. {
  39648. private static $lastError;
  39649. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  39650. {
  39651. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  39652. if ($originIsLocal && !is_file($originFile)) {
  39653. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  39654. }
  39655. $this->mkdir(\dirname($targetFile));
  39656. $doCopy = true;
  39657. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  39658. $doCopy = filemtime($originFile) > filemtime($targetFile);
  39659. }
  39660. if ($doCopy) {
  39661. if (false === $source = @fopen($originFile, 'r')) {
  39662. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  39663. }
  39664. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  39665. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  39666. }
  39667. $bytesCopied = stream_copy_to_stream($source, $target);
  39668. fclose($source);
  39669. fclose($target);
  39670. unset($source, $target);
  39671. if (!is_file($targetFile)) {
  39672. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  39673. }
  39674. if ($originIsLocal) {
  39675. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  39676. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  39677. 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);
  39678. }
  39679. }
  39680. }
  39681. }
  39682. public function mkdir($dirs, $mode = 0777)
  39683. {
  39684. foreach ($this->toIterator($dirs) as $dir) {
  39685. if (is_dir($dir)) {
  39686. continue;
  39687. }
  39688. if (!self::box('mkdir', $dir, $mode, true)) {
  39689. if (!is_dir($dir)) {
  39690. if (self::$lastError) {
  39691. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  39692. }
  39693. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  39694. }
  39695. }
  39696. }
  39697. }
  39698. public function exists($files)
  39699. {
  39700. $maxPathLength = PHP_MAXPATHLEN - 2;
  39701. foreach ($this->toIterator($files) as $file) {
  39702. if (\strlen($file) > $maxPathLength) {
  39703. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  39704. }
  39705. if (!file_exists($file)) {
  39706. return false;
  39707. }
  39708. }
  39709. return true;
  39710. }
  39711. public function touch($files, $time = null, $atime = null)
  39712. {
  39713. foreach ($this->toIterator($files) as $file) {
  39714. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  39715. if (true !== $touch) {
  39716. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  39717. }
  39718. }
  39719. }
  39720. public function remove($files)
  39721. {
  39722. if ($files instanceof \Traversable) {
  39723. $files = iterator_to_array($files, false);
  39724. } elseif (!\is_array($files)) {
  39725. $files = array($files);
  39726. }
  39727. $files = array_reverse($files);
  39728. foreach ($files as $file) {
  39729. if (is_link($file)) {
  39730. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  39731. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  39732. }
  39733. } elseif (is_dir($file)) {
  39734. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  39735. if (!self::box('rmdir', $file) && file_exists($file)) {
  39736. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  39737. }
  39738. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  39739. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  39740. }
  39741. }
  39742. }
  39743. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  39744. {
  39745. foreach ($this->toIterator($files) as $file) {
  39746. if (true !== @chmod($file, $mode & ~$umask)) {
  39747. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  39748. }
  39749. if ($recursive && is_dir($file) && !is_link($file)) {
  39750. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  39751. }
  39752. }
  39753. }
  39754. public function chown($files, $user, $recursive = false)
  39755. {
  39756. foreach ($this->toIterator($files) as $file) {
  39757. if ($recursive && is_dir($file) && !is_link($file)) {
  39758. $this->chown(new \FilesystemIterator($file), $user, true);
  39759. }
  39760. if (is_link($file) && \function_exists('lchown')) {
  39761. if (true !== @lchown($file, $user)) {
  39762. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  39763. }
  39764. } else {
  39765. if (true !== @chown($file, $user)) {
  39766. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  39767. }
  39768. }
  39769. }
  39770. }
  39771. public function chgrp($files, $group, $recursive = false)
  39772. {
  39773. foreach ($this->toIterator($files) as $file) {
  39774. if ($recursive && is_dir($file) && !is_link($file)) {
  39775. $this->chgrp(new \FilesystemIterator($file), $group, true);
  39776. }
  39777. if (is_link($file) && \function_exists('lchgrp')) {
  39778. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  39779. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  39780. }
  39781. } else {
  39782. if (true !== @chgrp($file, $group)) {
  39783. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  39784. }
  39785. }
  39786. }
  39787. }
  39788. public function rename($origin, $target, $overwrite = false)
  39789. {
  39790. if (!$overwrite && $this->isReadable($target)) {
  39791. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  39792. }
  39793. if (true !== @rename($origin, $target)) {
  39794. if (is_dir($origin)) {
  39795. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  39796. $this->remove($origin);
  39797. return;
  39798. }
  39799. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  39800. }
  39801. }
  39802. private function isReadable($filename)
  39803. {
  39804. $maxPathLength = PHP_MAXPATHLEN - 2;
  39805. if (\strlen($filename) > $maxPathLength) {
  39806. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  39807. }
  39808. return is_readable($filename);
  39809. }
  39810. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  39811. {
  39812. if ('\\' === \DIRECTORY_SEPARATOR) {
  39813. $originDir = strtr($originDir, '/', '\\');
  39814. $targetDir = strtr($targetDir, '/', '\\');
  39815. if ($copyOnWindows) {
  39816. $this->mirror($originDir, $targetDir);
  39817. return;
  39818. }
  39819. }
  39820. $this->mkdir(\dirname($targetDir));
  39821. if (is_link($targetDir)) {
  39822. if (readlink($targetDir) === $originDir) {
  39823. return;
  39824. }
  39825. $this->remove($targetDir);
  39826. }
  39827. if (!self::box('symlink', $originDir, $targetDir)) {
  39828. if (null !== self::$lastError) {
  39829. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  39830. 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);
  39831. }
  39832. }
  39833. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  39834. }
  39835. }
  39836. public function makePathRelative($endPath, $startPath)
  39837. {
  39838. if ('\\' === \DIRECTORY_SEPARATOR) {
  39839. $endPath = str_replace('\\', '/', $endPath);
  39840. $startPath = str_replace('\\', '/', $startPath);
  39841. }
  39842. $stripDriveLetter = function ($path) {
  39843. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  39844. return substr($path, 2);
  39845. }
  39846. return $path;
  39847. };
  39848. $endPath = $stripDriveLetter($endPath);
  39849. $startPath = $stripDriveLetter($startPath);
  39850. $startPathArr = explode('/', trim($startPath, '/'));
  39851. $endPathArr = explode('/', trim($endPath, '/'));
  39852. $normalizePathArray = function ($pathSegments, $absolute) {
  39853. $result = array();
  39854. foreach ($pathSegments as $segment) {
  39855. if ('..' === $segment && ($absolute || \count($result))) {
  39856. array_pop($result);
  39857. } elseif ('.' !== $segment) {
  39858. $result[] = $segment;
  39859. }
  39860. }
  39861. return $result;
  39862. };
  39863. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  39864. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  39865. $index = 0;
  39866. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  39867. ++$index;
  39868. }
  39869. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  39870. $depth = 0;
  39871. } else {
  39872. $depth = \count($startPathArr) - $index;
  39873. }
  39874. $traverser = str_repeat('../', $depth);
  39875. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  39876. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  39877. return '' === $relativePath ? './' : $relativePath;
  39878. }
  39879. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  39880. {
  39881. $targetDir = rtrim($targetDir, '/\\');
  39882. $originDir = rtrim($originDir, '/\\');
  39883. $originDirLen = \strlen($originDir);
  39884. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  39885. $deleteIterator = $iterator;
  39886. if (null === $deleteIterator) {
  39887. $flags = \FilesystemIterator::SKIP_DOTS;
  39888. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  39889. }
  39890. $targetDirLen = \strlen($targetDir);
  39891. foreach ($deleteIterator as $file) {
  39892. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  39893. if (!$this->exists($origin)) {
  39894. $this->remove($file);
  39895. }
  39896. }
  39897. }
  39898. $copyOnWindows = false;
  39899. if (isset($options['copy_on_windows'])) {
  39900. $copyOnWindows = $options['copy_on_windows'];
  39901. }
  39902. if (null === $iterator) {
  39903. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  39904. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  39905. }
  39906. if ($this->exists($originDir)) {
  39907. $this->mkdir($targetDir);
  39908. }
  39909. foreach ($iterator as $file) {
  39910. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  39911. if ($copyOnWindows) {
  39912. if (is_file($file)) {
  39913. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  39914. } elseif (is_dir($file)) {
  39915. $this->mkdir($target);
  39916. } else {
  39917. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  39918. }
  39919. } else {
  39920. if (is_link($file)) {
  39921. $this->symlink($file->getLinkTarget(), $target);
  39922. } elseif (is_dir($file)) {
  39923. $this->mkdir($target);
  39924. } elseif (is_file($file)) {
  39925. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  39926. } else {
  39927. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  39928. }
  39929. }
  39930. }
  39931. }
  39932. public function isAbsolutePath($file)
  39933. {
  39934. return strspn($file, '/\\', 0, 1)
  39935. || (\strlen($file) > 3 && ctype_alpha($file[0])
  39936. && ':' === substr($file, 1, 1)
  39937. && strspn($file, '/\\', 2, 1)
  39938. )
  39939. || null !== parse_url($file, PHP_URL_SCHEME)
  39940. ;
  39941. }
  39942. public function tempnam($dir, $prefix)
  39943. {
  39944. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  39945. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  39946. $tmpFile = @tempnam($hierarchy, $prefix);
  39947. if (false !== $tmpFile) {
  39948. if (null !== $scheme && 'gs' !== $scheme) {
  39949. return $scheme.'://'.$tmpFile;
  39950. }
  39951. return $tmpFile;
  39952. }
  39953. throw new IOException('A temporary file could not be created.');
  39954. }
  39955. for ($i = 0; $i < 10; ++$i) {
  39956. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  39957. $handle = @fopen($tmpFile, 'x+');
  39958. if (false === $handle) {
  39959. continue;
  39960. }
  39961. @fclose($handle);
  39962. return $tmpFile;
  39963. }
  39964. throw new IOException('A temporary file could not be created.');
  39965. }
  39966. public function dumpFile($filename, $content, $mode = 0666)
  39967. {
  39968. $dir = \dirname($filename);
  39969. if (!is_dir($dir)) {
  39970. $this->mkdir($dir);
  39971. }
  39972. if (!is_writable($dir)) {
  39973. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  39974. }
  39975. $tmpFile = $this->tempnam($dir, basename($filename));
  39976. if (false === @file_put_contents($tmpFile, $content)) {
  39977. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  39978. }
  39979. if (null !== $mode) {
  39980. if (\func_num_args() > 2) {
  39981. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  39982. }
  39983. $this->chmod($tmpFile, $mode);
  39984. } elseif (file_exists($filename)) {
  39985. @chmod($tmpFile, fileperms($filename));
  39986. }
  39987. $this->rename($tmpFile, $filename, true);
  39988. }
  39989. private function toIterator($files)
  39990. {
  39991. if (!$files instanceof \Traversable) {
  39992. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  39993. }
  39994. return $files;
  39995. }
  39996. private function getSchemeAndHierarchy($filename)
  39997. {
  39998. $components = explode('://', $filename, 2);
  39999. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  40000. }
  40001. private static function box($func)
  40002. {
  40003. self::$lastError = null;
  40004. \set_error_handler(__CLASS__.'::handleError');
  40005. try {
  40006. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  40007. \restore_error_handler();
  40008. return $result;
  40009. } catch (\Throwable $e) {
  40010. } catch (\Exception $e) {
  40011. }
  40012. \restore_error_handler();
  40013. throw $e;
  40014. }
  40015. public static function handleError($type, $msg)
  40016. {
  40017. self::$lastError = $msg;
  40018. }
  40019. }
  40020. Copyright (c) 2004-2018 Fabien Potencier
  40021. Permission is hereby granted, free of charge, to any person obtaining a copy
  40022. of this software and associated documentation files (the "Software"), to deal
  40023. in the Software without restriction, including without limitation the rights
  40024. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  40025. copies of the Software, and to permit persons to whom the Software is furnished
  40026. to do so, subject to the following conditions:
  40027. The above copyright notice and this permission notice shall be included in all
  40028. copies or substantial portions of the Software.
  40029. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  40030. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40031. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  40032. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  40033. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  40034. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  40035. THE SOFTWARE.
  40036. <?php
  40037. namespace Symfony\Component\Filesystem;
  40038. use Symfony\Component\Filesystem\Exception\IOException;
  40039. class LockHandler
  40040. {
  40041. private $file;
  40042. private $handle;
  40043. public function __construct($name, $lockPath = null)
  40044. {
  40045. $lockPath = $lockPath ?: sys_get_temp_dir();
  40046. if (!is_dir($lockPath)) {
  40047. $fs = new Filesystem();
  40048. $fs->mkdir($lockPath);
  40049. }
  40050. if (!is_writable($lockPath)) {
  40051. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  40052. }
  40053. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  40054. }
  40055. public function lock($blocking = false)
  40056. {
  40057. if ($this->handle) {
  40058. return true;
  40059. }
  40060. $error = null;
  40061. set_error_handler(function ($errno, $msg) use (&$error) {
  40062. $error = $msg;
  40063. });
  40064. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  40065. if ($this->handle = fopen($this->file, 'x')) {
  40066. chmod($this->file, 0666);
  40067. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  40068. usleep(100);
  40069. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  40070. }
  40071. }
  40072. restore_error_handler();
  40073. if (!$this->handle) {
  40074. throw new IOException($error, 0, null, $this->file);
  40075. }
  40076. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  40077. fclose($this->handle);
  40078. $this->handle = null;
  40079. return false;
  40080. }
  40081. return true;
  40082. }
  40083. public function release()
  40084. {
  40085. if ($this->handle) {
  40086. flock($this->handle, LOCK_UN | LOCK_NB);
  40087. fclose($this->handle);
  40088. $this->handle = null;
  40089. }
  40090. }
  40091. }
  40092. <?php
  40093. namespace Symfony\Component\Finder\Adapter;
  40094. @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);
  40095. abstract class AbstractAdapter implements AdapterInterface
  40096. {
  40097. protected $followLinks = false;
  40098. protected $mode = 0;
  40099. protected $minDepth = 0;
  40100. protected $maxDepth = PHP_INT_MAX;
  40101. protected $exclude = array();
  40102. protected $names = array();
  40103. protected $notNames = array();
  40104. protected $contains = array();
  40105. protected $notContains = array();
  40106. protected $sizes = array();
  40107. protected $dates = array();
  40108. protected $filters = array();
  40109. protected $sort = false;
  40110. protected $paths = array();
  40111. protected $notPaths = array();
  40112. protected $ignoreUnreadableDirs = false;
  40113. private static $areSupported = array();
  40114. public function isSupported()
  40115. {
  40116. $name = $this->getName();
  40117. if (!array_key_exists($name, self::$areSupported)) {
  40118. self::$areSupported[$name] = $this->canBeUsed();
  40119. }
  40120. return self::$areSupported[$name];
  40121. }
  40122. public function setFollowLinks($followLinks)
  40123. {
  40124. $this->followLinks = $followLinks;
  40125. return $this;
  40126. }
  40127. public function setMode($mode)
  40128. {
  40129. $this->mode = $mode;
  40130. return $this;
  40131. }
  40132. public function setDepths(array $depths)
  40133. {
  40134. $this->minDepth = 0;
  40135. $this->maxDepth = PHP_INT_MAX;
  40136. foreach ($depths as $comparator) {
  40137. switch ($comparator->getOperator()) {
  40138. case '>':
  40139. $this->minDepth = $comparator->getTarget() + 1;
  40140. break;
  40141. case '>=':
  40142. $this->minDepth = $comparator->getTarget();
  40143. break;
  40144. case '<':
  40145. $this->maxDepth = $comparator->getTarget() - 1;
  40146. break;
  40147. case '<=':
  40148. $this->maxDepth = $comparator->getTarget();
  40149. break;
  40150. default:
  40151. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  40152. }
  40153. }
  40154. return $this;
  40155. }
  40156. public function setExclude(array $exclude)
  40157. {
  40158. $this->exclude = $exclude;
  40159. return $this;
  40160. }
  40161. public function setNames(array $names)
  40162. {
  40163. $this->names = $names;
  40164. return $this;
  40165. }
  40166. public function setNotNames(array $notNames)
  40167. {
  40168. $this->notNames = $notNames;
  40169. return $this;
  40170. }
  40171. public function setContains(array $contains)
  40172. {
  40173. $this->contains = $contains;
  40174. return $this;
  40175. }
  40176. public function setNotContains(array $notContains)
  40177. {
  40178. $this->notContains = $notContains;
  40179. return $this;
  40180. }
  40181. public function setSizes(array $sizes)
  40182. {
  40183. $this->sizes = $sizes;
  40184. return $this;
  40185. }
  40186. public function setDates(array $dates)
  40187. {
  40188. $this->dates = $dates;
  40189. return $this;
  40190. }
  40191. public function setFilters(array $filters)
  40192. {
  40193. $this->filters = $filters;
  40194. return $this;
  40195. }
  40196. public function setSort($sort)
  40197. {
  40198. $this->sort = $sort;
  40199. return $this;
  40200. }
  40201. public function setPath(array $paths)
  40202. {
  40203. $this->paths = $paths;
  40204. return $this;
  40205. }
  40206. public function setNotPath(array $notPaths)
  40207. {
  40208. $this->notPaths = $notPaths;
  40209. return $this;
  40210. }
  40211. public function ignoreUnreadableDirs($ignore = true)
  40212. {
  40213. $this->ignoreUnreadableDirs = (bool) $ignore;
  40214. return $this;
  40215. }
  40216. abstract protected function canBeUsed();
  40217. }
  40218. <?php
  40219. namespace Symfony\Component\Finder\Adapter;
  40220. @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);
  40221. use Symfony\Component\Finder\Comparator\DateComparator;
  40222. use Symfony\Component\Finder\Comparator\NumberComparator;
  40223. use Symfony\Component\Finder\Exception\AccessDeniedException;
  40224. use Symfony\Component\Finder\Expression\Expression;
  40225. use Symfony\Component\Finder\Iterator;
  40226. use Symfony\Component\Finder\Shell\Command;
  40227. use Symfony\Component\Finder\Shell\Shell;
  40228. abstract class AbstractFindAdapter extends AbstractAdapter
  40229. {
  40230. protected $shell;
  40231. public function __construct()
  40232. {
  40233. $this->shell = new Shell();
  40234. }
  40235. public function searchInDirectory($dir)
  40236. {
  40237. $dir = realpath($dir);
  40238. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  40239. return new Iterator\FilePathsIterator(array(), $dir);
  40240. }
  40241. $command = Command::create();
  40242. $find = $this->buildFindCommand($command, $dir);
  40243. if ($this->followLinks) {
  40244. $find->add('-follow');
  40245. }
  40246. $find->add('-mindepth')->add($this->minDepth + 1);
  40247. if (PHP_INT_MAX !== $this->maxDepth) {
  40248. $find->add('-maxdepth')->add($this->maxDepth + 1);
  40249. }
  40250. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  40251. $find->add('-type d');
  40252. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  40253. $find->add('-type f');
  40254. }
  40255. $this->buildNamesFiltering($find, $this->names);
  40256. $this->buildNamesFiltering($find, $this->notNames, true);
  40257. $this->buildPathsFiltering($find, $dir, $this->paths);
  40258. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  40259. $this->buildSizesFiltering($find, $this->sizes);
  40260. $this->buildDatesFiltering($find, $this->dates);
  40261. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  40262. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  40263. if ($useGrep && ($this->contains || $this->notContains)) {
  40264. $grep = $command->ins('grep');
  40265. $this->buildContentFiltering($grep, $this->contains);
  40266. $this->buildContentFiltering($grep, $this->notContains, true);
  40267. }
  40268. if ($useSort) {
  40269. $this->buildSorting($command, $this->sort);
  40270. }
  40271. $command->setErrorHandler(
  40272. $this->ignoreUnreadableDirs
  40273. ? function ($stderr) { }
  40274. : function ($stderr) { throw new AccessDeniedException($stderr); }
  40275. );
  40276. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  40277. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  40278. if ($this->exclude) {
  40279. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  40280. }
  40281. if (!$useGrep && ($this->contains || $this->notContains)) {
  40282. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  40283. }
  40284. if ($this->filters) {
  40285. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  40286. }
  40287. if (!$useSort && $this->sort) {
  40288. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  40289. $iterator = $iteratorAggregate->getIterator();
  40290. }
  40291. return $iterator;
  40292. }
  40293. protected function canBeUsed()
  40294. {
  40295. return $this->shell->testCommand('find');
  40296. }
  40297. protected function buildFindCommand(Command $command, $dir)
  40298. {
  40299. return $command
  40300. ->ins('find')
  40301. ->add('find ')
  40302. ->arg($dir)
  40303. ->add('-noleaf');
  40304. }
  40305. private function buildNamesFiltering(Command $command, array $names, $not = false)
  40306. {
  40307. if (0 === \count($names)) {
  40308. return;
  40309. }
  40310. $command->add($not ? '-not' : null)->cmd('(');
  40311. foreach ($names as $i => $name) {
  40312. $expr = Expression::create($name);
  40313. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  40314. $expr = Expression::create($expr->getGlob()->toRegex(false));
  40315. }
  40316. if ($expr->isRegex()) {
  40317. $regex = $expr->getRegex();
  40318. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  40319. ->setStartFlag(false)
  40320. ->setStartJoker(true)
  40321. ->replaceJokers('[^/]');
  40322. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  40323. $regex->setEndJoker(false)->append('[^/]*');
  40324. }
  40325. }
  40326. $command
  40327. ->add($i > 0 ? '-or' : null)
  40328. ->add($expr->isRegex()
  40329. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  40330. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  40331. )
  40332. ->arg($expr->renderPattern());
  40333. }
  40334. $command->cmd(')');
  40335. }
  40336. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  40337. {
  40338. if (0 === \count($paths)) {
  40339. return;
  40340. }
  40341. $command->add($not ? '-not' : null)->cmd('(');
  40342. foreach ($paths as $i => $path) {
  40343. $expr = Expression::create($path);
  40344. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  40345. $expr = Expression::create($expr->getGlob()->toRegex(false));
  40346. }
  40347. if ($expr->isRegex()) {
  40348. $regex = $expr->getRegex();
  40349. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  40350. } else {
  40351. $expr->prepend('*')->append('*');
  40352. }
  40353. $command
  40354. ->add($i > 0 ? '-or' : null)
  40355. ->add($expr->isRegex()
  40356. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  40357. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  40358. )
  40359. ->arg($expr->renderPattern());
  40360. }
  40361. $command->cmd(')');
  40362. }
  40363. private function buildSizesFiltering(Command $command, array $sizes)
  40364. {
  40365. foreach ($sizes as $i => $size) {
  40366. $command->add($i > 0 ? '-and' : null);
  40367. switch ($size->getOperator()) {
  40368. case '<=':
  40369. $command->add('-size -'.($size->getTarget() + 1).'c');
  40370. break;
  40371. case '>=':
  40372. $command->add('-size +'.($size->getTarget() - 1).'c');
  40373. break;
  40374. case '>':
  40375. $command->add('-size +'.$size->getTarget().'c');
  40376. break;
  40377. case '!=':
  40378. $command->add('-size -'.$size->getTarget().'c');
  40379. $command->add('-size +'.$size->getTarget().'c');
  40380. break;
  40381. case '<':
  40382. default:
  40383. $command->add('-size -'.$size->getTarget().'c');
  40384. }
  40385. }
  40386. }
  40387. private function buildDatesFiltering(Command $command, array $dates)
  40388. {
  40389. foreach ($dates as $i => $date) {
  40390. $command->add($i > 0 ? '-and' : null);
  40391. $mins = (int) round((time() - $date->getTarget()) / 60);
  40392. if (0 > $mins) {
  40393. $command->add(' -mmin -0');
  40394. return;
  40395. }
  40396. switch ($date->getOperator()) {
  40397. case '<=':
  40398. $command->add('-mmin +'.($mins - 1));
  40399. break;
  40400. case '>=':
  40401. $command->add('-mmin -'.($mins + 1));
  40402. break;
  40403. case '>':
  40404. $command->add('-mmin -'.$mins);
  40405. break;
  40406. case '!=':
  40407. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  40408. break;
  40409. case '<':
  40410. default:
  40411. $command->add('-mmin +'.$mins);
  40412. }
  40413. }
  40414. }
  40415. private function buildSorting(Command $command, $sort)
  40416. {
  40417. $this->buildFormatSorting($command, $sort);
  40418. }
  40419. abstract protected function buildFormatSorting(Command $command, $sort);
  40420. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  40421. }
  40422. <?php
  40423. namespace Symfony\Component\Finder\Adapter;
  40424. interface AdapterInterface
  40425. {
  40426. public function setFollowLinks($followLinks);
  40427. public function setMode($mode);
  40428. public function setExclude(array $exclude);
  40429. public function setDepths(array $depths);
  40430. public function setNames(array $names);
  40431. public function setNotNames(array $notNames);
  40432. public function setContains(array $contains);
  40433. public function setNotContains(array $notContains);
  40434. public function setSizes(array $sizes);
  40435. public function setDates(array $dates);
  40436. public function setFilters(array $filters);
  40437. public function setSort($sort);
  40438. public function setPath(array $paths);
  40439. public function setNotPath(array $notPaths);
  40440. public function ignoreUnreadableDirs($ignore = true);
  40441. public function searchInDirectory($dir);
  40442. public function isSupported();
  40443. public function getName();
  40444. }
  40445. <?php
  40446. namespace Symfony\Component\Finder\Adapter;
  40447. @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);
  40448. use Symfony\Component\Finder\Expression\Expression;
  40449. use Symfony\Component\Finder\Iterator\SortableIterator;
  40450. use Symfony\Component\Finder\Shell\Command;
  40451. use Symfony\Component\Finder\Shell\Shell;
  40452. class BsdFindAdapter extends AbstractFindAdapter
  40453. {
  40454. public function getName()
  40455. {
  40456. return 'bsd_find';
  40457. }
  40458. protected function canBeUsed()
  40459. {
  40460. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  40461. }
  40462. protected function buildFormatSorting(Command $command, $sort)
  40463. {
  40464. switch ($sort) {
  40465. case SortableIterator::SORT_BY_NAME:
  40466. $command->ins('sort')->add('| sort');
  40467. return;
  40468. case SortableIterator::SORT_BY_TYPE:
  40469. $format = '%HT';
  40470. break;
  40471. case SortableIterator::SORT_BY_ACCESSED_TIME:
  40472. $format = '%a';
  40473. break;
  40474. case SortableIterator::SORT_BY_CHANGED_TIME:
  40475. $format = '%c';
  40476. break;
  40477. case SortableIterator::SORT_BY_MODIFIED_TIME:
  40478. $format = '%m';
  40479. break;
  40480. default:
  40481. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  40482. }
  40483. $command
  40484. ->add('-print0 | xargs -0 stat -f')
  40485. ->arg($format.'%t%N')
  40486. ->add('| sort | cut -f 2');
  40487. }
  40488. protected function buildFindCommand(Command $command, $dir)
  40489. {
  40490. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  40491. return $command;
  40492. }
  40493. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  40494. {
  40495. foreach ($contains as $contain) {
  40496. $expr = Expression::create($contain);
  40497. $command
  40498. ->add('| grep -v \'^$\'')
  40499. ->add('| xargs -I{} grep -I')
  40500. ->add($expr->isCaseSensitive() ? null : '-i')
  40501. ->add($not ? '-L' : '-l')
  40502. ->add('-Ee')->arg($expr->renderPattern())
  40503. ->add('{}')
  40504. ;
  40505. }
  40506. }
  40507. }
  40508. <?php
  40509. namespace Symfony\Component\Finder\Adapter;
  40510. @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);
  40511. use Symfony\Component\Finder\Expression\Expression;
  40512. use Symfony\Component\Finder\Iterator\SortableIterator;
  40513. use Symfony\Component\Finder\Shell\Command;
  40514. use Symfony\Component\Finder\Shell\Shell;
  40515. class GnuFindAdapter extends AbstractFindAdapter
  40516. {
  40517. public function getName()
  40518. {
  40519. return 'gnu_find';
  40520. }
  40521. protected function buildFormatSorting(Command $command, $sort)
  40522. {
  40523. switch ($sort) {
  40524. case SortableIterator::SORT_BY_NAME:
  40525. $command->ins('sort')->add('| sort');
  40526. return;
  40527. case SortableIterator::SORT_BY_TYPE:
  40528. $format = '%y';
  40529. break;
  40530. case SortableIterator::SORT_BY_ACCESSED_TIME:
  40531. $format = '%A@';
  40532. break;
  40533. case SortableIterator::SORT_BY_CHANGED_TIME:
  40534. $format = '%C@';
  40535. break;
  40536. case SortableIterator::SORT_BY_MODIFIED_TIME:
  40537. $format = '%T@';
  40538. break;
  40539. default:
  40540. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  40541. }
  40542. $command
  40543. ->get('find')
  40544. ->add('-printf')
  40545. ->arg($format.' %h/%f\\n')
  40546. ->add('| sort | cut')
  40547. ->arg('-d ')
  40548. ->arg('-f2-')
  40549. ;
  40550. }
  40551. protected function canBeUsed()
  40552. {
  40553. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  40554. }
  40555. protected function buildFindCommand(Command $command, $dir)
  40556. {
  40557. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  40558. }
  40559. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  40560. {
  40561. foreach ($contains as $contain) {
  40562. $expr = Expression::create($contain);
  40563. $command
  40564. ->add('| xargs -I{} -r grep -I')
  40565. ->add($expr->isCaseSensitive() ? null : '-i')
  40566. ->add($not ? '-L' : '-l')
  40567. ->add('-Ee')->arg($expr->renderPattern())
  40568. ->add('{}')
  40569. ;
  40570. }
  40571. }
  40572. }
  40573. <?php
  40574. namespace Symfony\Component\Finder\Adapter;
  40575. @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);
  40576. use Symfony\Component\Finder\Iterator;
  40577. class PhpAdapter extends AbstractAdapter
  40578. {
  40579. public function searchInDirectory($dir)
  40580. {
  40581. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  40582. if ($this->followLinks) {
  40583. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  40584. }
  40585. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  40586. if ($this->exclude) {
  40587. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  40588. }
  40589. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  40590. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  40591. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  40592. }
  40593. if ($this->mode) {
  40594. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  40595. }
  40596. if ($this->names || $this->notNames) {
  40597. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  40598. }
  40599. if ($this->contains || $this->notContains) {
  40600. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  40601. }
  40602. if ($this->sizes) {
  40603. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  40604. }
  40605. if ($this->dates) {
  40606. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  40607. }
  40608. if ($this->filters) {
  40609. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  40610. }
  40611. if ($this->paths || $this->notPaths) {
  40612. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  40613. }
  40614. if ($this->sort) {
  40615. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  40616. $iterator = $iteratorAggregate->getIterator();
  40617. }
  40618. return $iterator;
  40619. }
  40620. public function getName()
  40621. {
  40622. return 'php';
  40623. }
  40624. protected function canBeUsed()
  40625. {
  40626. return true;
  40627. }
  40628. }
  40629. <?php
  40630. namespace Symfony\Component\Finder\Comparator;
  40631. class Comparator
  40632. {
  40633. private $target;
  40634. private $operator = '==';
  40635. public function getTarget()
  40636. {
  40637. return $this->target;
  40638. }
  40639. public function setTarget($target)
  40640. {
  40641. $this->target = $target;
  40642. }
  40643. public function getOperator()
  40644. {
  40645. return $this->operator;
  40646. }
  40647. public function setOperator($operator)
  40648. {
  40649. if (!$operator) {
  40650. $operator = '==';
  40651. }
  40652. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  40653. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  40654. }
  40655. $this->operator = $operator;
  40656. }
  40657. public function test($test)
  40658. {
  40659. switch ($this->operator) {
  40660. case '>':
  40661. return $test > $this->target;
  40662. case '>=':
  40663. return $test >= $this->target;
  40664. case '<':
  40665. return $test < $this->target;
  40666. case '<=':
  40667. return $test <= $this->target;
  40668. case '!=':
  40669. return $test != $this->target;
  40670. }
  40671. return $test == $this->target;
  40672. }
  40673. }
  40674. <?php
  40675. namespace Symfony\Component\Finder\Comparator;
  40676. class DateComparator extends Comparator
  40677. {
  40678. public function __construct($test)
  40679. {
  40680. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  40681. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  40682. }
  40683. try {
  40684. $date = new \DateTime($matches[2]);
  40685. $target = $date->format('U');
  40686. } catch (\Exception $e) {
  40687. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  40688. }
  40689. $operator = isset($matches[1]) ? $matches[1] : '==';
  40690. if ('since' === $operator || 'after' === $operator) {
  40691. $operator = '>';
  40692. }
  40693. if ('until' === $operator || 'before' === $operator) {
  40694. $operator = '<';
  40695. }
  40696. $this->setOperator($operator);
  40697. $this->setTarget($target);
  40698. }
  40699. }
  40700. <?php
  40701. namespace Symfony\Component\Finder\Comparator;
  40702. class NumberComparator extends Comparator
  40703. {
  40704. public function __construct($test)
  40705. {
  40706. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  40707. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  40708. }
  40709. $target = $matches[2];
  40710. if (!is_numeric($target)) {
  40711. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  40712. }
  40713. if (isset($matches[3])) {
  40714. switch (strtolower($matches[3])) {
  40715. case 'k':
  40716. $target *= 1000;
  40717. break;
  40718. case 'ki':
  40719. $target *= 1024;
  40720. break;
  40721. case 'm':
  40722. $target *= 1000000;
  40723. break;
  40724. case 'mi':
  40725. $target *= 1024 * 1024;
  40726. break;
  40727. case 'g':
  40728. $target *= 1000000000;
  40729. break;
  40730. case 'gi':
  40731. $target *= 1024 * 1024 * 1024;
  40732. break;
  40733. }
  40734. }
  40735. $this->setTarget($target);
  40736. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  40737. }
  40738. }
  40739. <?php
  40740. namespace Symfony\Component\Finder\Exception;
  40741. class AccessDeniedException extends \UnexpectedValueException
  40742. {
  40743. }
  40744. <?php
  40745. namespace Symfony\Component\Finder\Exception;
  40746. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  40747. use Symfony\Component\Finder\Adapter\AdapterInterface;
  40748. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  40749. {
  40750. private $adapter;
  40751. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  40752. {
  40753. $this->adapter = $adapter;
  40754. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  40755. }
  40756. public function getAdapter()
  40757. {
  40758. return $this->adapter;
  40759. }
  40760. }
  40761. <?php
  40762. namespace Symfony\Component\Finder\Exception;
  40763. interface ExceptionInterface
  40764. {
  40765. public function getAdapter();
  40766. }
  40767. <?php
  40768. namespace Symfony\Component\Finder\Exception;
  40769. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  40770. class OperationNotPermitedException extends AdapterFailureException
  40771. {
  40772. }
  40773. <?php
  40774. namespace Symfony\Component\Finder\Exception;
  40775. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  40776. use Symfony\Component\Finder\Adapter\AdapterInterface;
  40777. use Symfony\Component\Finder\Shell\Command;
  40778. class ShellCommandFailureException extends AdapterFailureException
  40779. {
  40780. private $command;
  40781. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  40782. {
  40783. $this->command = $command;
  40784. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  40785. }
  40786. public function getCommand()
  40787. {
  40788. return $this->command;
  40789. }
  40790. }
  40791. <?php
  40792. namespace Symfony\Component\Finder\Expression;
  40793. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  40794. class Expression implements ValueInterface
  40795. {
  40796. const TYPE_REGEX = 1;
  40797. const TYPE_GLOB = 2;
  40798. private $value;
  40799. public static function create($expr)
  40800. {
  40801. return new self($expr);
  40802. }
  40803. public function __construct($expr)
  40804. {
  40805. try {
  40806. $this->value = Regex::create($expr);
  40807. } catch (\InvalidArgumentException $e) {
  40808. $this->value = new Glob($expr);
  40809. }
  40810. }
  40811. public function __toString()
  40812. {
  40813. return $this->render();
  40814. }
  40815. public function render()
  40816. {
  40817. return $this->value->render();
  40818. }
  40819. public function renderPattern()
  40820. {
  40821. return $this->value->renderPattern();
  40822. }
  40823. public function isCaseSensitive()
  40824. {
  40825. return $this->value->isCaseSensitive();
  40826. }
  40827. public function getType()
  40828. {
  40829. return $this->value->getType();
  40830. }
  40831. public function prepend($expr)
  40832. {
  40833. $this->value->prepend($expr);
  40834. return $this;
  40835. }
  40836. public function append($expr)
  40837. {
  40838. $this->value->append($expr);
  40839. return $this;
  40840. }
  40841. public function isRegex()
  40842. {
  40843. return self::TYPE_REGEX === $this->value->getType();
  40844. }
  40845. public function isGlob()
  40846. {
  40847. return self::TYPE_GLOB === $this->value->getType();
  40848. }
  40849. public function getGlob()
  40850. {
  40851. if (self::TYPE_GLOB !== $this->value->getType()) {
  40852. throw new \LogicException('Regex can\'t be transformed to glob.');
  40853. }
  40854. return $this->value;
  40855. }
  40856. public function getRegex()
  40857. {
  40858. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  40859. }
  40860. }
  40861. <?php
  40862. namespace Symfony\Component\Finder\Expression;
  40863. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  40864. use Symfony\Component\Finder\Glob as FinderGlob;
  40865. class Glob implements ValueInterface
  40866. {
  40867. private $pattern;
  40868. public function __construct($pattern)
  40869. {
  40870. $this->pattern = $pattern;
  40871. }
  40872. public function render()
  40873. {
  40874. return $this->pattern;
  40875. }
  40876. public function renderPattern()
  40877. {
  40878. return $this->pattern;
  40879. }
  40880. public function getType()
  40881. {
  40882. return Expression::TYPE_GLOB;
  40883. }
  40884. public function isCaseSensitive()
  40885. {
  40886. return true;
  40887. }
  40888. public function prepend($expr)
  40889. {
  40890. $this->pattern = $expr.$this->pattern;
  40891. return $this;
  40892. }
  40893. public function append($expr)
  40894. {
  40895. $this->pattern .= $expr;
  40896. return $this;
  40897. }
  40898. public function isExpandable()
  40899. {
  40900. return false !== strpos($this->pattern, '{')
  40901. && false !== strpos($this->pattern, '}');
  40902. }
  40903. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  40904. {
  40905. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  40906. return new Regex($regex);
  40907. }
  40908. }
  40909. <?php
  40910. namespace Symfony\Component\Finder\Expression;
  40911. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  40912. class Regex implements ValueInterface
  40913. {
  40914. const START_FLAG = '^';
  40915. const END_FLAG = '$';
  40916. const BOUNDARY = '~';
  40917. const JOKER = '.*';
  40918. const ESCAPING = '\\';
  40919. private $pattern;
  40920. private $options;
  40921. private $startFlag;
  40922. private $endFlag;
  40923. private $startJoker;
  40924. private $endJoker;
  40925. public static function create($expr)
  40926. {
  40927. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  40928. $start = substr($m[1], 0, 1);
  40929. $end = substr($m[1], -1);
  40930. if (
  40931. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  40932. || ('{' === $start && '}' === $end)
  40933. || ('(' === $start && ')' === $end)
  40934. ) {
  40935. return new self(substr($m[1], 1, -1), $m[2], $end);
  40936. }
  40937. }
  40938. throw new \InvalidArgumentException('Given expression is not a regex.');
  40939. }
  40940. public function __construct($pattern, $options = '', $delimiter = null)
  40941. {
  40942. if (null !== $delimiter) {
  40943. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  40944. }
  40945. $this->parsePattern($pattern);
  40946. $this->options = $options;
  40947. }
  40948. public function __toString()
  40949. {
  40950. return $this->render();
  40951. }
  40952. public function render()
  40953. {
  40954. return self::BOUNDARY
  40955. .$this->renderPattern()
  40956. .self::BOUNDARY
  40957. .$this->options;
  40958. }
  40959. public function renderPattern()
  40960. {
  40961. return ($this->startFlag ? self::START_FLAG : '')
  40962. .($this->startJoker ? self::JOKER : '')
  40963. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  40964. .($this->endJoker ? self::JOKER : '')
  40965. .($this->endFlag ? self::END_FLAG : '');
  40966. }
  40967. public function isCaseSensitive()
  40968. {
  40969. return !$this->hasOption('i');
  40970. }
  40971. public function getType()
  40972. {
  40973. return Expression::TYPE_REGEX;
  40974. }
  40975. public function prepend($expr)
  40976. {
  40977. $this->pattern = $expr.$this->pattern;
  40978. return $this;
  40979. }
  40980. public function append($expr)
  40981. {
  40982. $this->pattern .= $expr;
  40983. return $this;
  40984. }
  40985. public function hasOption($option)
  40986. {
  40987. return false !== strpos($this->options, $option);
  40988. }
  40989. public function addOption($option)
  40990. {
  40991. if (!$this->hasOption($option)) {
  40992. $this->options .= $option;
  40993. }
  40994. return $this;
  40995. }
  40996. public function removeOption($option)
  40997. {
  40998. $this->options = str_replace($option, '', $this->options);
  40999. return $this;
  41000. }
  41001. public function setStartFlag($startFlag)
  41002. {
  41003. $this->startFlag = $startFlag;
  41004. return $this;
  41005. }
  41006. public function hasStartFlag()
  41007. {
  41008. return $this->startFlag;
  41009. }
  41010. public function setEndFlag($endFlag)
  41011. {
  41012. $this->endFlag = (bool) $endFlag;
  41013. return $this;
  41014. }
  41015. public function hasEndFlag()
  41016. {
  41017. return $this->endFlag;
  41018. }
  41019. public function setStartJoker($startJoker)
  41020. {
  41021. $this->startJoker = $startJoker;
  41022. return $this;
  41023. }
  41024. public function hasStartJoker()
  41025. {
  41026. return $this->startJoker;
  41027. }
  41028. public function setEndJoker($endJoker)
  41029. {
  41030. $this->endJoker = (bool) $endJoker;
  41031. return $this;
  41032. }
  41033. public function hasEndJoker()
  41034. {
  41035. return $this->endJoker;
  41036. }
  41037. public function replaceJokers($replacement)
  41038. {
  41039. $replace = function ($subject) use ($replacement) {
  41040. $subject = $subject[0];
  41041. $replace = 0 === substr_count($subject, '\\') % 2;
  41042. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  41043. };
  41044. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  41045. return $this;
  41046. }
  41047. private function parsePattern($pattern)
  41048. {
  41049. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  41050. $pattern = substr($pattern, 1);
  41051. }
  41052. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  41053. $pattern = substr($pattern, 2);
  41054. }
  41055. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  41056. $pattern = substr($pattern, 0, -1);
  41057. }
  41058. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  41059. $pattern = substr($pattern, 0, -2);
  41060. }
  41061. $this->pattern = $pattern;
  41062. }
  41063. }
  41064. <?php
  41065. namespace Symfony\Component\Finder\Expression;
  41066. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  41067. interface ValueInterface
  41068. {
  41069. public function render();
  41070. public function renderPattern();
  41071. public function isCaseSensitive();
  41072. public function getType();
  41073. public function prepend($expr);
  41074. public function append($expr);
  41075. }
  41076. <?php
  41077. namespace Symfony\Component\Finder;
  41078. use Symfony\Component\Finder\Adapter\AdapterInterface;
  41079. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  41080. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  41081. use Symfony\Component\Finder\Adapter\PhpAdapter;
  41082. use Symfony\Component\Finder\Comparator\DateComparator;
  41083. use Symfony\Component\Finder\Comparator\NumberComparator;
  41084. use Symfony\Component\Finder\Exception\ExceptionInterface;
  41085. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  41086. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  41087. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  41088. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  41089. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  41090. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  41091. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  41092. use Symfony\Component\Finder\Iterator\SortableIterator;
  41093. class Finder implements \IteratorAggregate, \Countable
  41094. {
  41095. const IGNORE_VCS_FILES = 1;
  41096. const IGNORE_DOT_FILES = 2;
  41097. private $mode = 0;
  41098. private $names = array();
  41099. private $notNames = array();
  41100. private $exclude = array();
  41101. private $filters = array();
  41102. private $depths = array();
  41103. private $sizes = array();
  41104. private $followLinks = false;
  41105. private $sort = false;
  41106. private $ignore = 0;
  41107. private $dirs = array();
  41108. private $dates = array();
  41109. private $iterators = array();
  41110. private $contains = array();
  41111. private $notContains = array();
  41112. private $adapters = null;
  41113. private $paths = array();
  41114. private $notPaths = array();
  41115. private $ignoreUnreadableDirs = false;
  41116. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  41117. public function __construct()
  41118. {
  41119. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  41120. }
  41121. public static function create()
  41122. {
  41123. return new static();
  41124. }
  41125. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  41126. {
  41127. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  41128. $this->initDefaultAdapters();
  41129. $this->adapters[$adapter->getName()] = array(
  41130. 'adapter' => $adapter,
  41131. 'priority' => $priority,
  41132. 'selected' => false,
  41133. );
  41134. return $this->sortAdapters();
  41135. }
  41136. public function useBestAdapter()
  41137. {
  41138. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  41139. $this->initDefaultAdapters();
  41140. $this->resetAdapterSelection();
  41141. return $this->sortAdapters();
  41142. }
  41143. public function setAdapter($name)
  41144. {
  41145. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  41146. $this->initDefaultAdapters();
  41147. if (!isset($this->adapters[$name])) {
  41148. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  41149. }
  41150. $this->resetAdapterSelection();
  41151. $this->adapters[$name]['selected'] = true;
  41152. return $this->sortAdapters();
  41153. }
  41154. public function removeAdapters()
  41155. {
  41156. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  41157. $this->adapters = array();
  41158. return $this;
  41159. }
  41160. public function getAdapters()
  41161. {
  41162. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  41163. $this->initDefaultAdapters();
  41164. return array_values(array_map(function (array $adapter) {
  41165. return $adapter['adapter'];
  41166. }, $this->adapters));
  41167. }
  41168. public function directories()
  41169. {
  41170. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  41171. return $this;
  41172. }
  41173. public function files()
  41174. {
  41175. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  41176. return $this;
  41177. }
  41178. public function depth($level)
  41179. {
  41180. $this->depths[] = new Comparator\NumberComparator($level);
  41181. return $this;
  41182. }
  41183. public function date($date)
  41184. {
  41185. $this->dates[] = new Comparator\DateComparator($date);
  41186. return $this;
  41187. }
  41188. public function name($pattern)
  41189. {
  41190. $this->names[] = $pattern;
  41191. return $this;
  41192. }
  41193. public function notName($pattern)
  41194. {
  41195. $this->notNames[] = $pattern;
  41196. return $this;
  41197. }
  41198. public function contains($pattern)
  41199. {
  41200. $this->contains[] = $pattern;
  41201. return $this;
  41202. }
  41203. public function notContains($pattern)
  41204. {
  41205. $this->notContains[] = $pattern;
  41206. return $this;
  41207. }
  41208. public function path($pattern)
  41209. {
  41210. $this->paths[] = $pattern;
  41211. return $this;
  41212. }
  41213. public function notPath($pattern)
  41214. {
  41215. $this->notPaths[] = $pattern;
  41216. return $this;
  41217. }
  41218. public function size($size)
  41219. {
  41220. $this->sizes[] = new Comparator\NumberComparator($size);
  41221. return $this;
  41222. }
  41223. public function exclude($dirs)
  41224. {
  41225. $this->exclude = array_merge($this->exclude, (array) $dirs);
  41226. return $this;
  41227. }
  41228. public function ignoreDotFiles($ignoreDotFiles)
  41229. {
  41230. if ($ignoreDotFiles) {
  41231. $this->ignore |= static::IGNORE_DOT_FILES;
  41232. } else {
  41233. $this->ignore &= ~static::IGNORE_DOT_FILES;
  41234. }
  41235. return $this;
  41236. }
  41237. public function ignoreVCS($ignoreVCS)
  41238. {
  41239. if ($ignoreVCS) {
  41240. $this->ignore |= static::IGNORE_VCS_FILES;
  41241. } else {
  41242. $this->ignore &= ~static::IGNORE_VCS_FILES;
  41243. }
  41244. return $this;
  41245. }
  41246. public static function addVCSPattern($pattern)
  41247. {
  41248. foreach ((array) $pattern as $p) {
  41249. self::$vcsPatterns[] = $p;
  41250. }
  41251. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  41252. }
  41253. public function sort(\Closure $closure)
  41254. {
  41255. $this->sort = $closure;
  41256. return $this;
  41257. }
  41258. public function sortByName()
  41259. {
  41260. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  41261. return $this;
  41262. }
  41263. public function sortByType()
  41264. {
  41265. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  41266. return $this;
  41267. }
  41268. public function sortByAccessedTime()
  41269. {
  41270. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  41271. return $this;
  41272. }
  41273. public function sortByChangedTime()
  41274. {
  41275. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  41276. return $this;
  41277. }
  41278. public function sortByModifiedTime()
  41279. {
  41280. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  41281. return $this;
  41282. }
  41283. public function filter(\Closure $closure)
  41284. {
  41285. $this->filters[] = $closure;
  41286. return $this;
  41287. }
  41288. public function followLinks()
  41289. {
  41290. $this->followLinks = true;
  41291. return $this;
  41292. }
  41293. public function ignoreUnreadableDirs($ignore = true)
  41294. {
  41295. $this->ignoreUnreadableDirs = (bool) $ignore;
  41296. return $this;
  41297. }
  41298. public function in($dirs)
  41299. {
  41300. $resolvedDirs = array();
  41301. foreach ((array) $dirs as $dir) {
  41302. if (is_dir($dir)) {
  41303. $resolvedDirs[] = $this->normalizeDir($dir);
  41304. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  41305. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  41306. } else {
  41307. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  41308. }
  41309. }
  41310. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  41311. return $this;
  41312. }
  41313. public function getIterator()
  41314. {
  41315. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  41316. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  41317. }
  41318. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  41319. return $this->searchInDirectory($this->dirs[0]);
  41320. }
  41321. $iterator = new \AppendIterator();
  41322. foreach ($this->dirs as $dir) {
  41323. $iterator->append($this->searchInDirectory($dir));
  41324. }
  41325. foreach ($this->iterators as $it) {
  41326. $iterator->append($it);
  41327. }
  41328. return $iterator;
  41329. }
  41330. public function append($iterator)
  41331. {
  41332. if ($iterator instanceof \IteratorAggregate) {
  41333. $this->iterators[] = $iterator->getIterator();
  41334. } elseif ($iterator instanceof \Iterator) {
  41335. $this->iterators[] = $iterator;
  41336. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  41337. $it = new \ArrayIterator();
  41338. foreach ($iterator as $file) {
  41339. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  41340. }
  41341. $this->iterators[] = $it;
  41342. } else {
  41343. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  41344. }
  41345. return $this;
  41346. }
  41347. public function count()
  41348. {
  41349. return iterator_count($this->getIterator());
  41350. }
  41351. private function sortAdapters()
  41352. {
  41353. uasort($this->adapters, function (array $a, array $b) {
  41354. if ($a['selected'] || $b['selected']) {
  41355. return $a['selected'] ? -1 : 1;
  41356. }
  41357. return $a['priority'] > $b['priority'] ? -1 : 1;
  41358. });
  41359. return $this;
  41360. }
  41361. private function searchInDirectory($dir)
  41362. {
  41363. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  41364. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  41365. }
  41366. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  41367. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  41368. }
  41369. if ($this->adapters) {
  41370. foreach ($this->adapters as $adapter) {
  41371. if ($adapter['adapter']->isSupported()) {
  41372. try {
  41373. return $this
  41374. ->buildAdapter($adapter['adapter'])
  41375. ->searchInDirectory($dir);
  41376. } catch (ExceptionInterface $e) {
  41377. }
  41378. }
  41379. }
  41380. }
  41381. $minDepth = 0;
  41382. $maxDepth = PHP_INT_MAX;
  41383. foreach ($this->depths as $comparator) {
  41384. switch ($comparator->getOperator()) {
  41385. case '>':
  41386. $minDepth = $comparator->getTarget() + 1;
  41387. break;
  41388. case '>=':
  41389. $minDepth = $comparator->getTarget();
  41390. break;
  41391. case '<':
  41392. $maxDepth = $comparator->getTarget() - 1;
  41393. break;
  41394. case '<=':
  41395. $maxDepth = $comparator->getTarget();
  41396. break;
  41397. default:
  41398. $minDepth = $maxDepth = $comparator->getTarget();
  41399. }
  41400. }
  41401. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  41402. if ($this->followLinks) {
  41403. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  41404. }
  41405. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  41406. if ($this->exclude) {
  41407. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  41408. }
  41409. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  41410. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  41411. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  41412. }
  41413. if ($this->mode) {
  41414. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  41415. }
  41416. if ($this->names || $this->notNames) {
  41417. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  41418. }
  41419. if ($this->contains || $this->notContains) {
  41420. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  41421. }
  41422. if ($this->sizes) {
  41423. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  41424. }
  41425. if ($this->dates) {
  41426. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  41427. }
  41428. if ($this->filters) {
  41429. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  41430. }
  41431. if ($this->paths || $this->notPaths) {
  41432. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  41433. }
  41434. if ($this->sort) {
  41435. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  41436. $iterator = $iteratorAggregate->getIterator();
  41437. }
  41438. return $iterator;
  41439. }
  41440. private function buildAdapter(AdapterInterface $adapter)
  41441. {
  41442. return $adapter
  41443. ->setFollowLinks($this->followLinks)
  41444. ->setDepths($this->depths)
  41445. ->setMode($this->mode)
  41446. ->setExclude($this->exclude)
  41447. ->setNames($this->names)
  41448. ->setNotNames($this->notNames)
  41449. ->setContains($this->contains)
  41450. ->setNotContains($this->notContains)
  41451. ->setSizes($this->sizes)
  41452. ->setDates($this->dates)
  41453. ->setFilters($this->filters)
  41454. ->setSort($this->sort)
  41455. ->setPath($this->paths)
  41456. ->setNotPath($this->notPaths)
  41457. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  41458. }
  41459. private function resetAdapterSelection()
  41460. {
  41461. $this->adapters = array_map(function (array $properties) {
  41462. $properties['selected'] = false;
  41463. return $properties;
  41464. }, $this->adapters);
  41465. }
  41466. private function initDefaultAdapters()
  41467. {
  41468. if (null === $this->adapters) {
  41469. $this->adapters = array();
  41470. $this
  41471. ->addAdapter(new GnuFindAdapter())
  41472. ->addAdapter(new BsdFindAdapter())
  41473. ->addAdapter(new PhpAdapter(), -50)
  41474. ->setAdapter('php')
  41475. ;
  41476. }
  41477. }
  41478. private function normalizeDir($dir)
  41479. {
  41480. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  41481. }
  41482. }
  41483. <?php
  41484. namespace Symfony\Component\Finder;
  41485. class Glob
  41486. {
  41487. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  41488. {
  41489. $firstByte = true;
  41490. $escaping = false;
  41491. $inCurlies = 0;
  41492. $regex = '';
  41493. $sizeGlob = \strlen($glob);
  41494. for ($i = 0; $i < $sizeGlob; ++$i) {
  41495. $car = $glob[$i];
  41496. if ($firstByte) {
  41497. if ($strictLeadingDot && '.' !== $car) {
  41498. $regex .= '(?=[^\.])';
  41499. }
  41500. $firstByte = false;
  41501. }
  41502. if ('/' === $car) {
  41503. $firstByte = true;
  41504. }
  41505. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  41506. $regex .= "\\$car";
  41507. } elseif ('*' === $car) {
  41508. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  41509. } elseif ('?' === $car) {
  41510. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  41511. } elseif ('{' === $car) {
  41512. $regex .= $escaping ? '\\{' : '(';
  41513. if (!$escaping) {
  41514. ++$inCurlies;
  41515. }
  41516. } elseif ('}' === $car && $inCurlies) {
  41517. $regex .= $escaping ? '}' : ')';
  41518. if (!$escaping) {
  41519. --$inCurlies;
  41520. }
  41521. } elseif (',' === $car && $inCurlies) {
  41522. $regex .= $escaping ? ',' : '|';
  41523. } elseif ('\\' === $car) {
  41524. if ($escaping) {
  41525. $regex .= '\\\\';
  41526. $escaping = false;
  41527. } else {
  41528. $escaping = true;
  41529. }
  41530. continue;
  41531. } else {
  41532. $regex .= $car;
  41533. }
  41534. $escaping = false;
  41535. }
  41536. return $delimiter.'^'.$regex.'$'.$delimiter;
  41537. }
  41538. }
  41539. <?php
  41540. namespace Symfony\Component\Finder\Iterator;
  41541. class CustomFilterIterator extends FilterIterator
  41542. {
  41543. private $filters = array();
  41544. public function __construct(\Iterator $iterator, array $filters)
  41545. {
  41546. foreach ($filters as $filter) {
  41547. if (!\is_callable($filter)) {
  41548. throw new \InvalidArgumentException('Invalid PHP callback.');
  41549. }
  41550. }
  41551. $this->filters = $filters;
  41552. parent::__construct($iterator);
  41553. }
  41554. public function accept()
  41555. {
  41556. $fileinfo = $this->current();
  41557. foreach ($this->filters as $filter) {
  41558. if (false === \call_user_func($filter, $fileinfo)) {
  41559. return false;
  41560. }
  41561. }
  41562. return true;
  41563. }
  41564. }
  41565. <?php
  41566. namespace Symfony\Component\Finder\Iterator;
  41567. use Symfony\Component\Finder\Comparator\DateComparator;
  41568. class DateRangeFilterIterator extends FilterIterator
  41569. {
  41570. private $comparators = array();
  41571. public function __construct(\Iterator $iterator, array $comparators)
  41572. {
  41573. $this->comparators = $comparators;
  41574. parent::__construct($iterator);
  41575. }
  41576. public function accept()
  41577. {
  41578. $fileinfo = $this->current();
  41579. if (!file_exists($fileinfo->getPathname())) {
  41580. return false;
  41581. }
  41582. $filedate = $fileinfo->getMTime();
  41583. foreach ($this->comparators as $compare) {
  41584. if (!$compare->test($filedate)) {
  41585. return false;
  41586. }
  41587. }
  41588. return true;
  41589. }
  41590. }
  41591. <?php
  41592. namespace Symfony\Component\Finder\Iterator;
  41593. class DepthRangeFilterIterator extends FilterIterator
  41594. {
  41595. private $minDepth = 0;
  41596. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  41597. {
  41598. $this->minDepth = $minDepth;
  41599. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  41600. parent::__construct($iterator);
  41601. }
  41602. public function accept()
  41603. {
  41604. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  41605. }
  41606. }
  41607. <?php
  41608. namespace Symfony\Component\Finder\Iterator;
  41609. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  41610. {
  41611. private $iterator;
  41612. private $isRecursive;
  41613. private $excludedDirs = array();
  41614. private $excludedPattern;
  41615. public function __construct(\Iterator $iterator, array $directories)
  41616. {
  41617. $this->iterator = $iterator;
  41618. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  41619. $patterns = array();
  41620. foreach ($directories as $directory) {
  41621. $directory = rtrim($directory, '/');
  41622. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  41623. $patterns[] = preg_quote($directory, '#');
  41624. } else {
  41625. $this->excludedDirs[$directory] = true;
  41626. }
  41627. }
  41628. if ($patterns) {
  41629. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  41630. }
  41631. parent::__construct($iterator);
  41632. }
  41633. public function accept()
  41634. {
  41635. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  41636. return false;
  41637. }
  41638. if ($this->excludedPattern) {
  41639. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  41640. $path = str_replace('\\', '/', $path);
  41641. return !preg_match($this->excludedPattern, $path);
  41642. }
  41643. return true;
  41644. }
  41645. public function hasChildren()
  41646. {
  41647. return $this->isRecursive && $this->iterator->hasChildren();
  41648. }
  41649. public function getChildren()
  41650. {
  41651. $children = new self($this->iterator->getChildren(), array());
  41652. $children->excludedDirs = $this->excludedDirs;
  41653. $children->excludedPattern = $this->excludedPattern;
  41654. return $children;
  41655. }
  41656. }
  41657. <?php
  41658. namespace Symfony\Component\Finder\Iterator;
  41659. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  41660. use Symfony\Component\Finder\SplFileInfo;
  41661. class FilePathsIterator extends \ArrayIterator
  41662. {
  41663. private $baseDir;
  41664. private $baseDirLength;
  41665. private $subPath;
  41666. private $subPathname;
  41667. private $current;
  41668. public function __construct(array $paths, $baseDir)
  41669. {
  41670. $this->baseDir = $baseDir;
  41671. $this->baseDirLength = \strlen($baseDir);
  41672. parent::__construct($paths);
  41673. }
  41674. public function __call($name, array $arguments)
  41675. {
  41676. return \call_user_func_array(array($this->current(), $name), $arguments);
  41677. }
  41678. public function current()
  41679. {
  41680. return $this->current;
  41681. }
  41682. public function key()
  41683. {
  41684. return $this->current->getPathname();
  41685. }
  41686. public function next()
  41687. {
  41688. parent::next();
  41689. $this->buildProperties();
  41690. }
  41691. public function rewind()
  41692. {
  41693. parent::rewind();
  41694. $this->buildProperties();
  41695. }
  41696. public function getSubPath()
  41697. {
  41698. return $this->subPath;
  41699. }
  41700. public function getSubPathname()
  41701. {
  41702. return $this->subPathname;
  41703. }
  41704. private function buildProperties()
  41705. {
  41706. $absolutePath = parent::current();
  41707. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  41708. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  41709. $dir = \dirname($this->subPathname);
  41710. $this->subPath = '.' === $dir ? '' : $dir;
  41711. } else {
  41712. $this->subPath = $this->subPathname = '';
  41713. }
  41714. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  41715. }
  41716. }
  41717. <?php
  41718. namespace Symfony\Component\Finder\Iterator;
  41719. class FileTypeFilterIterator extends FilterIterator
  41720. {
  41721. const ONLY_FILES = 1;
  41722. const ONLY_DIRECTORIES = 2;
  41723. private $mode;
  41724. public function __construct(\Iterator $iterator, $mode)
  41725. {
  41726. $this->mode = $mode;
  41727. parent::__construct($iterator);
  41728. }
  41729. public function accept()
  41730. {
  41731. $fileinfo = $this->current();
  41732. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  41733. return false;
  41734. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  41735. return false;
  41736. }
  41737. return true;
  41738. }
  41739. }
  41740. <?php
  41741. namespace Symfony\Component\Finder\Iterator;
  41742. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  41743. {
  41744. public function accept()
  41745. {
  41746. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  41747. return true;
  41748. }
  41749. $fileinfo = $this->current();
  41750. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  41751. return false;
  41752. }
  41753. $content = $fileinfo->getContents();
  41754. if (!$content) {
  41755. return false;
  41756. }
  41757. return $this->isAccepted($content);
  41758. }
  41759. protected function toRegex($str)
  41760. {
  41761. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  41762. }
  41763. }
  41764. <?php
  41765. namespace Symfony\Component\Finder\Iterator;
  41766. use Symfony\Component\Finder\Glob;
  41767. class FilenameFilterIterator extends MultiplePcreFilterIterator
  41768. {
  41769. public function accept()
  41770. {
  41771. return $this->isAccepted($this->current()->getFilename());
  41772. }
  41773. protected function toRegex($str)
  41774. {
  41775. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  41776. }
  41777. }
  41778. <?php
  41779. namespace Symfony\Component\Finder\Iterator;
  41780. abstract class FilterIterator extends \FilterIterator
  41781. {
  41782. public function rewind()
  41783. {
  41784. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  41785. parent::rewind();
  41786. return;
  41787. }
  41788. $iterator = $this;
  41789. while ($iterator instanceof \OuterIterator) {
  41790. $innerIterator = $iterator->getInnerIterator();
  41791. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  41792. if ($innerIterator->isRewindable()) {
  41793. $innerIterator->next();
  41794. $innerIterator->rewind();
  41795. }
  41796. } elseif ($innerIterator instanceof \FilesystemIterator) {
  41797. $innerIterator->next();
  41798. $innerIterator->rewind();
  41799. }
  41800. $iterator = $innerIterator;
  41801. }
  41802. parent::rewind();
  41803. }
  41804. }
  41805. <?php
  41806. namespace Symfony\Component\Finder\Iterator;
  41807. abstract class MultiplePcreFilterIterator extends FilterIterator
  41808. {
  41809. protected $matchRegexps = array();
  41810. protected $noMatchRegexps = array();
  41811. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  41812. {
  41813. foreach ($matchPatterns as $pattern) {
  41814. $this->matchRegexps[] = $this->toRegex($pattern);
  41815. }
  41816. foreach ($noMatchPatterns as $pattern) {
  41817. $this->noMatchRegexps[] = $this->toRegex($pattern);
  41818. }
  41819. parent::__construct($iterator);
  41820. }
  41821. protected function isAccepted($string)
  41822. {
  41823. foreach ($this->noMatchRegexps as $regex) {
  41824. if (preg_match($regex, $string)) {
  41825. return false;
  41826. }
  41827. }
  41828. if ($this->matchRegexps) {
  41829. foreach ($this->matchRegexps as $regex) {
  41830. if (preg_match($regex, $string)) {
  41831. return true;
  41832. }
  41833. }
  41834. return false;
  41835. }
  41836. return true;
  41837. }
  41838. protected function isRegex($str)
  41839. {
  41840. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  41841. $start = substr($m[1], 0, 1);
  41842. $end = substr($m[1], -1);
  41843. if ($start === $end) {
  41844. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  41845. }
  41846. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  41847. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  41848. return true;
  41849. }
  41850. }
  41851. }
  41852. return false;
  41853. }
  41854. abstract protected function toRegex($str);
  41855. }
  41856. <?php
  41857. namespace Symfony\Component\Finder\Iterator;
  41858. class PathFilterIterator extends MultiplePcreFilterIterator
  41859. {
  41860. public function accept()
  41861. {
  41862. $filename = $this->current()->getRelativePathname();
  41863. if ('\\' === \DIRECTORY_SEPARATOR) {
  41864. $filename = str_replace('\\', '/', $filename);
  41865. }
  41866. return $this->isAccepted($filename);
  41867. }
  41868. protected function toRegex($str)
  41869. {
  41870. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  41871. }
  41872. }
  41873. <?php
  41874. namespace Symfony\Component\Finder\Iterator;
  41875. use Symfony\Component\Finder\Exception\AccessDeniedException;
  41876. use Symfony\Component\Finder\SplFileInfo;
  41877. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  41878. {
  41879. private $ignoreUnreadableDirs;
  41880. private $rewindable;
  41881. private $rootPath;
  41882. private $subPath;
  41883. private $directorySeparator = '/';
  41884. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  41885. {
  41886. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  41887. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  41888. }
  41889. parent::__construct($path, $flags);
  41890. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  41891. $this->rootPath = (string) $path;
  41892. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  41893. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  41894. }
  41895. }
  41896. public function current()
  41897. {
  41898. if (null === $subPathname = $this->subPath) {
  41899. $subPathname = $this->subPath = (string) $this->getSubPath();
  41900. }
  41901. if ('' !== $subPathname) {
  41902. $subPathname .= $this->directorySeparator;
  41903. }
  41904. $subPathname .= $this->getFilename();
  41905. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  41906. }
  41907. public function getChildren()
  41908. {
  41909. try {
  41910. $children = parent::getChildren();
  41911. if ($children instanceof self) {
  41912. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  41913. $children->rewindable = &$this->rewindable;
  41914. $children->rootPath = $this->rootPath;
  41915. }
  41916. return $children;
  41917. } catch (\UnexpectedValueException $e) {
  41918. if ($this->ignoreUnreadableDirs) {
  41919. return new \RecursiveArrayIterator(array());
  41920. } else {
  41921. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  41922. }
  41923. }
  41924. }
  41925. public function rewind()
  41926. {
  41927. if (false === $this->isRewindable()) {
  41928. return;
  41929. }
  41930. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  41931. parent::next();
  41932. }
  41933. parent::rewind();
  41934. }
  41935. public function isRewindable()
  41936. {
  41937. if (null !== $this->rewindable) {
  41938. return $this->rewindable;
  41939. }
  41940. if ('' === $this->getPath()) {
  41941. return $this->rewindable = false;
  41942. }
  41943. if (false !== $stream = @opendir($this->getPath())) {
  41944. $infos = stream_get_meta_data($stream);
  41945. closedir($stream);
  41946. if ($infos['seekable']) {
  41947. return $this->rewindable = true;
  41948. }
  41949. }
  41950. return $this->rewindable = false;
  41951. }
  41952. }
  41953. <?php
  41954. namespace Symfony\Component\Finder\Iterator;
  41955. use Symfony\Component\Finder\Comparator\NumberComparator;
  41956. class SizeRangeFilterIterator extends FilterIterator
  41957. {
  41958. private $comparators = array();
  41959. public function __construct(\Iterator $iterator, array $comparators)
  41960. {
  41961. $this->comparators = $comparators;
  41962. parent::__construct($iterator);
  41963. }
  41964. public function accept()
  41965. {
  41966. $fileinfo = $this->current();
  41967. if (!$fileinfo->isFile()) {
  41968. return true;
  41969. }
  41970. $filesize = $fileinfo->getSize();
  41971. foreach ($this->comparators as $compare) {
  41972. if (!$compare->test($filesize)) {
  41973. return false;
  41974. }
  41975. }
  41976. return true;
  41977. }
  41978. }
  41979. <?php
  41980. namespace Symfony\Component\Finder\Iterator;
  41981. class SortableIterator implements \IteratorAggregate
  41982. {
  41983. const SORT_BY_NAME = 1;
  41984. const SORT_BY_TYPE = 2;
  41985. const SORT_BY_ACCESSED_TIME = 3;
  41986. const SORT_BY_CHANGED_TIME = 4;
  41987. const SORT_BY_MODIFIED_TIME = 5;
  41988. private $iterator;
  41989. private $sort;
  41990. public function __construct(\Traversable $iterator, $sort)
  41991. {
  41992. $this->iterator = $iterator;
  41993. if (self::SORT_BY_NAME === $sort) {
  41994. $this->sort = function ($a, $b) {
  41995. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  41996. };
  41997. } elseif (self::SORT_BY_TYPE === $sort) {
  41998. $this->sort = function ($a, $b) {
  41999. if ($a->isDir() && $b->isFile()) {
  42000. return -1;
  42001. } elseif ($a->isFile() && $b->isDir()) {
  42002. return 1;
  42003. }
  42004. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  42005. };
  42006. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  42007. $this->sort = function ($a, $b) {
  42008. return $a->getATime() - $b->getATime();
  42009. };
  42010. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  42011. $this->sort = function ($a, $b) {
  42012. return $a->getCTime() - $b->getCTime();
  42013. };
  42014. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  42015. $this->sort = function ($a, $b) {
  42016. return $a->getMTime() - $b->getMTime();
  42017. };
  42018. } elseif (\is_callable($sort)) {
  42019. $this->sort = $sort;
  42020. } else {
  42021. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  42022. }
  42023. }
  42024. public function getIterator()
  42025. {
  42026. $array = iterator_to_array($this->iterator, true);
  42027. uasort($array, $this->sort);
  42028. return new \ArrayIterator($array);
  42029. }
  42030. }
  42031. Copyright (c) 2004-2018 Fabien Potencier
  42032. Permission is hereby granted, free of charge, to any person obtaining a copy
  42033. of this software and associated documentation files (the "Software"), to deal
  42034. in the Software without restriction, including without limitation the rights
  42035. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  42036. copies of the Software, and to permit persons to whom the Software is furnished
  42037. to do so, subject to the following conditions:
  42038. The above copyright notice and this permission notice shall be included in all
  42039. copies or substantial portions of the Software.
  42040. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42041. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42042. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42043. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42044. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42045. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  42046. THE SOFTWARE.
  42047. <?php
  42048. namespace Symfony\Component\Finder\Shell;
  42049. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  42050. class Command
  42051. {
  42052. private $parent;
  42053. private $bits = array();
  42054. private $labels = array();
  42055. private $errorHandler;
  42056. public function __construct(Command $parent = null)
  42057. {
  42058. $this->parent = $parent;
  42059. }
  42060. public function __toString()
  42061. {
  42062. return $this->join();
  42063. }
  42064. public static function create(Command $parent = null)
  42065. {
  42066. return new self($parent);
  42067. }
  42068. public static function escape($input)
  42069. {
  42070. return escapeshellcmd($input);
  42071. }
  42072. public static function quote($input)
  42073. {
  42074. return escapeshellarg($input);
  42075. }
  42076. public function add($bit)
  42077. {
  42078. $this->bits[] = $bit;
  42079. return $this;
  42080. }
  42081. public function top($bit)
  42082. {
  42083. array_unshift($this->bits, $bit);
  42084. foreach ($this->labels as $label => $index) {
  42085. ++$this->labels[$label];
  42086. }
  42087. return $this;
  42088. }
  42089. public function arg($arg)
  42090. {
  42091. $this->bits[] = self::quote($arg);
  42092. return $this;
  42093. }
  42094. public function cmd($esc)
  42095. {
  42096. $this->bits[] = self::escape($esc);
  42097. return $this;
  42098. }
  42099. public function ins($label)
  42100. {
  42101. if (isset($this->labels[$label])) {
  42102. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  42103. }
  42104. $this->bits[] = self::create($this);
  42105. $this->labels[$label] = \count($this->bits) - 1;
  42106. return $this->bits[$this->labels[$label]];
  42107. }
  42108. public function get($label)
  42109. {
  42110. if (!isset($this->labels[$label])) {
  42111. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  42112. }
  42113. return $this->bits[$this->labels[$label]];
  42114. }
  42115. public function end()
  42116. {
  42117. if (null === $this->parent) {
  42118. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  42119. }
  42120. return $this->parent;
  42121. }
  42122. public function length()
  42123. {
  42124. return \count($this->bits);
  42125. }
  42126. public function setErrorHandler(\Closure $errorHandler)
  42127. {
  42128. $this->errorHandler = $errorHandler;
  42129. return $this;
  42130. }
  42131. public function getErrorHandler()
  42132. {
  42133. return $this->errorHandler;
  42134. }
  42135. public function execute()
  42136. {
  42137. if (null === $errorHandler = $this->errorHandler) {
  42138. exec($this->join(), $output);
  42139. } else {
  42140. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  42141. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  42142. if ($error = stream_get_contents($pipes[2])) {
  42143. $errorHandler($error);
  42144. }
  42145. proc_close($process);
  42146. }
  42147. return $output ?: array();
  42148. }
  42149. public function join()
  42150. {
  42151. return implode(' ', array_filter(
  42152. array_map(function ($bit) {
  42153. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  42154. }, $this->bits),
  42155. function ($bit) { return null !== $bit; }
  42156. ));
  42157. }
  42158. public function addAtIndex($bit, $index)
  42159. {
  42160. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  42161. return $this;
  42162. }
  42163. }
  42164. <?php
  42165. namespace Symfony\Component\Finder\Shell;
  42166. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  42167. class Shell
  42168. {
  42169. const TYPE_UNIX = 1;
  42170. const TYPE_DARWIN = 2;
  42171. const TYPE_CYGWIN = 3;
  42172. const TYPE_WINDOWS = 4;
  42173. const TYPE_BSD = 5;
  42174. private $type;
  42175. public function getType()
  42176. {
  42177. if (null === $this->type) {
  42178. $this->type = $this->guessType();
  42179. }
  42180. return $this->type;
  42181. }
  42182. public function testCommand($command)
  42183. {
  42184. if (!\function_exists('exec')) {
  42185. return false;
  42186. }
  42187. $testCommand = 'which ';
  42188. if (self::TYPE_WINDOWS === $this->type) {
  42189. $testCommand = 'where ';
  42190. }
  42191. $command = escapeshellcmd($command);
  42192. exec($testCommand.$command, $output, $code);
  42193. return 0 === $code && \count($output) > 0;
  42194. }
  42195. private function guessType()
  42196. {
  42197. $os = strtolower(PHP_OS);
  42198. if (false !== strpos($os, 'cygwin')) {
  42199. return self::TYPE_CYGWIN;
  42200. }
  42201. if (false !== strpos($os, 'darwin')) {
  42202. return self::TYPE_DARWIN;
  42203. }
  42204. if (false !== strpos($os, 'bsd')) {
  42205. return self::TYPE_BSD;
  42206. }
  42207. if (0 === strpos($os, 'win')) {
  42208. return self::TYPE_WINDOWS;
  42209. }
  42210. return self::TYPE_UNIX;
  42211. }
  42212. }
  42213. <?php
  42214. namespace Symfony\Component\Finder;
  42215. class SplFileInfo extends \SplFileInfo
  42216. {
  42217. private $relativePath;
  42218. private $relativePathname;
  42219. public function __construct($file, $relativePath, $relativePathname)
  42220. {
  42221. parent::__construct($file);
  42222. $this->relativePath = $relativePath;
  42223. $this->relativePathname = $relativePathname;
  42224. }
  42225. public function getRelativePath()
  42226. {
  42227. return $this->relativePath;
  42228. }
  42229. public function getRelativePathname()
  42230. {
  42231. return $this->relativePathname;
  42232. }
  42233. public function getContents()
  42234. {
  42235. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  42236. $content = file_get_contents($this->getPathname());
  42237. restore_error_handler();
  42238. if (false === $content) {
  42239. throw new \RuntimeException($error);
  42240. }
  42241. return $content;
  42242. }
  42243. }
  42244. <?php
  42245. namespace Symfony\Polyfill\Ctype;
  42246. final class Ctype
  42247. {
  42248. public static function ctype_alnum($text)
  42249. {
  42250. $text = self::convert_int_to_char_for_ctype($text);
  42251. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  42252. }
  42253. public static function ctype_alpha($text)
  42254. {
  42255. $text = self::convert_int_to_char_for_ctype($text);
  42256. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  42257. }
  42258. public static function ctype_cntrl($text)
  42259. {
  42260. $text = self::convert_int_to_char_for_ctype($text);
  42261. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  42262. }
  42263. public static function ctype_digit($text)
  42264. {
  42265. $text = self::convert_int_to_char_for_ctype($text);
  42266. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  42267. }
  42268. public static function ctype_graph($text)
  42269. {
  42270. $text = self::convert_int_to_char_for_ctype($text);
  42271. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  42272. }
  42273. public static function ctype_lower($text)
  42274. {
  42275. $text = self::convert_int_to_char_for_ctype($text);
  42276. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  42277. }
  42278. public static function ctype_print($text)
  42279. {
  42280. $text = self::convert_int_to_char_for_ctype($text);
  42281. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  42282. }
  42283. public static function ctype_punct($text)
  42284. {
  42285. $text = self::convert_int_to_char_for_ctype($text);
  42286. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  42287. }
  42288. public static function ctype_space($text)
  42289. {
  42290. $text = self::convert_int_to_char_for_ctype($text);
  42291. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  42292. }
  42293. public static function ctype_upper($text)
  42294. {
  42295. $text = self::convert_int_to_char_for_ctype($text);
  42296. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  42297. }
  42298. public static function ctype_xdigit($text)
  42299. {
  42300. $text = self::convert_int_to_char_for_ctype($text);
  42301. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  42302. }
  42303. private static function convert_int_to_char_for_ctype($int)
  42304. {
  42305. if (!\is_int($int)) {
  42306. return $int;
  42307. }
  42308. if ($int < -128 || $int > 255) {
  42309. return (string) $int;
  42310. }
  42311. if ($int < 0) {
  42312. $int += 256;
  42313. }
  42314. return \chr($int);
  42315. }
  42316. }
  42317. Copyright (c) 2018 Fabien Potencier
  42318. Permission is hereby granted, free of charge, to any person obtaining a copy
  42319. of this software and associated documentation files (the "Software"), to deal
  42320. in the Software without restriction, including without limitation the rights
  42321. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  42322. copies of the Software, and to permit persons to whom the Software is furnished
  42323. to do so, subject to the following conditions:
  42324. The above copyright notice and this permission notice shall be included in all
  42325. copies or substantial portions of the Software.
  42326. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42327. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42328. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42329. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42330. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42331. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  42332. THE SOFTWARE.
  42333. <?php
  42334. use Symfony\Polyfill\Ctype as p;
  42335. if (!function_exists('ctype_alnum')) {
  42336. function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
  42337. function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
  42338. function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
  42339. function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
  42340. function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
  42341. function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
  42342. function ctype_print($text) { return p\Ctype::ctype_print($text); }
  42343. function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
  42344. function ctype_space($text) { return p\Ctype::ctype_space($text); }
  42345. function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
  42346. function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
  42347. }
  42348. Copyright (c) 2015-2018 Fabien Potencier
  42349. Permission is hereby granted, free of charge, to any person obtaining a copy
  42350. of this software and associated documentation files (the "Software"), to deal
  42351. in the Software without restriction, including without limitation the rights
  42352. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  42353. copies of the Software, and to permit persons to whom the Software is furnished
  42354. to do so, subject to the following conditions:
  42355. The above copyright notice and this permission notice shall be included in all
  42356. copies or substantial portions of the Software.
  42357. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42358. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42359. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42360. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42361. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42362. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  42363. THE SOFTWARE.
  42364. <?php
  42365. namespace Symfony\Polyfill\Mbstring;
  42366. final class Mbstring
  42367. {
  42368. const MB_CASE_FOLD = PHP_INT_MAX;
  42369. private static $encodingList = array('ASCII', 'UTF-8');
  42370. private static $language = 'neutral';
  42371. private static $internalEncoding = 'UTF-8';
  42372. private static $caseFold = array(
  42373. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  42374. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  42375. );
  42376. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  42377. {
  42378. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  42379. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  42380. } else {
  42381. $fromEncoding = self::getEncoding($fromEncoding);
  42382. }
  42383. $toEncoding = self::getEncoding($toEncoding);
  42384. if ('BASE64' === $fromEncoding) {
  42385. $s = base64_decode($s);
  42386. $fromEncoding = $toEncoding;
  42387. }
  42388. if ('BASE64' === $toEncoding) {
  42389. return base64_encode($s);
  42390. }
  42391. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  42392. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  42393. $fromEncoding = 'Windows-1252';
  42394. }
  42395. if ('UTF-8' !== $fromEncoding) {
  42396. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  42397. }
  42398. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  42399. }
  42400. if ('HTML-ENTITIES' === $fromEncoding) {
  42401. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  42402. $fromEncoding = 'UTF-8';
  42403. }
  42404. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  42405. }
  42406. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  42407. {
  42408. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  42409. $ok = true;
  42410. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  42411. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  42412. $ok = false;
  42413. }
  42414. });
  42415. return $ok ? $fromEncoding : false;
  42416. }
  42417. public static function mb_decode_mimeheader($s)
  42418. {
  42419. return iconv_mime_decode($s, 2, self::$internalEncoding);
  42420. }
  42421. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  42422. {
  42423. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  42424. }
  42425. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  42426. {
  42427. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  42428. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  42429. return null;
  42430. }
  42431. if (!\is_array($convmap) || !$convmap) {
  42432. return false;
  42433. }
  42434. if (null !== $encoding && !\is_scalar($encoding)) {
  42435. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  42436. return '';
  42437. }
  42438. $s = (string) $s;
  42439. if ('' === $s) {
  42440. return '';
  42441. }
  42442. $encoding = self::getEncoding($encoding);
  42443. if ('UTF-8' === $encoding) {
  42444. $encoding = null;
  42445. if (!preg_match('//u', $s)) {
  42446. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  42447. }
  42448. } else {
  42449. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  42450. }
  42451. $cnt = floor(\count($convmap) / 4) * 4;
  42452. for ($i = 0; $i < $cnt; $i += 4) {
  42453. $convmap[$i] += $convmap[$i + 2];
  42454. $convmap[$i + 1] += $convmap[$i + 2];
  42455. }
  42456. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  42457. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  42458. for ($i = 0; $i < $cnt; $i += 4) {
  42459. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  42460. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  42461. }
  42462. }
  42463. return $m[0];
  42464. }, $s);
  42465. if (null === $encoding) {
  42466. return $s;
  42467. }
  42468. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  42469. }
  42470. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  42471. {
  42472. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  42473. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  42474. return null;
  42475. }
  42476. if (!\is_array($convmap) || !$convmap) {
  42477. return false;
  42478. }
  42479. if (null !== $encoding && !\is_scalar($encoding)) {
  42480. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  42481. return null;
  42482. }
  42483. if (null !== $is_hex && !\is_scalar($is_hex)) {
  42484. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  42485. return null;
  42486. }
  42487. $s = (string) $s;
  42488. if ('' === $s) {
  42489. return '';
  42490. }
  42491. $encoding = self::getEncoding($encoding);
  42492. if ('UTF-8' === $encoding) {
  42493. $encoding = null;
  42494. if (!preg_match('//u', $s)) {
  42495. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  42496. }
  42497. } else {
  42498. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  42499. }
  42500. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  42501. $cnt = floor(\count($convmap) / 4) * 4;
  42502. $i = 0;
  42503. $len = \strlen($s);
  42504. $result = '';
  42505. while ($i < $len) {
  42506. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  42507. $uchr = substr($s, $i, $ulen);
  42508. $i += $ulen;
  42509. $c = self::mb_ord($uchr);
  42510. for ($j = 0; $j < $cnt; $j += 4) {
  42511. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  42512. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  42513. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  42514. continue 2;
  42515. }
  42516. }
  42517. $result .= $uchr;
  42518. }
  42519. if (null === $encoding) {
  42520. return $result;
  42521. }
  42522. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  42523. }
  42524. public static function mb_convert_case($s, $mode, $encoding = null)
  42525. {
  42526. $s = (string) $s;
  42527. if ('' === $s) {
  42528. return '';
  42529. }
  42530. $encoding = self::getEncoding($encoding);
  42531. if ('UTF-8' === $encoding) {
  42532. $encoding = null;
  42533. if (!preg_match('//u', $s)) {
  42534. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  42535. }
  42536. } else {
  42537. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  42538. }
  42539. if (MB_CASE_TITLE == $mode) {
  42540. static $titleRegexp = null;
  42541. if (null === $titleRegexp) {
  42542. $titleRegexp = self::getData('titleCaseRegexp');
  42543. }
  42544. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  42545. } else {
  42546. if (MB_CASE_UPPER == $mode) {
  42547. static $upper = null;
  42548. if (null === $upper) {
  42549. $upper = self::getData('upperCase');
  42550. }
  42551. $map = $upper;
  42552. } else {
  42553. if (self::MB_CASE_FOLD === $mode) {
  42554. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  42555. }
  42556. static $lower = null;
  42557. if (null === $lower) {
  42558. $lower = self::getData('lowerCase');
  42559. }
  42560. $map = $lower;
  42561. }
  42562. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  42563. $i = 0;
  42564. $len = \strlen($s);
  42565. while ($i < $len) {
  42566. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  42567. $uchr = substr($s, $i, $ulen);
  42568. $i += $ulen;
  42569. if (isset($map[$uchr])) {
  42570. $uchr = $map[$uchr];
  42571. $nlen = \strlen($uchr);
  42572. if ($nlen == $ulen) {
  42573. $nlen = $i;
  42574. do {
  42575. $s[--$nlen] = $uchr[--$ulen];
  42576. } while ($ulen);
  42577. } else {
  42578. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  42579. $len += $nlen - $ulen;
  42580. $i += $nlen - $ulen;
  42581. }
  42582. }
  42583. }
  42584. }
  42585. if (null === $encoding) {
  42586. return $s;
  42587. }
  42588. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  42589. }
  42590. public static function mb_internal_encoding($encoding = null)
  42591. {
  42592. if (null === $encoding) {
  42593. return self::$internalEncoding;
  42594. }
  42595. $encoding = self::getEncoding($encoding);
  42596. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  42597. self::$internalEncoding = $encoding;
  42598. return true;
  42599. }
  42600. return false;
  42601. }
  42602. public static function mb_language($lang = null)
  42603. {
  42604. if (null === $lang) {
  42605. return self::$language;
  42606. }
  42607. switch ($lang = strtolower($lang)) {
  42608. case 'uni':
  42609. case 'neutral':
  42610. self::$language = $lang;
  42611. return true;
  42612. }
  42613. return false;
  42614. }
  42615. public static function mb_list_encodings()
  42616. {
  42617. return array('UTF-8');
  42618. }
  42619. public static function mb_encoding_aliases($encoding)
  42620. {
  42621. switch (strtoupper($encoding)) {
  42622. case 'UTF8':
  42623. case 'UTF-8':
  42624. return array('utf8');
  42625. }
  42626. return false;
  42627. }
  42628. public static function mb_check_encoding($var = null, $encoding = null)
  42629. {
  42630. if (null === $encoding) {
  42631. if (null === $var) {
  42632. return false;
  42633. }
  42634. $encoding = self::$internalEncoding;
  42635. }
  42636. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  42637. }
  42638. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  42639. {
  42640. if (null === $encodingList) {
  42641. $encodingList = self::$encodingList;
  42642. } else {
  42643. if (!\is_array($encodingList)) {
  42644. $encodingList = array_map('trim', explode(',', $encodingList));
  42645. }
  42646. $encodingList = array_map('strtoupper', $encodingList);
  42647. }
  42648. foreach ($encodingList as $enc) {
  42649. switch ($enc) {
  42650. case 'ASCII':
  42651. if (!preg_match('/[\x80-\xFF]/', $str)) {
  42652. return $enc;
  42653. }
  42654. break;
  42655. case 'UTF8':
  42656. case 'UTF-8':
  42657. if (preg_match('//u', $str)) {
  42658. return 'UTF-8';
  42659. }
  42660. break;
  42661. default:
  42662. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  42663. return $enc;
  42664. }
  42665. }
  42666. }
  42667. return false;
  42668. }
  42669. public static function mb_detect_order($encodingList = null)
  42670. {
  42671. if (null === $encodingList) {
  42672. return self::$encodingList;
  42673. }
  42674. if (!\is_array($encodingList)) {
  42675. $encodingList = array_map('trim', explode(',', $encodingList));
  42676. }
  42677. $encodingList = array_map('strtoupper', $encodingList);
  42678. foreach ($encodingList as $enc) {
  42679. switch ($enc) {
  42680. default:
  42681. if (strncmp($enc, 'ISO-8859-', 9)) {
  42682. return false;
  42683. }
  42684. case 'ASCII':
  42685. case 'UTF8':
  42686. case 'UTF-8':
  42687. }
  42688. }
  42689. self::$encodingList = $encodingList;
  42690. return true;
  42691. }
  42692. public static function mb_strlen($s, $encoding = null)
  42693. {
  42694. $encoding = self::getEncoding($encoding);
  42695. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  42696. return \strlen($s);
  42697. }
  42698. return @iconv_strlen($s, $encoding);
  42699. }
  42700. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  42701. {
  42702. $encoding = self::getEncoding($encoding);
  42703. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  42704. return strpos($haystack, $needle, $offset);
  42705. }
  42706. $needle = (string) $needle;
  42707. if ('' === $needle) {
  42708. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  42709. return false;
  42710. }
  42711. return iconv_strpos($haystack, $needle, $offset, $encoding);
  42712. }
  42713. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  42714. {
  42715. $encoding = self::getEncoding($encoding);
  42716. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  42717. return strrpos($haystack, $needle, $offset);
  42718. }
  42719. if ($offset != (int) $offset) {
  42720. $offset = 0;
  42721. } elseif ($offset = (int) $offset) {
  42722. if ($offset < 0) {
  42723. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  42724. $offset = 0;
  42725. } else {
  42726. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  42727. }
  42728. }
  42729. $pos = iconv_strrpos($haystack, $needle, $encoding);
  42730. return false !== $pos ? $offset + $pos : false;
  42731. }
  42732. public static function mb_strtolower($s, $encoding = null)
  42733. {
  42734. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  42735. }
  42736. public static function mb_strtoupper($s, $encoding = null)
  42737. {
  42738. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  42739. }
  42740. public static function mb_substitute_character($c = null)
  42741. {
  42742. if (0 === strcasecmp($c, 'none')) {
  42743. return true;
  42744. }
  42745. return null !== $c ? false : 'none';
  42746. }
  42747. public static function mb_substr($s, $start, $length = null, $encoding = null)
  42748. {
  42749. $encoding = self::getEncoding($encoding);
  42750. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  42751. return substr($s, $start, null === $length ? 2147483647 : $length);
  42752. }
  42753. if ($start < 0) {
  42754. $start = iconv_strlen($s, $encoding) + $start;
  42755. if ($start < 0) {
  42756. $start = 0;
  42757. }
  42758. }
  42759. if (null === $length) {
  42760. $length = 2147483647;
  42761. } elseif ($length < 0) {
  42762. $length = iconv_strlen($s, $encoding) + $length - $start;
  42763. if ($length < 0) {
  42764. return '';
  42765. }
  42766. }
  42767. return (string) iconv_substr($s, $start, $length, $encoding);
  42768. }
  42769. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  42770. {
  42771. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  42772. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  42773. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  42774. }
  42775. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  42776. {
  42777. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  42778. return self::getSubpart($pos, $part, $haystack, $encoding);
  42779. }
  42780. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  42781. {
  42782. $encoding = self::getEncoding($encoding);
  42783. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  42784. return strrchr($haystack, $needle, $part);
  42785. }
  42786. $needle = self::mb_substr($needle, 0, 1, $encoding);
  42787. $pos = iconv_strrpos($haystack, $needle, $encoding);
  42788. return self::getSubpart($pos, $part, $haystack, $encoding);
  42789. }
  42790. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  42791. {
  42792. $needle = self::mb_substr($needle, 0, 1, $encoding);
  42793. $pos = self::mb_strripos($haystack, $needle, $encoding);
  42794. return self::getSubpart($pos, $part, $haystack, $encoding);
  42795. }
  42796. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  42797. {
  42798. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  42799. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  42800. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  42801. }
  42802. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  42803. {
  42804. $pos = strpos($haystack, $needle);
  42805. if (false === $pos) {
  42806. return false;
  42807. }
  42808. if ($part) {
  42809. return substr($haystack, 0, $pos);
  42810. }
  42811. return substr($haystack, $pos);
  42812. }
  42813. public static function mb_get_info($type = 'all')
  42814. {
  42815. $info = array(
  42816. 'internal_encoding' => self::$internalEncoding,
  42817. 'http_output' => 'pass',
  42818. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  42819. 'func_overload' => 0,
  42820. 'func_overload_list' => 'no overload',
  42821. 'mail_charset' => 'UTF-8',
  42822. 'mail_header_encoding' => 'BASE64',
  42823. 'mail_body_encoding' => 'BASE64',
  42824. 'illegal_chars' => 0,
  42825. 'encoding_translation' => 'Off',
  42826. 'language' => self::$language,
  42827. 'detect_order' => self::$encodingList,
  42828. 'substitute_character' => 'none',
  42829. 'strict_detection' => 'Off',
  42830. );
  42831. if ('all' === $type) {
  42832. return $info;
  42833. }
  42834. if (isset($info[$type])) {
  42835. return $info[$type];
  42836. }
  42837. return false;
  42838. }
  42839. public static function mb_http_input($type = '')
  42840. {
  42841. return false;
  42842. }
  42843. public static function mb_http_output($encoding = null)
  42844. {
  42845. return null !== $encoding ? 'pass' === $encoding : 'pass';
  42846. }
  42847. public static function mb_strwidth($s, $encoding = null)
  42848. {
  42849. $encoding = self::getEncoding($encoding);
  42850. if ('UTF-8' !== $encoding) {
  42851. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  42852. }
  42853. $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);
  42854. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  42855. }
  42856. public static function mb_substr_count($haystack, $needle, $encoding = null)
  42857. {
  42858. return substr_count($haystack, $needle);
  42859. }
  42860. public static function mb_output_handler($contents, $status)
  42861. {
  42862. return $contents;
  42863. }
  42864. public static function mb_chr($code, $encoding = null)
  42865. {
  42866. if (0x80 > $code %= 0x200000) {
  42867. $s = \chr($code);
  42868. } elseif (0x800 > $code) {
  42869. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  42870. } elseif (0x10000 > $code) {
  42871. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  42872. } else {
  42873. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  42874. }
  42875. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  42876. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  42877. }
  42878. return $s;
  42879. }
  42880. public static function mb_ord($s, $encoding = null)
  42881. {
  42882. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  42883. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  42884. }
  42885. if (1 === \strlen($s)) {
  42886. return \ord($s);
  42887. }
  42888. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  42889. if (0xF0 <= $code) {
  42890. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  42891. }
  42892. if (0xE0 <= $code) {
  42893. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  42894. }
  42895. if (0xC0 <= $code) {
  42896. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  42897. }
  42898. return $code;
  42899. }
  42900. private static function getSubpart($pos, $part, $haystack, $encoding)
  42901. {
  42902. if (false === $pos) {
  42903. return false;
  42904. }
  42905. if ($part) {
  42906. return self::mb_substr($haystack, 0, $pos, $encoding);
  42907. }
  42908. return self::mb_substr($haystack, $pos, null, $encoding);
  42909. }
  42910. private static function html_encoding_callback(array $m)
  42911. {
  42912. $i = 1;
  42913. $entities = '';
  42914. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  42915. while (isset($m[$i])) {
  42916. if (0x80 > $m[$i]) {
  42917. $entities .= \chr($m[$i++]);
  42918. continue;
  42919. }
  42920. if (0xF0 <= $m[$i]) {
  42921. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  42922. } elseif (0xE0 <= $m[$i]) {
  42923. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  42924. } else {
  42925. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  42926. }
  42927. $entities .= '&#'.$c.';';
  42928. }
  42929. return $entities;
  42930. }
  42931. private static function title_case(array $s)
  42932. {
  42933. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  42934. }
  42935. private static function getData($file)
  42936. {
  42937. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  42938. return require $file;
  42939. }
  42940. return false;
  42941. }
  42942. private static function getEncoding($encoding)
  42943. {
  42944. if (null === $encoding) {
  42945. return self::$internalEncoding;
  42946. }
  42947. $encoding = strtoupper($encoding);
  42948. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  42949. return 'CP850';
  42950. }
  42951. if ('UTF8' === $encoding) {
  42952. return 'UTF-8';
  42953. }
  42954. return $encoding;
  42955. }
  42956. }
  42957. <?php
  42958. return array(
  42959. 'A' => 'a',
  42960. 'B' => 'b',
  42961. 'C' => 'c',
  42962. 'D' => 'd',
  42963. 'E' => 'e',
  42964. 'F' => 'f',
  42965. 'G' => 'g',
  42966. 'H' => 'h',
  42967. 'I' => 'i',
  42968. 'J' => 'j',
  42969. 'K' => 'k',
  42970. 'L' => 'l',
  42971. 'M' => 'm',
  42972. 'N' => 'n',
  42973. 'O' => 'o',
  42974. 'P' => 'p',
  42975. 'Q' => 'q',
  42976. 'R' => 'r',
  42977. 'S' => 's',
  42978. 'T' => 't',
  42979. 'U' => 'u',
  42980. 'V' => 'v',
  42981. 'W' => 'w',
  42982. 'X' => 'x',
  42983. 'Y' => 'y',
  42984. 'Z' => 'z',
  42985. 'À' => 'à',
  42986. '�' => 'á',
  42987. 'Â' => 'â',
  42988. 'Ã' => 'ã',
  42989. 'Ä' => 'ä',
  42990. 'Ã…' => 'Ã¥',
  42991. 'Æ' => 'æ',
  42992. 'Ç' => 'ç',
  42993. 'È' => 'è',
  42994. 'É' => 'é',
  42995. 'Ê' => 'ê',
  42996. 'Ë' => 'ë',
  42997. 'Ì' => 'ì',
  42998. '�' => 'í',
  42999. 'Î' => 'î',
  43000. '�' => 'ï',
  43001. '�' => 'ð',
  43002. 'Ñ' => 'ñ',
  43003. 'Ò' => 'ò',
  43004. 'Ó' => 'ó',
  43005. 'Ô' => 'ô',
  43006. 'Õ' => 'õ',
  43007. 'Ö' => 'ö',
  43008. 'Ø' => 'ø',
  43009. 'Ù' => 'ù',
  43010. 'Ú' => 'ú',
  43011. 'Û' => 'û',
  43012. 'Ü' => 'ü',
  43013. '�' => 'ý',
  43014. 'Þ' => 'þ',
  43015. 'Ā' => '�',
  43016. 'Ă' => 'ă',
  43017. 'Ä„' => 'Ä…',
  43018. 'Ć' => 'ć',
  43019. 'Ĉ' => 'ĉ',
  43020. 'ÄŠ' => 'Ä‹',
  43021. 'Č' => '�',
  43022. 'Ď' => '�',
  43023. '�' => 'đ',
  43024. 'Ä’' => 'Ä“',
  43025. 'Ä”' => 'Ä•',
  43026. 'Ä–' => 'Ä—',
  43027. 'Ę' => 'ę',
  43028. 'Äš' => 'Ä›',
  43029. 'Ĝ' => '�',
  43030. 'Äž' => 'ÄŸ',
  43031. 'Ä ' => 'Ä¡',
  43032. 'Ä¢' => 'Ä£',
  43033. 'Ĥ' => 'ĥ',
  43034. 'Ħ' => 'ħ',
  43035. 'Ĩ' => 'ĩ',
  43036. 'Ī' => 'ī',
  43037. 'Ĭ' => 'ĭ',
  43038. 'Į' => 'į',
  43039. 'İ' => 'i',
  43040. 'IJ' => 'ij',
  43041. 'Ĵ' => 'ĵ',
  43042. 'Ķ' => 'ķ',
  43043. 'Ĺ' => 'ĺ',
  43044. 'Ļ' => 'ļ',
  43045. 'Ľ' => 'ľ',
  43046. 'Ä¿' => 'Å€',
  43047. '�' => 'ł',
  43048. 'Ń' => 'ń',
  43049. 'Ņ' => 'ņ',
  43050. 'Ň' => 'ň',
  43051. 'ÅŠ' => 'Å‹',
  43052. 'Ō' => '�',
  43053. 'Ŏ' => '�',
  43054. '�' => 'ő',
  43055. 'Å’' => 'Å“',
  43056. 'Å”' => 'Å•',
  43057. 'Å–' => 'Å—',
  43058. 'Ř' => 'ř',
  43059. 'Åš' => 'Å›',
  43060. 'Ŝ' => '�',
  43061. 'Åž' => 'ÅŸ',
  43062. 'Å ' => 'Å¡',
  43063. 'Å¢' => 'Å£',
  43064. 'Ť' => 'ť',
  43065. 'Ŧ' => 'ŧ',
  43066. 'Ũ' => 'ũ',
  43067. 'Ū' => 'ū',
  43068. 'Ŭ' => 'ŭ',
  43069. 'Ů' => 'ů',
  43070. 'Ű' => 'ű',
  43071. 'Ų' => 'ų',
  43072. 'Ŵ' => 'ŵ',
  43073. 'Ŷ' => 'ŷ',
  43074. 'Ÿ' => 'ÿ',
  43075. 'Ź' => 'ź',
  43076. 'Ż' => 'ż',
  43077. 'Ž' => 'ž',
  43078. '�' => 'ɓ',
  43079. 'Ƃ' => 'ƃ',
  43080. 'Æ„' => 'Æ…',
  43081. 'Ɔ' => 'ɔ',
  43082. 'Ƈ' => 'ƈ',
  43083. 'Ɖ' => 'ɖ',
  43084. 'ÆŠ' => 'É—',
  43085. 'Ƌ' => 'ƌ',
  43086. 'Ǝ' => '�',
  43087. '�' => 'ə',
  43088. '�' => 'ɛ',
  43089. 'Æ‘' => 'Æ’',
  43090. 'Æ“' => 'É ',
  43091. 'Æ”' => 'É£',
  43092. 'Æ–' => 'É©',
  43093. 'Ɨ' => 'ɨ',
  43094. 'Ƙ' => 'ƙ',
  43095. 'Ɯ' => 'ɯ',
  43096. '�' => 'ɲ',
  43097. 'Ɵ' => 'ɵ',
  43098. 'Æ ' => 'Æ¡',
  43099. 'Æ¢' => 'Æ£',
  43100. 'Ƥ' => 'ƥ',
  43101. 'Ʀ' => 'ʀ',
  43102. 'Ƨ' => 'ƨ',
  43103. 'Ʃ' => 'ʃ',
  43104. 'Ƭ' => 'ƭ',
  43105. 'Ʈ' => 'ʈ',
  43106. 'Ư' => 'ư',
  43107. 'Ʊ' => 'ʊ',
  43108. 'Ʋ' => 'ʋ',
  43109. 'Ƴ' => 'ƴ',
  43110. 'Ƶ' => 'ƶ',
  43111. 'Æ·' => 'Ê’',
  43112. 'Ƹ' => 'ƹ',
  43113. 'Ƽ' => 'ƽ',
  43114. 'DŽ' => 'dž',
  43115. 'Dž' => 'dž',
  43116. 'LJ' => 'lj',
  43117. 'Lj' => 'lj',
  43118. 'NJ' => 'nj',
  43119. 'Nj' => 'nj',
  43120. '�' => 'ǎ',
  43121. '�' => '�',
  43122. 'Ç‘' => 'Ç’',
  43123. 'Ç“' => 'Ç”',
  43124. 'Ç•' => 'Ç–',
  43125. 'Ǘ' => 'ǘ',
  43126. 'Ç™' => 'Çš',
  43127. 'Ǜ' => 'ǜ',
  43128. 'Çž' => 'ÇŸ',
  43129. 'Ç ' => 'Ç¡',
  43130. 'Ç¢' => 'Ç£',
  43131. 'Ǥ' => 'ǥ',
  43132. 'Ǧ' => 'ǧ',
  43133. 'Ǩ' => 'ǩ',
  43134. 'Ǫ' => 'ǫ',
  43135. 'Ǭ' => 'ǭ',
  43136. 'Ǯ' => 'ǯ',
  43137. 'DZ' => 'dz',
  43138. 'Dz' => 'dz',
  43139. 'Ǵ' => 'ǵ',
  43140. 'Ƕ' => 'ƕ',
  43141. 'Ç·' => 'Æ¿',
  43142. 'Ǹ' => 'ǹ',
  43143. 'Ǻ' => 'ǻ',
  43144. 'Ǽ' => 'ǽ',
  43145. 'Ǿ' => 'ǿ',
  43146. 'Ȁ' => '�',
  43147. 'Ȃ' => 'ȃ',
  43148. 'È„' => 'È…',
  43149. 'Ȇ' => 'ȇ',
  43150. 'Ȉ' => 'ȉ',
  43151. 'ÈŠ' => 'È‹',
  43152. 'Ȍ' => '�',
  43153. 'Ȏ' => '�',
  43154. '�' => 'ȑ',
  43155. 'È’' => 'È“',
  43156. 'È”' => 'È•',
  43157. 'È–' => 'È—',
  43158. 'Ș' => 'ș',
  43159. 'Èš' => 'È›',
  43160. 'Ȝ' => '�',
  43161. 'Èž' => 'ÈŸ',
  43162. 'È ' => 'Æž',
  43163. 'È¢' => 'È£',
  43164. 'Ȥ' => 'ȥ',
  43165. 'Ȧ' => 'ȧ',
  43166. 'Ȩ' => 'ȩ',
  43167. 'Ȫ' => 'ȫ',
  43168. 'Ȭ' => 'ȭ',
  43169. 'Ȯ' => 'ȯ',
  43170. 'Ȱ' => 'ȱ',
  43171. 'Ȳ' => 'ȳ',
  43172. 'Ⱥ' => 'ⱥ',
  43173. 'Ȼ' => 'ȼ',
  43174. 'Ƚ' => 'ƚ',
  43175. 'Ⱦ' => 'ⱦ',
  43176. '�' => 'ɂ',
  43177. 'Ƀ' => 'ƀ',
  43178. 'Ʉ' => 'ʉ',
  43179. 'Ʌ' => 'ʌ',
  43180. 'Ɇ' => 'ɇ',
  43181. 'Ɉ' => 'ɉ',
  43182. 'ÉŠ' => 'É‹',
  43183. 'Ɍ' => '�',
  43184. 'Ɏ' => '�',
  43185. 'Ͱ' => 'ͱ',
  43186. 'Ͳ' => 'ͳ',
  43187. 'Ͷ' => 'ͷ',
  43188. 'Ϳ' => 'ϳ',
  43189. 'Ά' => 'ά',
  43190. 'Έ' => 'έ',
  43191. 'Ή' => 'ή',
  43192. 'Ί' => 'ί',
  43193. 'Ό' => 'ό',
  43194. 'Ύ' => '�',
  43195. '�' => 'ώ',
  43196. 'Α' => 'α',
  43197. 'Β' => 'β',
  43198. 'Γ' => 'γ',
  43199. 'Δ' => 'δ',
  43200. 'Ε' => 'ε',
  43201. 'Ζ' => 'ζ',
  43202. 'Η' => 'η',
  43203. 'Θ' => 'θ',
  43204. 'Ι' => 'ι',
  43205. 'Κ' => 'κ',
  43206. 'Λ' => 'λ',
  43207. 'Μ' => 'μ',
  43208. '�' => 'ν',
  43209. 'Ξ' => 'ξ',
  43210. 'Ο' => 'ο',
  43211. 'Π' => 'π',
  43212. 'Ρ' => '�',
  43213. 'Σ' => 'σ',
  43214. 'Τ' => 'τ',
  43215. 'Î¥' => 'Ï…',
  43216. 'Φ' => 'φ',
  43217. 'Χ' => 'χ',
  43218. 'Ψ' => 'ψ',
  43219. 'Ω' => 'ω',
  43220. 'Ϊ' => 'ϊ',
  43221. 'Ϋ' => 'ϋ',
  43222. '�' => 'ϗ',
  43223. 'Ϙ' => 'ϙ',
  43224. 'Ïš' => 'Ï›',
  43225. 'Ϝ' => '�',
  43226. 'Ïž' => 'ÏŸ',
  43227. 'Ï ' => 'Ï¡',
  43228. 'Ï¢' => 'Ï£',
  43229. 'Ϥ' => 'ϥ',
  43230. 'Ϧ' => 'ϧ',
  43231. 'Ϩ' => 'ϩ',
  43232. 'Ϫ' => 'ϫ',
  43233. 'Ϭ' => 'ϭ',
  43234. 'Ϯ' => 'ϯ',
  43235. 'ϴ' => 'θ',
  43236. 'Ϸ' => 'ϸ',
  43237. 'Ϲ' => 'ϲ',
  43238. 'Ϻ' => 'ϻ',
  43239. 'Ͻ' => 'ͻ',
  43240. 'Ͼ' => 'ͼ',
  43241. 'Ͽ' => 'ͽ',
  43242. 'Ѐ' => '�',
  43243. '�' => 'ё',
  43244. 'Ђ' => 'ђ',
  43245. 'Ѓ' => 'ѓ',
  43246. 'Є' => 'є',
  43247. 'Ð…' => 'Ñ•',
  43248. 'І' => 'і',
  43249. 'Ї' => 'ї',
  43250. 'Ј' => 'ј',
  43251. 'Љ' => 'љ',
  43252. 'Њ' => 'њ',
  43253. 'Ћ' => 'ћ',
  43254. 'Ќ' => 'ќ',
  43255. '�' => '�',
  43256. 'ÐŽ' => 'Ñž',
  43257. '�' => 'џ',
  43258. '�' => 'а',
  43259. 'Б' => 'б',
  43260. 'В' => 'в',
  43261. 'Г' => 'г',
  43262. 'Д' => 'д',
  43263. 'Е' => 'е',
  43264. 'Ж' => 'ж',
  43265. 'З' => 'з',
  43266. 'И' => 'и',
  43267. 'Й' => 'й',
  43268. 'К' => 'к',
  43269. 'Л' => 'л',
  43270. 'М' => 'м',
  43271. '�' => 'н',
  43272. 'О' => 'о',
  43273. 'П' => 'п',
  43274. 'Р' => 'р',
  43275. 'С' => '�',
  43276. 'Т' => 'т',
  43277. 'У' => 'у',
  43278. 'Ф' => 'ф',
  43279. 'Ð¥' => 'Ñ…',
  43280. 'Ц' => 'ц',
  43281. 'Ч' => 'ч',
  43282. 'Ш' => 'ш',
  43283. 'Щ' => 'щ',
  43284. 'Ъ' => 'ъ',
  43285. 'Ы' => 'ы',
  43286. 'Ь' => 'ь',
  43287. 'Э' => '�',
  43288. 'Ю' => 'ю',
  43289. 'Я' => '�',
  43290. 'Ñ ' => 'Ñ¡',
  43291. 'Ñ¢' => 'Ñ£',
  43292. 'Ѥ' => 'ѥ',
  43293. 'Ѧ' => 'ѧ',
  43294. 'Ѩ' => 'ѩ',
  43295. 'Ѫ' => 'ѫ',
  43296. 'Ѭ' => 'ѭ',
  43297. 'Ѯ' => 'ѯ',
  43298. 'Ѱ' => 'ѱ',
  43299. 'Ѳ' => 'ѳ',
  43300. 'Ѵ' => 'ѵ',
  43301. 'Ѷ' => 'ѷ',
  43302. 'Ѹ' => 'ѹ',
  43303. 'Ѻ' => 'ѻ',
  43304. 'Ѽ' => 'ѽ',
  43305. 'Ѿ' => 'ѿ',
  43306. 'Ò€' => 'Ò�',
  43307. 'ÒŠ' => 'Ò‹',
  43308. 'Ҍ' => '�',
  43309. 'ÒŽ' => 'Ò�',
  43310. 'Ò�' => 'Ò‘',
  43311. 'Ò’' => 'Ò“',
  43312. 'Ò”' => 'Ò•',
  43313. 'Ò–' => 'Ò—',
  43314. 'Ò˜' => 'Ò™',
  43315. 'Òš' => 'Ò›',
  43316. 'Ҝ' => '�',
  43317. 'Òž' => 'ÒŸ',
  43318. 'Ò ' => 'Ò¡',
  43319. 'Ò¢' => 'Ò£',
  43320. 'Ò¤' => 'Ò¥',
  43321. 'Ò¦' => 'Ò§',
  43322. 'Ò¨' => 'Ò©',
  43323. 'Òª' => 'Ò«',
  43324. 'Ò¬' => 'Ò­',
  43325. 'Ò®' => 'Ò¯',
  43326. 'Ò°' => 'Ò±',
  43327. 'Ò²' => 'Ò³',
  43328. 'Ò´' => 'Òµ',
  43329. 'Ò¶' => 'Ò·',
  43330. 'Ò¸' => 'Ò¹',
  43331. 'Òº' => 'Ò»',
  43332. 'Ò¼' => 'Ò½',
  43333. 'Ò¾' => 'Ò¿',
  43334. 'Ó€' => 'Ó�',
  43335. 'Ó�' => 'Ó‚',
  43336. 'Óƒ' => 'Ó„',
  43337. 'Ó…' => 'Ó†',
  43338. 'Ó‡' => 'Óˆ',
  43339. 'Ó‰' => 'ÓŠ',
  43340. 'Ӌ' => 'ӌ',
  43341. 'Ó�' => 'ÓŽ',
  43342. 'Ó�' => 'Ó‘',
  43343. 'Ó’' => 'Ó“',
  43344. 'Ó”' => 'Ó•',
  43345. 'Ó–' => 'Ó—',
  43346. 'Ó˜' => 'Ó™',
  43347. 'Óš' => 'Ó›',
  43348. 'Ӝ' => '�',
  43349. 'Óž' => 'ÓŸ',
  43350. 'Ó ' => 'Ó¡',
  43351. 'Ó¢' => 'Ó£',
  43352. 'Ó¤' => 'Ó¥',
  43353. 'Ó¦' => 'Ó§',
  43354. 'Ó¨' => 'Ó©',
  43355. 'Óª' => 'Ó«',
  43356. 'Ó¬' => 'Ó­',
  43357. 'Ó®' => 'Ó¯',
  43358. 'Ó°' => 'Ó±',
  43359. 'Ó²' => 'Ó³',
  43360. 'Ó´' => 'Óµ',
  43361. 'Ó¶' => 'Ó·',
  43362. 'Ó¸' => 'Ó¹',
  43363. 'Óº' => 'Ó»',
  43364. 'Ó¼' => 'Ó½',
  43365. 'Ó¾' => 'Ó¿',
  43366. 'Ô€' => 'Ô�',
  43367. 'Ô‚' => 'Ôƒ',
  43368. 'Ô„' => 'Ô…',
  43369. 'Ô†' => 'Ô‡',
  43370. 'Ôˆ' => 'Ô‰',
  43371. 'ÔŠ' => 'Ô‹',
  43372. 'Ԍ' => '�',
  43373. 'ÔŽ' => 'Ô�',
  43374. 'Ô�' => 'Ô‘',
  43375. 'Ô’' => 'Ô“',
  43376. 'Ô”' => 'Ô•',
  43377. 'Ô–' => 'Ô—',
  43378. 'Ô˜' => 'Ô™',
  43379. 'Ôš' => 'Ô›',
  43380. 'Ԝ' => '�',
  43381. 'Ôž' => 'ÔŸ',
  43382. 'Ô ' => 'Ô¡',
  43383. 'Ô¢' => 'Ô£',
  43384. 'Ô¤' => 'Ô¥',
  43385. 'Ô¦' => 'Ô§',
  43386. 'Ô¨' => 'Ô©',
  43387. 'Ôª' => 'Ô«',
  43388. 'Ô¬' => 'Ô­',
  43389. 'Ô®' => 'Ô¯',
  43390. 'Ô±' => 'Õ¡',
  43391. 'Ô²' => 'Õ¢',
  43392. 'Ô³' => 'Õ£',
  43393. 'Ô´' => 'Õ¤',
  43394. 'Ôµ' => 'Õ¥',
  43395. 'Ô¶' => 'Õ¦',
  43396. 'Ô·' => 'Õ§',
  43397. 'Ô¸' => 'Õ¨',
  43398. 'Ô¹' => 'Õ©',
  43399. 'Ôº' => 'Õª',
  43400. 'Ô»' => 'Õ«',
  43401. 'Ô¼' => 'Õ¬',
  43402. 'Ô½' => 'Õ­',
  43403. 'Ô¾' => 'Õ®',
  43404. 'Ô¿' => 'Õ¯',
  43405. 'Õ€' => 'Õ°',
  43406. 'Õ�' => 'Õ±',
  43407. 'Õ‚' => 'Õ²',
  43408. 'Õƒ' => 'Õ³',
  43409. 'Õ„' => 'Õ´',
  43410. 'Õ…' => 'Õµ',
  43411. 'Õ†' => 'Õ¶',
  43412. 'Õ‡' => 'Õ·',
  43413. 'Õˆ' => 'Õ¸',
  43414. 'Õ‰' => 'Õ¹',
  43415. 'ÕŠ' => 'Õº',
  43416. 'Õ‹' => 'Õ»',
  43417. 'Ռ' => 'ռ',
  43418. 'Õ�' => 'Õ½',
  43419. 'ÕŽ' => 'Õ¾',
  43420. 'Õ�' => 'Õ¿',
  43421. 'Õ�' => 'Ö€',
  43422. 'Õ‘' => 'Ö�',
  43423. 'Õ’' => 'Ö‚',
  43424. 'Õ“' => 'Öƒ',
  43425. 'Õ”' => 'Ö„',
  43426. 'Õ•' => 'Ö…',
  43427. 'Õ–' => 'Ö†',
  43428. 'á‚ ' => 'â´€',
  43429. 'á‚¡' => 'â´�',
  43430. 'á‚¢' => 'â´‚',
  43431. 'á‚£' => 'â´ƒ',
  43432. 'Ⴄ' => 'ⴄ',
  43433. 'á‚¥' => 'â´…',
  43434. 'Ⴆ' => 'ⴆ',
  43435. 'á‚§' => 'â´‡',
  43436. 'Ⴈ' => 'ⴈ',
  43437. 'á‚©' => 'â´‰',
  43438. 'Ⴊ' => 'ⴊ',
  43439. 'á‚«' => 'â´‹',
  43440. 'Ⴌ' => 'ⴌ',
  43441. 'á‚­' => 'â´�',
  43442. 'á‚®' => 'â´Ž',
  43443. 'Ⴏ' => '�',
  43444. 'á‚°' => 'â´�',
  43445. 'Ⴑ' => 'ⴑ',
  43446. 'Ⴒ' => 'ⴒ',
  43447. 'Ⴓ' => 'ⴓ',
  43448. 'á‚´' => 'â´”',
  43449. 'Ⴕ' => 'ⴕ',
  43450. 'á‚¶' => 'â´–',
  43451. 'á‚·' => 'â´—',
  43452. 'Ⴘ' => 'ⴘ',
  43453. 'Ⴙ' => 'ⴙ',
  43454. 'Ⴚ' => 'ⴚ',
  43455. 'á‚»' => 'â´›',
  43456. 'Ⴜ' => 'ⴜ',
  43457. 'Ⴝ' => '�',
  43458. 'Ⴞ' => 'ⴞ',
  43459. 'á‚¿' => 'â´Ÿ',
  43460. 'Ⴠ' => 'ⴠ',
  43461. '�' => 'ⴡ',
  43462. 'Ⴢ' => 'ⴢ',
  43463. 'Ⴣ' => 'ⴣ',
  43464. 'Ⴤ' => 'ⴤ',
  43465. 'Ⴥ' => 'ⴥ',
  43466. 'Ⴧ' => 'ⴧ',
  43467. '�' => 'ⴭ',
  43468. 'Ḁ' => '�',
  43469. 'Ḃ' => 'ḃ',
  43470. 'Ḅ' => 'ḅ',
  43471. 'Ḇ' => 'ḇ',
  43472. 'Ḉ' => 'ḉ',
  43473. 'Ḋ' => 'ḋ',
  43474. 'Ḍ' => '�',
  43475. 'Ḏ' => '�',
  43476. '�' => 'ḑ',
  43477. 'Ḓ' => 'ḓ',
  43478. 'Ḕ' => 'ḕ',
  43479. 'Ḗ' => 'ḗ',
  43480. 'Ḙ' => 'ḙ',
  43481. 'Ḛ' => 'ḛ',
  43482. 'Ḝ' => '�',
  43483. 'Ḟ' => 'ḟ',
  43484. 'Ḡ' => 'ḡ',
  43485. 'Ḣ' => 'ḣ',
  43486. 'Ḥ' => 'ḥ',
  43487. 'Ḧ' => 'ḧ',
  43488. 'Ḩ' => 'ḩ',
  43489. 'Ḫ' => 'ḫ',
  43490. 'Ḭ' => 'ḭ',
  43491. 'Ḯ' => 'ḯ',
  43492. 'Ḱ' => 'ḱ',
  43493. 'Ḳ' => 'ḳ',
  43494. 'Ḵ' => 'ḵ',
  43495. 'Ḷ' => 'ḷ',
  43496. 'Ḹ' => 'ḹ',
  43497. 'Ḻ' => 'ḻ',
  43498. 'Ḽ' => 'ḽ',
  43499. 'Ḿ' => 'ḿ',
  43500. 'Ṁ' => '�',
  43501. 'Ṃ' => 'ṃ',
  43502. 'Ṅ' => 'ṅ',
  43503. 'Ṇ' => 'ṇ',
  43504. 'Ṉ' => 'ṉ',
  43505. 'Ṋ' => 'ṋ',
  43506. 'Ṍ' => '�',
  43507. 'Ṏ' => '�',
  43508. '�' => 'ṑ',
  43509. 'Ṓ' => 'ṓ',
  43510. 'Ṕ' => 'ṕ',
  43511. 'á¹–' => 'á¹—',
  43512. 'Ṙ' => 'ṙ',
  43513. 'Ṛ' => 'ṛ',
  43514. 'Ṝ' => '�',
  43515. 'Ṟ' => 'ṟ',
  43516. 'Ṡ' => 'ṡ',
  43517. 'á¹¢' => 'á¹£',
  43518. 'Ṥ' => 'ṥ',
  43519. 'Ṧ' => 'ṧ',
  43520. 'Ṩ' => 'ṩ',
  43521. 'Ṫ' => 'ṫ',
  43522. 'Ṭ' => 'ṭ',
  43523. 'Ṯ' => 'ṯ',
  43524. 'á¹°' => 'á¹±',
  43525. 'á¹²' => 'á¹³',
  43526. 'á¹´' => 'á¹µ',
  43527. 'á¹¶' => 'á¹·',
  43528. 'Ṹ' => 'ṹ',
  43529. 'Ṻ' => 'ṻ',
  43530. 'á¹¼' => 'á¹½',
  43531. 'Ṿ' => 'ṿ',
  43532. 'Ẁ' => '�',
  43533. 'Ẃ' => 'ẃ',
  43534. 'Ẅ' => 'ẅ',
  43535. 'Ẇ' => 'ẇ',
  43536. 'Ẉ' => 'ẉ',
  43537. 'Ẋ' => 'ẋ',
  43538. 'Ẍ' => '�',
  43539. 'Ẏ' => '�',
  43540. '�' => 'ẑ',
  43541. 'Ẓ' => 'ẓ',
  43542. 'Ẕ' => 'ẕ',
  43543. 'ẞ' => 'ß',
  43544. 'Ạ' => 'ạ',
  43545. 'Ả' => 'ả',
  43546. 'Ấ' => 'ấ',
  43547. 'Ầ' => 'ầ',
  43548. 'Ẩ' => 'ẩ',
  43549. 'Ẫ' => 'ẫ',
  43550. 'Ậ' => 'ậ',
  43551. 'Ắ' => 'ắ',
  43552. 'Ằ' => 'ằ',
  43553. 'Ẳ' => 'ẳ',
  43554. 'Ẵ' => 'ẵ',
  43555. 'Ặ' => 'ặ',
  43556. 'Ẹ' => 'ẹ',
  43557. 'Ẻ' => 'ẻ',
  43558. 'Ẽ' => 'ẽ',
  43559. 'Ế' => 'ế',
  43560. 'Ề' => '�',
  43561. 'Ể' => 'ể',
  43562. 'Ễ' => 'ễ',
  43563. 'Ệ' => 'ệ',
  43564. 'Ỉ' => 'ỉ',
  43565. 'Ị' => 'ị',
  43566. 'Ọ' => '�',
  43567. 'Ỏ' => '�',
  43568. '�' => 'ố',
  43569. 'Ồ' => 'ồ',
  43570. 'Ổ' => 'ổ',
  43571. 'á»–' => 'á»—',
  43572. 'Ộ' => 'ộ',
  43573. 'Ớ' => 'ớ',
  43574. 'Ờ' => '�',
  43575. 'Ở' => 'ở',
  43576. 'Ỡ' => 'ỡ',
  43577. 'Ợ' => 'ợ',
  43578. 'Ụ' => 'ụ',
  43579. 'Ủ' => 'ủ',
  43580. 'Ứ' => 'ứ',
  43581. 'Ừ' => 'ừ',
  43582. 'Ử' => 'ử',
  43583. 'Ữ' => 'ữ',
  43584. 'á»°' => 'á»±',
  43585. 'Ỳ' => 'ỳ',
  43586. 'Ỵ' => 'ỵ',
  43587. 'á»¶' => 'á»·',
  43588. 'Ỹ' => 'ỹ',
  43589. 'Ỻ' => 'ỻ',
  43590. 'Ỽ' => 'ỽ',
  43591. 'Ỿ' => 'ỿ',
  43592. 'Ἀ' => 'ἀ',
  43593. 'Ἁ' => '�',
  43594. 'Ἂ' => 'ἂ',
  43595. 'Ἃ' => 'ἃ',
  43596. 'Ἄ' => 'ἄ',
  43597. '�' => 'ἅ',
  43598. 'Ἆ' => 'ἆ',
  43599. '�' => 'ἇ',
  43600. 'Ἐ' => '�',
  43601. 'Ἑ' => 'ἑ',
  43602. 'Ἒ' => 'ἒ',
  43603. 'Ἓ' => 'ἓ',
  43604. 'Ἔ' => 'ἔ',
  43605. '�' => 'ἕ',
  43606. 'Ἠ' => 'ἠ',
  43607. 'Ἡ' => 'ἡ',
  43608. 'Ἢ' => 'ἢ',
  43609. 'Ἣ' => 'ἣ',
  43610. 'Ἤ' => 'ἤ',
  43611. 'á¼­' => 'á¼¥',
  43612. 'Ἦ' => 'ἦ',
  43613. 'Ἧ' => 'ἧ',
  43614. 'Ἰ' => 'ἰ',
  43615. 'á¼¹' => 'á¼±',
  43616. 'Ἲ' => 'ἲ',
  43617. 'á¼»' => 'á¼³',
  43618. 'á¼¼' => 'á¼´',
  43619. 'á¼½' => 'á¼µ',
  43620. 'á¼¾' => 'á¼¶',
  43621. 'Ἷ' => 'ἷ',
  43622. 'Ὀ' => 'ὀ',
  43623. 'Ὁ' => '�',
  43624. 'Ὂ' => 'ὂ',
  43625. 'Ὃ' => 'ὃ',
  43626. 'Ὄ' => 'ὄ',
  43627. '�' => 'ὅ',
  43628. 'Ὑ' => 'ὑ',
  43629. 'Ὓ' => 'ὓ',
  43630. '�' => 'ὕ',
  43631. 'Ὗ' => 'ὗ',
  43632. 'Ὠ' => 'ὠ',
  43633. 'Ὡ' => 'ὡ',
  43634. 'Ὢ' => 'ὢ',
  43635. 'Ὣ' => 'ὣ',
  43636. 'Ὤ' => 'ὤ',
  43637. 'á½­' => 'á½¥',
  43638. 'Ὦ' => 'ὦ',
  43639. 'Ὧ' => 'ὧ',
  43640. 'ᾈ' => 'ᾀ',
  43641. 'ᾉ' => '�',
  43642. 'ᾊ' => 'ᾂ',
  43643. 'ᾋ' => 'ᾃ',
  43644. 'ᾌ' => 'ᾄ',
  43645. '�' => 'ᾅ',
  43646. 'ᾎ' => 'ᾆ',
  43647. '�' => 'ᾇ',
  43648. 'ᾘ' => '�',
  43649. 'ᾙ' => 'ᾑ',
  43650. 'ᾚ' => 'ᾒ',
  43651. 'ᾛ' => 'ᾓ',
  43652. 'ᾜ' => 'ᾔ',
  43653. '�' => 'ᾕ',
  43654. 'ᾞ' => 'ᾖ',
  43655. 'ᾟ' => 'ᾗ',
  43656. 'ᾨ' => 'ᾠ',
  43657. 'ᾩ' => 'ᾡ',
  43658. 'ᾪ' => 'ᾢ',
  43659. 'ᾫ' => 'ᾣ',
  43660. 'ᾬ' => 'ᾤ',
  43661. 'á¾­' => 'á¾¥',
  43662. 'ᾮ' => 'ᾦ',
  43663. 'ᾯ' => 'ᾧ',
  43664. 'Ᾰ' => 'ᾰ',
  43665. 'á¾¹' => 'á¾±',
  43666. 'Ὰ' => 'ὰ',
  43667. 'á¾»' => 'á½±',
  43668. 'á¾¼' => 'á¾³',
  43669. 'Ὲ' => 'ὲ',
  43670. 'Έ' => 'έ',
  43671. 'Ὴ' => 'ὴ',
  43672. 'á¿‹' => 'á½µ',
  43673. 'ῌ' => 'ῃ',
  43674. 'Ῐ' => '�',
  43675. 'á¿™' => 'á¿‘',
  43676. 'Ὶ' => 'ὶ',
  43677. 'á¿›' => 'á½·',
  43678. 'Ῠ' => 'ῠ',
  43679. 'á¿©' => 'á¿¡',
  43680. 'Ὺ' => 'ὺ',
  43681. 'á¿«' => 'á½»',
  43682. 'Ῥ' => 'ῥ',
  43683. 'Ὸ' => 'ὸ',
  43684. 'Ό' => 'ό',
  43685. 'Ὼ' => 'ὼ',
  43686. 'á¿»' => 'á½½',
  43687. 'ῼ' => 'ῳ',
  43688. 'Ω' => 'ω',
  43689. 'K' => 'k',
  43690. 'â„«' => 'Ã¥',
  43691. 'Ⅎ' => 'ⅎ',
  43692. 'â… ' => 'â…°',
  43693. 'â…¡' => 'â…±',
  43694. 'â…¢' => 'â…²',
  43695. 'â…£' => 'â…³',
  43696. 'â…¤' => 'â…´',
  43697. 'â…¥' => 'â…µ',
  43698. 'â…¦' => 'â…¶',
  43699. 'â…§' => 'â…·',
  43700. 'â…¨' => 'â…¸',
  43701. 'â…©' => 'â…¹',
  43702. 'â…ª' => 'â…º',
  43703. 'â…«' => 'â…»',
  43704. 'â…¬' => 'â…¼',
  43705. 'â…­' => 'â…½',
  43706. 'â…®' => 'â…¾',
  43707. 'â…¯' => 'â…¿',
  43708. 'Ↄ' => 'ↄ',
  43709. 'Ⓐ' => '�',
  43710. 'â’·' => 'â“‘',
  43711. 'â’¸' => 'â“’',
  43712. 'â’¹' => 'â““',
  43713. 'â’º' => 'â“”',
  43714. 'â’»' => 'â“•',
  43715. 'â’¼' => 'â“–',
  43716. 'â’½' => 'â“—',
  43717. 'Ⓘ' => 'ⓘ',
  43718. 'â’¿' => 'â“™',
  43719. 'Ⓚ' => 'ⓚ',
  43720. '�' => 'ⓛ',
  43721. 'Ⓜ' => 'ⓜ',
  43722. 'Ⓝ' => '�',
  43723. 'Ⓞ' => 'ⓞ',
  43724. 'Ⓟ' => 'ⓟ',
  43725. 'Ⓠ' => 'ⓠ',
  43726. 'Ⓡ' => 'ⓡ',
  43727. 'Ⓢ' => 'ⓢ',
  43728. 'Ⓣ' => 'ⓣ',
  43729. 'Ⓤ' => 'ⓤ',
  43730. 'â“‹' => 'â“¥',
  43731. 'Ⓦ' => 'ⓦ',
  43732. '�' => 'ⓧ',
  43733. 'Ⓨ' => 'ⓨ',
  43734. '�' => 'ⓩ',
  43735. 'â°€' => 'â°°',
  43736. 'â°�' => 'â°±',
  43737. 'â°‚' => 'â°²',
  43738. 'â°ƒ' => 'â°³',
  43739. 'â°„' => 'â°´',
  43740. 'â°…' => 'â°µ',
  43741. 'â°†' => 'â°¶',
  43742. 'â°‡' => 'â°·',
  43743. 'â°ˆ' => 'â°¸',
  43744. 'â°‰' => 'â°¹',
  43745. 'â°Š' => 'â°º',
  43746. 'â°‹' => 'â°»',
  43747. 'Ⰼ' => 'ⰼ',
  43748. 'â°�' => 'â°½',
  43749. 'â°Ž' => 'â°¾',
  43750. 'â°�' => 'â°¿',
  43751. 'â°�' => 'â±€',
  43752. 'Ⱁ' => '�',
  43753. 'Ⱂ' => 'ⱂ',
  43754. 'Ⱃ' => 'ⱃ',
  43755. 'Ⱄ' => 'ⱄ',
  43756. 'â°•' => 'â±…',
  43757. 'Ⱆ' => 'ⱆ',
  43758. 'Ⱇ' => 'ⱇ',
  43759. 'Ⱈ' => 'ⱈ',
  43760. 'Ⱉ' => 'ⱉ',
  43761. 'Ⱊ' => 'ⱊ',
  43762. 'Ⱋ' => 'ⱋ',
  43763. 'Ⱌ' => 'ⱌ',
  43764. '�' => '�',
  43765. 'Ⱎ' => 'ⱎ',
  43766. 'Ⱏ' => '�',
  43767. 'Ⱐ' => '�',
  43768. 'Ⱑ' => 'ⱑ',
  43769. 'â°¢' => 'â±’',
  43770. 'Ⱓ' => 'ⱓ',
  43771. 'â°¤' => 'â±”',
  43772. 'Ⱕ' => 'ⱕ',
  43773. 'â°¦' => 'â±–',
  43774. 'â°§' => 'â±—',
  43775. 'Ⱘ' => 'ⱘ',
  43776. 'â°©' => 'â±™',
  43777. 'Ⱚ' => 'ⱚ',
  43778. 'â°«' => 'â±›',
  43779. 'Ⱜ' => 'ⱜ',
  43780. 'Ⱝ' => '�',
  43781. 'Ⱞ' => 'ⱞ',
  43782. 'Ⱡ' => 'ⱡ',
  43783. 'â±¢' => 'É«',
  43784. 'â±£' => 'áµ½',
  43785. 'Ɽ' => 'ɽ',
  43786. 'Ⱨ' => 'ⱨ',
  43787. 'Ⱪ' => 'ⱪ',
  43788. 'Ⱬ' => 'ⱬ',
  43789. 'â±­' => 'É‘',
  43790. 'Ɱ' => 'ɱ',
  43791. 'Ɐ' => '�',
  43792. 'â±°' => 'É’',
  43793. 'â±²' => 'â±³',
  43794. 'â±µ' => 'â±¶',
  43795. 'â±¾' => 'È¿',
  43796. 'Ɀ' => 'ɀ',
  43797. 'Ⲁ' => '�',
  43798. 'Ⲃ' => 'ⲃ',
  43799. 'Ⲅ' => 'ⲅ',
  43800. 'Ⲇ' => 'ⲇ',
  43801. 'Ⲉ' => 'ⲉ',
  43802. 'Ⲋ' => 'ⲋ',
  43803. 'Ⲍ' => '�',
  43804. 'Ⲏ' => '�',
  43805. '�' => 'ⲑ',
  43806. 'Ⲓ' => 'ⲓ',
  43807. 'Ⲕ' => 'ⲕ',
  43808. 'â²–' => 'â²—',
  43809. 'Ⲙ' => 'ⲙ',
  43810. 'Ⲛ' => 'ⲛ',
  43811. 'Ⲝ' => '�',
  43812. 'Ⲟ' => 'ⲟ',
  43813. 'Ⲡ' => 'ⲡ',
  43814. 'â²¢' => 'â²£',
  43815. 'Ⲥ' => 'ⲥ',
  43816. 'Ⲧ' => 'ⲧ',
  43817. 'Ⲩ' => 'ⲩ',
  43818. 'Ⲫ' => 'ⲫ',
  43819. 'Ⲭ' => 'ⲭ',
  43820. 'Ⲯ' => 'ⲯ',
  43821. 'â²°' => 'â²±',
  43822. 'â²²' => 'â²³',
  43823. 'â²´' => 'â²µ',
  43824. 'â²¶' => 'â²·',
  43825. 'Ⲹ' => 'ⲹ',
  43826. 'Ⲻ' => 'ⲻ',
  43827. 'â²¼' => 'â²½',
  43828. 'Ⲿ' => 'ⲿ',
  43829. 'Ⳁ' => '�',
  43830. 'Ⳃ' => 'ⳃ',
  43831. 'Ⳅ' => 'ⳅ',
  43832. 'Ⳇ' => 'ⳇ',
  43833. 'Ⳉ' => 'ⳉ',
  43834. 'Ⳋ' => 'ⳋ',
  43835. 'Ⳍ' => '�',
  43836. 'Ⳏ' => '�',
  43837. '�' => 'ⳑ',
  43838. 'Ⳓ' => 'ⳓ',
  43839. 'Ⳕ' => 'ⳕ',
  43840. 'â³–' => 'â³—',
  43841. 'Ⳙ' => 'ⳙ',
  43842. 'Ⳛ' => 'ⳛ',
  43843. 'Ⳝ' => '�',
  43844. 'Ⳟ' => 'ⳟ',
  43845. 'Ⳡ' => 'ⳡ',
  43846. 'â³¢' => 'â³£',
  43847. 'Ⳬ' => 'ⳬ',
  43848. 'â³­' => 'â³®',
  43849. 'â³²' => 'â³³',
  43850. 'Ꙁ' => '�',
  43851. 'Ꙃ' => 'ꙃ',
  43852. 'Ꙅ' => 'ꙅ',
  43853. 'Ꙇ' => 'ꙇ',
  43854. 'Ꙉ' => 'ꙉ',
  43855. 'Ꙋ' => 'ꙋ',
  43856. 'Ꙍ' => '�',
  43857. 'Ꙏ' => '�',
  43858. '�' => 'ꙑ',
  43859. 'Ꙓ' => 'ꙓ',
  43860. 'Ꙕ' => 'ꙕ',
  43861. 'ê™–' => 'ê™—',
  43862. 'Ꙙ' => 'ꙙ',
  43863. 'Ꙛ' => 'ꙛ',
  43864. 'Ꙝ' => '�',
  43865. 'Ꙟ' => 'ꙟ',
  43866. 'Ꙡ' => 'ꙡ',
  43867. 'Ꙣ' => 'ꙣ',
  43868. 'Ꙥ' => 'ꙥ',
  43869. 'Ꙧ' => 'ꙧ',
  43870. 'Ꙩ' => 'ꙩ',
  43871. 'Ꙫ' => 'ꙫ',
  43872. 'Ꙭ' => 'ꙭ',
  43873. 'Ꚁ' => '�',
  43874. 'Ꚃ' => 'ꚃ',
  43875. 'êš„' => 'êš…',
  43876. 'Ꚇ' => 'ꚇ',
  43877. 'Ꚉ' => 'ꚉ',
  43878. 'Ꚋ' => 'ꚋ',
  43879. 'Ꚍ' => '�',
  43880. 'Ꚏ' => '�',
  43881. '�' => 'ꚑ',
  43882. 'êš’' => 'êš“',
  43883. 'êš”' => 'êš•',
  43884. 'êš–' => 'êš—',
  43885. 'Ꚙ' => 'ꚙ',
  43886. 'êšš' => 'êš›',
  43887. 'Ꜣ' => 'ꜣ',
  43888. 'Ꜥ' => 'ꜥ',
  43889. 'Ꜧ' => 'ꜧ',
  43890. 'Ꜩ' => 'ꜩ',
  43891. 'Ꜫ' => 'ꜫ',
  43892. 'Ꜭ' => 'ꜭ',
  43893. 'Ꜯ' => 'ꜯ',
  43894. 'Ꜳ' => 'ꜳ',
  43895. 'Ꜵ' => 'ꜵ',
  43896. 'Ꜷ' => 'ꜷ',
  43897. 'Ꜹ' => 'ꜹ',
  43898. 'Ꜻ' => 'ꜻ',
  43899. 'Ꜽ' => 'ꜽ',
  43900. 'Ꜿ' => 'ꜿ',
  43901. '�' => '�',
  43902. '�' => '�',
  43903. '�' => '�',
  43904. '�' => '�',
  43905. '�' => '�',
  43906. '�' => '�',
  43907. '�' => '�',
  43908. '�' => '�',
  43909. '�' => '�',
  43910. '�' => '�',
  43911. '�' => '�',
  43912. '�' => '�',
  43913. '�' => '�',
  43914. '�' => '�',
  43915. '�' => '�',
  43916. '�' => '�',
  43917. '�' => '�',
  43918. '�' => '�',
  43919. '�' => '�',
  43920. '�' => '�',
  43921. '�' => '�',
  43922. '�' => '�',
  43923. '�' => '�',
  43924. '�' => '�',
  43925. '�' => '�',
  43926. '�' => '�',
  43927. '�' => 'ᵹ',
  43928. '�' => '�',
  43929. 'Ꞁ' => '�',
  43930. 'Ꞃ' => 'ꞃ',
  43931. 'êž„' => 'êž…',
  43932. 'Ꞇ' => 'ꞇ',
  43933. 'Ꞌ' => 'ꞌ',
  43934. '�' => 'ɥ',
  43935. '�' => 'ꞑ',
  43936. 'êž’' => 'êž“',
  43937. 'êž–' => 'êž—',
  43938. 'Ꞙ' => 'ꞙ',
  43939. 'êžš' => 'êž›',
  43940. 'Ꞝ' => '�',
  43941. 'Ꞟ' => 'ꞟ',
  43942. 'êž ' => 'êž¡',
  43943. 'Ꞣ' => 'ꞣ',
  43944. 'Ꞥ' => 'ꞥ',
  43945. 'Ꞧ' => 'ꞧ',
  43946. 'Ꞩ' => 'ꞩ',
  43947. 'Ɦ' => 'ɦ',
  43948. 'Ɜ' => 'ɜ',
  43949. 'Ɡ' => 'ɡ',
  43950. 'Ɬ' => 'ɬ',
  43951. 'êž°' => 'Êž',
  43952. 'Ʇ' => 'ʇ',
  43953. 'A' => '�',
  43954. 'B' => 'b',
  43955. 'C' => 'c',
  43956. 'D' => 'd',
  43957. 'ï¼¥' => 'ï½…',
  43958. 'F' => 'f',
  43959. 'G' => 'g',
  43960. 'H' => 'h',
  43961. 'I' => 'i',
  43962. 'J' => 'j',
  43963. 'K' => 'k',
  43964. 'L' => 'l',
  43965. 'M' => '�',
  43966. 'N' => 'n',
  43967. 'O' => '�',
  43968. 'P' => '�',
  43969. 'Q' => 'q',
  43970. 'ï¼²' => 'ï½’',
  43971. 'S' => 's',
  43972. 'ï¼´' => 'ï½”',
  43973. 'U' => 'u',
  43974. 'ï¼¶' => 'ï½–',
  43975. 'ï¼·' => 'ï½—',
  43976. 'X' => 'x',
  43977. 'ï¼¹' => 'ï½™',
  43978. 'Z' => 'z',
  43979. '�' => '�',
  43980. '�' => '�',
  43981. '�' => '�',
  43982. '�' => '�',
  43983. '�' => '�',
  43984. '�' => '�',
  43985. '�' => '�',
  43986. '�' => '�',
  43987. '�' => '�',
  43988. '�' => '�',
  43989. '�' => '�',
  43990. '�' => '�',
  43991. '�' => '�',
  43992. '�' => '�',
  43993. '�' => '�',
  43994. '�' => '�',
  43995. '�' => '�',
  43996. '�' => '�',
  43997. '�' => '�',
  43998. '�' => '�',
  43999. '�' => '�',
  44000. '�' => '�',
  44001. '�' => '�',
  44002. '�' => '�',
  44003. '�' => '�',
  44004. '�' => '�',
  44005. '�' => '�',
  44006. '�' => '�',
  44007. '�' => '�',
  44008. '�' => '�',
  44009. '�' => '�',
  44010. '�' => '�',
  44011. '�' => '�',
  44012. '�' => '�',
  44013. '�' => '�',
  44014. '�' => '�',
  44015. '�' => '�',
  44016. '�' => '�',
  44017. '�' => '�',
  44018. '�' => '�',
  44019. 'ð‘¢ ' => 'ð‘£€',
  44020. '𑢡' => '�',
  44021. '𑢢' => '𑣂',
  44022. '𑢣' => '𑣃',
  44023. '𑢤' => '𑣄',
  44024. 'ð‘¢¥' => 'ð‘£…',
  44025. '𑢦' => '𑣆',
  44026. '𑢧' => '𑣇',
  44027. '𑢨' => '𑣈',
  44028. '𑢩' => '𑣉',
  44029. '𑢪' => '𑣊',
  44030. '𑢫' => '𑣋',
  44031. '𑢬' => '𑣌',
  44032. '𑢭' => '�',
  44033. '𑢮' => '𑣎',
  44034. '𑢯' => '�',
  44035. '𑢰' => '�',
  44036. '𑢱' => '𑣑',
  44037. 'ð‘¢²' => 'ð‘£’',
  44038. '𑢳' => '𑣓',
  44039. 'ð‘¢´' => 'ð‘£”',
  44040. '𑢵' => '𑣕',
  44041. 'ð‘¢¶' => 'ð‘£–',
  44042. 'ð‘¢·' => 'ð‘£—',
  44043. '𑢸' => '𑣘',
  44044. 'ð‘¢¹' => 'ð‘£™',
  44045. '𑢺' => '𑣚',
  44046. 'ð‘¢»' => 'ð‘£›',
  44047. '𑢼' => '𑣜',
  44048. '𑢽' => '�',
  44049. '𑢾' => '𑣞',
  44050. '𑢿' => '𑣟',
  44051. );
  44052. <?php
  44053. 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';
  44054. <?php
  44055. return array(
  44056. 'a' => 'A',
  44057. 'b' => 'B',
  44058. 'c' => 'C',
  44059. 'd' => 'D',
  44060. 'e' => 'E',
  44061. 'f' => 'F',
  44062. 'g' => 'G',
  44063. 'h' => 'H',
  44064. 'i' => 'I',
  44065. 'j' => 'J',
  44066. 'k' => 'K',
  44067. 'l' => 'L',
  44068. 'm' => 'M',
  44069. 'n' => 'N',
  44070. 'o' => 'O',
  44071. 'p' => 'P',
  44072. 'q' => 'Q',
  44073. 'r' => 'R',
  44074. 's' => 'S',
  44075. 't' => 'T',
  44076. 'u' => 'U',
  44077. 'v' => 'V',
  44078. 'w' => 'W',
  44079. 'x' => 'X',
  44080. 'y' => 'Y',
  44081. 'z' => 'Z',
  44082. 'µ' => 'Μ',
  44083. 'à' => 'À',
  44084. 'á' => '�',
  44085. 'â' => 'Â',
  44086. 'ã' => 'Ã',
  44087. 'ä' => 'Ä',
  44088. 'Ã¥' => 'Ã…',
  44089. 'æ' => 'Æ',
  44090. 'ç' => 'Ç',
  44091. 'è' => 'È',
  44092. 'é' => 'É',
  44093. 'ê' => 'Ê',
  44094. 'ë' => 'Ë',
  44095. 'ì' => 'Ì',
  44096. 'í' => '�',
  44097. 'î' => 'Î',
  44098. 'ï' => '�',
  44099. 'ð' => '�',
  44100. 'ñ' => 'Ñ',
  44101. 'ò' => 'Ò',
  44102. 'ó' => 'Ó',
  44103. 'ô' => 'Ô',
  44104. 'õ' => 'Õ',
  44105. 'ö' => 'Ö',
  44106. 'ø' => 'Ø',
  44107. 'ù' => 'Ù',
  44108. 'ú' => 'Ú',
  44109. 'û' => 'Û',
  44110. 'ü' => 'Ü',
  44111. 'ý' => '�',
  44112. 'þ' => 'Þ',
  44113. 'ÿ' => 'Ÿ',
  44114. '�' => 'Ā',
  44115. 'ă' => 'Ă',
  44116. 'Ä…' => 'Ä„',
  44117. 'ć' => 'Ć',
  44118. 'ĉ' => 'Ĉ',
  44119. 'Ä‹' => 'ÄŠ',
  44120. '�' => 'Č',
  44121. '�' => 'Ď',
  44122. 'đ' => '�',
  44123. 'Ä“' => 'Ä’',
  44124. 'Ä•' => 'Ä”',
  44125. 'Ä—' => 'Ä–',
  44126. 'ę' => 'Ę',
  44127. 'Ä›' => 'Äš',
  44128. '�' => 'Ĝ',
  44129. 'ÄŸ' => 'Äž',
  44130. 'Ä¡' => 'Ä ',
  44131. 'Ä£' => 'Ä¢',
  44132. 'ĥ' => 'Ĥ',
  44133. 'ħ' => 'Ħ',
  44134. 'ĩ' => 'Ĩ',
  44135. 'ī' => 'Ī',
  44136. 'ĭ' => 'Ĭ',
  44137. 'į' => 'Į',
  44138. 'ı' => 'I',
  44139. 'ij' => 'IJ',
  44140. 'ĵ' => 'Ĵ',
  44141. 'ķ' => 'Ķ',
  44142. 'ĺ' => 'Ĺ',
  44143. 'ļ' => 'Ļ',
  44144. 'ľ' => 'Ľ',
  44145. 'Å€' => 'Ä¿',
  44146. 'ł' => '�',
  44147. 'ń' => 'Ń',
  44148. 'ņ' => 'Ņ',
  44149. 'ň' => 'Ň',
  44150. 'Å‹' => 'ÅŠ',
  44151. '�' => 'Ō',
  44152. '�' => 'Ŏ',
  44153. 'ő' => '�',
  44154. 'Å“' => 'Å’',
  44155. 'Å•' => 'Å”',
  44156. 'Å—' => 'Å–',
  44157. 'ř' => 'Ř',
  44158. 'Å›' => 'Åš',
  44159. '�' => 'Ŝ',
  44160. 'ÅŸ' => 'Åž',
  44161. 'Å¡' => 'Å ',
  44162. 'Å£' => 'Å¢',
  44163. 'ť' => 'Ť',
  44164. 'ŧ' => 'Ŧ',
  44165. 'ũ' => 'Ũ',
  44166. 'ū' => 'Ū',
  44167. 'ŭ' => 'Ŭ',
  44168. 'ů' => 'Ů',
  44169. 'ű' => 'Ű',
  44170. 'ų' => 'Ų',
  44171. 'ŵ' => 'Ŵ',
  44172. 'ŷ' => 'Ŷ',
  44173. 'ź' => 'Ź',
  44174. 'ż' => 'Ż',
  44175. 'ž' => 'Ž',
  44176. 'Å¿' => 'S',
  44177. 'ƀ' => 'Ƀ',
  44178. 'ƃ' => 'Ƃ',
  44179. 'Æ…' => 'Æ„',
  44180. 'ƈ' => 'Ƈ',
  44181. 'ƌ' => 'Ƌ',
  44182. 'Æ’' => 'Æ‘',
  44183. 'ƕ' => 'Ƕ',
  44184. 'ƙ' => 'Ƙ',
  44185. 'ƚ' => 'Ƚ',
  44186. 'Æž' => 'È ',
  44187. 'Æ¡' => 'Æ ',
  44188. 'Æ£' => 'Æ¢',
  44189. 'ƥ' => 'Ƥ',
  44190. 'ƨ' => 'Ƨ',
  44191. 'ƭ' => 'Ƭ',
  44192. 'ư' => 'Ư',
  44193. 'ƴ' => 'Ƴ',
  44194. 'ƶ' => 'Ƶ',
  44195. 'ƹ' => 'Ƹ',
  44196. 'ƽ' => 'Ƽ',
  44197. 'Æ¿' => 'Ç·',
  44198. 'Ç…' => 'Ç„',
  44199. 'dž' => 'DŽ',
  44200. 'Lj' => 'LJ',
  44201. 'lj' => 'LJ',
  44202. 'Ç‹' => 'ÇŠ',
  44203. 'nj' => 'NJ',
  44204. 'ǎ' => '�',
  44205. '�' => '�',
  44206. 'Ç’' => 'Ç‘',
  44207. 'Ç”' => 'Ç“',
  44208. 'Ç–' => 'Ç•',
  44209. 'ǘ' => 'Ǘ',
  44210. 'Çš' => 'Ç™',
  44211. 'ǜ' => 'Ǜ',
  44212. '�' => 'Ǝ',
  44213. 'ÇŸ' => 'Çž',
  44214. 'Ç¡' => 'Ç ',
  44215. 'Ç£' => 'Ç¢',
  44216. 'ǥ' => 'Ǥ',
  44217. 'ǧ' => 'Ǧ',
  44218. 'ǩ' => 'Ǩ',
  44219. 'ǫ' => 'Ǫ',
  44220. 'ǭ' => 'Ǭ',
  44221. 'ǯ' => 'Ǯ',
  44222. 'Dz' => 'DZ',
  44223. 'dz' => 'DZ',
  44224. 'ǵ' => 'Ǵ',
  44225. 'ǹ' => 'Ǹ',
  44226. 'ǻ' => 'Ǻ',
  44227. 'ǽ' => 'Ǽ',
  44228. 'ǿ' => 'Ǿ',
  44229. '�' => 'Ȁ',
  44230. 'ȃ' => 'Ȃ',
  44231. 'È…' => 'È„',
  44232. 'ȇ' => 'Ȇ',
  44233. 'ȉ' => 'Ȉ',
  44234. 'È‹' => 'ÈŠ',
  44235. '�' => 'Ȍ',
  44236. '�' => 'Ȏ',
  44237. 'ȑ' => '�',
  44238. 'È“' => 'È’',
  44239. 'È•' => 'È”',
  44240. 'È—' => 'È–',
  44241. 'ș' => 'Ș',
  44242. 'È›' => 'Èš',
  44243. '�' => 'Ȝ',
  44244. 'ÈŸ' => 'Èž',
  44245. 'È£' => 'È¢',
  44246. 'ȥ' => 'Ȥ',
  44247. 'ȧ' => 'Ȧ',
  44248. 'ȩ' => 'Ȩ',
  44249. 'ȫ' => 'Ȫ',
  44250. 'ȭ' => 'Ȭ',
  44251. 'ȯ' => 'Ȯ',
  44252. 'ȱ' => 'Ȱ',
  44253. 'ȳ' => 'Ȳ',
  44254. 'ȼ' => 'Ȼ',
  44255. 'È¿' => 'â±¾',
  44256. 'ɀ' => 'Ɀ',
  44257. 'ɂ' => '�',
  44258. 'ɇ' => 'Ɇ',
  44259. 'ɉ' => 'Ɉ',
  44260. 'É‹' => 'ÉŠ',
  44261. '�' => 'Ɍ',
  44262. '�' => 'Ɏ',
  44263. '�' => 'Ɐ',
  44264. 'É‘' => 'â±­',
  44265. 'É’' => 'â±°',
  44266. 'ɓ' => '�',
  44267. 'ɔ' => 'Ɔ',
  44268. 'ɖ' => 'Ɖ',
  44269. 'É—' => 'ÆŠ',
  44270. 'ə' => '�',
  44271. 'ɛ' => '�',
  44272. 'ɜ' => 'Ɜ',
  44273. 'É ' => 'Æ“',
  44274. 'ɡ' => 'Ɡ',
  44275. 'É£' => 'Æ”',
  44276. 'ɥ' => '�',
  44277. 'ɦ' => 'Ɦ',
  44278. 'ɨ' => 'Ɨ',
  44279. 'É©' => 'Æ–',
  44280. 'É«' => 'â±¢',
  44281. 'ɬ' => 'Ɬ',
  44282. 'ɯ' => 'Ɯ',
  44283. 'ɱ' => 'Ɱ',
  44284. 'ɲ' => '�',
  44285. 'ɵ' => 'Ɵ',
  44286. 'ɽ' => 'Ɽ',
  44287. 'ʀ' => 'Ʀ',
  44288. 'ʃ' => 'Ʃ',
  44289. 'ʇ' => 'Ʇ',
  44290. 'ʈ' => 'Ʈ',
  44291. 'ʉ' => 'Ʉ',
  44292. 'ʊ' => 'Ʊ',
  44293. 'ʋ' => 'Ʋ',
  44294. 'ʌ' => 'Ʌ',
  44295. 'Ê’' => 'Æ·',
  44296. 'Êž' => 'êž°',
  44297. 'ͅ' => 'Ι',
  44298. 'ͱ' => 'Ͱ',
  44299. 'ͳ' => 'Ͳ',
  44300. 'ͷ' => 'Ͷ',
  44301. 'ͻ' => 'Ͻ',
  44302. 'ͼ' => 'Ͼ',
  44303. 'ͽ' => 'Ͽ',
  44304. 'ά' => 'Ά',
  44305. 'έ' => 'Έ',
  44306. 'ή' => 'Ή',
  44307. 'ί' => 'Ί',
  44308. 'α' => 'Α',
  44309. 'β' => 'Β',
  44310. 'γ' => 'Γ',
  44311. 'δ' => 'Δ',
  44312. 'ε' => 'Ε',
  44313. 'ζ' => 'Ζ',
  44314. 'η' => 'Η',
  44315. 'θ' => 'Θ',
  44316. 'ι' => 'Ι',
  44317. 'κ' => 'Κ',
  44318. 'λ' => 'Λ',
  44319. 'μ' => 'Μ',
  44320. 'ν' => '�',
  44321. 'ξ' => 'Ξ',
  44322. 'ο' => 'Ο',
  44323. 'π' => 'Π',
  44324. '�' => 'Ρ',
  44325. 'ς' => 'Σ',
  44326. 'σ' => 'Σ',
  44327. 'τ' => 'Τ',
  44328. 'Ï…' => 'Î¥',
  44329. 'φ' => 'Φ',
  44330. 'χ' => 'Χ',
  44331. 'ψ' => 'Ψ',
  44332. 'ω' => 'Ω',
  44333. 'ϊ' => 'Ϊ',
  44334. 'ϋ' => 'Ϋ',
  44335. 'ό' => 'Ό',
  44336. '�' => 'Ύ',
  44337. 'ώ' => '�',
  44338. '�' => 'Β',
  44339. 'ϑ' => 'Θ',
  44340. 'ϕ' => 'Φ',
  44341. 'ϖ' => 'Π',
  44342. 'ϗ' => '�',
  44343. 'ϙ' => 'Ϙ',
  44344. 'Ï›' => 'Ïš',
  44345. '�' => 'Ϝ',
  44346. 'ÏŸ' => 'Ïž',
  44347. 'Ï¡' => 'Ï ',
  44348. 'Ï£' => 'Ï¢',
  44349. 'ϥ' => 'Ϥ',
  44350. 'ϧ' => 'Ϧ',
  44351. 'ϩ' => 'Ϩ',
  44352. 'ϫ' => 'Ϫ',
  44353. 'ϭ' => 'Ϭ',
  44354. 'ϯ' => 'Ϯ',
  44355. 'ϰ' => 'Κ',
  44356. 'ϱ' => 'Ρ',
  44357. 'ϲ' => 'Ϲ',
  44358. 'ϳ' => 'Ϳ',
  44359. 'ϵ' => 'Ε',
  44360. 'ϸ' => 'Ϸ',
  44361. 'ϻ' => 'Ϻ',
  44362. 'а' => '�',
  44363. 'б' => 'Б',
  44364. 'в' => 'В',
  44365. 'г' => 'Г',
  44366. 'д' => 'Д',
  44367. 'е' => 'Е',
  44368. 'ж' => 'Ж',
  44369. 'з' => 'З',
  44370. 'и' => 'И',
  44371. 'й' => 'Й',
  44372. 'к' => 'К',
  44373. 'л' => 'Л',
  44374. 'м' => 'М',
  44375. 'н' => '�',
  44376. 'о' => 'О',
  44377. 'п' => 'П',
  44378. 'р' => 'Р',
  44379. '�' => 'С',
  44380. 'т' => 'Т',
  44381. 'у' => 'У',
  44382. 'ф' => 'Ф',
  44383. 'Ñ…' => 'Ð¥',
  44384. 'ц' => 'Ц',
  44385. 'ч' => 'Ч',
  44386. 'ш' => 'Ш',
  44387. 'щ' => 'Щ',
  44388. 'ъ' => 'Ъ',
  44389. 'ы' => 'Ы',
  44390. 'ь' => 'Ь',
  44391. '�' => 'Э',
  44392. 'ю' => 'Ю',
  44393. '�' => 'Я',
  44394. '�' => 'Ѐ',
  44395. 'ё' => '�',
  44396. 'ђ' => 'Ђ',
  44397. 'ѓ' => 'Ѓ',
  44398. 'є' => 'Є',
  44399. 'Ñ•' => 'Ð…',
  44400. 'і' => 'І',
  44401. 'ї' => 'Ї',
  44402. 'ј' => 'Ј',
  44403. 'љ' => 'Љ',
  44404. 'њ' => 'Њ',
  44405. 'ћ' => 'Ћ',
  44406. 'ќ' => 'Ќ',
  44407. '�' => '�',
  44408. 'Ñž' => 'ÐŽ',
  44409. 'џ' => '�',
  44410. 'Ñ¡' => 'Ñ ',
  44411. 'Ñ£' => 'Ñ¢',
  44412. 'ѥ' => 'Ѥ',
  44413. 'ѧ' => 'Ѧ',
  44414. 'ѩ' => 'Ѩ',
  44415. 'ѫ' => 'Ѫ',
  44416. 'ѭ' => 'Ѭ',
  44417. 'ѯ' => 'Ѯ',
  44418. 'ѱ' => 'Ѱ',
  44419. 'ѳ' => 'Ѳ',
  44420. 'ѵ' => 'Ѵ',
  44421. 'ѷ' => 'Ѷ',
  44422. 'ѹ' => 'Ѹ',
  44423. 'ѻ' => 'Ѻ',
  44424. 'ѽ' => 'Ѽ',
  44425. 'ѿ' => 'Ѿ',
  44426. 'Ò�' => 'Ò€',
  44427. 'Ò‹' => 'ÒŠ',
  44428. '�' => 'Ҍ',
  44429. 'Ò�' => 'ÒŽ',
  44430. 'Ò‘' => 'Ò�',
  44431. 'Ò“' => 'Ò’',
  44432. 'Ò•' => 'Ò”',
  44433. 'Ò—' => 'Ò–',
  44434. 'Ò™' => 'Ò˜',
  44435. 'Ò›' => 'Òš',
  44436. '�' => 'Ҝ',
  44437. 'ÒŸ' => 'Òž',
  44438. 'Ò¡' => 'Ò ',
  44439. 'Ò£' => 'Ò¢',
  44440. 'Ò¥' => 'Ò¤',
  44441. 'Ò§' => 'Ò¦',
  44442. 'Ò©' => 'Ò¨',
  44443. 'Ò«' => 'Òª',
  44444. 'Ò­' => 'Ò¬',
  44445. 'Ò¯' => 'Ò®',
  44446. 'Ò±' => 'Ò°',
  44447. 'Ò³' => 'Ò²',
  44448. 'Òµ' => 'Ò´',
  44449. 'Ò·' => 'Ò¶',
  44450. 'Ò¹' => 'Ò¸',
  44451. 'Ò»' => 'Òº',
  44452. 'Ò½' => 'Ò¼',
  44453. 'Ò¿' => 'Ò¾',
  44454. 'Ó‚' => 'Ó�',
  44455. 'Ó„' => 'Óƒ',
  44456. 'Ó†' => 'Ó…',
  44457. 'Óˆ' => 'Ó‡',
  44458. 'ÓŠ' => 'Ó‰',
  44459. 'ӌ' => 'Ӌ',
  44460. 'ÓŽ' => 'Ó�',
  44461. 'Ó�' => 'Ó€',
  44462. 'Ó‘' => 'Ó�',
  44463. 'Ó“' => 'Ó’',
  44464. 'Ó•' => 'Ó”',
  44465. 'Ó—' => 'Ó–',
  44466. 'Ó™' => 'Ó˜',
  44467. 'Ó›' => 'Óš',
  44468. '�' => 'Ӝ',
  44469. 'ÓŸ' => 'Óž',
  44470. 'Ó¡' => 'Ó ',
  44471. 'Ó£' => 'Ó¢',
  44472. 'Ó¥' => 'Ó¤',
  44473. 'Ó§' => 'Ó¦',
  44474. 'Ó©' => 'Ó¨',
  44475. 'Ó«' => 'Óª',
  44476. 'Ó­' => 'Ó¬',
  44477. 'Ó¯' => 'Ó®',
  44478. 'Ó±' => 'Ó°',
  44479. 'Ó³' => 'Ó²',
  44480. 'Óµ' => 'Ó´',
  44481. 'Ó·' => 'Ó¶',
  44482. 'Ó¹' => 'Ó¸',
  44483. 'Ó»' => 'Óº',
  44484. 'Ó½' => 'Ó¼',
  44485. 'Ó¿' => 'Ó¾',
  44486. 'Ô�' => 'Ô€',
  44487. 'Ôƒ' => 'Ô‚',
  44488. 'Ô…' => 'Ô„',
  44489. 'Ô‡' => 'Ô†',
  44490. 'Ô‰' => 'Ôˆ',
  44491. 'Ô‹' => 'ÔŠ',
  44492. '�' => 'Ԍ',
  44493. 'Ô�' => 'ÔŽ',
  44494. 'Ô‘' => 'Ô�',
  44495. 'Ô“' => 'Ô’',
  44496. 'Ô•' => 'Ô”',
  44497. 'Ô—' => 'Ô–',
  44498. 'Ô™' => 'Ô˜',
  44499. 'Ô›' => 'Ôš',
  44500. '�' => 'Ԝ',
  44501. 'ÔŸ' => 'Ôž',
  44502. 'Ô¡' => 'Ô ',
  44503. 'Ô£' => 'Ô¢',
  44504. 'Ô¥' => 'Ô¤',
  44505. 'Ô§' => 'Ô¦',
  44506. 'Ô©' => 'Ô¨',
  44507. 'Ô«' => 'Ôª',
  44508. 'Ô­' => 'Ô¬',
  44509. 'Ô¯' => 'Ô®',
  44510. 'Õ¡' => 'Ô±',
  44511. 'Õ¢' => 'Ô²',
  44512. 'Õ£' => 'Ô³',
  44513. 'Õ¤' => 'Ô´',
  44514. 'Õ¥' => 'Ôµ',
  44515. 'Õ¦' => 'Ô¶',
  44516. 'Õ§' => 'Ô·',
  44517. 'Õ¨' => 'Ô¸',
  44518. 'Õ©' => 'Ô¹',
  44519. 'Õª' => 'Ôº',
  44520. 'Õ«' => 'Ô»',
  44521. 'Õ¬' => 'Ô¼',
  44522. 'Õ­' => 'Ô½',
  44523. 'Õ®' => 'Ô¾',
  44524. 'Õ¯' => 'Ô¿',
  44525. 'Õ°' => 'Õ€',
  44526. 'Õ±' => 'Õ�',
  44527. 'Õ²' => 'Õ‚',
  44528. 'Õ³' => 'Õƒ',
  44529. 'Õ´' => 'Õ„',
  44530. 'Õµ' => 'Õ…',
  44531. 'Õ¶' => 'Õ†',
  44532. 'Õ·' => 'Õ‡',
  44533. 'Õ¸' => 'Õˆ',
  44534. 'Õ¹' => 'Õ‰',
  44535. 'Õº' => 'ÕŠ',
  44536. 'Õ»' => 'Õ‹',
  44537. 'ռ' => 'Ռ',
  44538. 'Õ½' => 'Õ�',
  44539. 'Õ¾' => 'ÕŽ',
  44540. 'Õ¿' => 'Õ�',
  44541. 'Ö€' => 'Õ�',
  44542. 'Ö�' => 'Õ‘',
  44543. 'Ö‚' => 'Õ’',
  44544. 'Öƒ' => 'Õ“',
  44545. 'Ö„' => 'Õ”',
  44546. 'Ö…' => 'Õ•',
  44547. 'Ö†' => 'Õ–',
  44548. 'ᵹ' => '�',
  44549. 'áµ½' => 'â±£',
  44550. '�' => 'Ḁ',
  44551. 'ḃ' => 'Ḃ',
  44552. 'ḅ' => 'Ḅ',
  44553. 'ḇ' => 'Ḇ',
  44554. 'ḉ' => 'Ḉ',
  44555. 'ḋ' => 'Ḋ',
  44556. '�' => 'Ḍ',
  44557. '�' => 'Ḏ',
  44558. 'ḑ' => '�',
  44559. 'ḓ' => 'Ḓ',
  44560. 'ḕ' => 'Ḕ',
  44561. 'ḗ' => 'Ḗ',
  44562. 'ḙ' => 'Ḙ',
  44563. 'ḛ' => 'Ḛ',
  44564. '�' => 'Ḝ',
  44565. 'ḟ' => 'Ḟ',
  44566. 'ḡ' => 'Ḡ',
  44567. 'ḣ' => 'Ḣ',
  44568. 'ḥ' => 'Ḥ',
  44569. 'ḧ' => 'Ḧ',
  44570. 'ḩ' => 'Ḩ',
  44571. 'ḫ' => 'Ḫ',
  44572. 'ḭ' => 'Ḭ',
  44573. 'ḯ' => 'Ḯ',
  44574. 'ḱ' => 'Ḱ',
  44575. 'ḳ' => 'Ḳ',
  44576. 'ḵ' => 'Ḵ',
  44577. 'ḷ' => 'Ḷ',
  44578. 'ḹ' => 'Ḹ',
  44579. 'ḻ' => 'Ḻ',
  44580. 'ḽ' => 'Ḽ',
  44581. 'ḿ' => 'Ḿ',
  44582. '�' => 'Ṁ',
  44583. 'ṃ' => 'Ṃ',
  44584. 'ṅ' => 'Ṅ',
  44585. 'ṇ' => 'Ṇ',
  44586. 'ṉ' => 'Ṉ',
  44587. 'ṋ' => 'Ṋ',
  44588. '�' => 'Ṍ',
  44589. '�' => 'Ṏ',
  44590. 'ṑ' => '�',
  44591. 'ṓ' => 'Ṓ',
  44592. 'ṕ' => 'Ṕ',
  44593. 'á¹—' => 'á¹–',
  44594. 'ṙ' => 'Ṙ',
  44595. 'ṛ' => 'Ṛ',
  44596. '�' => 'Ṝ',
  44597. 'ṟ' => 'Ṟ',
  44598. 'ṡ' => 'Ṡ',
  44599. 'á¹£' => 'á¹¢',
  44600. 'ṥ' => 'Ṥ',
  44601. 'ṧ' => 'Ṧ',
  44602. 'ṩ' => 'Ṩ',
  44603. 'ṫ' => 'Ṫ',
  44604. 'ṭ' => 'Ṭ',
  44605. 'ṯ' => 'Ṯ',
  44606. 'á¹±' => 'á¹°',
  44607. 'á¹³' => 'á¹²',
  44608. 'á¹µ' => 'á¹´',
  44609. 'á¹·' => 'á¹¶',
  44610. 'ṹ' => 'Ṹ',
  44611. 'ṻ' => 'Ṻ',
  44612. 'á¹½' => 'á¹¼',
  44613. 'ṿ' => 'Ṿ',
  44614. '�' => 'Ẁ',
  44615. 'ẃ' => 'Ẃ',
  44616. 'ẅ' => 'Ẅ',
  44617. 'ẇ' => 'Ẇ',
  44618. 'ẉ' => 'Ẉ',
  44619. 'ẋ' => 'Ẋ',
  44620. '�' => 'Ẍ',
  44621. '�' => 'Ẏ',
  44622. 'ẑ' => '�',
  44623. 'ẓ' => 'Ẓ',
  44624. 'ẕ' => 'Ẕ',
  44625. 'ẛ' => 'Ṡ',
  44626. 'ạ' => 'Ạ',
  44627. 'ả' => 'Ả',
  44628. 'ấ' => 'Ấ',
  44629. 'ầ' => 'Ầ',
  44630. 'ẩ' => 'Ẩ',
  44631. 'ẫ' => 'Ẫ',
  44632. 'ậ' => 'Ậ',
  44633. 'ắ' => 'Ắ',
  44634. 'ằ' => 'Ằ',
  44635. 'ẳ' => 'Ẳ',
  44636. 'ẵ' => 'Ẵ',
  44637. 'ặ' => 'Ặ',
  44638. 'ẹ' => 'Ẹ',
  44639. 'ẻ' => 'Ẻ',
  44640. 'ẽ' => 'Ẽ',
  44641. 'ế' => 'Ế',
  44642. '�' => 'Ề',
  44643. 'ể' => 'Ể',
  44644. 'ễ' => 'Ễ',
  44645. 'ệ' => 'Ệ',
  44646. 'ỉ' => 'Ỉ',
  44647. 'ị' => 'Ị',
  44648. '�' => 'Ọ',
  44649. '�' => 'Ỏ',
  44650. 'ố' => '�',
  44651. 'ồ' => 'Ồ',
  44652. 'ổ' => 'Ổ',
  44653. 'á»—' => 'á»–',
  44654. 'ộ' => 'Ộ',
  44655. 'ớ' => 'Ớ',
  44656. '�' => 'Ờ',
  44657. 'ở' => 'Ở',
  44658. 'ỡ' => 'Ỡ',
  44659. 'ợ' => 'Ợ',
  44660. 'ụ' => 'Ụ',
  44661. 'ủ' => 'Ủ',
  44662. 'ứ' => 'Ứ',
  44663. 'ừ' => 'Ừ',
  44664. 'ử' => 'Ử',
  44665. 'ữ' => 'Ữ',
  44666. 'á»±' => 'á»°',
  44667. 'ỳ' => 'Ỳ',
  44668. 'ỵ' => 'Ỵ',
  44669. 'á»·' => 'á»¶',
  44670. 'ỹ' => 'Ỹ',
  44671. 'ỻ' => 'Ỻ',
  44672. 'ỽ' => 'Ỽ',
  44673. 'ỿ' => 'Ỿ',
  44674. 'ἀ' => 'Ἀ',
  44675. '�' => 'Ἁ',
  44676. 'ἂ' => 'Ἂ',
  44677. 'ἃ' => 'Ἃ',
  44678. 'ἄ' => 'Ἄ',
  44679. 'ἅ' => '�',
  44680. 'ἆ' => 'Ἆ',
  44681. 'ἇ' => '�',
  44682. '�' => 'Ἐ',
  44683. 'ἑ' => 'Ἑ',
  44684. 'ἒ' => 'Ἒ',
  44685. 'ἓ' => 'Ἓ',
  44686. 'ἔ' => 'Ἔ',
  44687. 'ἕ' => '�',
  44688. 'ἠ' => 'Ἠ',
  44689. 'ἡ' => 'Ἡ',
  44690. 'ἢ' => 'Ἢ',
  44691. 'ἣ' => 'Ἣ',
  44692. 'ἤ' => 'Ἤ',
  44693. 'á¼¥' => 'á¼­',
  44694. 'ἦ' => 'Ἦ',
  44695. 'ἧ' => 'Ἧ',
  44696. 'ἰ' => 'Ἰ',
  44697. 'á¼±' => 'á¼¹',
  44698. 'ἲ' => 'Ἲ',
  44699. 'á¼³' => 'á¼»',
  44700. 'á¼´' => 'á¼¼',
  44701. 'á¼µ' => 'á¼½',
  44702. 'á¼¶' => 'á¼¾',
  44703. 'ἷ' => 'Ἷ',
  44704. 'ὀ' => 'Ὀ',
  44705. '�' => 'Ὁ',
  44706. 'ὂ' => 'Ὂ',
  44707. 'ὃ' => 'Ὃ',
  44708. 'ὄ' => 'Ὄ',
  44709. 'ὅ' => '�',
  44710. 'ὑ' => 'Ὑ',
  44711. 'ὓ' => 'Ὓ',
  44712. 'ὕ' => '�',
  44713. 'ὗ' => 'Ὗ',
  44714. 'ὠ' => 'Ὠ',
  44715. 'ὡ' => 'Ὡ',
  44716. 'ὢ' => 'Ὢ',
  44717. 'ὣ' => 'Ὣ',
  44718. 'ὤ' => 'Ὤ',
  44719. 'á½¥' => 'á½­',
  44720. 'ὦ' => 'Ὦ',
  44721. 'ὧ' => 'Ὧ',
  44722. 'ὰ' => 'Ὰ',
  44723. 'á½±' => 'á¾»',
  44724. 'ὲ' => 'Ὲ',
  44725. 'έ' => 'Έ',
  44726. 'ὴ' => 'Ὴ',
  44727. 'á½µ' => 'á¿‹',
  44728. 'ὶ' => 'Ὶ',
  44729. 'á½·' => 'á¿›',
  44730. 'ὸ' => 'Ὸ',
  44731. 'ό' => 'Ό',
  44732. 'ὺ' => 'Ὺ',
  44733. 'á½»' => 'á¿«',
  44734. 'ὼ' => 'Ὼ',
  44735. 'á½½' => 'á¿»',
  44736. 'ᾀ' => 'ᾈ',
  44737. '�' => 'ᾉ',
  44738. 'ᾂ' => 'ᾊ',
  44739. 'ᾃ' => 'ᾋ',
  44740. 'ᾄ' => 'ᾌ',
  44741. 'ᾅ' => '�',
  44742. 'ᾆ' => 'ᾎ',
  44743. 'ᾇ' => '�',
  44744. '�' => 'ᾘ',
  44745. 'ᾑ' => 'ᾙ',
  44746. 'ᾒ' => 'ᾚ',
  44747. 'ᾓ' => 'ᾛ',
  44748. 'ᾔ' => 'ᾜ',
  44749. 'ᾕ' => '�',
  44750. 'ᾖ' => 'ᾞ',
  44751. 'ᾗ' => 'ᾟ',
  44752. 'ᾠ' => 'ᾨ',
  44753. 'ᾡ' => 'ᾩ',
  44754. 'ᾢ' => 'ᾪ',
  44755. 'ᾣ' => 'ᾫ',
  44756. 'ᾤ' => 'ᾬ',
  44757. 'á¾¥' => 'á¾­',
  44758. 'ᾦ' => 'ᾮ',
  44759. 'ᾧ' => 'ᾯ',
  44760. 'ᾰ' => 'Ᾰ',
  44761. 'á¾±' => 'á¾¹',
  44762. 'á¾³' => 'á¾¼',
  44763. 'ι' => 'Ι',
  44764. 'ῃ' => 'ῌ',
  44765. '�' => 'Ῐ',
  44766. 'á¿‘' => 'á¿™',
  44767. 'ῠ' => 'Ῠ',
  44768. 'á¿¡' => 'á¿©',
  44769. 'ῥ' => 'Ῥ',
  44770. 'ῳ' => 'ῼ',
  44771. 'ⅎ' => 'Ⅎ',
  44772. 'â…°' => 'â… ',
  44773. 'â…±' => 'â…¡',
  44774. 'â…²' => 'â…¢',
  44775. 'â…³' => 'â…£',
  44776. 'â…´' => 'â…¤',
  44777. 'â…µ' => 'â…¥',
  44778. 'â…¶' => 'â…¦',
  44779. 'â…·' => 'â…§',
  44780. 'â…¸' => 'â…¨',
  44781. 'â…¹' => 'â…©',
  44782. 'â…º' => 'â…ª',
  44783. 'â…»' => 'â…«',
  44784. 'â…¼' => 'â…¬',
  44785. 'â…½' => 'â…­',
  44786. 'â…¾' => 'â…®',
  44787. 'â…¿' => 'â…¯',
  44788. 'ↄ' => 'Ↄ',
  44789. '�' => 'Ⓐ',
  44790. 'â“‘' => 'â’·',
  44791. 'â“’' => 'â’¸',
  44792. 'â““' => 'â’¹',
  44793. 'â“”' => 'â’º',
  44794. 'â“•' => 'â’»',
  44795. 'â“–' => 'â’¼',
  44796. 'â“—' => 'â’½',
  44797. 'ⓘ' => 'Ⓘ',
  44798. 'â“™' => 'â’¿',
  44799. 'ⓚ' => 'Ⓚ',
  44800. 'ⓛ' => '�',
  44801. 'ⓜ' => 'Ⓜ',
  44802. '�' => 'Ⓝ',
  44803. 'ⓞ' => 'Ⓞ',
  44804. 'ⓟ' => 'Ⓟ',
  44805. 'ⓠ' => 'Ⓠ',
  44806. 'ⓡ' => 'Ⓡ',
  44807. 'ⓢ' => 'Ⓢ',
  44808. 'ⓣ' => 'Ⓣ',
  44809. 'ⓤ' => 'Ⓤ',
  44810. 'â“¥' => 'â“‹',
  44811. 'ⓦ' => 'Ⓦ',
  44812. 'ⓧ' => '�',
  44813. 'ⓨ' => 'Ⓨ',
  44814. 'ⓩ' => '�',
  44815. 'â°°' => 'â°€',
  44816. 'â°±' => 'â°�',
  44817. 'â°²' => 'â°‚',
  44818. 'â°³' => 'â°ƒ',
  44819. 'â°´' => 'â°„',
  44820. 'â°µ' => 'â°…',
  44821. 'â°¶' => 'â°†',
  44822. 'â°·' => 'â°‡',
  44823. 'â°¸' => 'â°ˆ',
  44824. 'â°¹' => 'â°‰',
  44825. 'â°º' => 'â°Š',
  44826. 'â°»' => 'â°‹',
  44827. 'ⰼ' => 'Ⰼ',
  44828. 'â°½' => 'â°�',
  44829. 'â°¾' => 'â°Ž',
  44830. 'â°¿' => 'â°�',
  44831. 'â±€' => 'â°�',
  44832. '�' => 'Ⱁ',
  44833. 'ⱂ' => 'Ⱂ',
  44834. 'ⱃ' => 'Ⱃ',
  44835. 'ⱄ' => 'Ⱄ',
  44836. 'â±…' => 'â°•',
  44837. 'ⱆ' => 'Ⱆ',
  44838. 'ⱇ' => 'Ⱇ',
  44839. 'ⱈ' => 'Ⱈ',
  44840. 'ⱉ' => 'Ⱉ',
  44841. 'ⱊ' => 'Ⱊ',
  44842. 'ⱋ' => 'Ⱋ',
  44843. 'ⱌ' => 'Ⱌ',
  44844. '�' => '�',
  44845. 'ⱎ' => 'Ⱎ',
  44846. '�' => 'Ⱏ',
  44847. '�' => 'Ⱐ',
  44848. 'ⱑ' => 'Ⱑ',
  44849. 'â±’' => 'â°¢',
  44850. 'ⱓ' => 'Ⱓ',
  44851. 'â±”' => 'â°¤',
  44852. 'ⱕ' => 'Ⱕ',
  44853. 'â±–' => 'â°¦',
  44854. 'â±—' => 'â°§',
  44855. 'ⱘ' => 'Ⱘ',
  44856. 'â±™' => 'â°©',
  44857. 'ⱚ' => 'Ⱚ',
  44858. 'â±›' => 'â°«',
  44859. 'ⱜ' => 'Ⱜ',
  44860. '�' => 'Ⱝ',
  44861. 'ⱞ' => 'Ⱞ',
  44862. 'ⱡ' => 'Ⱡ',
  44863. 'ⱥ' => 'Ⱥ',
  44864. 'ⱦ' => 'Ⱦ',
  44865. 'ⱨ' => 'Ⱨ',
  44866. 'ⱪ' => 'Ⱪ',
  44867. 'ⱬ' => 'Ⱬ',
  44868. 'â±³' => 'â±²',
  44869. 'â±¶' => 'â±µ',
  44870. '�' => 'Ⲁ',
  44871. 'ⲃ' => 'Ⲃ',
  44872. 'ⲅ' => 'Ⲅ',
  44873. 'ⲇ' => 'Ⲇ',
  44874. 'ⲉ' => 'Ⲉ',
  44875. 'ⲋ' => 'Ⲋ',
  44876. '�' => 'Ⲍ',
  44877. '�' => 'Ⲏ',
  44878. 'ⲑ' => '�',
  44879. 'ⲓ' => 'Ⲓ',
  44880. 'ⲕ' => 'Ⲕ',
  44881. 'â²—' => 'â²–',
  44882. 'ⲙ' => 'Ⲙ',
  44883. 'ⲛ' => 'Ⲛ',
  44884. '�' => 'Ⲝ',
  44885. 'ⲟ' => 'Ⲟ',
  44886. 'ⲡ' => 'Ⲡ',
  44887. 'â²£' => 'â²¢',
  44888. 'ⲥ' => 'Ⲥ',
  44889. 'ⲧ' => 'Ⲧ',
  44890. 'ⲩ' => 'Ⲩ',
  44891. 'ⲫ' => 'Ⲫ',
  44892. 'ⲭ' => 'Ⲭ',
  44893. 'ⲯ' => 'Ⲯ',
  44894. 'â²±' => 'â²°',
  44895. 'â²³' => 'â²²',
  44896. 'â²µ' => 'â²´',
  44897. 'â²·' => 'â²¶',
  44898. 'ⲹ' => 'Ⲹ',
  44899. 'ⲻ' => 'Ⲻ',
  44900. 'â²½' => 'â²¼',
  44901. 'ⲿ' => 'Ⲿ',
  44902. '�' => 'Ⳁ',
  44903. 'ⳃ' => 'Ⳃ',
  44904. 'ⳅ' => 'Ⳅ',
  44905. 'ⳇ' => 'Ⳇ',
  44906. 'ⳉ' => 'Ⳉ',
  44907. 'ⳋ' => 'Ⳋ',
  44908. '�' => 'Ⳍ',
  44909. '�' => 'Ⳏ',
  44910. 'ⳑ' => '�',
  44911. 'ⳓ' => 'Ⳓ',
  44912. 'ⳕ' => 'Ⳕ',
  44913. 'â³—' => 'â³–',
  44914. 'ⳙ' => 'Ⳙ',
  44915. 'ⳛ' => 'Ⳛ',
  44916. '�' => 'Ⳝ',
  44917. 'ⳟ' => 'Ⳟ',
  44918. 'ⳡ' => 'Ⳡ',
  44919. 'â³£' => 'â³¢',
  44920. 'ⳬ' => 'Ⳬ',
  44921. 'â³®' => 'â³­',
  44922. 'â³³' => 'â³²',
  44923. 'â´€' => 'á‚ ',
  44924. 'â´�' => 'á‚¡',
  44925. 'â´‚' => 'á‚¢',
  44926. 'â´ƒ' => 'á‚£',
  44927. 'ⴄ' => 'Ⴄ',
  44928. 'â´…' => 'á‚¥',
  44929. 'ⴆ' => 'Ⴆ',
  44930. 'â´‡' => 'á‚§',
  44931. 'ⴈ' => 'Ⴈ',
  44932. 'â´‰' => 'á‚©',
  44933. 'ⴊ' => 'Ⴊ',
  44934. 'â´‹' => 'á‚«',
  44935. 'ⴌ' => 'Ⴌ',
  44936. 'â´�' => 'á‚­',
  44937. 'â´Ž' => 'á‚®',
  44938. '�' => 'Ⴏ',
  44939. 'â´�' => 'á‚°',
  44940. 'ⴑ' => 'Ⴑ',
  44941. 'ⴒ' => 'Ⴒ',
  44942. 'ⴓ' => 'Ⴓ',
  44943. 'â´”' => 'á‚´',
  44944. 'ⴕ' => 'Ⴕ',
  44945. 'â´–' => 'á‚¶',
  44946. 'â´—' => 'á‚·',
  44947. 'ⴘ' => 'Ⴘ',
  44948. 'ⴙ' => 'Ⴙ',
  44949. 'ⴚ' => 'Ⴚ',
  44950. 'â´›' => 'á‚»',
  44951. 'ⴜ' => 'Ⴜ',
  44952. '�' => 'Ⴝ',
  44953. 'ⴞ' => 'Ⴞ',
  44954. 'â´Ÿ' => 'á‚¿',
  44955. 'ⴠ' => 'Ⴠ',
  44956. 'ⴡ' => '�',
  44957. 'ⴢ' => 'Ⴢ',
  44958. 'ⴣ' => 'Ⴣ',
  44959. 'ⴤ' => 'Ⴤ',
  44960. 'ⴥ' => 'Ⴥ',
  44961. 'ⴧ' => 'Ⴧ',
  44962. 'ⴭ' => '�',
  44963. '�' => 'Ꙁ',
  44964. 'ꙃ' => 'Ꙃ',
  44965. 'ꙅ' => 'Ꙅ',
  44966. 'ꙇ' => 'Ꙇ',
  44967. 'ꙉ' => 'Ꙉ',
  44968. 'ꙋ' => 'Ꙋ',
  44969. '�' => 'Ꙍ',
  44970. '�' => 'Ꙏ',
  44971. 'ꙑ' => '�',
  44972. 'ꙓ' => 'Ꙓ',
  44973. 'ꙕ' => 'Ꙕ',
  44974. 'ê™—' => 'ê™–',
  44975. 'ꙙ' => 'Ꙙ',
  44976. 'ꙛ' => 'Ꙛ',
  44977. '�' => 'Ꙝ',
  44978. 'ꙟ' => 'Ꙟ',
  44979. 'ꙡ' => 'Ꙡ',
  44980. 'ꙣ' => 'Ꙣ',
  44981. 'ꙥ' => 'Ꙥ',
  44982. 'ꙧ' => 'Ꙧ',
  44983. 'ꙩ' => 'Ꙩ',
  44984. 'ꙫ' => 'Ꙫ',
  44985. 'ꙭ' => 'Ꙭ',
  44986. '�' => 'Ꚁ',
  44987. 'ꚃ' => 'Ꚃ',
  44988. 'êš…' => 'êš„',
  44989. 'ꚇ' => 'Ꚇ',
  44990. 'ꚉ' => 'Ꚉ',
  44991. 'ꚋ' => 'Ꚋ',
  44992. '�' => 'Ꚍ',
  44993. '�' => 'Ꚏ',
  44994. 'ꚑ' => '�',
  44995. 'êš“' => 'êš’',
  44996. 'êš•' => 'êš”',
  44997. 'êš—' => 'êš–',
  44998. 'ꚙ' => 'Ꚙ',
  44999. 'êš›' => 'êšš',
  45000. 'ꜣ' => 'Ꜣ',
  45001. 'ꜥ' => 'Ꜥ',
  45002. 'ꜧ' => 'Ꜧ',
  45003. 'ꜩ' => 'Ꜩ',
  45004. 'ꜫ' => 'Ꜫ',
  45005. 'ꜭ' => 'Ꜭ',
  45006. 'ꜯ' => 'Ꜯ',
  45007. 'ꜳ' => 'Ꜳ',
  45008. 'ꜵ' => 'Ꜵ',
  45009. 'ꜷ' => 'Ꜷ',
  45010. 'ꜹ' => 'Ꜹ',
  45011. 'ꜻ' => 'Ꜻ',
  45012. 'ꜽ' => 'Ꜽ',
  45013. 'ꜿ' => 'Ꜿ',
  45014. '�' => '�',
  45015. '�' => '�',
  45016. '�' => '�',
  45017. '�' => '�',
  45018. '�' => '�',
  45019. '�' => '�',
  45020. '�' => '�',
  45021. '�' => '�',
  45022. '�' => '�',
  45023. '�' => '�',
  45024. '�' => '�',
  45025. '�' => '�',
  45026. '�' => '�',
  45027. '�' => '�',
  45028. '�' => '�',
  45029. '�' => '�',
  45030. '�' => '�',
  45031. '�' => '�',
  45032. '�' => '�',
  45033. '�' => '�',
  45034. '�' => '�',
  45035. '�' => '�',
  45036. '�' => '�',
  45037. '�' => '�',
  45038. '�' => '�',
  45039. '�' => '�',
  45040. '�' => '�',
  45041. '�' => 'Ꞁ',
  45042. 'ꞃ' => 'Ꞃ',
  45043. 'êž…' => 'êž„',
  45044. 'ꞇ' => 'Ꞇ',
  45045. 'ꞌ' => 'Ꞌ',
  45046. 'ꞑ' => '�',
  45047. 'êž“' => 'êž’',
  45048. 'êž—' => 'êž–',
  45049. 'ꞙ' => 'Ꞙ',
  45050. 'êž›' => 'êžš',
  45051. '�' => 'Ꞝ',
  45052. 'ꞟ' => 'Ꞟ',
  45053. 'êž¡' => 'êž ',
  45054. 'ꞣ' => 'Ꞣ',
  45055. 'ꞥ' => 'Ꞥ',
  45056. 'ꞧ' => 'Ꞧ',
  45057. 'ꞩ' => 'Ꞩ',
  45058. '�' => 'A',
  45059. 'b' => 'B',
  45060. 'c' => 'C',
  45061. 'd' => 'D',
  45062. 'ï½…' => 'ï¼¥',
  45063. 'f' => 'F',
  45064. 'g' => 'G',
  45065. 'h' => 'H',
  45066. 'i' => 'I',
  45067. 'j' => 'J',
  45068. 'k' => 'K',
  45069. 'l' => 'L',
  45070. '�' => 'M',
  45071. 'n' => 'N',
  45072. '�' => 'O',
  45073. '�' => 'P',
  45074. 'q' => 'Q',
  45075. 'ï½’' => 'ï¼²',
  45076. 's' => 'S',
  45077. 'ï½”' => 'ï¼´',
  45078. 'u' => 'U',
  45079. 'ï½–' => 'ï¼¶',
  45080. 'ï½—' => 'ï¼·',
  45081. 'x' => 'X',
  45082. 'ï½™' => 'ï¼¹',
  45083. 'z' => 'Z',
  45084. '�' => '�',
  45085. '�' => '�',
  45086. '�' => '�',
  45087. '�' => '�',
  45088. '�' => '�',
  45089. '�' => '�',
  45090. '�' => '�',
  45091. '�' => '�',
  45092. '�' => '�',
  45093. '�' => '�',
  45094. '�' => '�',
  45095. '�' => '�',
  45096. '�' => '�',
  45097. '�' => '�',
  45098. '�' => '�',
  45099. '�' => '�',
  45100. '�' => '�',
  45101. '�' => '�',
  45102. '�' => '�',
  45103. '�' => '�',
  45104. '�' => '�',
  45105. '�' => '�',
  45106. '�' => '�',
  45107. '�' => '�',
  45108. '�' => '�',
  45109. '�' => '�',
  45110. '�' => '�',
  45111. '�' => '�',
  45112. '�' => '�',
  45113. '�' => '�',
  45114. '�' => '�',
  45115. '�' => '�',
  45116. '�' => '�',
  45117. '�' => '�',
  45118. '�' => '�',
  45119. '�' => '�',
  45120. '�' => '�',
  45121. '�' => '�',
  45122. '�' => '�',
  45123. '�' => '�',
  45124. 'ð‘£€' => 'ð‘¢ ',
  45125. '�' => '𑢡',
  45126. '𑣂' => '𑢢',
  45127. '𑣃' => '𑢣',
  45128. '𑣄' => '𑢤',
  45129. 'ð‘£…' => 'ð‘¢¥',
  45130. '𑣆' => '𑢦',
  45131. '𑣇' => '𑢧',
  45132. '𑣈' => '𑢨',
  45133. '𑣉' => '𑢩',
  45134. '𑣊' => '𑢪',
  45135. '𑣋' => '𑢫',
  45136. '𑣌' => '𑢬',
  45137. '�' => '𑢭',
  45138. '𑣎' => '𑢮',
  45139. '�' => '𑢯',
  45140. '�' => '𑢰',
  45141. '𑣑' => '𑢱',
  45142. 'ð‘£’' => 'ð‘¢²',
  45143. '𑣓' => '𑢳',
  45144. 'ð‘£”' => 'ð‘¢´',
  45145. '𑣕' => '𑢵',
  45146. 'ð‘£–' => 'ð‘¢¶',
  45147. 'ð‘£—' => 'ð‘¢·',
  45148. '𑣘' => '𑢸',
  45149. 'ð‘£™' => 'ð‘¢¹',
  45150. '𑣚' => '𑢺',
  45151. 'ð‘£›' => 'ð‘¢»',
  45152. '𑣜' => '𑢼',
  45153. '�' => '𑢽',
  45154. '𑣞' => '𑢾',
  45155. '𑣟' => '𑢿',
  45156. );
  45157. <?php
  45158. use Symfony\Polyfill\Mbstring as p;
  45159. if (!function_exists('mb_strlen')) {
  45160. define('MB_CASE_UPPER', 0);
  45161. define('MB_CASE_LOWER', 1);
  45162. define('MB_CASE_TITLE', 2);
  45163. function mb_convert_encoding($s, $to, $from = null) { return p\Mbstring::mb_convert_encoding($s, $to, $from); }
  45164. function mb_decode_mimeheader($s) { return p\Mbstring::mb_decode_mimeheader($s); }
  45165. function mb_encode_mimeheader($s, $charset = null, $transferEnc = null, $lf = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($s, $charset, $transferEnc, $lf, $indent); }
  45166. function mb_decode_numericentity($s, $convmap, $enc = null) { return p\Mbstring::mb_decode_numericentity($s, $convmap, $enc); }
  45167. function mb_encode_numericentity($s, $convmap, $enc = null, $is_hex = false) { return p\Mbstring::mb_encode_numericentity($s, $convmap, $enc, $is_hex); }
  45168. function mb_convert_case($s, $mode, $enc = null) { return p\Mbstring::mb_convert_case($s, $mode, $enc); }
  45169. function mb_internal_encoding($enc = null) { return p\Mbstring::mb_internal_encoding($enc); }
  45170. function mb_language($lang = null) { return p\Mbstring::mb_language($lang); }
  45171. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  45172. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  45173. function mb_check_encoding($var = null, $encoding = null) { return p\Mbstring::mb_check_encoding($var, $encoding); }
  45174. function mb_detect_encoding($str, $encodingList = null, $strict = false) { return p\Mbstring::mb_detect_encoding($str, $encodingList, $strict); }
  45175. function mb_detect_order($encodingList = null) { return p\Mbstring::mb_detect_order($encodingList); }
  45176. function mb_parse_str($s, &$result = array()) { parse_str($s, $result); }
  45177. function mb_strlen($s, $enc = null) { return p\Mbstring::mb_strlen($s, $enc); }
  45178. function mb_strpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strpos($s, $needle, $offset, $enc); }
  45179. function mb_strtolower($s, $enc = null) { return p\Mbstring::mb_strtolower($s, $enc); }
  45180. function mb_strtoupper($s, $enc = null) { return p\Mbstring::mb_strtoupper($s, $enc); }
  45181. function mb_substitute_character($char = null) { return p\Mbstring::mb_substitute_character($char); }
  45182. function mb_substr($s, $start, $length = 2147483647, $enc = null) { return p\Mbstring::mb_substr($s, $start, $length, $enc); }
  45183. function mb_stripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_stripos($s, $needle, $offset, $enc); }
  45184. function mb_stristr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_stristr($s, $needle, $part, $enc); }
  45185. function mb_strrchr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrchr($s, $needle, $part, $enc); }
  45186. function mb_strrichr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrichr($s, $needle, $part, $enc); }
  45187. function mb_strripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strripos($s, $needle, $offset, $enc); }
  45188. function mb_strrpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strrpos($s, $needle, $offset, $enc); }
  45189. function mb_strstr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strstr($s, $needle, $part, $enc); }
  45190. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  45191. function mb_http_output($enc = null) { return p\Mbstring::mb_http_output($enc); }
  45192. function mb_strwidth($s, $enc = null) { return p\Mbstring::mb_strwidth($s, $enc); }
  45193. function mb_substr_count($haystack, $needle, $enc = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $enc); }
  45194. function mb_output_handler($contents, $status) { return p\Mbstring::mb_output_handler($contents, $status); }
  45195. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  45196. 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); }
  45197. }
  45198. if (!function_exists('mb_chr')) {
  45199. function mb_ord($s, $enc = null) { return p\Mbstring::mb_ord($s, $enc); }
  45200. function mb_chr($code, $enc = null) { return p\Mbstring::mb_chr($code, $enc); }
  45201. function mb_scrub($s, $enc = null) { $enc = null === $enc ? mb_internal_encoding() : $enc; return mb_convert_encoding($s, $enc, $enc); }
  45202. }
  45203. <?php
  45204. namespace Symfony\Component\Process\Exception;
  45205. interface ExceptionInterface
  45206. {
  45207. }
  45208. <?php
  45209. namespace Symfony\Component\Process\Exception;
  45210. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  45211. {
  45212. }
  45213. <?php
  45214. namespace Symfony\Component\Process\Exception;
  45215. class LogicException extends \LogicException implements ExceptionInterface
  45216. {
  45217. }
  45218. <?php
  45219. namespace Symfony\Component\Process\Exception;
  45220. use Symfony\Component\Process\Process;
  45221. class ProcessFailedException extends RuntimeException
  45222. {
  45223. private $process;
  45224. public function __construct(Process $process)
  45225. {
  45226. if ($process->isSuccessful()) {
  45227. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  45228. }
  45229. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  45230. $process->getCommandLine(),
  45231. $process->getExitCode(),
  45232. $process->getExitCodeText(),
  45233. $process->getWorkingDirectory()
  45234. );
  45235. if (!$process->isOutputDisabled()) {
  45236. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  45237. $process->getOutput(),
  45238. $process->getErrorOutput()
  45239. );
  45240. }
  45241. parent::__construct($error);
  45242. $this->process = $process;
  45243. }
  45244. public function getProcess()
  45245. {
  45246. return $this->process;
  45247. }
  45248. }
  45249. <?php
  45250. namespace Symfony\Component\Process\Exception;
  45251. use Symfony\Component\Process\Process;
  45252. class ProcessTimedOutException extends RuntimeException
  45253. {
  45254. const TYPE_GENERAL = 1;
  45255. const TYPE_IDLE = 2;
  45256. private $process;
  45257. private $timeoutType;
  45258. public function __construct(Process $process, $timeoutType)
  45259. {
  45260. $this->process = $process;
  45261. $this->timeoutType = $timeoutType;
  45262. parent::__construct(sprintf(
  45263. 'The process "%s" exceeded the timeout of %s seconds.',
  45264. $process->getCommandLine(),
  45265. $this->getExceededTimeout()
  45266. ));
  45267. }
  45268. public function getProcess()
  45269. {
  45270. return $this->process;
  45271. }
  45272. public function isGeneralTimeout()
  45273. {
  45274. return self::TYPE_GENERAL === $this->timeoutType;
  45275. }
  45276. public function isIdleTimeout()
  45277. {
  45278. return self::TYPE_IDLE === $this->timeoutType;
  45279. }
  45280. public function getExceededTimeout()
  45281. {
  45282. switch ($this->timeoutType) {
  45283. case self::TYPE_GENERAL:
  45284. return $this->process->getTimeout();
  45285. case self::TYPE_IDLE:
  45286. return $this->process->getIdleTimeout();
  45287. default:
  45288. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  45289. }
  45290. }
  45291. }
  45292. <?php
  45293. namespace Symfony\Component\Process\Exception;
  45294. class RuntimeException extends \RuntimeException implements ExceptionInterface
  45295. {
  45296. }
  45297. <?php
  45298. namespace Symfony\Component\Process;
  45299. class ExecutableFinder
  45300. {
  45301. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  45302. public function setSuffixes(array $suffixes)
  45303. {
  45304. $this->suffixes = $suffixes;
  45305. }
  45306. public function addSuffix($suffix)
  45307. {
  45308. $this->suffixes[] = $suffix;
  45309. }
  45310. public function find($name, $default = null, array $extraDirs = array())
  45311. {
  45312. if (ini_get('open_basedir')) {
  45313. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  45314. $dirs = array();
  45315. foreach ($searchPath as $path) {
  45316. if (@is_dir($path)) {
  45317. $dirs[] = $path;
  45318. } else {
  45319. if (basename($path) == $name && @is_executable($path)) {
  45320. return $path;
  45321. }
  45322. }
  45323. }
  45324. } else {
  45325. $dirs = array_merge(
  45326. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  45327. $extraDirs
  45328. );
  45329. }
  45330. $suffixes = array('');
  45331. if ('\\' === \DIRECTORY_SEPARATOR) {
  45332. $pathExt = getenv('PATHEXT');
  45333. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  45334. }
  45335. foreach ($suffixes as $suffix) {
  45336. foreach ($dirs as $dir) {
  45337. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  45338. return $file;
  45339. }
  45340. }
  45341. }
  45342. return $default;
  45343. }
  45344. }
  45345. Copyright (c) 2004-2018 Fabien Potencier
  45346. Permission is hereby granted, free of charge, to any person obtaining a copy
  45347. of this software and associated documentation files (the "Software"), to deal
  45348. in the Software without restriction, including without limitation the rights
  45349. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  45350. copies of the Software, and to permit persons to whom the Software is furnished
  45351. to do so, subject to the following conditions:
  45352. The above copyright notice and this permission notice shall be included in all
  45353. copies or substantial portions of the Software.
  45354. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45355. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  45356. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  45357. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  45358. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  45359. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  45360. THE SOFTWARE.
  45361. <?php
  45362. namespace Symfony\Component\Process;
  45363. class PhpExecutableFinder
  45364. {
  45365. private $executableFinder;
  45366. public function __construct()
  45367. {
  45368. $this->executableFinder = new ExecutableFinder();
  45369. }
  45370. public function find($includeArgs = true)
  45371. {
  45372. $args = $this->findArguments();
  45373. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  45374. if (\defined('HHVM_VERSION')) {
  45375. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  45376. }
  45377. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  45378. return PHP_BINARY.$args;
  45379. }
  45380. if ($php = getenv('PHP_PATH')) {
  45381. if (!@is_executable($php)) {
  45382. return false;
  45383. }
  45384. return $php;
  45385. }
  45386. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  45387. if (@is_executable($php)) {
  45388. return $php;
  45389. }
  45390. }
  45391. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  45392. return $php;
  45393. }
  45394. $dirs = array(PHP_BINDIR);
  45395. if ('\\' === \DIRECTORY_SEPARATOR) {
  45396. $dirs[] = 'C:\xampp\php\\';
  45397. }
  45398. return $this->executableFinder->find('php', false, $dirs);
  45399. }
  45400. public function findArguments()
  45401. {
  45402. $arguments = array();
  45403. if (\defined('HHVM_VERSION')) {
  45404. $arguments[] = '--php';
  45405. } elseif ('phpdbg' === \PHP_SAPI) {
  45406. $arguments[] = '-qrr';
  45407. }
  45408. return $arguments;
  45409. }
  45410. }
  45411. <?php
  45412. namespace Symfony\Component\Process;
  45413. use Symfony\Component\Process\Exception\RuntimeException;
  45414. class PhpProcess extends Process
  45415. {
  45416. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  45417. {
  45418. $executableFinder = new PhpExecutableFinder();
  45419. if (false === $php = $executableFinder->find()) {
  45420. $php = null;
  45421. }
  45422. if ('phpdbg' === \PHP_SAPI) {
  45423. $file = tempnam(sys_get_temp_dir(), 'dbg');
  45424. file_put_contents($file, $script);
  45425. register_shutdown_function('unlink', $file);
  45426. $php .= ' '.ProcessUtils::escapeArgument($file);
  45427. $script = null;
  45428. }
  45429. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  45430. $php = 'exec '.$php;
  45431. }
  45432. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  45433. }
  45434. public function setPhpBinary($php)
  45435. {
  45436. $this->setCommandLine($php);
  45437. }
  45438. public function start($callback = null)
  45439. {
  45440. if (null === $this->getCommandLine()) {
  45441. throw new RuntimeException('Unable to find the PHP executable.');
  45442. }
  45443. parent::start($callback);
  45444. }
  45445. }
  45446. <?php
  45447. namespace Symfony\Component\Process\Pipes;
  45448. abstract class AbstractPipes implements PipesInterface
  45449. {
  45450. public $pipes = array();
  45451. private $inputBuffer = '';
  45452. private $input;
  45453. private $blocked = true;
  45454. private $lastError;
  45455. public function __construct($input)
  45456. {
  45457. if (\is_resource($input)) {
  45458. $this->input = $input;
  45459. } elseif (\is_string($input)) {
  45460. $this->inputBuffer = $input;
  45461. } else {
  45462. $this->inputBuffer = (string) $input;
  45463. }
  45464. }
  45465. public function close()
  45466. {
  45467. foreach ($this->pipes as $pipe) {
  45468. fclose($pipe);
  45469. }
  45470. $this->pipes = array();
  45471. }
  45472. protected function hasSystemCallBeenInterrupted()
  45473. {
  45474. $lastError = $this->lastError;
  45475. $this->lastError = null;
  45476. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  45477. }
  45478. protected function unblock()
  45479. {
  45480. if (!$this->blocked) {
  45481. return;
  45482. }
  45483. foreach ($this->pipes as $pipe) {
  45484. stream_set_blocking($pipe, 0);
  45485. }
  45486. if (null !== $this->input) {
  45487. stream_set_blocking($this->input, 0);
  45488. }
  45489. $this->blocked = false;
  45490. }
  45491. protected function write()
  45492. {
  45493. if (!isset($this->pipes[0])) {
  45494. return;
  45495. }
  45496. $input = $this->input;
  45497. $r = $e = array();
  45498. $w = array($this->pipes[0]);
  45499. if (false === @stream_select($r, $w, $e, 0, 0)) {
  45500. return;
  45501. }
  45502. foreach ($w as $stdin) {
  45503. if (isset($this->inputBuffer[0])) {
  45504. $written = fwrite($stdin, $this->inputBuffer);
  45505. $this->inputBuffer = substr($this->inputBuffer, $written);
  45506. if (isset($this->inputBuffer[0])) {
  45507. return array($this->pipes[0]);
  45508. }
  45509. }
  45510. if ($input) {
  45511. for (;;) {
  45512. $data = fread($input, self::CHUNK_SIZE);
  45513. if (!isset($data[0])) {
  45514. break;
  45515. }
  45516. $written = fwrite($stdin, $data);
  45517. $data = substr($data, $written);
  45518. if (isset($data[0])) {
  45519. $this->inputBuffer = $data;
  45520. return array($this->pipes[0]);
  45521. }
  45522. }
  45523. if (feof($input)) {
  45524. $this->input = null;
  45525. }
  45526. }
  45527. }
  45528. if (null === $this->input && !isset($this->inputBuffer[0])) {
  45529. fclose($this->pipes[0]);
  45530. unset($this->pipes[0]);
  45531. } elseif (!$w) {
  45532. return array($this->pipes[0]);
  45533. }
  45534. }
  45535. public function handleError($type, $msg)
  45536. {
  45537. $this->lastError = $msg;
  45538. }
  45539. }
  45540. <?php
  45541. namespace Symfony\Component\Process\Pipes;
  45542. interface PipesInterface
  45543. {
  45544. const CHUNK_SIZE = 16384;
  45545. public function getDescriptors();
  45546. public function getFiles();
  45547. public function readAndWrite($blocking, $close = false);
  45548. public function areOpen();
  45549. public function close();
  45550. }
  45551. <?php
  45552. namespace Symfony\Component\Process\Pipes;
  45553. use Symfony\Component\Process\Process;
  45554. class UnixPipes extends AbstractPipes
  45555. {
  45556. private $ttyMode;
  45557. private $ptyMode;
  45558. private $disableOutput;
  45559. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  45560. {
  45561. $this->ttyMode = (bool) $ttyMode;
  45562. $this->ptyMode = (bool) $ptyMode;
  45563. $this->disableOutput = (bool) $disableOutput;
  45564. parent::__construct($input);
  45565. }
  45566. public function __destruct()
  45567. {
  45568. $this->close();
  45569. }
  45570. public function getDescriptors()
  45571. {
  45572. if ($this->disableOutput) {
  45573. $nullstream = fopen('/dev/null', 'c');
  45574. return array(
  45575. array('pipe', 'r'),
  45576. $nullstream,
  45577. $nullstream,
  45578. );
  45579. }
  45580. if ($this->ttyMode) {
  45581. return array(
  45582. array('file', '/dev/tty', 'r'),
  45583. array('file', '/dev/tty', 'w'),
  45584. array('file', '/dev/tty', 'w'),
  45585. );
  45586. }
  45587. if ($this->ptyMode && Process::isPtySupported()) {
  45588. return array(
  45589. array('pty'),
  45590. array('pty'),
  45591. array('pty'),
  45592. );
  45593. }
  45594. return array(
  45595. array('pipe', 'r'),
  45596. array('pipe', 'w'),
  45597. array('pipe', 'w'),
  45598. );
  45599. }
  45600. public function getFiles()
  45601. {
  45602. return array();
  45603. }
  45604. public function readAndWrite($blocking, $close = false)
  45605. {
  45606. $this->unblock();
  45607. $w = $this->write();
  45608. $read = $e = array();
  45609. $r = $this->pipes;
  45610. unset($r[0]);
  45611. set_error_handler(array($this, 'handleError'));
  45612. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  45613. restore_error_handler();
  45614. if (!$this->hasSystemCallBeenInterrupted()) {
  45615. $this->pipes = array();
  45616. }
  45617. return $read;
  45618. }
  45619. restore_error_handler();
  45620. foreach ($r as $pipe) {
  45621. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  45622. do {
  45623. $data = fread($pipe, self::CHUNK_SIZE);
  45624. $read[$type] .= $data;
  45625. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  45626. if (!isset($read[$type][0])) {
  45627. unset($read[$type]);
  45628. }
  45629. if ($close && feof($pipe)) {
  45630. fclose($pipe);
  45631. unset($this->pipes[$type]);
  45632. }
  45633. }
  45634. return $read;
  45635. }
  45636. public function areOpen()
  45637. {
  45638. return (bool) $this->pipes;
  45639. }
  45640. public static function create(Process $process, $input)
  45641. {
  45642. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  45643. }
  45644. }
  45645. <?php
  45646. namespace Symfony\Component\Process\Pipes;
  45647. use Symfony\Component\Process\Exception\RuntimeException;
  45648. use Symfony\Component\Process\Process;
  45649. class WindowsPipes extends AbstractPipes
  45650. {
  45651. private $files = array();
  45652. private $fileHandles = array();
  45653. private $lockHandles = array();
  45654. private $readBytes = array(
  45655. Process::STDOUT => 0,
  45656. Process::STDERR => 0,
  45657. );
  45658. private $disableOutput;
  45659. public function __construct($disableOutput, $input)
  45660. {
  45661. $this->disableOutput = (bool) $disableOutput;
  45662. if (!$this->disableOutput) {
  45663. $pipes = array(
  45664. Process::STDOUT => Process::OUT,
  45665. Process::STDERR => Process::ERR,
  45666. );
  45667. $tmpDir = sys_get_temp_dir();
  45668. $lastError = 'unknown reason';
  45669. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  45670. for ($i = 0;; ++$i) {
  45671. foreach ($pipes as $pipe => $name) {
  45672. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  45673. if (!$h = fopen($file.'.lock', 'w')) {
  45674. restore_error_handler();
  45675. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  45676. }
  45677. if (!flock($h, LOCK_EX | LOCK_NB)) {
  45678. continue 2;
  45679. }
  45680. if (isset($this->lockHandles[$pipe])) {
  45681. flock($this->lockHandles[$pipe], LOCK_UN);
  45682. fclose($this->lockHandles[$pipe]);
  45683. }
  45684. $this->lockHandles[$pipe] = $h;
  45685. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  45686. flock($this->lockHandles[$pipe], LOCK_UN);
  45687. fclose($this->lockHandles[$pipe]);
  45688. unset($this->lockHandles[$pipe]);
  45689. continue 2;
  45690. }
  45691. $this->fileHandles[$pipe] = $h;
  45692. $this->files[$pipe] = $file;
  45693. }
  45694. break;
  45695. }
  45696. restore_error_handler();
  45697. }
  45698. parent::__construct($input);
  45699. }
  45700. public function __destruct()
  45701. {
  45702. $this->close();
  45703. }
  45704. public function getDescriptors()
  45705. {
  45706. if ($this->disableOutput) {
  45707. $nullstream = fopen('NUL', 'c');
  45708. return array(
  45709. array('pipe', 'r'),
  45710. $nullstream,
  45711. $nullstream,
  45712. );
  45713. }
  45714. return array(
  45715. array('pipe', 'r'),
  45716. array('file', 'NUL', 'w'),
  45717. array('file', 'NUL', 'w'),
  45718. );
  45719. }
  45720. public function getFiles()
  45721. {
  45722. return $this->files;
  45723. }
  45724. public function readAndWrite($blocking, $close = false)
  45725. {
  45726. $this->unblock();
  45727. $w = $this->write();
  45728. $read = $r = $e = array();
  45729. if ($blocking) {
  45730. if ($w) {
  45731. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  45732. } elseif ($this->fileHandles) {
  45733. usleep(Process::TIMEOUT_PRECISION * 1E6);
  45734. }
  45735. }
  45736. foreach ($this->fileHandles as $type => $fileHandle) {
  45737. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  45738. if (isset($data[0])) {
  45739. $this->readBytes[$type] += \strlen($data);
  45740. $read[$type] = $data;
  45741. }
  45742. if ($close) {
  45743. ftruncate($fileHandle, 0);
  45744. fclose($fileHandle);
  45745. flock($this->lockHandles[$type], LOCK_UN);
  45746. fclose($this->lockHandles[$type]);
  45747. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  45748. }
  45749. }
  45750. return $read;
  45751. }
  45752. public function areOpen()
  45753. {
  45754. return $this->pipes && $this->fileHandles;
  45755. }
  45756. public function close()
  45757. {
  45758. parent::close();
  45759. foreach ($this->fileHandles as $type => $handle) {
  45760. ftruncate($handle, 0);
  45761. fclose($handle);
  45762. flock($this->lockHandles[$type], LOCK_UN);
  45763. fclose($this->lockHandles[$type]);
  45764. }
  45765. $this->fileHandles = $this->lockHandles = array();
  45766. }
  45767. public static function create(Process $process, $input)
  45768. {
  45769. return new static($process->isOutputDisabled(), $input);
  45770. }
  45771. }
  45772. <?php
  45773. namespace Symfony\Component\Process;
  45774. use Symfony\Component\Process\Exception\InvalidArgumentException;
  45775. use Symfony\Component\Process\Exception\LogicException;
  45776. use Symfony\Component\Process\Exception\ProcessFailedException;
  45777. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  45778. use Symfony\Component\Process\Exception\RuntimeException;
  45779. use Symfony\Component\Process\Pipes\PipesInterface;
  45780. use Symfony\Component\Process\Pipes\UnixPipes;
  45781. use Symfony\Component\Process\Pipes\WindowsPipes;
  45782. class Process
  45783. {
  45784. const ERR = 'err';
  45785. const OUT = 'out';
  45786. const STATUS_READY = 'ready';
  45787. const STATUS_STARTED = 'started';
  45788. const STATUS_TERMINATED = 'terminated';
  45789. const STDIN = 0;
  45790. const STDOUT = 1;
  45791. const STDERR = 2;
  45792. const TIMEOUT_PRECISION = 0.2;
  45793. private $callback;
  45794. private $commandline;
  45795. private $cwd;
  45796. private $env;
  45797. private $input;
  45798. private $starttime;
  45799. private $lastOutputTime;
  45800. private $timeout;
  45801. private $idleTimeout;
  45802. private $options;
  45803. private $exitcode;
  45804. private $fallbackStatus = array();
  45805. private $processInformation;
  45806. private $outputDisabled = false;
  45807. private $stdout;
  45808. private $stderr;
  45809. private $enhanceWindowsCompatibility = true;
  45810. private $enhanceSigchildCompatibility;
  45811. private $process;
  45812. private $status = self::STATUS_READY;
  45813. private $incrementalOutputOffset = 0;
  45814. private $incrementalErrorOutputOffset = 0;
  45815. private $tty;
  45816. private $pty;
  45817. private $useFileHandles = false;
  45818. private $processPipes;
  45819. private $latestSignal;
  45820. private static $sigchild;
  45821. public static $exitCodes = array(
  45822. 0 => 'OK',
  45823. 1 => 'General error',
  45824. 2 => 'Misuse of shell builtins',
  45825. 126 => 'Invoked command cannot execute',
  45826. 127 => 'Command not found',
  45827. 128 => 'Invalid exit argument',
  45828. 129 => 'Hangup',
  45829. 130 => 'Interrupt',
  45830. 131 => 'Quit and dump core',
  45831. 132 => 'Illegal instruction',
  45832. 133 => 'Trace/breakpoint trap',
  45833. 134 => 'Process aborted',
  45834. 135 => 'Bus error: "access to undefined portion of memory object"',
  45835. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  45836. 137 => 'Kill (terminate immediately)',
  45837. 138 => 'User-defined 1',
  45838. 139 => 'Segmentation violation',
  45839. 140 => 'User-defined 2',
  45840. 141 => 'Write to pipe with no one reading',
  45841. 142 => 'Signal raised by alarm',
  45842. 143 => 'Termination (request to terminate)',
  45843. 145 => 'Child process terminated, stopped (or continued*)',
  45844. 146 => 'Continue if stopped',
  45845. 147 => 'Stop executing temporarily',
  45846. 148 => 'Terminal stop signal',
  45847. 149 => 'Background process attempting to read from tty ("in")',
  45848. 150 => 'Background process attempting to write to tty ("out")',
  45849. 151 => 'Urgent data available on socket',
  45850. 152 => 'CPU time limit exceeded',
  45851. 153 => 'File size limit exceeded',
  45852. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  45853. 155 => 'Profiling timer expired',
  45854. 157 => 'Pollable event',
  45855. 159 => 'Bad syscall',
  45856. );
  45857. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  45858. {
  45859. if (!\function_exists('proc_open')) {
  45860. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  45861. }
  45862. $this->commandline = $commandline;
  45863. $this->cwd = $cwd;
  45864. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  45865. $this->cwd = getcwd();
  45866. }
  45867. if (null !== $env) {
  45868. $this->setEnv($env);
  45869. }
  45870. $this->setInput($input);
  45871. $this->setTimeout($timeout);
  45872. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  45873. $this->pty = false;
  45874. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  45875. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  45876. }
  45877. public function __destruct()
  45878. {
  45879. $this->stop(0);
  45880. }
  45881. public function __clone()
  45882. {
  45883. $this->resetProcessData();
  45884. }
  45885. public function run($callback = null)
  45886. {
  45887. $this->start($callback);
  45888. return $this->wait();
  45889. }
  45890. public function mustRun($callback = null)
  45891. {
  45892. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  45893. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  45894. }
  45895. if (0 !== $this->run($callback)) {
  45896. throw new ProcessFailedException($this);
  45897. }
  45898. return $this;
  45899. }
  45900. public function start($callback = null)
  45901. {
  45902. if ($this->isRunning()) {
  45903. throw new RuntimeException('Process is already running');
  45904. }
  45905. if ($this->outputDisabled && null !== $callback) {
  45906. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  45907. }
  45908. $this->resetProcessData();
  45909. $this->starttime = $this->lastOutputTime = microtime(true);
  45910. $this->callback = $this->buildCallback($callback);
  45911. $descriptors = $this->getDescriptors();
  45912. $commandline = $this->commandline;
  45913. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  45914. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  45915. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  45916. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  45917. }
  45918. $commandline .= '"';
  45919. if (!isset($this->options['bypass_shell'])) {
  45920. $this->options['bypass_shell'] = true;
  45921. }
  45922. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  45923. $descriptors[3] = array('pipe', 'w');
  45924. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  45925. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  45926. $ptsWorkaround = fopen(__FILE__, 'r');
  45927. }
  45928. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  45929. if (!\is_resource($this->process)) {
  45930. throw new RuntimeException('Unable to launch a new process.');
  45931. }
  45932. $this->status = self::STATUS_STARTED;
  45933. if (isset($descriptors[3])) {
  45934. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  45935. }
  45936. if ($this->tty) {
  45937. return;
  45938. }
  45939. $this->updateStatus(false);
  45940. $this->checkTimeout();
  45941. }
  45942. public function restart($callback = null)
  45943. {
  45944. if ($this->isRunning()) {
  45945. throw new RuntimeException('Process is already running');
  45946. }
  45947. $process = clone $this;
  45948. $process->start($callback);
  45949. return $process;
  45950. }
  45951. public function wait($callback = null)
  45952. {
  45953. $this->requireProcessIsStarted(__FUNCTION__);
  45954. $this->updateStatus(false);
  45955. if (null !== $callback) {
  45956. $this->callback = $this->buildCallback($callback);
  45957. }
  45958. do {
  45959. $this->checkTimeout();
  45960. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  45961. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  45962. } while ($running);
  45963. while ($this->isRunning()) {
  45964. usleep(1000);
  45965. }
  45966. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  45967. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  45968. }
  45969. return $this->exitcode;
  45970. }
  45971. public function getPid()
  45972. {
  45973. return $this->isRunning() ? $this->processInformation['pid'] : null;
  45974. }
  45975. public function signal($signal)
  45976. {
  45977. $this->doSignal($signal, true);
  45978. return $this;
  45979. }
  45980. public function disableOutput()
  45981. {
  45982. if ($this->isRunning()) {
  45983. throw new RuntimeException('Disabling output while the process is running is not possible.');
  45984. }
  45985. if (null !== $this->idleTimeout) {
  45986. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  45987. }
  45988. $this->outputDisabled = true;
  45989. return $this;
  45990. }
  45991. public function enableOutput()
  45992. {
  45993. if ($this->isRunning()) {
  45994. throw new RuntimeException('Enabling output while the process is running is not possible.');
  45995. }
  45996. $this->outputDisabled = false;
  45997. return $this;
  45998. }
  45999. public function isOutputDisabled()
  46000. {
  46001. return $this->outputDisabled;
  46002. }
  46003. public function getOutput()
  46004. {
  46005. $this->readPipesForOutput(__FUNCTION__);
  46006. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  46007. return '';
  46008. }
  46009. return $ret;
  46010. }
  46011. public function getIncrementalOutput()
  46012. {
  46013. $this->readPipesForOutput(__FUNCTION__);
  46014. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  46015. $this->incrementalOutputOffset = ftell($this->stdout);
  46016. if (false === $latest) {
  46017. return '';
  46018. }
  46019. return $latest;
  46020. }
  46021. public function clearOutput()
  46022. {
  46023. ftruncate($this->stdout, 0);
  46024. fseek($this->stdout, 0);
  46025. $this->incrementalOutputOffset = 0;
  46026. return $this;
  46027. }
  46028. public function getErrorOutput()
  46029. {
  46030. $this->readPipesForOutput(__FUNCTION__);
  46031. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  46032. return '';
  46033. }
  46034. return $ret;
  46035. }
  46036. public function getIncrementalErrorOutput()
  46037. {
  46038. $this->readPipesForOutput(__FUNCTION__);
  46039. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  46040. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  46041. if (false === $latest) {
  46042. return '';
  46043. }
  46044. return $latest;
  46045. }
  46046. public function clearErrorOutput()
  46047. {
  46048. ftruncate($this->stderr, 0);
  46049. fseek($this->stderr, 0);
  46050. $this->incrementalErrorOutputOffset = 0;
  46051. return $this;
  46052. }
  46053. public function getExitCode()
  46054. {
  46055. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  46056. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  46057. }
  46058. $this->updateStatus(false);
  46059. return $this->exitcode;
  46060. }
  46061. public function getExitCodeText()
  46062. {
  46063. if (null === $exitcode = $this->getExitCode()) {
  46064. return;
  46065. }
  46066. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  46067. }
  46068. public function isSuccessful()
  46069. {
  46070. return 0 === $this->getExitCode();
  46071. }
  46072. public function hasBeenSignaled()
  46073. {
  46074. $this->requireProcessIsTerminated(__FUNCTION__);
  46075. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  46076. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  46077. }
  46078. return $this->processInformation['signaled'];
  46079. }
  46080. public function getTermSignal()
  46081. {
  46082. $this->requireProcessIsTerminated(__FUNCTION__);
  46083. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  46084. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  46085. }
  46086. return $this->processInformation['termsig'];
  46087. }
  46088. public function hasBeenStopped()
  46089. {
  46090. $this->requireProcessIsTerminated(__FUNCTION__);
  46091. return $this->processInformation['stopped'];
  46092. }
  46093. public function getStopSignal()
  46094. {
  46095. $this->requireProcessIsTerminated(__FUNCTION__);
  46096. return $this->processInformation['stopsig'];
  46097. }
  46098. public function isRunning()
  46099. {
  46100. if (self::STATUS_STARTED !== $this->status) {
  46101. return false;
  46102. }
  46103. $this->updateStatus(false);
  46104. return $this->processInformation['running'];
  46105. }
  46106. public function isStarted()
  46107. {
  46108. return self::STATUS_READY != $this->status;
  46109. }
  46110. public function isTerminated()
  46111. {
  46112. $this->updateStatus(false);
  46113. return self::STATUS_TERMINATED == $this->status;
  46114. }
  46115. public function getStatus()
  46116. {
  46117. $this->updateStatus(false);
  46118. return $this->status;
  46119. }
  46120. public function stop($timeout = 10, $signal = null)
  46121. {
  46122. $timeoutMicro = microtime(true) + $timeout;
  46123. if ($this->isRunning()) {
  46124. $this->doSignal(15, false);
  46125. do {
  46126. usleep(1000);
  46127. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  46128. if ($this->isRunning()) {
  46129. $this->doSignal($signal ?: 9, false);
  46130. }
  46131. }
  46132. if ($this->isRunning()) {
  46133. if (isset($this->fallbackStatus['pid'])) {
  46134. unset($this->fallbackStatus['pid']);
  46135. return $this->stop(0, $signal);
  46136. }
  46137. $this->close();
  46138. }
  46139. return $this->exitcode;
  46140. }
  46141. public function addOutput($line)
  46142. {
  46143. $this->lastOutputTime = microtime(true);
  46144. fseek($this->stdout, 0, SEEK_END);
  46145. fwrite($this->stdout, $line);
  46146. fseek($this->stdout, $this->incrementalOutputOffset);
  46147. }
  46148. public function addErrorOutput($line)
  46149. {
  46150. $this->lastOutputTime = microtime(true);
  46151. fseek($this->stderr, 0, SEEK_END);
  46152. fwrite($this->stderr, $line);
  46153. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  46154. }
  46155. public function getCommandLine()
  46156. {
  46157. return $this->commandline;
  46158. }
  46159. public function setCommandLine($commandline)
  46160. {
  46161. $this->commandline = $commandline;
  46162. return $this;
  46163. }
  46164. public function getTimeout()
  46165. {
  46166. return $this->timeout;
  46167. }
  46168. public function getIdleTimeout()
  46169. {
  46170. return $this->idleTimeout;
  46171. }
  46172. public function setTimeout($timeout)
  46173. {
  46174. $this->timeout = $this->validateTimeout($timeout);
  46175. return $this;
  46176. }
  46177. public function setIdleTimeout($timeout)
  46178. {
  46179. if (null !== $timeout && $this->outputDisabled) {
  46180. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  46181. }
  46182. $this->idleTimeout = $this->validateTimeout($timeout);
  46183. return $this;
  46184. }
  46185. public function setTty($tty)
  46186. {
  46187. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  46188. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  46189. }
  46190. if ($tty) {
  46191. static $isTtySupported;
  46192. if (null === $isTtySupported) {
  46193. $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);
  46194. }
  46195. if (!$isTtySupported) {
  46196. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  46197. }
  46198. }
  46199. $this->tty = (bool) $tty;
  46200. return $this;
  46201. }
  46202. public function isTty()
  46203. {
  46204. return $this->tty;
  46205. }
  46206. public function setPty($bool)
  46207. {
  46208. $this->pty = (bool) $bool;
  46209. return $this;
  46210. }
  46211. public function isPty()
  46212. {
  46213. return $this->pty;
  46214. }
  46215. public function getWorkingDirectory()
  46216. {
  46217. if (null === $this->cwd) {
  46218. return getcwd() ?: null;
  46219. }
  46220. return $this->cwd;
  46221. }
  46222. public function setWorkingDirectory($cwd)
  46223. {
  46224. $this->cwd = $cwd;
  46225. return $this;
  46226. }
  46227. public function getEnv()
  46228. {
  46229. return $this->env;
  46230. }
  46231. public function setEnv(array $env)
  46232. {
  46233. $env = array_filter($env, function ($value) {
  46234. return !\is_array($value);
  46235. });
  46236. $this->env = array();
  46237. foreach ($env as $key => $value) {
  46238. $this->env[$key] = (string) $value;
  46239. }
  46240. return $this;
  46241. }
  46242. public function getStdin()
  46243. {
  46244. @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);
  46245. return $this->getInput();
  46246. }
  46247. public function getInput()
  46248. {
  46249. return $this->input;
  46250. }
  46251. public function setStdin($stdin)
  46252. {
  46253. @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);
  46254. return $this->setInput($stdin);
  46255. }
  46256. public function setInput($input)
  46257. {
  46258. if ($this->isRunning()) {
  46259. throw new LogicException('Input can not be set while the process is running.');
  46260. }
  46261. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  46262. return $this;
  46263. }
  46264. public function getOptions()
  46265. {
  46266. return $this->options;
  46267. }
  46268. public function setOptions(array $options)
  46269. {
  46270. $this->options = $options;
  46271. return $this;
  46272. }
  46273. public function getEnhanceWindowsCompatibility()
  46274. {
  46275. return $this->enhanceWindowsCompatibility;
  46276. }
  46277. public function setEnhanceWindowsCompatibility($enhance)
  46278. {
  46279. $this->enhanceWindowsCompatibility = (bool) $enhance;
  46280. return $this;
  46281. }
  46282. public function getEnhanceSigchildCompatibility()
  46283. {
  46284. return $this->enhanceSigchildCompatibility;
  46285. }
  46286. public function setEnhanceSigchildCompatibility($enhance)
  46287. {
  46288. $this->enhanceSigchildCompatibility = (bool) $enhance;
  46289. return $this;
  46290. }
  46291. public function checkTimeout()
  46292. {
  46293. if (self::STATUS_STARTED !== $this->status) {
  46294. return;
  46295. }
  46296. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  46297. $this->stop(0);
  46298. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  46299. }
  46300. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  46301. $this->stop(0);
  46302. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  46303. }
  46304. }
  46305. public static function isPtySupported()
  46306. {
  46307. static $result;
  46308. if (null !== $result) {
  46309. return $result;
  46310. }
  46311. if ('\\' === \DIRECTORY_SEPARATOR) {
  46312. return $result = false;
  46313. }
  46314. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  46315. }
  46316. private function getDescriptors()
  46317. {
  46318. if ('\\' === \DIRECTORY_SEPARATOR) {
  46319. $this->processPipes = WindowsPipes::create($this, $this->input);
  46320. } else {
  46321. $this->processPipes = UnixPipes::create($this, $this->input);
  46322. }
  46323. return $this->processPipes->getDescriptors();
  46324. }
  46325. protected function buildCallback($callback)
  46326. {
  46327. $that = $this;
  46328. $out = self::OUT;
  46329. $callback = function ($type, $data) use ($that, $callback, $out) {
  46330. if ($out == $type) {
  46331. $that->addOutput($data);
  46332. } else {
  46333. $that->addErrorOutput($data);
  46334. }
  46335. if (null !== $callback) {
  46336. \call_user_func($callback, $type, $data);
  46337. }
  46338. };
  46339. return $callback;
  46340. }
  46341. protected function updateStatus($blocking)
  46342. {
  46343. if (self::STATUS_STARTED !== $this->status) {
  46344. return;
  46345. }
  46346. $this->processInformation = proc_get_status($this->process);
  46347. $running = $this->processInformation['running'];
  46348. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  46349. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  46350. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  46351. }
  46352. if (!$running) {
  46353. $this->close();
  46354. }
  46355. }
  46356. protected function isSigchildEnabled()
  46357. {
  46358. if (null !== self::$sigchild) {
  46359. return self::$sigchild;
  46360. }
  46361. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  46362. return self::$sigchild = false;
  46363. }
  46364. ob_start();
  46365. phpinfo(INFO_GENERAL);
  46366. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  46367. }
  46368. private function readPipesForOutput($caller)
  46369. {
  46370. if ($this->outputDisabled) {
  46371. throw new LogicException('Output has been disabled.');
  46372. }
  46373. $this->requireProcessIsStarted($caller);
  46374. $this->updateStatus(false);
  46375. }
  46376. private function validateTimeout($timeout)
  46377. {
  46378. $timeout = (float) $timeout;
  46379. if (0.0 === $timeout) {
  46380. $timeout = null;
  46381. } elseif ($timeout < 0) {
  46382. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  46383. }
  46384. return $timeout;
  46385. }
  46386. private function readPipes($blocking, $close)
  46387. {
  46388. $result = $this->processPipes->readAndWrite($blocking, $close);
  46389. $callback = $this->callback;
  46390. foreach ($result as $type => $data) {
  46391. if (3 !== $type) {
  46392. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  46393. } elseif (!isset($this->fallbackStatus['signaled'])) {
  46394. $this->fallbackStatus['exitcode'] = (int) $data;
  46395. }
  46396. }
  46397. }
  46398. private function close()
  46399. {
  46400. $this->processPipes->close();
  46401. if (\is_resource($this->process)) {
  46402. proc_close($this->process);
  46403. }
  46404. $this->exitcode = $this->processInformation['exitcode'];
  46405. $this->status = self::STATUS_TERMINATED;
  46406. if (-1 === $this->exitcode) {
  46407. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  46408. $this->exitcode = 128 + $this->processInformation['termsig'];
  46409. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  46410. $this->processInformation['signaled'] = true;
  46411. $this->processInformation['termsig'] = -1;
  46412. }
  46413. }
  46414. $this->callback = null;
  46415. return $this->exitcode;
  46416. }
  46417. private function resetProcessData()
  46418. {
  46419. $this->starttime = null;
  46420. $this->callback = null;
  46421. $this->exitcode = null;
  46422. $this->fallbackStatus = array();
  46423. $this->processInformation = null;
  46424. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  46425. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  46426. $this->process = null;
  46427. $this->latestSignal = null;
  46428. $this->status = self::STATUS_READY;
  46429. $this->incrementalOutputOffset = 0;
  46430. $this->incrementalErrorOutputOffset = 0;
  46431. }
  46432. private function doSignal($signal, $throwException)
  46433. {
  46434. if (null === $pid = $this->getPid()) {
  46435. if ($throwException) {
  46436. throw new LogicException('Can not send signal on a non running process.');
  46437. }
  46438. return false;
  46439. }
  46440. if ('\\' === \DIRECTORY_SEPARATOR) {
  46441. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  46442. if ($exitCode && $this->isRunning()) {
  46443. if ($throwException) {
  46444. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  46445. }
  46446. return false;
  46447. }
  46448. } else {
  46449. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  46450. $ok = @proc_terminate($this->process, $signal);
  46451. } elseif (\function_exists('posix_kill')) {
  46452. $ok = @posix_kill($pid, $signal);
  46453. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  46454. $ok = false === fgets($pipes[2]);
  46455. }
  46456. if (!$ok) {
  46457. if ($throwException) {
  46458. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  46459. }
  46460. return false;
  46461. }
  46462. }
  46463. $this->latestSignal = (int) $signal;
  46464. $this->fallbackStatus['signaled'] = true;
  46465. $this->fallbackStatus['exitcode'] = -1;
  46466. $this->fallbackStatus['termsig'] = $this->latestSignal;
  46467. return true;
  46468. }
  46469. private function requireProcessIsStarted($functionName)
  46470. {
  46471. if (!$this->isStarted()) {
  46472. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  46473. }
  46474. }
  46475. private function requireProcessIsTerminated($functionName)
  46476. {
  46477. if (!$this->isTerminated()) {
  46478. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  46479. }
  46480. }
  46481. }
  46482. <?php
  46483. namespace Symfony\Component\Process;
  46484. use Symfony\Component\Process\Exception\InvalidArgumentException;
  46485. use Symfony\Component\Process\Exception\LogicException;
  46486. class ProcessBuilder
  46487. {
  46488. private $arguments;
  46489. private $cwd;
  46490. private $env = array();
  46491. private $input;
  46492. private $timeout = 60;
  46493. private $options = array();
  46494. private $inheritEnv = true;
  46495. private $prefix = array();
  46496. private $outputDisabled = false;
  46497. public function __construct(array $arguments = array())
  46498. {
  46499. $this->arguments = $arguments;
  46500. }
  46501. public static function create(array $arguments = array())
  46502. {
  46503. return new static($arguments);
  46504. }
  46505. public function add($argument)
  46506. {
  46507. $this->arguments[] = $argument;
  46508. return $this;
  46509. }
  46510. public function setPrefix($prefix)
  46511. {
  46512. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  46513. return $this;
  46514. }
  46515. public function setArguments(array $arguments)
  46516. {
  46517. $this->arguments = $arguments;
  46518. return $this;
  46519. }
  46520. public function setWorkingDirectory($cwd)
  46521. {
  46522. $this->cwd = $cwd;
  46523. return $this;
  46524. }
  46525. public function inheritEnvironmentVariables($inheritEnv = true)
  46526. {
  46527. $this->inheritEnv = $inheritEnv;
  46528. return $this;
  46529. }
  46530. public function setEnv($name, $value)
  46531. {
  46532. $this->env[$name] = $value;
  46533. return $this;
  46534. }
  46535. public function addEnvironmentVariables(array $variables)
  46536. {
  46537. $this->env = array_replace($this->env, $variables);
  46538. return $this;
  46539. }
  46540. public function setInput($input)
  46541. {
  46542. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  46543. return $this;
  46544. }
  46545. public function setTimeout($timeout)
  46546. {
  46547. if (null === $timeout) {
  46548. $this->timeout = null;
  46549. return $this;
  46550. }
  46551. $timeout = (float) $timeout;
  46552. if ($timeout < 0) {
  46553. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  46554. }
  46555. $this->timeout = $timeout;
  46556. return $this;
  46557. }
  46558. public function setOption($name, $value)
  46559. {
  46560. $this->options[$name] = $value;
  46561. return $this;
  46562. }
  46563. public function disableOutput()
  46564. {
  46565. $this->outputDisabled = true;
  46566. return $this;
  46567. }
  46568. public function enableOutput()
  46569. {
  46570. $this->outputDisabled = false;
  46571. return $this;
  46572. }
  46573. public function getProcess()
  46574. {
  46575. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  46576. throw new LogicException('You must add() command arguments before calling getProcess().');
  46577. }
  46578. $options = $this->options;
  46579. $arguments = array_merge($this->prefix, $this->arguments);
  46580. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  46581. if ($this->inheritEnv) {
  46582. $env = array_replace($_ENV, $_SERVER, $this->env);
  46583. } else {
  46584. $env = $this->env;
  46585. }
  46586. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  46587. if ($this->outputDisabled) {
  46588. $process->disableOutput();
  46589. }
  46590. return $process;
  46591. }
  46592. }
  46593. <?php
  46594. namespace Symfony\Component\Process;
  46595. use Symfony\Component\Process\Exception\InvalidArgumentException;
  46596. class ProcessUtils
  46597. {
  46598. private function __construct()
  46599. {
  46600. }
  46601. public static function escapeArgument($argument)
  46602. {
  46603. if ('\\' === \DIRECTORY_SEPARATOR) {
  46604. if ('' === $argument) {
  46605. return escapeshellarg($argument);
  46606. }
  46607. $escapedArgument = '';
  46608. $quote = false;
  46609. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  46610. if ('"' === $part) {
  46611. $escapedArgument .= '\\"';
  46612. } elseif (self::isSurroundedBy($part, '%')) {
  46613. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  46614. } else {
  46615. if ('\\' === substr($part, -1)) {
  46616. $part .= '\\';
  46617. }
  46618. $quote = true;
  46619. $escapedArgument .= $part;
  46620. }
  46621. }
  46622. if ($quote) {
  46623. $escapedArgument = '"'.$escapedArgument.'"';
  46624. }
  46625. return $escapedArgument;
  46626. }
  46627. return "'".str_replace("'", "'\\''", $argument)."'";
  46628. }
  46629. public static function validateInput($caller, $input)
  46630. {
  46631. if (null !== $input) {
  46632. if (\is_resource($input)) {
  46633. return $input;
  46634. }
  46635. if (\is_string($input)) {
  46636. return $input;
  46637. }
  46638. if (is_scalar($input)) {
  46639. return (string) $input;
  46640. }
  46641. if (\is_object($input) && method_exists($input, '__toString')) {
  46642. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  46643. return (string) $input;
  46644. }
  46645. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  46646. }
  46647. return $input;
  46648. }
  46649. private static function isSurroundedBy($arg, $char)
  46650. {
  46651. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  46652. }
  46653. }
  46654. Copyright (c) 2011 Jordi Boggiano
  46655. Permission is hereby granted, free of charge, to any person obtaining a copy
  46656. of this software and associated documentation files (the "Software"), to deal
  46657. in the Software without restriction, including without limitation the rights
  46658. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46659. copies of the Software, and to permit persons to whom the Software is furnished
  46660. to do so, subject to the following conditions:
  46661. The above copyright notice and this permission notice shall be included in all
  46662. copies or substantial portions of the Software.
  46663. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46664. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46665. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46666. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46667. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46668. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  46669. THE SOFTWARE.
  46670. <?php
  46671. namespace Seld\JsonLint;
  46672. class DuplicateKeyException extends ParsingException
  46673. {
  46674. public function __construct($message, $key, array $details = array())
  46675. {
  46676. $details['key'] = $key;
  46677. parent::__construct($message, $details);
  46678. }
  46679. public function getKey()
  46680. {
  46681. return $this->details['key'];
  46682. }
  46683. }
  46684. <?php
  46685. namespace Seld\JsonLint;
  46686. use stdClass;
  46687. class JsonParser
  46688. {
  46689. const DETECT_KEY_CONFLICTS = 1;
  46690. const ALLOW_DUPLICATE_KEYS = 2;
  46691. const PARSE_TO_ASSOC = 4;
  46692. private $lexer;
  46693. private $flags;
  46694. private $stack;
  46695. private $vstack;
  46696. private $lstack;
  46697. private $symbols = array(
  46698. 'error' => 2,
  46699. 'JSONString' => 3,
  46700. 'STRING' => 4,
  46701. 'JSONNumber' => 5,
  46702. 'NUMBER' => 6,
  46703. 'JSONNullLiteral' => 7,
  46704. 'NULL' => 8,
  46705. 'JSONBooleanLiteral' => 9,
  46706. 'TRUE' => 10,
  46707. 'FALSE' => 11,
  46708. 'JSONText' => 12,
  46709. 'JSONValue' => 13,
  46710. 'EOF' => 14,
  46711. 'JSONObject' => 15,
  46712. 'JSONArray' => 16,
  46713. '{' => 17,
  46714. '}' => 18,
  46715. 'JSONMemberList' => 19,
  46716. 'JSONMember' => 20,
  46717. ':' => 21,
  46718. ',' => 22,
  46719. '[' => 23,
  46720. ']' => 24,
  46721. 'JSONElementList' => 25,
  46722. '$accept' => 0,
  46723. '$end' => 1,
  46724. );
  46725. private $terminals_ = array(
  46726. 2 => "error",
  46727. 4 => "STRING",
  46728. 6 => "NUMBER",
  46729. 8 => "NULL",
  46730. 10 => "TRUE",
  46731. 11 => "FALSE",
  46732. 14 => "EOF",
  46733. 17 => "{",
  46734. 18 => "}",
  46735. 21 => ":",
  46736. 22 => ",",
  46737. 23 => "[",
  46738. 24 => "]",
  46739. );
  46740. private $productions_ = array(
  46741. 0,
  46742. array(3, 1),
  46743. array(5, 1),
  46744. array(7, 1),
  46745. array(9, 1),
  46746. array(9, 1),
  46747. array(12, 2),
  46748. array(13, 1),
  46749. array(13, 1),
  46750. array(13, 1),
  46751. array(13, 1),
  46752. array(13, 1),
  46753. array(13, 1),
  46754. array(15, 2),
  46755. array(15, 3),
  46756. array(20, 3),
  46757. array(19, 1),
  46758. array(19, 3),
  46759. array(16, 2),
  46760. array(16, 3),
  46761. array(25, 1),
  46762. array(25, 3)
  46763. );
  46764. 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)),
  46765. );
  46766. private $defaultActions = array(
  46767. 16 => array(2, 6)
  46768. );
  46769. public function lint($input, $flags = 0)
  46770. {
  46771. try {
  46772. $this->parse($input, $flags);
  46773. } catch (ParsingException $e) {
  46774. return $e;
  46775. }
  46776. }
  46777. public function parse($input, $flags = 0)
  46778. {
  46779. $this->failOnBOM($input);
  46780. $this->flags = $flags;
  46781. $this->stack = array(0);
  46782. $this->vstack = array(null);
  46783. $this->lstack = array();
  46784. $yytext = '';
  46785. $yylineno = 0;
  46786. $yyleng = 0;
  46787. $recovering = 0;
  46788. $TERROR = 2;
  46789. $EOF = 1;
  46790. $this->lexer = new Lexer();
  46791. $this->lexer->setInput($input);
  46792. $yyloc = $this->lexer->yylloc;
  46793. $this->lstack[] = $yyloc;
  46794. $symbol = null;
  46795. $preErrorSymbol = null;
  46796. $state = null;
  46797. $action = null;
  46798. $a = null;
  46799. $r = null;
  46800. $yyval = new stdClass;
  46801. $p = null;
  46802. $len = null;
  46803. $newState = null;
  46804. $expected = null;
  46805. $errStr = null;
  46806. while (true) {
  46807. $state = $this->stack[count($this->stack)-1];
  46808. if (isset($this->defaultActions[$state])) {
  46809. $action = $this->defaultActions[$state];
  46810. } else {
  46811. if ($symbol == null) {
  46812. $symbol = $this->lex();
  46813. }
  46814. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  46815. }
  46816. if (!$action || !$action[0]) {
  46817. if (!$recovering) {
  46818. $expected = array();
  46819. foreach ($this->table[$state] as $p => $ignore) {
  46820. if (isset($this->terminals_[$p]) && $p > 2) {
  46821. $expected[] = "'" . $this->terminals_[$p] . "'";
  46822. }
  46823. }
  46824. $message = null;
  46825. if (in_array("'STRING'", $expected) && in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  46826. $message = "Invalid string";
  46827. if ("'" === substr($this->lexer->match, 0, 1)) {
  46828. $message .= ", it appears you used single quotes instead of double quotes";
  46829. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u])}', $this->lexer->getUpcomingInput(), $match)) {
  46830. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  46831. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getUpcomingInput())) {
  46832. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  46833. }
  46834. }
  46835. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  46836. $errStr .= $this->lexer->showPosition() . "\n";
  46837. if ($message) {
  46838. $errStr .= $message;
  46839. } else {
  46840. $errStr .= (count($expected) > 1) ? "Expected one of: " : "Expected: ";
  46841. $errStr .= implode(', ', $expected);
  46842. }
  46843. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  46844. $errStr .= " - It appears you have an extra trailing comma";
  46845. }
  46846. $this->parseError($errStr, array(
  46847. 'text' => $this->lexer->match,
  46848. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  46849. 'line' => $this->lexer->yylineno,
  46850. 'loc' => $yyloc,
  46851. 'expected' => $expected,
  46852. ));
  46853. }
  46854. if ($recovering == 3) {
  46855. if ($symbol == $EOF) {
  46856. throw new ParsingException($errStr ?: 'Parsing halted.');
  46857. }
  46858. $yyleng = $this->lexer->yyleng;
  46859. $yytext = $this->lexer->yytext;
  46860. $yylineno = $this->lexer->yylineno;
  46861. $yyloc = $this->lexer->yylloc;
  46862. $symbol = $this->lex();
  46863. }
  46864. while (true) {
  46865. if (array_key_exists($TERROR, $this->table[$state])) {
  46866. break;
  46867. }
  46868. if ($state == 0) {
  46869. throw new ParsingException($errStr ?: 'Parsing halted.');
  46870. }
  46871. $this->popStack(1);
  46872. $state = $this->stack[count($this->stack)-1];
  46873. }
  46874. $preErrorSymbol = $symbol;
  46875. $symbol = $TERROR;
  46876. $state = $this->stack[count($this->stack)-1];
  46877. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  46878. $recovering = 3;
  46879. }
  46880. if (is_array($action[0]) && count($action) > 1) {
  46881. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  46882. }
  46883. switch ($action[0]) {
  46884. case 1:
  46885. $this->stack[] = $symbol;
  46886. $this->vstack[] = $this->lexer->yytext;
  46887. $this->lstack[] = $this->lexer->yylloc;
  46888. $this->stack[] = $action[1];
  46889. $symbol = null;
  46890. if (!$preErrorSymbol) {
  46891. $yyleng = $this->lexer->yyleng;
  46892. $yytext = $this->lexer->yytext;
  46893. $yylineno = $this->lexer->yylineno;
  46894. $yyloc = $this->lexer->yylloc;
  46895. if ($recovering > 0) {
  46896. $recovering--;
  46897. }
  46898. } else {
  46899. $symbol = $preErrorSymbol;
  46900. $preErrorSymbol = null;
  46901. }
  46902. break;
  46903. case 2:
  46904. $len = $this->productions_[$action[1]][1];
  46905. $yyval->token = $this->vstack[count($this->vstack) - $len];
  46906. $yyval->store = array(
  46907. 'first_line' => $this->lstack[count($this->lstack) - ($len ?: 1)]['first_line'],
  46908. 'last_line' => $this->lstack[count($this->lstack) - 1]['last_line'],
  46909. 'first_column' => $this->lstack[count($this->lstack) - ($len ?: 1)]['first_column'],
  46910. 'last_column' => $this->lstack[count($this->lstack) - 1]['last_column'],
  46911. );
  46912. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack, $this->lstack);
  46913. if (!$r instanceof Undefined) {
  46914. return $r;
  46915. }
  46916. if ($len) {
  46917. $this->popStack($len);
  46918. }
  46919. $this->stack[] = $this->productions_[$action[1]][0];
  46920. $this->vstack[] = $yyval->token;
  46921. $this->lstack[] = $yyval->store;
  46922. $newState = $this->table[$this->stack[count($this->stack)-2]][$this->stack[count($this->stack)-1]];
  46923. $this->stack[] = $newState;
  46924. break;
  46925. case 3:
  46926. return true;
  46927. }
  46928. }
  46929. return true;
  46930. }
  46931. protected function parseError($str, $hash)
  46932. {
  46933. throw new ParsingException($str, $hash);
  46934. }
  46935. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  46936. {
  46937. $len = count($tokens) - 1;
  46938. switch ($yystate) {
  46939. case 1:
  46940. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  46941. $yyval->token = $yytext;
  46942. break;
  46943. case 2:
  46944. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  46945. $yyval->token = floatval($yytext);
  46946. } else {
  46947. $yyval->token = strpos($yytext, '.') === false ? intval($yytext) : floatval($yytext);
  46948. }
  46949. break;
  46950. case 3:
  46951. $yyval->token = null;
  46952. break;
  46953. case 4:
  46954. $yyval->token = true;
  46955. break;
  46956. case 5:
  46957. $yyval->token = false;
  46958. break;
  46959. case 6:
  46960. return $yyval->token = $tokens[$len-1];
  46961. case 13:
  46962. if ($this->flags & self::PARSE_TO_ASSOC) {
  46963. $yyval->token = array();
  46964. } else {
  46965. $yyval->token = new stdClass;
  46966. }
  46967. break;
  46968. case 14:
  46969. $yyval->token = $tokens[$len-1];
  46970. break;
  46971. case 15:
  46972. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  46973. break;
  46974. case 16:
  46975. if (PHP_VERSION_ID < 70100) {
  46976. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  46977. } else {
  46978. $property = $tokens[$len][0];
  46979. }
  46980. if ($this->flags & self::PARSE_TO_ASSOC) {
  46981. $yyval->token = array();
  46982. $yyval->token[$property] = $tokens[$len][1];
  46983. } else {
  46984. $yyval->token = new stdClass;
  46985. $yyval->token->$property = $tokens[$len][1];
  46986. }
  46987. break;
  46988. case 17:
  46989. if ($this->flags & self::PARSE_TO_ASSOC) {
  46990. $yyval->token =& $tokens[$len-2];
  46991. $key = $tokens[$len][0];
  46992. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  46993. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  46994. $errStr .= $this->lexer->showPosition() . "\n";
  46995. $errStr .= "Duplicate key: ".$tokens[$len][0];
  46996. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  46997. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  46998. $duplicateCount = 1;
  46999. do {
  47000. $duplicateKey = $key . '.' . $duplicateCount++;
  47001. } while (isset($tokens[$len-2][$duplicateKey]));
  47002. $key = $duplicateKey;
  47003. }
  47004. $tokens[$len-2][$key] = $tokens[$len][1];
  47005. } else {
  47006. $yyval->token = $tokens[$len-2];
  47007. if (PHP_VERSION_ID < 70100) {
  47008. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  47009. } else {
  47010. $key = $tokens[$len][0];
  47011. }
  47012. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  47013. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47014. $errStr .= $this->lexer->showPosition() . "\n";
  47015. $errStr .= "Duplicate key: ".$tokens[$len][0];
  47016. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  47017. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  47018. $duplicateCount = 1;
  47019. do {
  47020. $duplicateKey = $key . '.' . $duplicateCount++;
  47021. } while (isset($tokens[$len-2]->$duplicateKey));
  47022. $key = $duplicateKey;
  47023. }
  47024. $tokens[$len-2]->$key = $tokens[$len][1];
  47025. }
  47026. break;
  47027. case 18:
  47028. $yyval->token = array();
  47029. break;
  47030. case 19:
  47031. $yyval->token = $tokens[$len-1];
  47032. break;
  47033. case 20:
  47034. $yyval->token = array($tokens[$len]);
  47035. break;
  47036. case 21:
  47037. $tokens[$len-2][] = $tokens[$len];
  47038. $yyval->token = $tokens[$len-2];
  47039. break;
  47040. }
  47041. return new Undefined();
  47042. }
  47043. private function stringInterpolation($match)
  47044. {
  47045. switch ($match[0]) {
  47046. case '\\\\':
  47047. return '\\';
  47048. case '\"':
  47049. return '"';
  47050. case '\b':
  47051. return chr(8);
  47052. case '\f':
  47053. return chr(12);
  47054. case '\n':
  47055. return "\n";
  47056. case '\r':
  47057. return "\r";
  47058. case '\t':
  47059. return "\t";
  47060. case '\/':
  47061. return "/";
  47062. default:
  47063. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', 0, 'UTF-8');
  47064. }
  47065. }
  47066. private function popStack($n)
  47067. {
  47068. $this->stack = array_slice($this->stack, 0, - (2 * $n));
  47069. $this->vstack = array_slice($this->vstack, 0, - $n);
  47070. $this->lstack = array_slice($this->lstack, 0, - $n);
  47071. }
  47072. private function lex()
  47073. {
  47074. $token = $this->lexer->lex() ?: 1;
  47075. if (!is_numeric($token)) {
  47076. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  47077. }
  47078. return $token;
  47079. }
  47080. private function failOnBOM($input)
  47081. {
  47082. $bom = "\xEF\xBB\xBF";
  47083. if (substr($input, 0, 3) === $bom) {
  47084. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  47085. }
  47086. }
  47087. }
  47088. <?php
  47089. namespace Seld\JsonLint;
  47090. class Lexer
  47091. {
  47092. private $EOF = 1;
  47093. private $rules = array(
  47094. 0 => '/^\s+/',
  47095. 1 => '/^-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  47096. 2 => '{^"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  47097. 3 => '/^\{/',
  47098. 4 => '/^\}/',
  47099. 5 => '/^\[/',
  47100. 6 => '/^\]/',
  47101. 7 => '/^,/',
  47102. 8 => '/^:/',
  47103. 9 => '/^true\b/',
  47104. 10 => '/^false\b/',
  47105. 11 => '/^null\b/',
  47106. 12 => '/^$/',
  47107. 13 => '/^./',
  47108. );
  47109. private $conditions = array(
  47110. "INITIAL" => array(
  47111. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  47112. "inclusive" => true,
  47113. ),
  47114. );
  47115. private $conditionStack;
  47116. private $input;
  47117. private $more;
  47118. private $done;
  47119. private $matched;
  47120. public $match;
  47121. public $yylineno;
  47122. public $yyleng;
  47123. public $yytext;
  47124. public $yylloc;
  47125. public function lex()
  47126. {
  47127. $r = $this->next();
  47128. if (!$r instanceof Undefined) {
  47129. return $r;
  47130. }
  47131. return $this->lex();
  47132. }
  47133. public function setInput($input)
  47134. {
  47135. $this->input = $input;
  47136. $this->more = false;
  47137. $this->done = false;
  47138. $this->yylineno = $this->yyleng = 0;
  47139. $this->yytext = $this->matched = $this->match = '';
  47140. $this->conditionStack = array('INITIAL');
  47141. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  47142. return $this;
  47143. }
  47144. public function showPosition()
  47145. {
  47146. $pre = str_replace("\n", '', $this->getPastInput());
  47147. $c = str_repeat('-', max(0, strlen($pre) - 1));
  47148. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  47149. }
  47150. public function getPastInput()
  47151. {
  47152. $past = substr($this->matched, 0, strlen($this->matched) - strlen($this->match));
  47153. return (strlen($past) > 20 ? '...' : '') . substr($past, -20);
  47154. }
  47155. public function getUpcomingInput()
  47156. {
  47157. $next = $this->match;
  47158. if (strlen($next) < 20) {
  47159. $next .= substr($this->input, 0, 20 - strlen($next));
  47160. }
  47161. return substr($next, 0, 20) . (strlen($next) > 20 ? '...' : '');
  47162. }
  47163. protected function parseError($str, $hash)
  47164. {
  47165. throw new \Exception($str);
  47166. }
  47167. private function next()
  47168. {
  47169. if ($this->done) {
  47170. return $this->EOF;
  47171. }
  47172. if ($this->input === '') {
  47173. $this->done = true;
  47174. }
  47175. $token = null;
  47176. $match = null;
  47177. $col = null;
  47178. $lines = null;
  47179. if (!$this->more) {
  47180. $this->yytext = '';
  47181. $this->match = '';
  47182. }
  47183. $rules = $this->getCurrentRules();
  47184. $rulesLen = count($rules);
  47185. for ($i=0; $i < $rulesLen; $i++) {
  47186. if (preg_match($this->rules[$rules[$i]], $this->input, $match)) {
  47187. preg_match_all('/\n.*/', $match[0], $lines);
  47188. $lines = $lines[0];
  47189. if ($lines) {
  47190. $this->yylineno += count($lines);
  47191. }
  47192. $this->yylloc = array(
  47193. 'first_line' => $this->yylloc['last_line'],
  47194. 'last_line' => $this->yylineno+1,
  47195. 'first_column' => $this->yylloc['last_column'],
  47196. 'last_column' => $lines ? strlen($lines[count($lines) - 1]) - 1 : $this->yylloc['last_column'] + strlen($match[0]),
  47197. );
  47198. $this->yytext .= $match[0];
  47199. $this->match .= $match[0];
  47200. $this->yyleng = strlen($this->yytext);
  47201. $this->more = false;
  47202. $this->input = substr($this->input, strlen($match[0]));
  47203. $this->matched .= $match[0];
  47204. $token = $this->performAction($rules[$i], $this->conditionStack[count($this->conditionStack)-1]);
  47205. if ($token) {
  47206. return $token;
  47207. }
  47208. return new Undefined();
  47209. }
  47210. }
  47211. if ($this->input === "") {
  47212. return $this->EOF;
  47213. }
  47214. $this->parseError(
  47215. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  47216. array(
  47217. 'text' => "",
  47218. 'token' => null,
  47219. 'line' => $this->yylineno,
  47220. )
  47221. );
  47222. }
  47223. private function getCurrentRules()
  47224. {
  47225. return $this->conditions[$this->conditionStack[count($this->conditionStack)-1]]['rules'];
  47226. }
  47227. private function performAction($avoiding_name_collisions, $YY_START)
  47228. {
  47229. switch ($avoiding_name_collisions) {
  47230. case 0:
  47231. break;
  47232. case 1:
  47233. return 6;
  47234. break;
  47235. case 2:
  47236. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  47237. return 4;
  47238. case 3:
  47239. return 17;
  47240. case 4:
  47241. return 18;
  47242. case 5:
  47243. return 23;
  47244. case 6:
  47245. return 24;
  47246. case 7:
  47247. return 22;
  47248. case 8:
  47249. return 21;
  47250. case 9:
  47251. return 10;
  47252. case 10:
  47253. return 11;
  47254. case 11:
  47255. return 8;
  47256. case 12:
  47257. return 14;
  47258. case 13:
  47259. return 'INVALID';
  47260. }
  47261. }
  47262. }
  47263. <?php
  47264. namespace Seld\JsonLint;
  47265. class ParsingException extends \Exception
  47266. {
  47267. protected $details;
  47268. public function __construct($message, $details = array())
  47269. {
  47270. $this->details = $details;
  47271. parent::__construct($message);
  47272. }
  47273. public function getDetails()
  47274. {
  47275. return $this->details;
  47276. }
  47277. }
  47278. <?php
  47279. namespace Seld\JsonLint;
  47280. class Undefined
  47281. {
  47282. }
  47283. MIT License
  47284. Copyright (c) 2016
  47285. Permission is hereby granted, free of charge, to any person obtaining a copy
  47286. of this software and associated documentation files (the "Software"), to deal
  47287. in the Software without restriction, including without limitation the rights
  47288. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47289. copies of the Software, and to permit persons to whom the Software is
  47290. furnished to do so, subject to the following conditions:
  47291. The above copyright notice and this permission notice shall be included in all
  47292. copies or substantial portions of the Software.
  47293. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47294. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47295. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47296. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47297. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47298. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  47299. SOFTWARE.
  47300. <?php
  47301. require __DIR__ . '/../vendor/autoload.php';
  47302. $data = json_decode(file_get_contents('data.json'));
  47303. $validator = new JsonSchema\Validator();
  47304. $validator->check($data, (object) array('$ref' => 'file://' . realpath('schema.json')));
  47305. if ($validator->isValid()) {
  47306. echo "The supplied JSON validates against the schema.\n";
  47307. } else {
  47308. echo "JSON does not validate. Violations:\n";
  47309. foreach ($validator->getErrors() as $error) {
  47310. echo sprintf("[%s] %s\n", $error['property'], $error['message']);
  47311. }
  47312. }
  47313. <?php
  47314. namespace JsonSchema\Constraints;
  47315. use JsonSchema\Entity\JsonPointer;
  47316. use JsonSchema\Exception\InvalidArgumentException;
  47317. use JsonSchema\Exception\ValidationException;
  47318. use JsonSchema\Validator;
  47319. class BaseConstraint
  47320. {
  47321. protected $errors = array();
  47322. protected $errorMask = Validator::ERROR_NONE;
  47323. protected $factory;
  47324. public function __construct(Factory $factory = null)
  47325. {
  47326. $this->factory = $factory ?: new Factory();
  47327. }
  47328. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  47329. {
  47330. $error = array(
  47331. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  47332. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  47333. 'message' => $message,
  47334. 'constraint' => $constraint,
  47335. 'context' => $this->factory->getErrorContext(),
  47336. );
  47337. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  47338. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  47339. }
  47340. if (is_array($more) && count($more) > 0) {
  47341. $error += $more;
  47342. }
  47343. $this->errors[] = $error;
  47344. $this->errorMask |= $error['context'];
  47345. }
  47346. public function addErrors(array $errors)
  47347. {
  47348. if ($errors) {
  47349. $this->errors = array_merge($this->errors, $errors);
  47350. $errorMask = &$this->errorMask;
  47351. array_walk($errors, function ($error) use (&$errorMask) {
  47352. if (isset($error['context'])) {
  47353. $errorMask |= $error['context'];
  47354. }
  47355. });
  47356. }
  47357. }
  47358. public function getErrors($errorContext = Validator::ERROR_ALL)
  47359. {
  47360. if ($errorContext === Validator::ERROR_ALL) {
  47361. return $this->errors;
  47362. }
  47363. return array_filter($this->errors, function ($error) use ($errorContext) {
  47364. if ($errorContext & $error['context']) {
  47365. return true;
  47366. }
  47367. });
  47368. }
  47369. public function numErrors($errorContext = Validator::ERROR_ALL)
  47370. {
  47371. if ($errorContext === Validator::ERROR_ALL) {
  47372. return count($this->errors);
  47373. }
  47374. return count($this->getErrors($errorContext));
  47375. }
  47376. public function isValid()
  47377. {
  47378. return !$this->getErrors();
  47379. }
  47380. public function reset()
  47381. {
  47382. $this->errors = array();
  47383. $this->errorMask = Validator::ERROR_NONE;
  47384. }
  47385. public function getErrorMask()
  47386. {
  47387. return $this->errorMask;
  47388. }
  47389. public static function arrayToObjectRecursive($array)
  47390. {
  47391. $json = json_encode($array);
  47392. if (json_last_error() !== \JSON_ERROR_NONE) {
  47393. $message = 'Unable to encode schema array as JSON';
  47394. if (function_exists('json_last_error_msg')) {
  47395. $message .= ': ' . json_last_error_msg();
  47396. }
  47397. throw new InvalidArgumentException($message);
  47398. }
  47399. return (object) json_decode($json);
  47400. }
  47401. }
  47402. <?php
  47403. namespace JsonSchema\Constraints;
  47404. use JsonSchema\Entity\JsonPointer;
  47405. class CollectionConstraint extends Constraint
  47406. {
  47407. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47408. {
  47409. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  47410. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  47411. }
  47412. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  47413. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  47414. }
  47415. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  47416. $unique = $value;
  47417. if (is_array($value) && count($value)) {
  47418. $unique = array_map(function ($e) {
  47419. return var_export($e, true);
  47420. }, $value);
  47421. }
  47422. if (count(array_unique($unique)) != count($value)) {
  47423. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  47424. }
  47425. }
  47426. if (isset($schema->items)) {
  47427. $this->validateItems($value, $schema, $path, $i);
  47428. }
  47429. }
  47430. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47431. {
  47432. if (is_object($schema->items)) {
  47433. if (isset($schema->items->type)
  47434. && (
  47435. $schema->items->type == 'string'
  47436. || $schema->items->type == 'number'
  47437. || $schema->items->type == 'integer'
  47438. )
  47439. && !isset($schema->additionalItems)
  47440. ) {
  47441. $type = $schema->items->type;
  47442. $typeValidator = $this->factory->createInstanceFor('type');
  47443. $validator = $this->factory->createInstanceFor($type === 'integer' ? 'number' : $type);
  47444. foreach ($value as $k => &$v) {
  47445. $k_path = $this->incrementPath($path, $k);
  47446. $typeValidator->check($v, $schema->items, $k_path, $i);
  47447. $validator->check($v, $schema->items, $k_path, $i);
  47448. }
  47449. unset($v);
  47450. $this->addErrors($typeValidator->getErrors());
  47451. $this->addErrors($validator->getErrors());
  47452. } else {
  47453. foreach ($value as $k => &$v) {
  47454. $initErrors = $this->getErrors();
  47455. $this->checkUndefined($v, $schema->items, $path, $k);
  47456. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  47457. $secondErrors = $this->getErrors();
  47458. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  47459. }
  47460. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  47461. $this->errors = $secondErrors;
  47462. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  47463. $this->errors = $initErrors;
  47464. }
  47465. }
  47466. unset($v);
  47467. }
  47468. } else {
  47469. foreach ($value as $k => &$v) {
  47470. if (array_key_exists($k, $schema->items)) {
  47471. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  47472. } else {
  47473. if (property_exists($schema, 'additionalItems')) {
  47474. if ($schema->additionalItems !== false) {
  47475. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  47476. } else {
  47477. $this->addError(
  47478. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  47479. }
  47480. } else {
  47481. $this->checkUndefined($v, new \stdClass(), $path, $k);
  47482. }
  47483. }
  47484. }
  47485. unset($v);
  47486. if (count($value) > 0) {
  47487. for ($k = count($value); $k < count($schema->items); $k++) {
  47488. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  47489. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  47490. }
  47491. }
  47492. }
  47493. }
  47494. }
  47495. <?php
  47496. namespace JsonSchema\Constraints;
  47497. use JsonSchema\Entity\JsonPointer;
  47498. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  47499. {
  47500. protected $inlineSchemaProperty = '$schema';
  47501. const CHECK_MODE_NONE = 0x00000000;
  47502. const CHECK_MODE_NORMAL = 0x00000001;
  47503. const CHECK_MODE_TYPE_CAST = 0x00000002;
  47504. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  47505. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  47506. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  47507. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  47508. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  47509. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  47510. protected function incrementPath(JsonPointer $path = null, $i)
  47511. {
  47512. $path = $path ?: new JsonPointer('');
  47513. $path = $path->withPropertyPaths(
  47514. array_merge(
  47515. $path->getPropertyPaths(),
  47516. array_filter(array($i), 'strlen')
  47517. )
  47518. );
  47519. return $path;
  47520. }
  47521. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47522. {
  47523. $validator = $this->factory->createInstanceFor('collection');
  47524. $validator->check($value, $schema, $path, $i);
  47525. $this->addErrors($validator->getErrors());
  47526. }
  47527. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  47528. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  47529. {
  47530. $validator = $this->factory->createInstanceFor('object');
  47531. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  47532. $this->addErrors($validator->getErrors());
  47533. }
  47534. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  47535. {
  47536. $validator = $this->factory->createInstanceFor('type');
  47537. $validator->check($value, $schema, $path, $i);
  47538. $this->addErrors($validator->getErrors());
  47539. }
  47540. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  47541. {
  47542. $validator = $this->factory->createInstanceFor('undefined');
  47543. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  47544. $this->addErrors($validator->getErrors());
  47545. }
  47546. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  47547. {
  47548. $validator = $this->factory->createInstanceFor('string');
  47549. $validator->check($value, $schema, $path, $i);
  47550. $this->addErrors($validator->getErrors());
  47551. }
  47552. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  47553. {
  47554. $validator = $this->factory->createInstanceFor('number');
  47555. $validator->check($value, $schema, $path, $i);
  47556. $this->addErrors($validator->getErrors());
  47557. }
  47558. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  47559. {
  47560. $validator = $this->factory->createInstanceFor('enum');
  47561. $validator->check($value, $schema, $path, $i);
  47562. $this->addErrors($validator->getErrors());
  47563. }
  47564. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  47565. {
  47566. $validator = $this->factory->createInstanceFor('format');
  47567. $validator->check($value, $schema, $path, $i);
  47568. $this->addErrors($validator->getErrors());
  47569. }
  47570. protected function getTypeCheck()
  47571. {
  47572. return $this->factory->getTypeCheck();
  47573. }
  47574. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  47575. {
  47576. $result = array_map(
  47577. function ($path) {
  47578. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  47579. },
  47580. $pointer->getPropertyPaths()
  47581. );
  47582. return trim(implode('', $result), '.');
  47583. }
  47584. }
  47585. <?php
  47586. namespace JsonSchema\Constraints;
  47587. use JsonSchema\Entity\JsonPointer;
  47588. interface ConstraintInterface
  47589. {
  47590. public function getErrors();
  47591. public function addErrors(array $errors);
  47592. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  47593. public function isValid();
  47594. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  47595. }
  47596. <?php
  47597. namespace JsonSchema\Constraints;
  47598. use JsonSchema\Entity\JsonPointer;
  47599. class EnumConstraint extends Constraint
  47600. {
  47601. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  47602. {
  47603. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  47604. return;
  47605. }
  47606. $type = gettype($element);
  47607. foreach ($schema->enum as $enum) {
  47608. $enumType = gettype($enum);
  47609. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  47610. if ((object) $element == $enum) {
  47611. return;
  47612. }
  47613. }
  47614. if ($type === gettype($enum)) {
  47615. if ($type == 'object') {
  47616. if ($element == $enum) {
  47617. return;
  47618. }
  47619. } elseif ($element === $enum) {
  47620. return;
  47621. }
  47622. }
  47623. }
  47624. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  47625. }
  47626. }
  47627. <?php
  47628. namespace JsonSchema\Constraints;
  47629. use JsonSchema\Exception\InvalidArgumentException;
  47630. use JsonSchema\SchemaStorage;
  47631. use JsonSchema\SchemaStorageInterface;
  47632. use JsonSchema\Uri\UriRetriever;
  47633. use JsonSchema\UriRetrieverInterface;
  47634. use JsonSchema\Validator;
  47635. class Factory
  47636. {
  47637. protected $schemaStorage;
  47638. protected $uriRetriever;
  47639. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  47640. private $typeCheck = array();
  47641. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  47642. protected $constraintMap = array(
  47643. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  47644. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  47645. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  47646. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  47647. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  47648. 'string' => 'JsonSchema\Constraints\StringConstraint',
  47649. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  47650. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  47651. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  47652. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  47653. 'validator' => 'JsonSchema\Validator'
  47654. );
  47655. private $instanceCache = array();
  47656. public function __construct(
  47657. SchemaStorageInterface $schemaStorage = null,
  47658. UriRetrieverInterface $uriRetriever = null,
  47659. $checkMode = Constraint::CHECK_MODE_NORMAL
  47660. ) {
  47661. $this->setConfig($checkMode);
  47662. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  47663. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  47664. }
  47665. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  47666. {
  47667. $this->checkMode = $checkMode;
  47668. }
  47669. public function addConfig($options)
  47670. {
  47671. $this->checkMode |= $options;
  47672. }
  47673. public function removeConfig($options)
  47674. {
  47675. $this->checkMode &= ~$options;
  47676. }
  47677. public function getConfig($options = null)
  47678. {
  47679. if ($options === null) {
  47680. return $this->checkMode;
  47681. }
  47682. return $this->checkMode & $options;
  47683. }
  47684. public function getUriRetriever()
  47685. {
  47686. return $this->uriRetriever;
  47687. }
  47688. public function getSchemaStorage()
  47689. {
  47690. return $this->schemaStorage;
  47691. }
  47692. public function getTypeCheck()
  47693. {
  47694. if (!isset($this->typeCheck[$this->checkMode])) {
  47695. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  47696. ? new TypeCheck\LooseTypeCheck()
  47697. : new TypeCheck\StrictTypeCheck();
  47698. }
  47699. return $this->typeCheck[$this->checkMode];
  47700. }
  47701. public function setConstraintClass($name, $class)
  47702. {
  47703. if (!class_exists($class)) {
  47704. throw new InvalidArgumentException('Unknown constraint ' . $name);
  47705. }
  47706. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  47707. throw new InvalidArgumentException('Invalid class ' . $name);
  47708. }
  47709. $this->constraintMap[$name] = $class;
  47710. return $this;
  47711. }
  47712. public function createInstanceFor($constraintName)
  47713. {
  47714. if (!isset($this->constraintMap[$constraintName])) {
  47715. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  47716. }
  47717. if (!isset($this->instanceCache[$constraintName])) {
  47718. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  47719. }
  47720. return clone $this->instanceCache[$constraintName];
  47721. }
  47722. public function getErrorContext()
  47723. {
  47724. return $this->errorContext;
  47725. }
  47726. public function setErrorContext($errorContext)
  47727. {
  47728. $this->errorContext = $errorContext;
  47729. }
  47730. }
  47731. <?php
  47732. namespace JsonSchema\Constraints;
  47733. use JsonSchema\Entity\JsonPointer;
  47734. use JsonSchema\Rfc3339;
  47735. class FormatConstraint extends Constraint
  47736. {
  47737. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  47738. {
  47739. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  47740. return;
  47741. }
  47742. switch ($schema->format) {
  47743. case 'date':
  47744. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  47745. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  47746. }
  47747. break;
  47748. case 'time':
  47749. if (!$this->validateDateTime($element, 'H:i:s')) {
  47750. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  47751. }
  47752. break;
  47753. case 'date-time':
  47754. if (null === Rfc3339::createFromString($element)) {
  47755. $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));
  47756. }
  47757. break;
  47758. case 'utc-millisec':
  47759. if (!$this->validateDateTime($element, 'U')) {
  47760. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  47761. }
  47762. break;
  47763. case 'regex':
  47764. if (!$this->validateRegex($element)) {
  47765. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  47766. }
  47767. break;
  47768. case 'color':
  47769. if (!$this->validateColor($element)) {
  47770. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  47771. }
  47772. break;
  47773. case 'style':
  47774. if (!$this->validateStyle($element)) {
  47775. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  47776. }
  47777. break;
  47778. case 'phone':
  47779. if (!$this->validatePhone($element)) {
  47780. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  47781. }
  47782. break;
  47783. case 'uri':
  47784. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  47785. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  47786. }
  47787. break;
  47788. case 'uriref':
  47789. case 'uri-reference':
  47790. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  47791. if (substr($element, 0, 2) === '//') {
  47792. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  47793. } elseif (substr($element, 0, 1) === '/') {
  47794. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  47795. } elseif (strlen($element)) {
  47796. $pathParts = explode('/', $element, 2);
  47797. if (strpos($pathParts[0], ':') !== false) {
  47798. $validURL = null;
  47799. } else {
  47800. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  47801. }
  47802. } else {
  47803. $validURL = null;
  47804. }
  47805. if ($validURL === null) {
  47806. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  47807. }
  47808. }
  47809. break;
  47810. case 'email':
  47811. $filterFlags = FILTER_NULL_ON_FAILURE;
  47812. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  47813. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  47814. }
  47815. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  47816. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  47817. }
  47818. break;
  47819. case 'ip-address':
  47820. case 'ipv4':
  47821. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  47822. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  47823. }
  47824. break;
  47825. case 'ipv6':
  47826. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  47827. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  47828. }
  47829. break;
  47830. case 'host-name':
  47831. case 'hostname':
  47832. if (!$this->validateHostname($element)) {
  47833. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  47834. }
  47835. break;
  47836. default:
  47837. break;
  47838. }
  47839. }
  47840. protected function validateDateTime($datetime, $format)
  47841. {
  47842. $dt = \DateTime::createFromFormat($format, $datetime);
  47843. if (!$dt) {
  47844. return false;
  47845. }
  47846. if ($datetime === $dt->format($format)) {
  47847. return true;
  47848. }
  47849. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  47850. return true;
  47851. }
  47852. return false;
  47853. }
  47854. protected function validateRegex($regex)
  47855. {
  47856. return false !== @preg_match('/' . $regex . '/u', '');
  47857. }
  47858. protected function validateColor($color)
  47859. {
  47860. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  47861. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  47862. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  47863. return true;
  47864. }
  47865. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  47866. }
  47867. protected function validateStyle($style)
  47868. {
  47869. $properties = explode(';', rtrim($style, ';'));
  47870. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  47871. return empty($invalidEntries);
  47872. }
  47873. protected function validatePhone($phone)
  47874. {
  47875. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  47876. }
  47877. protected function validateHostname($host)
  47878. {
  47879. $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';
  47880. return preg_match($hostnameRegex, $host);
  47881. }
  47882. }
  47883. <?php
  47884. namespace JsonSchema\Constraints;
  47885. use JsonSchema\Entity\JsonPointer;
  47886. class NumberConstraint extends Constraint
  47887. {
  47888. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  47889. {
  47890. if (isset($schema->exclusiveMinimum)) {
  47891. if (isset($schema->minimum)) {
  47892. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  47893. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  47894. } elseif ($element < $schema->minimum) {
  47895. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  47896. }
  47897. } else {
  47898. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  47899. }
  47900. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  47901. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  47902. }
  47903. if (isset($schema->exclusiveMaximum)) {
  47904. if (isset($schema->maximum)) {
  47905. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  47906. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  47907. } elseif ($element > $schema->maximum) {
  47908. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  47909. }
  47910. } else {
  47911. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  47912. }
  47913. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  47914. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  47915. }
  47916. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  47917. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  47918. }
  47919. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  47920. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  47921. }
  47922. $this->checkFormat($element, $schema, $path, $i);
  47923. }
  47924. private function fmod($number1, $number2)
  47925. {
  47926. $number1 = abs($number1);
  47927. $modulus = fmod($number1, $number2);
  47928. $precision = abs(0.0000000001);
  47929. $diff = (float) ($modulus - $number2);
  47930. if (-$precision < $diff && $diff < $precision) {
  47931. return 0.0;
  47932. }
  47933. $decimals1 = mb_strpos($number1, '.') ? mb_strlen($number1) - mb_strpos($number1, '.') - 1 : 0;
  47934. $decimals2 = mb_strpos($number2, '.') ? mb_strlen($number2) - mb_strpos($number2, '.') - 1 : 0;
  47935. return (float) round($modulus, max($decimals1, $decimals2));
  47936. }
  47937. }
  47938. <?php
  47939. namespace JsonSchema\Constraints;
  47940. use JsonSchema\Entity\JsonPointer;
  47941. class ObjectConstraint extends Constraint
  47942. {
  47943. protected $appliedDefaults = array();
  47944. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  47945. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  47946. {
  47947. if ($element instanceof UndefinedConstraint) {
  47948. return;
  47949. }
  47950. $this->appliedDefaults = $appliedDefaults;
  47951. $matches = array();
  47952. if ($patternProperties) {
  47953. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  47954. }
  47955. if ($properties) {
  47956. $this->validateProperties($element, $properties, $path);
  47957. }
  47958. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  47959. }
  47960. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  47961. {
  47962. $try = array('/', '#', '+', '~', '%');
  47963. $matches = array();
  47964. foreach ($patternProperties as $pregex => $schema) {
  47965. $delimiter = '/';
  47966. foreach ($try as $delimiter) {
  47967. if (strpos($pregex, $delimiter) === false) {
  47968. break;
  47969. }
  47970. }
  47971. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  47972. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  47973. continue;
  47974. }
  47975. foreach ($element as $i => $value) {
  47976. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  47977. $matches[] = $i;
  47978. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  47979. }
  47980. }
  47981. }
  47982. return $matches;
  47983. }
  47984. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  47985. $properties = null, $additionalProp = null)
  47986. {
  47987. $this->validateMinMaxConstraint($element, $schema, $path);
  47988. foreach ($element as $i => $value) {
  47989. $definition = $this->getProperty($properties, $i);
  47990. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  47991. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  47992. }
  47993. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  47994. if ($additionalProp === true) {
  47995. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  47996. } else {
  47997. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  47998. }
  47999. }
  48000. $require = $this->getProperty($definition, 'requires');
  48001. if ($require && !$this->getProperty($element, $require)) {
  48002. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  48003. }
  48004. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  48005. if (is_object($property)) {
  48006. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  48007. }
  48008. }
  48009. }
  48010. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  48011. {
  48012. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  48013. foreach ($properties as $i => $value) {
  48014. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  48015. $definition = $this->getProperty($properties, $i);
  48016. if (is_object($definition)) {
  48017. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  48018. }
  48019. }
  48020. }
  48021. protected function &getProperty(&$element, $property, $fallback = null)
  48022. {
  48023. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  48024. return $element[$property];
  48025. } elseif (is_object($element) && property_exists($element, $property)) {
  48026. return $element->$property;
  48027. }
  48028. return $fallback;
  48029. }
  48030. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  48031. {
  48032. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  48033. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  48034. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  48035. }
  48036. }
  48037. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  48038. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  48039. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  48040. }
  48041. }
  48042. }
  48043. }
  48044. <?php
  48045. namespace JsonSchema\Constraints;
  48046. use JsonSchema\Entity\JsonPointer;
  48047. use JsonSchema\Exception\InvalidArgumentException;
  48048. use JsonSchema\Exception\InvalidSchemaException;
  48049. use JsonSchema\Exception\RuntimeException;
  48050. use JsonSchema\Validator;
  48051. class SchemaConstraint extends Constraint
  48052. {
  48053. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  48054. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48055. {
  48056. if ($schema !== null) {
  48057. $validationSchema = $schema;
  48058. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  48059. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  48060. } else {
  48061. throw new InvalidArgumentException('no schema found to verify against');
  48062. }
  48063. if (is_array($validationSchema)) {
  48064. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  48065. }
  48066. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  48067. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  48068. throw new RuntimeException('Cannot validate the schema of a non-object');
  48069. }
  48070. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  48071. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  48072. } else {
  48073. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  48074. }
  48075. $schemaStorage = $this->factory->getSchemaStorage();
  48076. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  48077. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  48078. }
  48079. $initialErrorCount = $this->numErrors();
  48080. $initialConfig = $this->factory->getConfig();
  48081. $initialContext = $this->factory->getErrorContext();
  48082. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  48083. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  48084. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  48085. try {
  48086. $this->check($validationSchema, $schemaSpec);
  48087. } catch (\Exception $e) {
  48088. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  48089. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  48090. }
  48091. }
  48092. if ($this->numErrors() > $initialErrorCount) {
  48093. $this->addError($path, 'Schema is not valid', 'schema');
  48094. }
  48095. $this->factory->setConfig($initialConfig);
  48096. $this->factory->setErrorContext($initialContext);
  48097. }
  48098. $this->checkUndefined($element, $validationSchema, $path, $i);
  48099. }
  48100. }
  48101. <?php
  48102. namespace JsonSchema\Constraints;
  48103. use JsonSchema\Entity\JsonPointer;
  48104. class StringConstraint extends Constraint
  48105. {
  48106. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  48107. {
  48108. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  48109. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  48110. 'maxLength' => $schema->maxLength,
  48111. ));
  48112. }
  48113. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  48114. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  48115. 'minLength' => $schema->minLength,
  48116. ));
  48117. }
  48118. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  48119. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  48120. 'pattern' => $schema->pattern,
  48121. ));
  48122. }
  48123. $this->checkFormat($element, $schema, $path, $i);
  48124. }
  48125. private function strlen($string)
  48126. {
  48127. if (extension_loaded('mbstring')) {
  48128. return mb_strlen($string, mb_detect_encoding($string));
  48129. }
  48130. return strlen($string);
  48131. }
  48132. }
  48133. <?php
  48134. namespace JsonSchema\Constraints\TypeCheck;
  48135. class LooseTypeCheck implements TypeCheckInterface
  48136. {
  48137. public static function isObject($value)
  48138. {
  48139. return
  48140. is_object($value) ||
  48141. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  48142. }
  48143. public static function isArray($value)
  48144. {
  48145. return
  48146. is_array($value) &&
  48147. (count($value) == 0 || !self::isAssociativeArray($value));
  48148. }
  48149. public static function propertyGet($value, $property)
  48150. {
  48151. if (is_object($value)) {
  48152. return $value->{$property};
  48153. }
  48154. return $value[$property];
  48155. }
  48156. public static function propertySet(&$value, $property, $data)
  48157. {
  48158. if (is_object($value)) {
  48159. $value->{$property} = $data;
  48160. } else {
  48161. $value[$property] = $data;
  48162. }
  48163. }
  48164. public static function propertyExists($value, $property)
  48165. {
  48166. if (is_object($value)) {
  48167. return property_exists($value, $property);
  48168. }
  48169. return array_key_exists($property, $value);
  48170. }
  48171. public static function propertyCount($value)
  48172. {
  48173. if (is_object($value)) {
  48174. return count(get_object_vars($value));
  48175. }
  48176. return count($value);
  48177. }
  48178. private static function isAssociativeArray($arr)
  48179. {
  48180. return array_keys($arr) !== range(0, count($arr) - 1);
  48181. }
  48182. }
  48183. <?php
  48184. namespace JsonSchema\Constraints\TypeCheck;
  48185. class StrictTypeCheck implements TypeCheckInterface
  48186. {
  48187. public static function isObject($value)
  48188. {
  48189. return is_object($value);
  48190. }
  48191. public static function isArray($value)
  48192. {
  48193. return is_array($value);
  48194. }
  48195. public static function propertyGet($value, $property)
  48196. {
  48197. return $value->{$property};
  48198. }
  48199. public static function propertySet(&$value, $property, $data)
  48200. {
  48201. $value->{$property} = $data;
  48202. }
  48203. public static function propertyExists($value, $property)
  48204. {
  48205. return property_exists($value, $property);
  48206. }
  48207. public static function propertyCount($value)
  48208. {
  48209. return count(get_object_vars($value));
  48210. }
  48211. }
  48212. <?php
  48213. namespace JsonSchema\Constraints\TypeCheck;
  48214. interface TypeCheckInterface
  48215. {
  48216. public static function isObject($value);
  48217. public static function isArray($value);
  48218. public static function propertyGet($value, $property);
  48219. public static function propertySet(&$value, $property, $data);
  48220. public static function propertyExists($value, $property);
  48221. public static function propertyCount($value);
  48222. }
  48223. <?php
  48224. namespace JsonSchema\Constraints;
  48225. use JsonSchema\Entity\JsonPointer;
  48226. use JsonSchema\Exception\InvalidArgumentException;
  48227. use UnexpectedValueException as StandardUnexpectedValueException;
  48228. class TypeConstraint extends Constraint
  48229. {
  48230. public static $wording = array(
  48231. 'integer' => 'an integer',
  48232. 'number' => 'a number',
  48233. 'boolean' => 'a boolean',
  48234. 'object' => 'an object',
  48235. 'array' => 'an array',
  48236. 'string' => 'a string',
  48237. 'null' => 'a null',
  48238. 'any' => null,
  48239. 0 => null,
  48240. );
  48241. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  48242. {
  48243. $type = isset($schema->type) ? $schema->type : null;
  48244. $isValid = false;
  48245. $wording = array();
  48246. if (is_array($type)) {
  48247. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  48248. } elseif (is_object($type)) {
  48249. $this->checkUndefined($value, $type, $path);
  48250. return;
  48251. } else {
  48252. $isValid = $this->validateType($value, $type);
  48253. }
  48254. if ($isValid === false) {
  48255. if (!is_array($type)) {
  48256. $this->validateTypeNameWording($type);
  48257. $wording[] = self::$wording[$type];
  48258. }
  48259. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  48260. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  48261. }
  48262. }
  48263. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  48264. {
  48265. foreach ($type as $tp) {
  48266. if (is_object($tp)) {
  48267. if (!$isValid) {
  48268. $validator = $this->factory->createInstanceFor('type');
  48269. $subSchema = new \stdClass();
  48270. $subSchema->type = $tp;
  48271. $validator->check($value, $subSchema, $path, null);
  48272. $error = $validator->getErrors();
  48273. $isValid = !(bool) $error;
  48274. $validTypesWording[] = self::$wording['object'];
  48275. }
  48276. } else {
  48277. $this->validateTypeNameWording($tp);
  48278. $validTypesWording[] = self::$wording[$tp];
  48279. if (!$isValid) {
  48280. $isValid = $this->validateType($value, $tp);
  48281. }
  48282. }
  48283. }
  48284. }
  48285. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  48286. {
  48287. if ($listEnd === false || !isset($elements[1])) {
  48288. return implode($delimiter, $elements);
  48289. }
  48290. $lastElement = array_slice($elements, -1);
  48291. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  48292. $implodedElements = array_merge(array($firsElements), $lastElement);
  48293. return join(" $listEnd ", $implodedElements);
  48294. }
  48295. protected function validateTypeNameWording($type)
  48296. {
  48297. if (!isset(self::$wording[$type])) {
  48298. throw new StandardUnexpectedValueException(
  48299. sprintf(
  48300. 'No wording for %s available, expected wordings are: [%s]',
  48301. var_export($type, true),
  48302. implode(', ', array_filter(self::$wording)))
  48303. );
  48304. }
  48305. }
  48306. protected function validateType(&$value, $type)
  48307. {
  48308. if (!$type) {
  48309. return true;
  48310. }
  48311. if ('any' === $type) {
  48312. return true;
  48313. }
  48314. if ('object' === $type) {
  48315. return $this->getTypeCheck()->isObject($value);
  48316. }
  48317. if ('array' === $type) {
  48318. return $this->getTypeCheck()->isArray($value);
  48319. }
  48320. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  48321. if ('integer' === $type) {
  48322. if ($coerce) {
  48323. $value = $this->toInteger($value);
  48324. }
  48325. return is_int($value);
  48326. }
  48327. if ('number' === $type) {
  48328. if ($coerce) {
  48329. $value = $this->toNumber($value);
  48330. }
  48331. return is_numeric($value) && !is_string($value);
  48332. }
  48333. if ('boolean' === $type) {
  48334. if ($coerce) {
  48335. $value = $this->toBoolean($value);
  48336. }
  48337. return is_bool($value);
  48338. }
  48339. if ('string' === $type) {
  48340. return is_string($value);
  48341. }
  48342. if ('email' === $type) {
  48343. return is_string($value);
  48344. }
  48345. if ('null' === $type) {
  48346. return is_null($value);
  48347. }
  48348. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  48349. }
  48350. protected function toBoolean($value)
  48351. {
  48352. if ($value === 'true') {
  48353. return true;
  48354. }
  48355. if ($value === 'false') {
  48356. return false;
  48357. }
  48358. return $value;
  48359. }
  48360. protected function toNumber($value)
  48361. {
  48362. if (is_numeric($value)) {
  48363. return $value + 0;
  48364. }
  48365. return $value;
  48366. }
  48367. protected function toInteger($value)
  48368. {
  48369. if (is_numeric($value) && (int) $value == $value) {
  48370. return (int) $value;
  48371. }
  48372. return $value;
  48373. }
  48374. }
  48375. <?php
  48376. namespace JsonSchema\Constraints;
  48377. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  48378. use JsonSchema\Entity\JsonPointer;
  48379. use JsonSchema\Exception\ValidationException;
  48380. use JsonSchema\Uri\UriResolver;
  48381. class UndefinedConstraint extends Constraint
  48382. {
  48383. protected $appliedDefaults = array();
  48384. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  48385. {
  48386. if (is_null($schema) || !is_object($schema)) {
  48387. return;
  48388. }
  48389. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  48390. if ($fromDefault) {
  48391. $path->setFromDefault();
  48392. }
  48393. $this->validateCommonProperties($value, $schema, $path, $i);
  48394. $this->validateOfProperties($value, $schema, $path, '');
  48395. $this->validateTypes($value, $schema, $path, $i);
  48396. }
  48397. public function validateTypes(&$value, $schema = null, JsonPointer $path, $i = null)
  48398. {
  48399. if ($this->getTypeCheck()->isArray($value)) {
  48400. $this->checkArray($value, $schema, $path, $i);
  48401. }
  48402. if (LooseTypeCheck::isObject($value)) {
  48403. $this->checkObject(
  48404. $value,
  48405. $schema,
  48406. $path,
  48407. isset($schema->properties) ? $schema->properties : null,
  48408. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  48409. isset($schema->patternProperties) ? $schema->patternProperties : null,
  48410. $this->appliedDefaults
  48411. );
  48412. }
  48413. if (is_string($value)) {
  48414. $this->checkString($value, $schema, $path, $i);
  48415. }
  48416. if (is_numeric($value)) {
  48417. $this->checkNumber($value, $schema, $path, $i);
  48418. }
  48419. if (isset($schema->enum)) {
  48420. $this->checkEnum($value, $schema, $path, $i);
  48421. }
  48422. }
  48423. protected function validateCommonProperties(&$value, $schema = null, JsonPointer $path, $i = '')
  48424. {
  48425. if (isset($schema->extends)) {
  48426. if (is_string($schema->extends)) {
  48427. $schema->extends = $this->validateUri($schema, $schema->extends);
  48428. }
  48429. if (is_array($schema->extends)) {
  48430. foreach ($schema->extends as $extends) {
  48431. $this->checkUndefined($value, $extends, $path, $i);
  48432. }
  48433. } else {
  48434. $this->checkUndefined($value, $schema->extends, $path, $i);
  48435. }
  48436. }
  48437. if (!$path->fromDefault()) {
  48438. $this->applyDefaultValues($value, $schema, $path);
  48439. }
  48440. if ($this->getTypeCheck()->isObject($value)) {
  48441. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  48442. foreach ($schema->required as $required) {
  48443. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  48444. $this->addError(
  48445. $this->incrementPath($path ?: new JsonPointer(''), $required),
  48446. 'The property ' . $required . ' is required',
  48447. 'required'
  48448. );
  48449. }
  48450. }
  48451. } elseif (isset($schema->required) && !is_array($schema->required)) {
  48452. if ($schema->required && $value instanceof self) {
  48453. $propertyPaths = $path->getPropertyPaths();
  48454. $propertyName = end($propertyPaths);
  48455. $this->addError(
  48456. $path,
  48457. 'The property ' . $propertyName . ' is required',
  48458. 'required'
  48459. );
  48460. }
  48461. }
  48462. }
  48463. if (!($value instanceof self)) {
  48464. $this->checkType($value, $schema, $path, $i);
  48465. }
  48466. if (isset($schema->disallow)) {
  48467. $initErrors = $this->getErrors();
  48468. $typeSchema = new \stdClass();
  48469. $typeSchema->type = $schema->disallow;
  48470. $this->checkType($value, $typeSchema, $path);
  48471. if (count($this->getErrors()) == count($initErrors)) {
  48472. $this->addError($path, 'Disallowed value was matched', 'disallow');
  48473. } else {
  48474. $this->errors = $initErrors;
  48475. }
  48476. }
  48477. if (isset($schema->not)) {
  48478. $initErrors = $this->getErrors();
  48479. $this->checkUndefined($value, $schema->not, $path, $i);
  48480. if (count($this->getErrors()) == count($initErrors)) {
  48481. $this->addError($path, 'Matched a schema which it should not', 'not');
  48482. } else {
  48483. $this->errors = $initErrors;
  48484. }
  48485. }
  48486. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  48487. $this->validateDependencies($value, $schema->dependencies, $path);
  48488. }
  48489. }
  48490. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  48491. {
  48492. if (!$requiredOnly) {
  48493. return true;
  48494. }
  48495. if (
  48496. $name !== null
  48497. && isset($parentSchema->required)
  48498. && is_array($parentSchema->required)
  48499. && in_array($name, $parentSchema->required)
  48500. ) {
  48501. return true;
  48502. }
  48503. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  48504. return true;
  48505. }
  48506. return false;
  48507. }
  48508. protected function applyDefaultValues(&$value, $schema, $path)
  48509. {
  48510. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  48511. return;
  48512. }
  48513. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  48514. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  48515. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  48516. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  48517. if (
  48518. !LooseTypeCheck::propertyExists($value, $currentProperty)
  48519. && property_exists($propertyDefinition, 'default')
  48520. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  48521. ) {
  48522. if (is_object($propertyDefinition->default)) {
  48523. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  48524. } else {
  48525. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  48526. }
  48527. $this->appliedDefaults[] = $currentProperty;
  48528. }
  48529. }
  48530. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  48531. $items = array();
  48532. if (LooseTypeCheck::isArray($schema->items)) {
  48533. $items = $schema->items;
  48534. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  48535. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  48536. }
  48537. foreach ($items as $currentItem => $itemDefinition) {
  48538. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  48539. if (
  48540. !array_key_exists($currentItem, $value)
  48541. && property_exists($itemDefinition, 'default')
  48542. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  48543. if (is_object($itemDefinition->default)) {
  48544. $value[$currentItem] = clone $itemDefinition->default;
  48545. } else {
  48546. $value[$currentItem] = $itemDefinition->default;
  48547. }
  48548. }
  48549. $path->setFromDefault();
  48550. }
  48551. } elseif (
  48552. $value instanceof self
  48553. && property_exists($schema, 'default')
  48554. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  48555. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  48556. $path->setFromDefault();
  48557. }
  48558. }
  48559. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  48560. {
  48561. if ($value instanceof self) {
  48562. return;
  48563. }
  48564. if (isset($schema->allOf)) {
  48565. $isValid = true;
  48566. foreach ($schema->allOf as $allOf) {
  48567. $initErrors = $this->getErrors();
  48568. $this->checkUndefined($value, $allOf, $path, $i);
  48569. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  48570. }
  48571. if (!$isValid) {
  48572. $this->addError($path, 'Failed to match all schemas', 'allOf');
  48573. }
  48574. }
  48575. if (isset($schema->anyOf)) {
  48576. $isValid = false;
  48577. $startErrors = $this->getErrors();
  48578. $caughtException = null;
  48579. foreach ($schema->anyOf as $anyOf) {
  48580. $initErrors = $this->getErrors();
  48581. try {
  48582. $this->checkUndefined($value, $anyOf, $path, $i);
  48583. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  48584. break;
  48585. }
  48586. } catch (ValidationException $e) {
  48587. $isValid = false;
  48588. }
  48589. }
  48590. if (!$isValid) {
  48591. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  48592. } else {
  48593. $this->errors = $startErrors;
  48594. }
  48595. }
  48596. if (isset($schema->oneOf)) {
  48597. $allErrors = array();
  48598. $matchedSchemas = 0;
  48599. $startErrors = $this->getErrors();
  48600. foreach ($schema->oneOf as $oneOf) {
  48601. try {
  48602. $this->errors = array();
  48603. $this->checkUndefined($value, $oneOf, $path, $i);
  48604. if (count($this->getErrors()) == 0) {
  48605. $matchedSchemas++;
  48606. }
  48607. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  48608. } catch (ValidationException $e) {
  48609. }
  48610. }
  48611. if ($matchedSchemas !== 1) {
  48612. $this->addErrors(array_merge($allErrors, $startErrors));
  48613. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  48614. } else {
  48615. $this->errors = $startErrors;
  48616. }
  48617. }
  48618. }
  48619. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  48620. {
  48621. foreach ($dependencies as $key => $dependency) {
  48622. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  48623. if (is_string($dependency)) {
  48624. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  48625. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  48626. }
  48627. } elseif (is_array($dependency)) {
  48628. foreach ($dependency as $d) {
  48629. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  48630. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  48631. }
  48632. }
  48633. } elseif (is_object($dependency)) {
  48634. $this->checkUndefined($value, $dependency, $path, $i);
  48635. }
  48636. }
  48637. }
  48638. }
  48639. protected function validateUri($schema, $schemaUri = null)
  48640. {
  48641. $resolver = new UriResolver();
  48642. $retriever = $this->factory->getUriRetriever();
  48643. $jsonSchema = null;
  48644. if ($resolver->isValid($schemaUri)) {
  48645. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  48646. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  48647. }
  48648. return $jsonSchema;
  48649. }
  48650. }
  48651. <?php
  48652. namespace JsonSchema\Entity;
  48653. use JsonSchema\Exception\InvalidArgumentException;
  48654. class JsonPointer
  48655. {
  48656. private $filename;
  48657. private $propertyPaths = array();
  48658. private $fromDefault = false;
  48659. public function __construct($value)
  48660. {
  48661. if (!is_string($value)) {
  48662. throw new InvalidArgumentException('Ref value must be a string');
  48663. }
  48664. $splitRef = explode('#', $value, 2);
  48665. $this->filename = $splitRef[0];
  48666. if (array_key_exists(1, $splitRef)) {
  48667. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  48668. }
  48669. }
  48670. private function decodePropertyPaths($propertyPathString)
  48671. {
  48672. $paths = array();
  48673. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  48674. $path = $this->decodePath($path);
  48675. if (is_string($path) && '' !== $path) {
  48676. $paths[] = $path;
  48677. }
  48678. }
  48679. return $paths;
  48680. }
  48681. private function encodePropertyPaths()
  48682. {
  48683. return array_map(
  48684. array($this, 'encodePath'),
  48685. $this->getPropertyPaths()
  48686. );
  48687. }
  48688. private function decodePath($path)
  48689. {
  48690. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  48691. }
  48692. private function encodePath($path)
  48693. {
  48694. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  48695. }
  48696. public function getFilename()
  48697. {
  48698. return $this->filename;
  48699. }
  48700. public function getPropertyPaths()
  48701. {
  48702. return $this->propertyPaths;
  48703. }
  48704. public function withPropertyPaths(array $propertyPaths)
  48705. {
  48706. $new = clone $this;
  48707. $new->propertyPaths = $propertyPaths;
  48708. return $new;
  48709. }
  48710. public function getPropertyPathAsString()
  48711. {
  48712. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  48713. }
  48714. public function __toString()
  48715. {
  48716. return $this->getFilename() . $this->getPropertyPathAsString();
  48717. }
  48718. public function setFromDefault()
  48719. {
  48720. $this->fromDefault = true;
  48721. }
  48722. public function fromDefault()
  48723. {
  48724. return $this->fromDefault;
  48725. }
  48726. }
  48727. <?php
  48728. namespace JsonSchema\Exception;
  48729. interface ExceptionInterface
  48730. {
  48731. }
  48732. <?php
  48733. namespace JsonSchema\Exception;
  48734. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  48735. {
  48736. }
  48737. <?php
  48738. namespace JsonSchema\Exception;
  48739. class InvalidConfigException extends RuntimeException
  48740. {
  48741. }
  48742. <?php
  48743. namespace JsonSchema\Exception;
  48744. class InvalidSchemaException extends RuntimeException
  48745. {
  48746. }
  48747. <?php
  48748. namespace JsonSchema\Exception;
  48749. class InvalidSchemaMediaTypeException extends RuntimeException
  48750. {
  48751. }
  48752. <?php
  48753. namespace JsonSchema\Exception;
  48754. class InvalidSourceUriException extends InvalidArgumentException
  48755. {
  48756. }
  48757. <?php
  48758. namespace JsonSchema\Exception;
  48759. class JsonDecodingException extends RuntimeException
  48760. {
  48761. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  48762. {
  48763. switch ($code) {
  48764. case JSON_ERROR_DEPTH:
  48765. $message = 'The maximum stack depth has been exceeded';
  48766. break;
  48767. case JSON_ERROR_STATE_MISMATCH:
  48768. $message = 'Invalid or malformed JSON';
  48769. break;
  48770. case JSON_ERROR_CTRL_CHAR:
  48771. $message = 'Control character error, possibly incorrectly encoded';
  48772. break;
  48773. case JSON_ERROR_UTF8:
  48774. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  48775. break;
  48776. case JSON_ERROR_SYNTAX:
  48777. $message = 'JSON syntax is malformed';
  48778. break;
  48779. default:
  48780. $message = 'Syntax error';
  48781. }
  48782. parent::__construct($message, $code, $previous);
  48783. }
  48784. }
  48785. <?php
  48786. namespace JsonSchema\Exception;
  48787. class ResourceNotFoundException extends RuntimeException
  48788. {
  48789. }
  48790. <?php
  48791. namespace JsonSchema\Exception;
  48792. class RuntimeException extends \RuntimeException implements ExceptionInterface
  48793. {
  48794. }
  48795. <?php
  48796. namespace JsonSchema\Exception;
  48797. class UnresolvableJsonPointerException extends InvalidArgumentException
  48798. {
  48799. }
  48800. <?php
  48801. namespace JsonSchema\Exception;
  48802. class UriResolverException extends RuntimeException
  48803. {
  48804. }
  48805. <?php
  48806. namespace JsonSchema\Exception;
  48807. class ValidationException extends RuntimeException
  48808. {
  48809. }
  48810. <?php
  48811. namespace JsonSchema\Iterator;
  48812. class ObjectIterator implements \Iterator, \Countable
  48813. {
  48814. private $object;
  48815. private $position = 0;
  48816. private $data = array();
  48817. private $initialized = false;
  48818. public function __construct($object)
  48819. {
  48820. $this->object = $object;
  48821. }
  48822. public function current()
  48823. {
  48824. $this->initialize();
  48825. return $this->data[$this->position];
  48826. }
  48827. public function next()
  48828. {
  48829. $this->initialize();
  48830. $this->position++;
  48831. }
  48832. public function key()
  48833. {
  48834. $this->initialize();
  48835. return $this->position;
  48836. }
  48837. public function valid()
  48838. {
  48839. $this->initialize();
  48840. return isset($this->data[$this->position]);
  48841. }
  48842. public function rewind()
  48843. {
  48844. $this->initialize();
  48845. $this->position = 0;
  48846. }
  48847. public function count()
  48848. {
  48849. $this->initialize();
  48850. return count($this->data);
  48851. }
  48852. private function initialize()
  48853. {
  48854. if (!$this->initialized) {
  48855. $this->data = $this->buildDataFromObject($this->object);
  48856. $this->initialized = true;
  48857. }
  48858. }
  48859. private function buildDataFromObject($object)
  48860. {
  48861. $result = array();
  48862. $stack = new \SplStack();
  48863. $stack->push($object);
  48864. while (!$stack->isEmpty()) {
  48865. $current = $stack->pop();
  48866. if (is_object($current)) {
  48867. array_push($result, $current);
  48868. }
  48869. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  48870. if (is_object($propertyValue) || is_array($propertyValue)) {
  48871. $stack->push($propertyValue);
  48872. }
  48873. }
  48874. }
  48875. return $result;
  48876. }
  48877. private function getDataFromItem($item)
  48878. {
  48879. if (!is_object($item) && !is_array($item)) {
  48880. return array();
  48881. }
  48882. return is_object($item) ? get_object_vars($item) : $item;
  48883. }
  48884. }
  48885. <?php
  48886. namespace JsonSchema;
  48887. class Rfc3339
  48888. {
  48889. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  48890. public static function createFromString($string)
  48891. {
  48892. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  48893. return null;
  48894. }
  48895. $dateAndTime = $matches[1];
  48896. $microseconds = $matches[2] ?: '.000000';
  48897. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  48898. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  48899. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  48900. return $dateTime ?: null;
  48901. }
  48902. }
  48903. <?php
  48904. namespace JsonSchema;
  48905. use JsonSchema\Constraints\BaseConstraint;
  48906. use JsonSchema\Entity\JsonPointer;
  48907. use JsonSchema\Exception\UnresolvableJsonPointerException;
  48908. use JsonSchema\Uri\UriResolver;
  48909. use JsonSchema\Uri\UriRetriever;
  48910. class SchemaStorage implements SchemaStorageInterface
  48911. {
  48912. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  48913. protected $uriRetriever;
  48914. protected $uriResolver;
  48915. protected $schemas = array();
  48916. public function __construct(
  48917. UriRetrieverInterface $uriRetriever = null,
  48918. UriResolverInterface $uriResolver = null
  48919. ) {
  48920. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  48921. $this->uriResolver = $uriResolver ?: new UriResolver();
  48922. }
  48923. public function getUriRetriever()
  48924. {
  48925. return $this->uriRetriever;
  48926. }
  48927. public function getUriResolver()
  48928. {
  48929. return $this->uriResolver;
  48930. }
  48931. public function addSchema($id, $schema = null)
  48932. {
  48933. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  48934. $schema = $this->uriRetriever->retrieve($id);
  48935. }
  48936. if (is_array($schema)) {
  48937. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  48938. }
  48939. if (is_object($schema) && property_exists($schema, 'id')) {
  48940. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  48941. $schema->properties->id->format = 'uri-reference';
  48942. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  48943. $schema->properties->id->format = 'uri-reference';
  48944. $schema->properties->{'$ref'}->format = 'uri-reference';
  48945. }
  48946. }
  48947. $this->expandRefs($schema, $id);
  48948. $this->schemas[$id] = $schema;
  48949. }
  48950. private function expandRefs(&$schema, $base = null)
  48951. {
  48952. if (!is_object($schema)) {
  48953. if (is_array($schema)) {
  48954. foreach ($schema as &$member) {
  48955. $this->expandRefs($member, $base);
  48956. }
  48957. }
  48958. return;
  48959. }
  48960. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  48961. $base = $this->uriResolver->resolve($schema->id, $base);
  48962. }
  48963. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  48964. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  48965. $schema->{'$ref'} = (string) $refPointer;
  48966. }
  48967. foreach ($schema as &$member) {
  48968. $this->expandRefs($member, $base);
  48969. }
  48970. }
  48971. public function getSchema($id)
  48972. {
  48973. if (!array_key_exists($id, $this->schemas)) {
  48974. $this->addSchema($id);
  48975. }
  48976. return $this->schemas[$id];
  48977. }
  48978. public function resolveRef($ref)
  48979. {
  48980. $jsonPointer = new JsonPointer($ref);
  48981. $fileName = $jsonPointer->getFilename();
  48982. if (!strlen($fileName)) {
  48983. throw new UnresolvableJsonPointerException(sprintf(
  48984. "Could not resolve fragment '%s': no file is defined",
  48985. $jsonPointer->getPropertyPathAsString()
  48986. ));
  48987. }
  48988. $refSchema = $this->getSchema($fileName);
  48989. foreach ($jsonPointer->getPropertyPaths() as $path) {
  48990. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  48991. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  48992. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  48993. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  48994. } else {
  48995. throw new UnresolvableJsonPointerException(sprintf(
  48996. 'File: %s is found, but could not resolve fragment: %s',
  48997. $jsonPointer->getFilename(),
  48998. $jsonPointer->getPropertyPathAsString()
  48999. ));
  49000. }
  49001. }
  49002. return $refSchema;
  49003. }
  49004. public function resolveRefSchema($refSchema)
  49005. {
  49006. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  49007. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  49008. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  49009. unset($refSchema->{'$ref'});
  49010. }
  49011. return $refSchema;
  49012. }
  49013. }
  49014. <?php
  49015. namespace JsonSchema;
  49016. interface SchemaStorageInterface
  49017. {
  49018. public function addSchema($id, $schema = null);
  49019. public function getSchema($id);
  49020. public function resolveRef($ref);
  49021. public function resolveRefSchema($refSchema);
  49022. }
  49023. <?php
  49024. namespace JsonSchema\Uri\Retrievers;
  49025. abstract class AbstractRetriever implements UriRetrieverInterface
  49026. {
  49027. protected $contentType;
  49028. public function getContentType()
  49029. {
  49030. return $this->contentType;
  49031. }
  49032. }
  49033. <?php
  49034. namespace JsonSchema\Uri\Retrievers;
  49035. use JsonSchema\Exception\RuntimeException;
  49036. use JsonSchema\Validator;
  49037. class Curl extends AbstractRetriever
  49038. {
  49039. protected $messageBody;
  49040. public function __construct()
  49041. {
  49042. if (!function_exists('curl_init')) {
  49043. throw new RuntimeException('cURL not installed');
  49044. }
  49045. }
  49046. public function retrieve($uri)
  49047. {
  49048. $ch = curl_init();
  49049. curl_setopt($ch, CURLOPT_URL, $uri);
  49050. curl_setopt($ch, CURLOPT_HEADER, true);
  49051. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  49052. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  49053. $response = curl_exec($ch);
  49054. if (false === $response) {
  49055. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  49056. }
  49057. $this->fetchMessageBody($response);
  49058. $this->fetchContentType($response);
  49059. curl_close($ch);
  49060. return $this->messageBody;
  49061. }
  49062. private function fetchMessageBody($response)
  49063. {
  49064. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  49065. $this->messageBody = $match[1];
  49066. }
  49067. protected function fetchContentType($response)
  49068. {
  49069. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  49070. $this->contentType = trim($match[1]);
  49071. return true;
  49072. }
  49073. return false;
  49074. }
  49075. }
  49076. <?php
  49077. namespace JsonSchema\Uri\Retrievers;
  49078. use JsonSchema\Exception\ResourceNotFoundException;
  49079. class FileGetContents extends AbstractRetriever
  49080. {
  49081. protected $messageBody;
  49082. public function retrieve($uri)
  49083. {
  49084. $errorMessage = null;
  49085. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  49086. $errorMessage = $errstr;
  49087. });
  49088. $response = file_get_contents($uri);
  49089. restore_error_handler();
  49090. if ($errorMessage) {
  49091. throw new ResourceNotFoundException($errorMessage);
  49092. }
  49093. if (false === $response) {
  49094. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  49095. }
  49096. if ($response == ''
  49097. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  49098. ) {
  49099. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  49100. }
  49101. $this->messageBody = $response;
  49102. if (!empty($http_response_header)) {
  49103. $this->fetchContentType($http_response_header);
  49104. } else {
  49105. $this->contentType = null;
  49106. }
  49107. return $this->messageBody;
  49108. }
  49109. private function fetchContentType(array $headers)
  49110. {
  49111. foreach ($headers as $header) {
  49112. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  49113. return true;
  49114. }
  49115. }
  49116. return false;
  49117. }
  49118. protected static function getContentTypeMatchInHeader($header)
  49119. {
  49120. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  49121. return trim($match[1]);
  49122. }
  49123. return null;
  49124. }
  49125. }
  49126. <?php
  49127. namespace JsonSchema\Uri\Retrievers;
  49128. use JsonSchema\Validator;
  49129. class PredefinedArray extends AbstractRetriever
  49130. {
  49131. private $schemas;
  49132. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  49133. {
  49134. $this->schemas = $schemas;
  49135. $this->contentType = $contentType;
  49136. }
  49137. public function retrieve($uri)
  49138. {
  49139. if (!array_key_exists($uri, $this->schemas)) {
  49140. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  49141. 'The JSON schema "%s" was not found.',
  49142. $uri
  49143. ));
  49144. }
  49145. return $this->schemas[$uri];
  49146. }
  49147. }
  49148. <?php
  49149. namespace JsonSchema\Uri\Retrievers;
  49150. interface UriRetrieverInterface
  49151. {
  49152. public function retrieve($uri);
  49153. public function getContentType();
  49154. }
  49155. <?php
  49156. namespace JsonSchema\Uri;
  49157. use JsonSchema\Exception\UriResolverException;
  49158. use JsonSchema\UriResolverInterface;
  49159. class UriResolver implements UriResolverInterface
  49160. {
  49161. public function parse($uri)
  49162. {
  49163. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  49164. $components = array();
  49165. if (5 < count($match)) {
  49166. $components = array(
  49167. 'scheme' => $match[2],
  49168. 'authority' => $match[4],
  49169. 'path' => $match[5]
  49170. );
  49171. }
  49172. if (7 < count($match)) {
  49173. $components['query'] = $match[7];
  49174. }
  49175. if (9 < count($match)) {
  49176. $components['fragment'] = $match[9];
  49177. }
  49178. return $components;
  49179. }
  49180. public function generate(array $components)
  49181. {
  49182. $uri = $components['scheme'] . '://'
  49183. . $components['authority']
  49184. . $components['path'];
  49185. if (array_key_exists('query', $components) && strlen($components['query'])) {
  49186. $uri .= '?' . $components['query'];
  49187. }
  49188. if (array_key_exists('fragment', $components)) {
  49189. $uri .= '#' . $components['fragment'];
  49190. }
  49191. return $uri;
  49192. }
  49193. public function resolve($uri, $baseUri = null)
  49194. {
  49195. if (
  49196. !is_null($baseUri) &&
  49197. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  49198. !preg_match('|^[^/]+://|u', $baseUri)
  49199. ) {
  49200. if (is_file($baseUri)) {
  49201. $baseUri = 'file://' . realpath($baseUri);
  49202. } elseif (is_dir($baseUri)) {
  49203. $baseUri = 'file://' . realpath($baseUri) . '/';
  49204. } else {
  49205. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  49206. }
  49207. }
  49208. if ($uri == '') {
  49209. return $baseUri;
  49210. }
  49211. $components = $this->parse($uri);
  49212. $path = $components['path'];
  49213. if (!empty($components['scheme'])) {
  49214. return $uri;
  49215. }
  49216. $baseComponents = $this->parse($baseUri);
  49217. $basePath = $baseComponents['path'];
  49218. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  49219. if (isset($components['fragment'])) {
  49220. $baseComponents['fragment'] = $components['fragment'];
  49221. }
  49222. return $this->generate($baseComponents);
  49223. }
  49224. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  49225. {
  49226. $relativePath = self::normalizePath($relativePath);
  49227. if ($relativePath == '') {
  49228. return $basePath;
  49229. }
  49230. if ($relativePath[0] == '/') {
  49231. return $relativePath;
  49232. }
  49233. $basePathSegments = explode('/', $basePath);
  49234. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  49235. $numLevelUp = strlen($match[0]) /3 + 1;
  49236. if ($numLevelUp >= count($basePathSegments)) {
  49237. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  49238. }
  49239. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  49240. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  49241. return implode('/', $basePathSegments) . '/' . $path;
  49242. }
  49243. private static function normalizePath($path)
  49244. {
  49245. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  49246. $path = preg_replace('|//|', '/', $path);
  49247. return $path;
  49248. }
  49249. public function isValid($uri)
  49250. {
  49251. $components = $this->parse($uri);
  49252. return !empty($components);
  49253. }
  49254. }
  49255. <?php
  49256. namespace JsonSchema\Uri;
  49257. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  49258. use JsonSchema\Exception\JsonDecodingException;
  49259. use JsonSchema\Exception\ResourceNotFoundException;
  49260. use JsonSchema\Uri\Retrievers\FileGetContents;
  49261. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  49262. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  49263. use JsonSchema\Validator;
  49264. class UriRetriever implements BaseUriRetrieverInterface
  49265. {
  49266. protected $translationMap = array(
  49267. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  49268. );
  49269. protected $uriRetriever = null;
  49270. private $schemaCache = array();
  49271. public function confirmMediaType($uriRetriever, $uri)
  49272. {
  49273. $contentType = $uriRetriever->getContentType();
  49274. if (is_null($contentType)) {
  49275. return;
  49276. }
  49277. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  49278. return;
  49279. }
  49280. if (substr($uri, 0, 23) == 'http://json-schema.org/') {
  49281. return true;
  49282. }
  49283. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  49284. }
  49285. public function getUriRetriever()
  49286. {
  49287. if (is_null($this->uriRetriever)) {
  49288. $this->setUriRetriever(new FileGetContents());
  49289. }
  49290. return $this->uriRetriever;
  49291. }
  49292. public function resolvePointer($jsonSchema, $uri)
  49293. {
  49294. $resolver = new UriResolver();
  49295. $parsed = $resolver->parse($uri);
  49296. if (empty($parsed['fragment'])) {
  49297. return $jsonSchema;
  49298. }
  49299. $path = explode('/', $parsed['fragment']);
  49300. while ($path) {
  49301. $pathElement = array_shift($path);
  49302. if (!empty($pathElement)) {
  49303. $pathElement = str_replace('~1', '/', $pathElement);
  49304. $pathElement = str_replace('~0', '~', $pathElement);
  49305. if (!empty($jsonSchema->$pathElement)) {
  49306. $jsonSchema = $jsonSchema->$pathElement;
  49307. } else {
  49308. throw new ResourceNotFoundException(
  49309. 'Fragment "' . $parsed['fragment'] . '" not found'
  49310. . ' in ' . $uri
  49311. );
  49312. }
  49313. if (!is_object($jsonSchema)) {
  49314. throw new ResourceNotFoundException(
  49315. 'Fragment part "' . $pathElement . '" is no object '
  49316. . ' in ' . $uri
  49317. );
  49318. }
  49319. }
  49320. }
  49321. return $jsonSchema;
  49322. }
  49323. public function retrieve($uri, $baseUri = null, $translate = true)
  49324. {
  49325. $resolver = new UriResolver();
  49326. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  49327. $arParts = $resolver->parse($resolvedUri);
  49328. if (isset($arParts['fragment'])) {
  49329. unset($arParts['fragment']);
  49330. $fetchUri = $resolver->generate($arParts);
  49331. }
  49332. if ($translate) {
  49333. $fetchUri = $this->translate($fetchUri);
  49334. }
  49335. $jsonSchema = $this->loadSchema($fetchUri);
  49336. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  49337. if ($jsonSchema instanceof \stdClass) {
  49338. $jsonSchema->id = $resolvedUri;
  49339. }
  49340. return $jsonSchema;
  49341. }
  49342. protected function loadSchema($fetchUri)
  49343. {
  49344. if (isset($this->schemaCache[$fetchUri])) {
  49345. return $this->schemaCache[$fetchUri];
  49346. }
  49347. $uriRetriever = $this->getUriRetriever();
  49348. $contents = $this->uriRetriever->retrieve($fetchUri);
  49349. $this->confirmMediaType($uriRetriever, $fetchUri);
  49350. $jsonSchema = json_decode($contents);
  49351. if (JSON_ERROR_NONE < $error = json_last_error()) {
  49352. throw new JsonDecodingException($error);
  49353. }
  49354. $this->schemaCache[$fetchUri] = $jsonSchema;
  49355. return $jsonSchema;
  49356. }
  49357. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  49358. {
  49359. $this->uriRetriever = $uriRetriever;
  49360. return $this;
  49361. }
  49362. public function parse($uri)
  49363. {
  49364. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  49365. $components = array();
  49366. if (5 < count($match)) {
  49367. $components = array(
  49368. 'scheme' => $match[2],
  49369. 'authority' => $match[4],
  49370. 'path' => $match[5]
  49371. );
  49372. }
  49373. if (7 < count($match)) {
  49374. $components['query'] = $match[7];
  49375. }
  49376. if (9 < count($match)) {
  49377. $components['fragment'] = $match[9];
  49378. }
  49379. return $components;
  49380. }
  49381. public function generate(array $components)
  49382. {
  49383. $uri = $components['scheme'] . '://'
  49384. . $components['authority']
  49385. . $components['path'];
  49386. if (array_key_exists('query', $components)) {
  49387. $uri .= $components['query'];
  49388. }
  49389. if (array_key_exists('fragment', $components)) {
  49390. $uri .= $components['fragment'];
  49391. }
  49392. return $uri;
  49393. }
  49394. public function resolve($uri, $baseUri = null)
  49395. {
  49396. $components = $this->parse($uri);
  49397. $path = $components['path'];
  49398. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  49399. return $uri;
  49400. }
  49401. $baseComponents = $this->parse($baseUri);
  49402. $basePath = $baseComponents['path'];
  49403. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  49404. return $this->generate($baseComponents);
  49405. }
  49406. public function isValid($uri)
  49407. {
  49408. $components = $this->parse($uri);
  49409. return !empty($components);
  49410. }
  49411. public function setTranslation($from, $to)
  49412. {
  49413. $this->translationMap[$from] = $to;
  49414. }
  49415. public function translate($uri)
  49416. {
  49417. foreach ($this->translationMap as $from => $to) {
  49418. $uri = preg_replace($from, $to, $uri);
  49419. }
  49420. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  49421. return $uri;
  49422. }
  49423. }
  49424. <?php
  49425. namespace JsonSchema;
  49426. interface UriResolverInterface
  49427. {
  49428. public function resolve($uri, $baseUri = null);
  49429. }
  49430. <?php
  49431. namespace JsonSchema;
  49432. interface UriRetrieverInterface
  49433. {
  49434. public function retrieve($uri, $baseUri = null);
  49435. }
  49436. <?php
  49437. namespace JsonSchema;
  49438. use JsonSchema\Constraints\BaseConstraint;
  49439. use JsonSchema\Constraints\Constraint;
  49440. class Validator extends BaseConstraint
  49441. {
  49442. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  49443. const ERROR_NONE = 0x00000000;
  49444. const ERROR_ALL = 0xFFFFFFFF;
  49445. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  49446. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  49447. public function validate(&$value, $schema = null, $checkMode = null)
  49448. {
  49449. if (is_array($schema)) {
  49450. $schema = self::arrayToObjectRecursive($schema);
  49451. }
  49452. $initialCheckMode = $this->factory->getConfig();
  49453. if ($checkMode !== null) {
  49454. $this->factory->setConfig($checkMode);
  49455. }
  49456. if (is_object($schema) && property_exists($schema, 'id')) {
  49457. $schemaURI = $schema->id;
  49458. } else {
  49459. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  49460. }
  49461. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  49462. $validator = $this->factory->createInstanceFor('schema');
  49463. $validator->check(
  49464. $value,
  49465. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  49466. );
  49467. $this->factory->setConfig($initialCheckMode);
  49468. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  49469. return $validator->getErrorMask();
  49470. }
  49471. public function check($value, $schema)
  49472. {
  49473. return $this->validate($value, $schema);
  49474. }
  49475. public function coerce(&$value, $schema)
  49476. {
  49477. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  49478. }
  49479. }
  49480. Copyright (C) 2015 Composer
  49481. Permission is hereby granted, free of charge, to any person obtaining a copy of
  49482. this software and associated documentation files (the "Software"), to deal in
  49483. the Software without restriction, including without limitation the rights to
  49484. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  49485. of the Software, and to permit persons to whom the Software is furnished to do
  49486. so, subject to the following conditions:
  49487. The above copyright notice and this permission notice shall be included in all
  49488. copies or substantial portions of the Software.
  49489. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  49490. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  49491. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  49492. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  49493. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  49494. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  49495. SOFTWARE.
  49496. <?php
  49497. namespace Composer\Spdx;
  49498. class SpdxLicenses
  49499. {
  49500. const LICENSES_FILE = 'spdx-licenses.json';
  49501. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  49502. private $licenses;
  49503. private $licensesExpression;
  49504. private $exceptions;
  49505. private $exceptionsExpression;
  49506. public function __construct()
  49507. {
  49508. $this->loadLicenses();
  49509. $this->loadExceptions();
  49510. }
  49511. public function getLicenseByIdentifier($identifier)
  49512. {
  49513. $key = strtolower($identifier);
  49514. if (!isset($this->licenses[$key])) {
  49515. return;
  49516. }
  49517. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  49518. return array(
  49519. $name,
  49520. $isOsiApproved,
  49521. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  49522. $isDeprecatedLicenseId,
  49523. );
  49524. }
  49525. public function getLicenses()
  49526. {
  49527. return $this->licenses;
  49528. }
  49529. public function getExceptionByIdentifier($identifier)
  49530. {
  49531. $key = strtolower($identifier);
  49532. if (!isset($this->exceptions[$key])) {
  49533. return;
  49534. }
  49535. list($identifier, $name) = $this->exceptions[$key];
  49536. return array(
  49537. $name,
  49538. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  49539. );
  49540. }
  49541. public function getIdentifierByName($name)
  49542. {
  49543. foreach ($this->licenses as $licenseData) {
  49544. if ($licenseData[1] === $name) {
  49545. return $licenseData[0];
  49546. }
  49547. }
  49548. foreach ($this->exceptions as $licenseData) {
  49549. if ($licenseData[1] === $name) {
  49550. return $licenseData[0];
  49551. }
  49552. }
  49553. }
  49554. public function isOsiApprovedByIdentifier($identifier)
  49555. {
  49556. return $this->licenses[strtolower($identifier)][2];
  49557. }
  49558. public function isDeprecatedByIdentifier($identifier)
  49559. {
  49560. return $this->licenses[strtolower($identifier)][3];
  49561. }
  49562. public function validate($license)
  49563. {
  49564. if (is_array($license)) {
  49565. $count = count($license);
  49566. if ($count !== count(array_filter($license, 'is_string'))) {
  49567. throw new \InvalidArgumentException('Array of strings expected.');
  49568. }
  49569. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  49570. }
  49571. if (!is_string($license)) {
  49572. throw new \InvalidArgumentException(sprintf(
  49573. 'Array or String expected, %s given.',
  49574. gettype($license)
  49575. ));
  49576. }
  49577. return $this->isValidLicenseString($license);
  49578. }
  49579. public static function getResourcesDir()
  49580. {
  49581. return dirname(__DIR__) . '/res';
  49582. }
  49583. private function loadLicenses()
  49584. {
  49585. if (null !== $this->licenses) {
  49586. return;
  49587. }
  49588. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  49589. $this->licenses = array();
  49590. foreach (json_decode($json, true) as $identifier => $license) {
  49591. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  49592. }
  49593. }
  49594. private function loadExceptions()
  49595. {
  49596. if (null !== $this->exceptions) {
  49597. return;
  49598. }
  49599. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  49600. $this->exceptions = array();
  49601. foreach (json_decode($json, true) as $identifier => $exception) {
  49602. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  49603. }
  49604. }
  49605. private function getLicensesExpression()
  49606. {
  49607. if (null === $this->licensesExpression) {
  49608. $licenses = array_map('preg_quote', array_keys($this->licenses));
  49609. rsort($licenses);
  49610. $licenses = implode('|', $licenses);
  49611. $this->licensesExpression = $licenses;
  49612. }
  49613. return $this->licensesExpression;
  49614. }
  49615. private function getExceptionsExpression()
  49616. {
  49617. if (null === $this->exceptionsExpression) {
  49618. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  49619. rsort($exceptions);
  49620. $exceptions = implode('|', $exceptions);
  49621. $this->exceptionsExpression = $exceptions;
  49622. }
  49623. return $this->exceptionsExpression;
  49624. }
  49625. private function isValidLicenseString($license)
  49626. {
  49627. if (isset($this->licenses[strtolower($license)])) {
  49628. return true;
  49629. }
  49630. $licenses = $this->getLicensesExpression();
  49631. $exceptions = $this->getExceptionsExpression();
  49632. $regex = <<<REGEX
  49633. {
  49634. (?(DEFINE)
  49635. # idstring: 1*( ALPHA / DIGIT / - / . )
  49636. (?<idstring>[\pL\pN.-]{1,})
  49637. # license-id: taken from list
  49638. (?<licenseid>${licenses})
  49639. # license-exception-id: taken from list
  49640. (?<licenseexceptionid>${exceptions})
  49641. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  49642. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  49643. # simple-expresssion: license-id / license-id+ / license-ref
  49644. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  49645. # compound-expression: 1*(
  49646. # simple-expression /
  49647. # simple-expression WITH license-exception-id /
  49648. # compound-expression AND compound-expression /
  49649. # compound-expression OR compound-expression
  49650. # ) / ( compound-expression ) )
  49651. (?<compound_head>
  49652. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  49653. | \( \s* (?&compound_expression) \s* \)
  49654. )
  49655. (?<compound_expression>
  49656. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  49657. )
  49658. # license-expression: 1*1(simple-expression / compound-expression)
  49659. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  49660. ) # end of define
  49661. ^(NONE | NOASSERTION | (?&license_expression))$
  49662. }xi
  49663. REGEX;
  49664. $match = preg_match($regex, $license);
  49665. if (0 === $match) {
  49666. return false;
  49667. }
  49668. if (false === $match) {
  49669. throw new \RuntimeException('Regex failed to compile/run.');
  49670. }
  49671. return true;
  49672. }
  49673. }
  49674. Copyright (C) 2015 Composer
  49675. Permission is hereby granted, free of charge, to any person obtaining a copy of
  49676. this software and associated documentation files (the "Software"), to deal in
  49677. the Software without restriction, including without limitation the rights to
  49678. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  49679. of the Software, and to permit persons to whom the Software is furnished to do
  49680. so, subject to the following conditions:
  49681. The above copyright notice and this permission notice shall be included in all
  49682. copies or substantial portions of the Software.
  49683. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  49684. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  49685. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  49686. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  49687. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  49688. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  49689. SOFTWARE.
  49690. <?php
  49691. namespace Composer\Semver;
  49692. use Composer\Semver\Constraint\Constraint;
  49693. class Comparator
  49694. {
  49695. public static function greaterThan($version1, $version2)
  49696. {
  49697. return self::compare($version1, '>', $version2);
  49698. }
  49699. public static function greaterThanOrEqualTo($version1, $version2)
  49700. {
  49701. return self::compare($version1, '>=', $version2);
  49702. }
  49703. public static function lessThan($version1, $version2)
  49704. {
  49705. return self::compare($version1, '<', $version2);
  49706. }
  49707. public static function lessThanOrEqualTo($version1, $version2)
  49708. {
  49709. return self::compare($version1, '<=', $version2);
  49710. }
  49711. public static function equalTo($version1, $version2)
  49712. {
  49713. return self::compare($version1, '==', $version2);
  49714. }
  49715. public static function notEqualTo($version1, $version2)
  49716. {
  49717. return self::compare($version1, '!=', $version2);
  49718. }
  49719. public static function compare($version1, $operator, $version2)
  49720. {
  49721. $constraint = new Constraint($operator, $version2);
  49722. return $constraint->matches(new Constraint('==', $version1));
  49723. }
  49724. }
  49725. <?php
  49726. namespace Composer\Semver\Constraint;
  49727. trigger_error('The ' . __CLASS__ . ' abstract class is deprecated, there is no replacement for it, it will be removed in the next major version.', E_USER_DEPRECATED);
  49728. abstract class AbstractConstraint implements ConstraintInterface
  49729. {
  49730. protected $prettyString;
  49731. public function matches(ConstraintInterface $provider)
  49732. {
  49733. if ($provider instanceof $this) {
  49734. return $this->matchSpecific($provider);
  49735. }
  49736. return $provider->matches($this);
  49737. }
  49738. public function setPrettyString($prettyString)
  49739. {
  49740. $this->prettyString = $prettyString;
  49741. }
  49742. public function getPrettyString()
  49743. {
  49744. if ($this->prettyString) {
  49745. return $this->prettyString;
  49746. }
  49747. return $this->__toString();
  49748. }
  49749. }
  49750. <?php
  49751. namespace Composer\Semver\Constraint;
  49752. class Constraint implements ConstraintInterface
  49753. {
  49754. const OP_EQ = 0;
  49755. const OP_LT = 1;
  49756. const OP_LE = 2;
  49757. const OP_GT = 3;
  49758. const OP_GE = 4;
  49759. const OP_NE = 5;
  49760. private static $transOpStr = array(
  49761. '=' => self::OP_EQ,
  49762. '==' => self::OP_EQ,
  49763. '<' => self::OP_LT,
  49764. '<=' => self::OP_LE,
  49765. '>' => self::OP_GT,
  49766. '>=' => self::OP_GE,
  49767. '<>' => self::OP_NE,
  49768. '!=' => self::OP_NE,
  49769. );
  49770. private static $transOpInt = array(
  49771. self::OP_EQ => '==',
  49772. self::OP_LT => '<',
  49773. self::OP_LE => '<=',
  49774. self::OP_GT => '>',
  49775. self::OP_GE => '>=',
  49776. self::OP_NE => '!=',
  49777. );
  49778. protected $operator;
  49779. protected $version;
  49780. protected $prettyString;
  49781. public function matches(ConstraintInterface $provider)
  49782. {
  49783. if ($provider instanceof $this) {
  49784. return $this->matchSpecific($provider);
  49785. }
  49786. return $provider->matches($this);
  49787. }
  49788. public function setPrettyString($prettyString)
  49789. {
  49790. $this->prettyString = $prettyString;
  49791. }
  49792. public function getPrettyString()
  49793. {
  49794. if ($this->prettyString) {
  49795. return $this->prettyString;
  49796. }
  49797. return $this->__toString();
  49798. }
  49799. public static function getSupportedOperators()
  49800. {
  49801. return array_keys(self::$transOpStr);
  49802. }
  49803. public function __construct($operator, $version)
  49804. {
  49805. if (!isset(self::$transOpStr[$operator])) {
  49806. throw new \InvalidArgumentException(sprintf(
  49807. 'Invalid operator "%s" given, expected one of: %s',
  49808. $operator,
  49809. implode(', ', self::getSupportedOperators())
  49810. ));
  49811. }
  49812. $this->operator = self::$transOpStr[$operator];
  49813. $this->version = $version;
  49814. }
  49815. public function versionCompare($a, $b, $operator, $compareBranches = false)
  49816. {
  49817. if (!isset(self::$transOpStr[$operator])) {
  49818. throw new \InvalidArgumentException(sprintf(
  49819. 'Invalid operator "%s" given, expected one of: %s',
  49820. $operator,
  49821. implode(', ', self::getSupportedOperators())
  49822. ));
  49823. }
  49824. $aIsBranch = 'dev-' === substr($a, 0, 4);
  49825. $bIsBranch = 'dev-' === substr($b, 0, 4);
  49826. if ($aIsBranch && $bIsBranch) {
  49827. return $operator === '==' && $a === $b;
  49828. }
  49829. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  49830. return false;
  49831. }
  49832. return version_compare($a, $b, $operator);
  49833. }
  49834. public function matchSpecific(Constraint $provider, $compareBranches = false)
  49835. {
  49836. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  49837. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  49838. $isEqualOp = self::OP_EQ === $this->operator;
  49839. $isNonEqualOp = self::OP_NE === $this->operator;
  49840. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  49841. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  49842. if ($isNonEqualOp || $isProviderNonEqualOp) {
  49843. return !$isEqualOp && !$isProviderEqualOp
  49844. || $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  49845. }
  49846. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  49847. return true;
  49848. }
  49849. if ($this->versionCompare($provider->version, $this->version, self::$transOpInt[$this->operator], $compareBranches)) {
  49850. if ($provider->version === $this->version
  49851. && self::$transOpInt[$provider->operator] === $providerNoEqualOp
  49852. && self::$transOpInt[$this->operator] !== $noEqualOp) {
  49853. return false;
  49854. }
  49855. return true;
  49856. }
  49857. return false;
  49858. }
  49859. public function __toString()
  49860. {
  49861. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  49862. }
  49863. }
  49864. <?php
  49865. namespace Composer\Semver\Constraint;
  49866. interface ConstraintInterface
  49867. {
  49868. public function matches(ConstraintInterface $provider);
  49869. public function getPrettyString();
  49870. public function __toString();
  49871. }
  49872. <?php
  49873. namespace Composer\Semver\Constraint;
  49874. class EmptyConstraint implements ConstraintInterface
  49875. {
  49876. protected $prettyString;
  49877. public function matches(ConstraintInterface $provider)
  49878. {
  49879. return true;
  49880. }
  49881. public function setPrettyString($prettyString)
  49882. {
  49883. $this->prettyString = $prettyString;
  49884. }
  49885. public function getPrettyString()
  49886. {
  49887. if ($this->prettyString) {
  49888. return $this->prettyString;
  49889. }
  49890. return $this->__toString();
  49891. }
  49892. public function __toString()
  49893. {
  49894. return '[]';
  49895. }
  49896. }
  49897. <?php
  49898. namespace Composer\Semver\Constraint;
  49899. class MultiConstraint implements ConstraintInterface
  49900. {
  49901. protected $constraints;
  49902. protected $prettyString;
  49903. protected $conjunctive;
  49904. public function __construct(array $constraints, $conjunctive = true)
  49905. {
  49906. $this->constraints = $constraints;
  49907. $this->conjunctive = $conjunctive;
  49908. }
  49909. public function getConstraints()
  49910. {
  49911. return $this->constraints;
  49912. }
  49913. public function isConjunctive()
  49914. {
  49915. return $this->conjunctive;
  49916. }
  49917. public function isDisjunctive()
  49918. {
  49919. return !$this->conjunctive;
  49920. }
  49921. public function matches(ConstraintInterface $provider)
  49922. {
  49923. if (false === $this->conjunctive) {
  49924. foreach ($this->constraints as $constraint) {
  49925. if ($constraint->matches($provider)) {
  49926. return true;
  49927. }
  49928. }
  49929. return false;
  49930. }
  49931. foreach ($this->constraints as $constraint) {
  49932. if (!$constraint->matches($provider)) {
  49933. return false;
  49934. }
  49935. }
  49936. return true;
  49937. }
  49938. public function setPrettyString($prettyString)
  49939. {
  49940. $this->prettyString = $prettyString;
  49941. }
  49942. public function getPrettyString()
  49943. {
  49944. if ($this->prettyString) {
  49945. return $this->prettyString;
  49946. }
  49947. return $this->__toString();
  49948. }
  49949. public function __toString()
  49950. {
  49951. $constraints = array();
  49952. foreach ($this->constraints as $constraint) {
  49953. $constraints[] = (string) $constraint;
  49954. }
  49955. return '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  49956. }
  49957. }
  49958. <?php
  49959. namespace Composer\Semver;
  49960. use Composer\Semver\Constraint\Constraint;
  49961. class Semver
  49962. {
  49963. const SORT_ASC = 1;
  49964. const SORT_DESC = -1;
  49965. private static $versionParser;
  49966. public static function satisfies($version, $constraints)
  49967. {
  49968. if (null === self::$versionParser) {
  49969. self::$versionParser = new VersionParser();
  49970. }
  49971. $versionParser = self::$versionParser;
  49972. $provider = new Constraint('==', $versionParser->normalize($version));
  49973. $constraints = $versionParser->parseConstraints($constraints);
  49974. return $constraints->matches($provider);
  49975. }
  49976. public static function satisfiedBy(array $versions, $constraints)
  49977. {
  49978. $versions = array_filter($versions, function ($version) use ($constraints) {
  49979. return Semver::satisfies($version, $constraints);
  49980. });
  49981. return array_values($versions);
  49982. }
  49983. public static function sort(array $versions)
  49984. {
  49985. return self::usort($versions, self::SORT_ASC);
  49986. }
  49987. public static function rsort(array $versions)
  49988. {
  49989. return self::usort($versions, self::SORT_DESC);
  49990. }
  49991. private static function usort(array $versions, $direction)
  49992. {
  49993. if (null === self::$versionParser) {
  49994. self::$versionParser = new VersionParser();
  49995. }
  49996. $versionParser = self::$versionParser;
  49997. $normalized = array();
  49998. foreach ($versions as $key => $version) {
  49999. $normalized[] = array($versionParser->normalize($version), $key);
  50000. }
  50001. usort($normalized, function (array $left, array $right) use ($direction) {
  50002. if ($left[0] === $right[0]) {
  50003. return 0;
  50004. }
  50005. if (Comparator::lessThan($left[0], $right[0])) {
  50006. return -$direction;
  50007. }
  50008. return $direction;
  50009. });
  50010. $sorted = array();
  50011. foreach ($normalized as $item) {
  50012. $sorted[] = $versions[$item[1]];
  50013. }
  50014. return $sorted;
  50015. }
  50016. }
  50017. <?php
  50018. namespace Composer\Semver;
  50019. use Composer\Semver\Constraint\ConstraintInterface;
  50020. use Composer\Semver\Constraint\EmptyConstraint;
  50021. use Composer\Semver\Constraint\MultiConstraint;
  50022. use Composer\Semver\Constraint\Constraint;
  50023. class VersionParser
  50024. {
  50025. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  50026. private static $stabilities = array('stable', 'RC', 'beta', 'alpha', 'dev');
  50027. public static function parseStability($version)
  50028. {
  50029. $version = preg_replace('{#.+$}i', '', $version);
  50030. if ('dev-' === substr($version, 0, 4) || '-dev' === substr($version, -4)) {
  50031. return 'dev';
  50032. }
  50033. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  50034. if (!empty($match[3])) {
  50035. return 'dev';
  50036. }
  50037. if (!empty($match[1])) {
  50038. if ('beta' === $match[1] || 'b' === $match[1]) {
  50039. return 'beta';
  50040. }
  50041. if ('alpha' === $match[1] || 'a' === $match[1]) {
  50042. return 'alpha';
  50043. }
  50044. if ('rc' === $match[1]) {
  50045. return 'RC';
  50046. }
  50047. }
  50048. return 'stable';
  50049. }
  50050. public static function normalizeStability($stability)
  50051. {
  50052. $stability = strtolower($stability);
  50053. return $stability === 'rc' ? 'RC' : $stability;
  50054. }
  50055. public function normalize($version, $fullVersion = null)
  50056. {
  50057. $version = trim($version);
  50058. if (null === $fullVersion) {
  50059. $fullVersion = $version;
  50060. }
  50061. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  50062. $version = $match[1];
  50063. }
  50064. if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) {
  50065. return '9999999-dev';
  50066. }
  50067. if ('dev-' === strtolower(substr($version, 0, 4))) {
  50068. return 'dev-' . substr($version, 4);
  50069. }
  50070. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  50071. $version = $match[1];
  50072. }
  50073. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  50074. $version = $matches[1]
  50075. . (!empty($matches[2]) ? $matches[2] : '.0')
  50076. . (!empty($matches[3]) ? $matches[3] : '.0')
  50077. . (!empty($matches[4]) ? $matches[4] : '.0');
  50078. $index = 5;
  50079. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  50080. $version = preg_replace('{\D}', '.', $matches[1]);
  50081. $index = 2;
  50082. }
  50083. if (isset($index)) {
  50084. if (!empty($matches[$index])) {
  50085. if ('stable' === $matches[$index]) {
  50086. return $version;
  50087. }
  50088. $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index + 1]) ? ltrim($matches[$index + 1], '.-') : '');
  50089. }
  50090. if (!empty($matches[$index + 2])) {
  50091. $version .= '-dev';
  50092. }
  50093. return $version;
  50094. }
  50095. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  50096. try {
  50097. return $this->normalizeBranch($match[1]);
  50098. } catch (\Exception $e) {
  50099. }
  50100. }
  50101. $extraMessage = '';
  50102. if (preg_match('{ +as +' . preg_quote($version) . '$}', $fullVersion)) {
  50103. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  50104. } elseif (preg_match('{^' . preg_quote($version) . ' +as +}', $fullVersion)) {
  50105. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  50106. }
  50107. throw new \UnexpectedValueException('Invalid version string "' . $version . '"' . $extraMessage);
  50108. }
  50109. public function parseNumericAliasPrefix($branch)
  50110. {
  50111. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  50112. return $matches['version'] . '.';
  50113. }
  50114. return false;
  50115. }
  50116. public function normalizeBranch($name)
  50117. {
  50118. $name = trim($name);
  50119. if (in_array($name, array('master', 'trunk', 'default'))) {
  50120. return $this->normalize($name);
  50121. }
  50122. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  50123. $version = '';
  50124. for ($i = 1; $i < 5; ++$i) {
  50125. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  50126. }
  50127. return str_replace('x', '9999999', $version) . '-dev';
  50128. }
  50129. return 'dev-' . $name;
  50130. }
  50131. public function parseConstraints($constraints)
  50132. {
  50133. $prettyConstraint = $constraints;
  50134. if (preg_match('{^([^,\s]*?)@(' . implode('|', self::$stabilities) . ')$}i', $constraints, $match)) {
  50135. $constraints = empty($match[1]) ? '*' : $match[1];
  50136. }
  50137. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraints, $match)) {
  50138. $constraints = $match[1];
  50139. }
  50140. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  50141. $orGroups = array();
  50142. foreach ($orConstraints as $constraints) {
  50143. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  50144. if (count($andConstraints) > 1) {
  50145. $constraintObjects = array();
  50146. foreach ($andConstraints as $constraint) {
  50147. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  50148. $constraintObjects[] = $parsedConstraint;
  50149. }
  50150. }
  50151. } else {
  50152. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  50153. }
  50154. if (1 === count($constraintObjects)) {
  50155. $constraint = $constraintObjects[0];
  50156. } else {
  50157. $constraint = new MultiConstraint($constraintObjects);
  50158. }
  50159. $orGroups[] = $constraint;
  50160. }
  50161. if (1 === count($orGroups)) {
  50162. $constraint = $orGroups[0];
  50163. } elseif (2 === count($orGroups)
  50164. && $orGroups[0] instanceof MultiConstraint
  50165. && $orGroups[1] instanceof MultiConstraint
  50166. && 2 === count($orGroups[0]->getConstraints())
  50167. && 2 === count($orGroups[1]->getConstraints())
  50168. && ($a = (string) $orGroups[0])
  50169. && substr($a, 0, 3) === '[>=' && (false !== ($posA = strpos($a, '<', 4)))
  50170. && ($b = (string) $orGroups[1])
  50171. && substr($b, 0, 3) === '[>=' && (false !== ($posB = strpos($b, '<', 4)))
  50172. && substr($a, $posA + 2, -1) === substr($b, 4, $posB - 5)
  50173. ) {
  50174. $constraint = new MultiConstraint(array(
  50175. new Constraint('>=', substr($a, 4, $posA - 5)),
  50176. new Constraint('<', substr($b, $posB + 2, -1)),
  50177. ));
  50178. } else {
  50179. $constraint = new MultiConstraint($orGroups, false);
  50180. }
  50181. $constraint->setPrettyString($prettyConstraint);
  50182. return $constraint;
  50183. }
  50184. private function parseConstraint($constraint)
  50185. {
  50186. if (preg_match('{^([^,\s]+?)@(' . implode('|', self::$stabilities) . ')$}i', $constraint, $match)) {
  50187. $constraint = $match[1];
  50188. if ($match[2] !== 'stable') {
  50189. $stabilityModifier = $match[2];
  50190. }
  50191. }
  50192. if (preg_match('{^v?[xX*](\.[xX*])*$}i', $constraint)) {
  50193. return array(new EmptyConstraint());
  50194. }
  50195. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?' . self::$modifierRegex . '(?:\+[^\s]+)?';
  50196. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  50197. if (substr($constraint, 0, 2) === '~>') {
  50198. throw new \UnexpectedValueException(
  50199. 'Could not parse version constraint ' . $constraint . ': ' .
  50200. 'Invalid operator "~>", you probably meant to use the "~" operator'
  50201. );
  50202. }
  50203. if (isset($matches[4]) && '' !== $matches[4]) {
  50204. $position = 4;
  50205. } elseif (isset($matches[3]) && '' !== $matches[3]) {
  50206. $position = 3;
  50207. } elseif (isset($matches[2]) && '' !== $matches[2]) {
  50208. $position = 2;
  50209. } else {
  50210. $position = 1;
  50211. }
  50212. $stabilitySuffix = '';
  50213. if (!empty($matches[5])) {
  50214. $stabilitySuffix .= '-' . $this->expandStability($matches[5]) . (!empty($matches[6]) ? $matches[6] : '');
  50215. }
  50216. if (!empty($matches[7])) {
  50217. $stabilitySuffix .= '-dev';
  50218. }
  50219. if (!$stabilitySuffix) {
  50220. $stabilitySuffix = '-dev';
  50221. }
  50222. $lowVersion = $this->manipulateVersionString($matches, $position, 0) . $stabilitySuffix;
  50223. $lowerBound = new Constraint('>=', $lowVersion);
  50224. $highPosition = max(1, $position - 1);
  50225. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  50226. $upperBound = new Constraint('<', $highVersion);
  50227. return array(
  50228. $lowerBound,
  50229. $upperBound,
  50230. );
  50231. }
  50232. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  50233. if ('0' !== $matches[1] || '' === $matches[2]) {
  50234. $position = 1;
  50235. } elseif ('0' !== $matches[2] || '' === $matches[3]) {
  50236. $position = 2;
  50237. } else {
  50238. $position = 3;
  50239. }
  50240. $stabilitySuffix = '';
  50241. if (empty($matches[5]) && empty($matches[7])) {
  50242. $stabilitySuffix .= '-dev';
  50243. }
  50244. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  50245. $lowerBound = new Constraint('>=', $lowVersion);
  50246. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  50247. $upperBound = new Constraint('<', $highVersion);
  50248. return array(
  50249. $lowerBound,
  50250. $upperBound,
  50251. );
  50252. }
  50253. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  50254. if (isset($matches[3]) && '' !== $matches[3]) {
  50255. $position = 3;
  50256. } elseif (isset($matches[2]) && '' !== $matches[2]) {
  50257. $position = 2;
  50258. } else {
  50259. $position = 1;
  50260. }
  50261. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  50262. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  50263. if ($lowVersion === '0.0.0.0-dev') {
  50264. return array(new Constraint('<', $highVersion));
  50265. }
  50266. return array(
  50267. new Constraint('>=', $lowVersion),
  50268. new Constraint('<', $highVersion),
  50269. );
  50270. }
  50271. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  50272. $lowStabilitySuffix = '';
  50273. if (empty($matches[6]) && empty($matches[8])) {
  50274. $lowStabilitySuffix = '-dev';
  50275. }
  50276. $lowVersion = $this->normalize($matches['from']);
  50277. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  50278. $empty = function ($x) {
  50279. return ($x === 0 || $x === '0') ? false : empty($x);
  50280. };
  50281. if ((!$empty($matches[11]) && !$empty($matches[12])) || !empty($matches[14]) || !empty($matches[16])) {
  50282. $highVersion = $this->normalize($matches['to']);
  50283. $upperBound = new Constraint('<=', $highVersion);
  50284. } else {
  50285. $highMatch = array('', $matches[10], $matches[11], $matches[12], $matches[13]);
  50286. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[11]) ? 1 : 2, 1) . '-dev';
  50287. $upperBound = new Constraint('<', $highVersion);
  50288. }
  50289. return array(
  50290. $lowerBound,
  50291. $upperBound,
  50292. );
  50293. }
  50294. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  50295. try {
  50296. $version = $this->normalize($matches[2]);
  50297. if (!empty($stabilityModifier) && $this->parseStability($version) === 'stable') {
  50298. $version .= '-' . $stabilityModifier;
  50299. } elseif ('<' === $matches[1] || '>=' === $matches[1]) {
  50300. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  50301. if (substr($matches[2], 0, 4) !== 'dev-') {
  50302. $version .= '-dev';
  50303. }
  50304. }
  50305. }
  50306. return array(new Constraint($matches[1] ?: '=', $version));
  50307. } catch (\Exception $e) {
  50308. }
  50309. }
  50310. $message = 'Could not parse version constraint ' . $constraint;
  50311. if (isset($e)) {
  50312. $message .= ': ' . $e->getMessage();
  50313. }
  50314. throw new \UnexpectedValueException($message);
  50315. }
  50316. private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
  50317. {
  50318. for ($i = 4; $i > 0; --$i) {
  50319. if ($i > $position) {
  50320. $matches[$i] = $pad;
  50321. } elseif ($i === $position && $increment) {
  50322. $matches[$i] += $increment;
  50323. if ($matches[$i] < 0) {
  50324. $matches[$i] = $pad;
  50325. --$position;
  50326. if ($i === 1) {
  50327. return;
  50328. }
  50329. }
  50330. }
  50331. }
  50332. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  50333. }
  50334. private function expandStability($stability)
  50335. {
  50336. $stability = strtolower($stability);
  50337. switch ($stability) {
  50338. case 'a':
  50339. return 'alpha';
  50340. case 'b':
  50341. return 'beta';
  50342. case 'p':
  50343. case 'pl':
  50344. return 'patch';
  50345. case 'rc':
  50346. return 'RC';
  50347. default:
  50348. return $stability;
  50349. }
  50350. }
  50351. }
  50352. Copyright (C) 2016 Composer
  50353. Permission is hereby granted, free of charge, to any person obtaining a copy of
  50354. this software and associated documentation files (the "Software"), to deal in
  50355. the Software without restriction, including without limitation the rights to
  50356. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  50357. of the Software, and to permit persons to whom the Software is furnished to do
  50358. so, subject to the following conditions:
  50359. The above copyright notice and this permission notice shall be included in all
  50360. copies or substantial portions of the Software.
  50361. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50362. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  50363. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  50364. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  50365. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50366. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  50367. SOFTWARE.
  50368. <?php
  50369. namespace Composer\CaBundle;
  50370. use Psr\Log\LoggerInterface;
  50371. use Symfony\Component\Process\PhpProcess;
  50372. class CaBundle
  50373. {
  50374. private static $caPath;
  50375. private static $caFileValidity = array();
  50376. private static $useOpensslParse;
  50377. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  50378. {
  50379. if (self::$caPath !== null) {
  50380. return self::$caPath;
  50381. }
  50382. $envCertFile = getenv('SSL_CERT_FILE');
  50383. if ($envCertFile && is_readable($envCertFile) && static::validateCaFile($envCertFile, $logger)) {
  50384. return self::$caPath = $envCertFile;
  50385. }
  50386. $envCertDir = getenv('SSL_CERT_DIR');
  50387. if ($envCertDir && is_dir($envCertDir) && is_readable($envCertDir)) {
  50388. return self::$caPath = $envCertDir;
  50389. }
  50390. $configured = ini_get('openssl.cafile');
  50391. if ($configured && strlen($configured) > 0 && is_readable($configured) && static::validateCaFile($configured, $logger)) {
  50392. return self::$caPath = $configured;
  50393. }
  50394. $configured = ini_get('openssl.capath');
  50395. if ($configured && is_dir($configured) && is_readable($configured)) {
  50396. return self::$caPath = $configured;
  50397. }
  50398. $caBundlePaths = array(
  50399. '/etc/pki/tls/certs/ca-bundle.crt',
  50400. '/etc/ssl/certs/ca-certificates.crt',
  50401. '/etc/ssl/ca-bundle.pem',
  50402. '/usr/local/share/certs/ca-root-nss.crt',
  50403. '/usr/ssl/certs/ca-bundle.crt',
  50404. '/opt/local/share/curl/curl-ca-bundle.crt',
  50405. '/usr/local/share/curl/curl-ca-bundle.crt',
  50406. '/usr/share/ssl/certs/ca-bundle.crt',
  50407. '/etc/ssl/cert.pem',
  50408. '/usr/local/etc/ssl/cert.pem',
  50409. '/usr/local/etc/openssl/cert.pem',
  50410. );
  50411. foreach ($caBundlePaths as $caBundle) {
  50412. if (@is_readable($caBundle) && static::validateCaFile($caBundle, $logger)) {
  50413. return self::$caPath = $caBundle;
  50414. }
  50415. }
  50416. foreach ($caBundlePaths as $caBundle) {
  50417. $caBundle = dirname($caBundle);
  50418. if (@is_dir($caBundle) && glob($caBundle.'/*')) {
  50419. return self::$caPath = $caBundle;
  50420. }
  50421. }
  50422. return self::$caPath = static::getBundledCaBundlePath();
  50423. }
  50424. public static function getBundledCaBundlePath()
  50425. {
  50426. $caBundleFile = __DIR__.'/../res/cacert.pem';
  50427. if (0 === strpos($caBundleFile, 'phar://')) {
  50428. file_put_contents(
  50429. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-'),
  50430. file_get_contents($caBundleFile)
  50431. );
  50432. register_shutdown_function(function() use ($tempCaBundleFile) {
  50433. @unlink($tempCaBundleFile);
  50434. });
  50435. $caBundleFile = $tempCaBundleFile;
  50436. }
  50437. return $caBundleFile;
  50438. }
  50439. public static function validateCaFile($filename, LoggerInterface $logger = null)
  50440. {
  50441. static $warned = false;
  50442. if (isset(self::$caFileValidity[$filename])) {
  50443. return self::$caFileValidity[$filename];
  50444. }
  50445. $contents = file_get_contents($filename);
  50446. if (!static::isOpensslParseSafe()) {
  50447. if (!$warned && $logger) {
  50448. $logger->warning(sprintf(
  50449. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  50450. PHP_VERSION
  50451. ));
  50452. $warned = true;
  50453. }
  50454. $isValid = !empty($contents);
  50455. } else {
  50456. $isValid = (bool) openssl_x509_parse($contents);
  50457. }
  50458. if ($logger) {
  50459. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  50460. }
  50461. return self::$caFileValidity[$filename] = $isValid;
  50462. }
  50463. public static function isOpensslParseSafe()
  50464. {
  50465. if (null !== self::$useOpensslParse) {
  50466. return self::$useOpensslParse;
  50467. }
  50468. if (PHP_VERSION_ID >= 50600) {
  50469. return self::$useOpensslParse = true;
  50470. }
  50471. if (
  50472. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  50473. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  50474. || (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50507)
  50475. ) {
  50476. return self::$useOpensslParse = true;
  50477. }
  50478. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  50479. return self::$useOpensslParse = false;
  50480. }
  50481. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  50482. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  50483. if (preg_match($regex, PHP_VERSION, $m)) {
  50484. return ((int) $m[1]) >= $fixedVersion;
  50485. }
  50486. return false;
  50487. };
  50488. if (
  50489. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  50490. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  50491. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  50492. ) {
  50493. return self::$useOpensslParse = true;
  50494. }
  50495. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  50496. return self::$useOpensslParse = false;
  50497. }
  50498. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  50499. $script = <<<'EOT'
  50500. error_reporting(-1);
  50501. $info = openssl_x509_parse(base64_decode('%s'));
  50502. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  50503. EOT;
  50504. $script = '<'."?php\n".sprintf($script, $cert);
  50505. try {
  50506. $process = new PhpProcess($script);
  50507. $process->mustRun();
  50508. } catch (\Exception $e) {
  50509. return self::$useOpensslParse = false;
  50510. }
  50511. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  50512. $errorOutput = trim($process->getErrorOutput());
  50513. if (
  50514. count($output) === 3
  50515. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  50516. && $output[1] === 'string(27) "[email protected]"'
  50517. && $output[2] === 'int(-1)'
  50518. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  50519. ) {
  50520. return self::$useOpensslParse = true;
  50521. }
  50522. return self::$useOpensslParse = false;
  50523. }
  50524. public static function reset()
  50525. {
  50526. self::$caFileValidity = array();
  50527. self::$caPath = null;
  50528. self::$useOpensslParse = null;
  50529. }
  50530. }
  50531. MIT License
  50532. Copyright (c) 2017 Composer
  50533. Permission is hereby granted, free of charge, to any person obtaining a copy
  50534. of this software and associated documentation files (the "Software"), to deal
  50535. in the Software without restriction, including without limitation the rights
  50536. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  50537. copies of the Software, and to permit persons to whom the Software is
  50538. furnished to do so, subject to the following conditions:
  50539. The above copyright notice and this permission notice shall be included in all
  50540. copies or substantial portions of the Software.
  50541. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  50542. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  50543. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  50544. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  50545. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  50546. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  50547. SOFTWARE.
  50548. <?php
  50549. namespace Composer\XdebugHandler;
  50550. class PhpConfig
  50551. {
  50552. public function useOriginal()
  50553. {
  50554. $this->getDataAndReset();
  50555. return array();
  50556. }
  50557. public function useStandard()
  50558. {
  50559. if ($data = $this->getDataAndReset()) {
  50560. return array('-n', '-c', $data['tmpIni']);
  50561. }
  50562. return array();
  50563. }
  50564. public function usePersistent()
  50565. {
  50566. if ($data = $this->getDataAndReset()) {
  50567. Process::setEnv('PHPRC', $data['tmpIni']);
  50568. Process::setEnv('PHP_INI_SCAN_DIR', '');
  50569. }
  50570. return array();
  50571. }
  50572. private function getDataAndReset()
  50573. {
  50574. if ($data = XdebugHandler::getRestartSettings()) {
  50575. Process::setEnv('PHPRC', $data['phprc']);
  50576. Process::setEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  50577. }
  50578. return $data;
  50579. }
  50580. }
  50581. <?php
  50582. namespace Composer\XdebugHandler;
  50583. class Process
  50584. {
  50585. public static function addColorOption(array $args, $colorOption)
  50586. {
  50587. if (!$colorOption
  50588. || in_array($colorOption, $args)
  50589. || !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
  50590. return $args;
  50591. }
  50592. if (isset($matches[2])) {
  50593. if (false !== ($index = array_search($matches[2].'auto', $args))) {
  50594. $args[$index] = $colorOption;
  50595. return $args;
  50596. } elseif (preg_grep('/^'.$matches[2].'/', $args)) {
  50597. return $args;
  50598. }
  50599. } elseif (in_array('--no-'.$matches[1], $args)) {
  50600. return $args;
  50601. }
  50602. if (false !== ($index = array_search('--', $args))) {
  50603. array_splice($args, $index, 0, $colorOption);
  50604. } else {
  50605. $args[] = $colorOption;
  50606. }
  50607. return $args;
  50608. }
  50609. public static function escape($arg, $meta = true, $module = false)
  50610. {
  50611. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  50612. return "'".str_replace("'", "'\\''", $arg)."'";
  50613. }
  50614. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  50615. $arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  50616. if ($meta) {
  50617. $meta = $dquotes || preg_match('/%[^%]+%/', $arg);
  50618. if (!$meta) {
  50619. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  50620. } elseif ($module && !$dquotes && $quote) {
  50621. $meta = false;
  50622. }
  50623. }
  50624. if ($quote) {
  50625. $arg = '"'.preg_replace('/(\\\\*)$/', '$1$1', $arg).'"';
  50626. }
  50627. if ($meta) {
  50628. $arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
  50629. }
  50630. return $arg;
  50631. }
  50632. public static function supportsColor($output)
  50633. {
  50634. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  50635. return (function_exists('sapi_windows_vt100_support')
  50636. && sapi_windows_vt100_support($output))
  50637. || false !== getenv('ANSICON')
  50638. || 'ON' === getenv('ConEmuANSI')
  50639. || 'xterm' === getenv('TERM');
  50640. }
  50641. if (function_exists('stream_isatty')) {
  50642. return stream_isatty($output);
  50643. } elseif (function_exists('posix_isatty')) {
  50644. return posix_isatty($output);
  50645. }
  50646. $stat = fstat($output);
  50647. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  50648. }
  50649. public static function setEnv($name, $value = false)
  50650. {
  50651. $unset = false === $value;
  50652. if (!putenv($unset ? $name : $name.'='.$value)) {
  50653. return false;
  50654. }
  50655. if ($unset) {
  50656. unset($_SERVER[$name]);
  50657. } else {
  50658. $_SERVER[$name] = $value;
  50659. }
  50660. return true;
  50661. }
  50662. }
  50663. <?php
  50664. namespace Composer\XdebugHandler;
  50665. use Psr\Log\LoggerInterface;
  50666. use Psr\Log\LogLevel;
  50667. class Status
  50668. {
  50669. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  50670. const CHECK = 'Check';
  50671. const ERROR = 'Error';
  50672. const INFO = 'Info';
  50673. const NORESTART = 'NoRestart';
  50674. const RESTART = 'Restart';
  50675. const RESTARTING = 'Restarting';
  50676. const RESTARTED = 'Restarted';
  50677. private $debug;
  50678. private $envAllowXdebug;
  50679. private $loaded;
  50680. private $logger;
  50681. private $time;
  50682. public function __construct($envAllowXdebug, $debug)
  50683. {
  50684. $start = getenv(self::ENV_RESTART);
  50685. Process::setEnv(self::ENV_RESTART);
  50686. $this->time = $start ? round((microtime(true) - $start) * 1000) : 0;
  50687. $this->envAllowXdebug = $envAllowXdebug;
  50688. $this->debug = $debug && defined('STDERR');
  50689. }
  50690. public function setLogger(LoggerInterface $logger)
  50691. {
  50692. $this->logger = $logger;
  50693. }
  50694. public function report($op, $data)
  50695. {
  50696. if ($this->logger || $this->debug) {
  50697. call_user_func(array($this, 'report'.$op), $data);
  50698. }
  50699. }
  50700. private function output($text, $level = null)
  50701. {
  50702. if ($this->logger) {
  50703. $this->logger->log($level ?: LogLevel::DEBUG, $text);
  50704. }
  50705. if ($this->debug) {
  50706. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  50707. }
  50708. }
  50709. private function reportCheck($loaded)
  50710. {
  50711. $this->loaded = $loaded;
  50712. $this->output('Checking '.$this->envAllowXdebug);
  50713. }
  50714. private function reportError($error)
  50715. {
  50716. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  50717. }
  50718. private function reportInfo($info)
  50719. {
  50720. $this->output($info);
  50721. }
  50722. private function reportNoRestart()
  50723. {
  50724. $this->output($this->getLoadedMessage());
  50725. if ($this->loaded) {
  50726. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  50727. if (!getenv($this->envAllowXdebug)) {
  50728. $text .= ' Allowed by application';
  50729. }
  50730. $this->output($text);
  50731. }
  50732. }
  50733. private function reportRestart()
  50734. {
  50735. $this->output($this->getLoadedMessage());
  50736. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  50737. }
  50738. private function reportRestarted()
  50739. {
  50740. $loaded = $this->getLoadedMessage();
  50741. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  50742. $level = $this->loaded ? LogLevel::WARNING : null;
  50743. $this->output($text, $level);
  50744. }
  50745. private function reportRestarting($command)
  50746. {
  50747. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  50748. $this->output($text);
  50749. $text = 'Running '.$command;
  50750. $this->output($text);
  50751. }
  50752. private function getEnvAllow()
  50753. {
  50754. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  50755. }
  50756. private function getLoadedMessage()
  50757. {
  50758. $loaded = $this->loaded ? sprintf('loaded (%s)', $this->loaded) : 'not loaded';
  50759. return 'The xdebug extension is '.$loaded;
  50760. }
  50761. }
  50762. <?php
  50763. namespace Composer\XdebugHandler;
  50764. use Psr\Log\LoggerInterface;
  50765. class XdebugHandler
  50766. {
  50767. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  50768. const SUFFIX_INIS = '_ORIGINAL_INIS';
  50769. const RESTART_ID = 'internal';
  50770. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  50771. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  50772. protected $tmpIni;
  50773. private static $inRestart;
  50774. private static $name;
  50775. private static $skipped;
  50776. private $cli;
  50777. private $colorOption;
  50778. private $debug;
  50779. private $envAllowXdebug;
  50780. private $envOriginalInis;
  50781. private $loaded;
  50782. private $persistent;
  50783. private $script;
  50784. private $statusWriter;
  50785. public function __construct($envPrefix, $colorOption = '')
  50786. {
  50787. if (!is_string($envPrefix) || empty($envPrefix) || !is_string($colorOption)) {
  50788. throw new \RuntimeException('Invalid constructor parameter');
  50789. }
  50790. self::$name = strtoupper($envPrefix);
  50791. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  50792. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  50793. $this->colorOption = $colorOption;
  50794. if (extension_loaded('xdebug')) {
  50795. $ext = new \ReflectionExtension('xdebug');
  50796. $this->loaded = $ext->getVersion() ?: 'unknown';
  50797. }
  50798. if ($this->cli = PHP_SAPI === 'cli') {
  50799. $this->debug = getenv(self::DEBUG);
  50800. }
  50801. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  50802. }
  50803. public function setLogger(LoggerInterface $logger)
  50804. {
  50805. $this->statusWriter->setLogger($logger);
  50806. return $this;
  50807. }
  50808. public function setMainScript($script)
  50809. {
  50810. $this->script = $script;
  50811. return $this;
  50812. }
  50813. public function setPersistent()
  50814. {
  50815. $this->persistent = true;
  50816. return $this;
  50817. }
  50818. public function check()
  50819. {
  50820. $this->notify(Status::CHECK, $this->loaded);
  50821. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  50822. if (empty($envArgs[0]) && $this->requiresRestart((bool) $this->loaded)) {
  50823. $this->notify(Status::RESTART);
  50824. if ($this->prepareRestart()) {
  50825. $command = $this->getCommand();
  50826. $this->notify(Status::RESTARTING, $command);
  50827. $this->restart($command);
  50828. }
  50829. return;
  50830. }
  50831. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  50832. $this->notify(Status::RESTARTED);
  50833. Process::setEnv($this->envAllowXdebug);
  50834. self::$inRestart = true;
  50835. if (!$this->loaded) {
  50836. self::$skipped = $envArgs[1];
  50837. }
  50838. $this->setEnvRestartSettings($envArgs);
  50839. return;
  50840. }
  50841. $this->notify(Status::NORESTART);
  50842. if ($settings = self::getRestartSettings()) {
  50843. $this->syncSettings($settings);
  50844. }
  50845. }
  50846. public static function getAllIniFiles()
  50847. {
  50848. if (!empty(self::$name)) {
  50849. $env = getenv(self::$name.self::SUFFIX_INIS);
  50850. if (false !== $env) {
  50851. return explode(PATH_SEPARATOR, $env);
  50852. }
  50853. }
  50854. $paths = array((string) php_ini_loaded_file());
  50855. if ($scanned = php_ini_scanned_files()) {
  50856. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  50857. }
  50858. return $paths;
  50859. }
  50860. public static function getRestartSettings()
  50861. {
  50862. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  50863. if (count($envArgs) !== 6
  50864. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  50865. return;
  50866. }
  50867. return array(
  50868. 'tmpIni' => $envArgs[0],
  50869. 'scannedInis' => (bool) $envArgs[1],
  50870. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  50871. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  50872. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  50873. 'skipped' => $envArgs[5],
  50874. );
  50875. }
  50876. public static function getSkippedVersion()
  50877. {
  50878. return (string) self::$skipped;
  50879. }
  50880. protected function requiresRestart($isLoaded)
  50881. {
  50882. return $isLoaded;
  50883. }
  50884. protected function restart($command)
  50885. {
  50886. $this->doRestart($command);
  50887. }
  50888. private function doRestart($command)
  50889. {
  50890. passthru($command, $exitCode);
  50891. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  50892. if ($this->debug === '2') {
  50893. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  50894. } else {
  50895. @unlink($this->tmpIni);
  50896. }
  50897. exit($exitCode);
  50898. }
  50899. private function prepareRestart()
  50900. {
  50901. $error = '';
  50902. $iniFiles = self::getAllIniFiles();
  50903. $scannedInis = count($iniFiles) > 1;
  50904. $tmpDir = sys_get_temp_dir();
  50905. if (!$this->cli) {
  50906. $error = 'Unsupported SAPI: '.PHP_SAPI;
  50907. } elseif (!defined('PHP_BINARY')) {
  50908. $error = 'PHP version is too old: '.PHP_VERSION;
  50909. } elseif (false !== strpos(ini_get('disable_functions'), 'passthru')) {
  50910. $error = 'Required function is disabled: passthru';
  50911. } elseif (!$this->checkScanDirConfig()) {
  50912. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  50913. } elseif (!$this->checkMainScript()) {
  50914. $error = 'Unable to access main script: '.$this->script;
  50915. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  50916. $error = $error ?: 'Unable to create temp ini file at: '.$tmpDir;
  50917. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  50918. $error = 'Unable to set environment variables';
  50919. }
  50920. if ($error) {
  50921. $this->notify(Status::ERROR, $error);
  50922. }
  50923. return empty($error);
  50924. }
  50925. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  50926. {
  50927. if (!$this->tmpIni = @tempnam($tmpDir, '')) {
  50928. return false;
  50929. }
  50930. if (empty($iniFiles[0])) {
  50931. array_shift($iniFiles);
  50932. }
  50933. $content = '';
  50934. $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  50935. foreach ($iniFiles as $file) {
  50936. if (!$data = @file_get_contents($file)) {
  50937. $error = 'Unable to read ini: '.$file;
  50938. return false;
  50939. }
  50940. $content .= preg_replace($regex, ';$1', $data).PHP_EOL;
  50941. }
  50942. if ($config = parse_ini_string($content)) {
  50943. $loaded = ini_get_all(null, false);
  50944. $content .= $this->mergeLoadedConfig($loaded, $config);
  50945. }
  50946. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  50947. return @file_put_contents($this->tmpIni, $content);
  50948. }
  50949. private function getCommand()
  50950. {
  50951. $php = array(PHP_BINARY);
  50952. $args = array_slice($_SERVER['argv'], 1);
  50953. if (!$this->persistent) {
  50954. array_push($php, '-n', '-c', $this->tmpIni);
  50955. }
  50956. if (defined('STDOUT') && Process::supportsColor(STDOUT)) {
  50957. $args = Process::addColorOption($args, $this->colorOption);
  50958. }
  50959. $args = array_merge($php, array($this->script), $args);
  50960. $cmd = Process::escape(array_shift($args), true, true);
  50961. foreach ($args as $arg) {
  50962. $cmd .= ' '.Process::escape($arg);
  50963. }
  50964. return $cmd;
  50965. }
  50966. private function setEnvironment($scannedInis, array $iniFiles)
  50967. {
  50968. $scanDir = getenv('PHP_INI_SCAN_DIR');
  50969. $phprc = getenv('PHPRC');
  50970. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  50971. return false;
  50972. }
  50973. if ($this->persistent) {
  50974. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  50975. return false;
  50976. }
  50977. }
  50978. $envArgs = array(
  50979. self::RESTART_ID,
  50980. $this->loaded,
  50981. (int) $scannedInis,
  50982. false === $scanDir ? '*' : $scanDir,
  50983. false === $phprc ? '*' : $phprc,
  50984. );
  50985. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  50986. }
  50987. private function notify($op, $data = null)
  50988. {
  50989. $this->statusWriter->report($op, $data);
  50990. }
  50991. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  50992. {
  50993. $content = '';
  50994. foreach ($loadedConfig as $name => $value) {
  50995. if (!is_string($value)
  50996. || strpos($name, 'xdebug') === 0
  50997. || $name === 'apc.mmap_file_mask') {
  50998. continue;
  50999. }
  51000. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  51001. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  51002. }
  51003. }
  51004. return $content;
  51005. }
  51006. private function checkMainScript()
  51007. {
  51008. if (null !== $this->script) {
  51009. return file_exists($this->script) || '--' === $this->script;
  51010. }
  51011. if (file_exists($this->script = $_SERVER['argv'][0])) {
  51012. return true;
  51013. }
  51014. $options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false;
  51015. $trace = debug_backtrace($options);
  51016. if (($main = end($trace)) && isset($main['file'])) {
  51017. return file_exists($this->script = $main['file']);
  51018. }
  51019. return false;
  51020. }
  51021. private function setEnvRestartSettings($envArgs)
  51022. {
  51023. $settings = array(
  51024. php_ini_loaded_file(),
  51025. $envArgs[2],
  51026. $envArgs[3],
  51027. $envArgs[4],
  51028. getenv($this->envOriginalInis),
  51029. self::$skipped,
  51030. );
  51031. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  51032. }
  51033. private function syncSettings(array $settings)
  51034. {
  51035. if (false === getenv($this->envOriginalInis)) {
  51036. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  51037. }
  51038. self::$skipped = $settings['skipped'];
  51039. $this->notify(Status::INFO, 'Process called with existing restart settings');
  51040. }
  51041. private function checkScanDirConfig()
  51042. {
  51043. return !(getenv('PHP_INI_SCAN_DIR')
  51044. && !PHP_CONFIG_FILE_SCAN_DIR
  51045. && (PHP_VERSION_ID < 70113
  51046. || PHP_VERSION_ID === 70200));
  51047. }
  51048. }
  51049. Copyright (c) 2012 PHP Framework Interoperability Group
  51050. Permission is hereby granted, free of charge, to any person obtaining a copy
  51051. of this software and associated documentation files (the "Software"), to deal
  51052. in the Software without restriction, including without limitation the rights
  51053. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51054. copies of the Software, and to permit persons to whom the Software is
  51055. furnished to do so, subject to the following conditions:
  51056. The above copyright notice and this permission notice shall be included in
  51057. all copies or substantial portions of the Software.
  51058. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51059. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51060. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51061. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51062. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51063. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  51064. THE SOFTWARE.
  51065. <?php
  51066. namespace Psr\Log;
  51067. abstract class AbstractLogger implements LoggerInterface
  51068. {
  51069. public function emergency($message, array $context = array())
  51070. {
  51071. $this->log(LogLevel::EMERGENCY, $message, $context);
  51072. }
  51073. public function alert($message, array $context = array())
  51074. {
  51075. $this->log(LogLevel::ALERT, $message, $context);
  51076. }
  51077. public function critical($message, array $context = array())
  51078. {
  51079. $this->log(LogLevel::CRITICAL, $message, $context);
  51080. }
  51081. public function error($message, array $context = array())
  51082. {
  51083. $this->log(LogLevel::ERROR, $message, $context);
  51084. }
  51085. public function warning($message, array $context = array())
  51086. {
  51087. $this->log(LogLevel::WARNING, $message, $context);
  51088. }
  51089. public function notice($message, array $context = array())
  51090. {
  51091. $this->log(LogLevel::NOTICE, $message, $context);
  51092. }
  51093. public function info($message, array $context = array())
  51094. {
  51095. $this->log(LogLevel::INFO, $message, $context);
  51096. }
  51097. public function debug($message, array $context = array())
  51098. {
  51099. $this->log(LogLevel::DEBUG, $message, $context);
  51100. }
  51101. }
  51102. <?php
  51103. namespace Psr\Log;
  51104. class InvalidArgumentException extends \InvalidArgumentException
  51105. {
  51106. }
  51107. <?php
  51108. namespace Psr\Log;
  51109. class LogLevel
  51110. {
  51111. const EMERGENCY = 'emergency';
  51112. const ALERT = 'alert';
  51113. const CRITICAL = 'critical';
  51114. const ERROR = 'error';
  51115. const WARNING = 'warning';
  51116. const NOTICE = 'notice';
  51117. const INFO = 'info';
  51118. const DEBUG = 'debug';
  51119. }
  51120. <?php
  51121. namespace Psr\Log;
  51122. interface LoggerAwareInterface
  51123. {
  51124. public function setLogger(LoggerInterface $logger);
  51125. }
  51126. <?php
  51127. namespace Psr\Log;
  51128. trait LoggerAwareTrait
  51129. {
  51130. protected $logger;
  51131. public function setLogger(LoggerInterface $logger)
  51132. {
  51133. $this->logger = $logger;
  51134. }
  51135. }
  51136. <?php
  51137. namespace Psr\Log;
  51138. interface LoggerInterface
  51139. {
  51140. public function emergency($message, array $context = array());
  51141. public function alert($message, array $context = array());
  51142. public function critical($message, array $context = array());
  51143. public function error($message, array $context = array());
  51144. public function warning($message, array $context = array());
  51145. public function notice($message, array $context = array());
  51146. public function info($message, array $context = array());
  51147. public function debug($message, array $context = array());
  51148. public function log($level, $message, array $context = array());
  51149. }
  51150. <?php
  51151. namespace Psr\Log;
  51152. trait LoggerTrait
  51153. {
  51154. public function emergency($message, array $context = array())
  51155. {
  51156. $this->log(LogLevel::EMERGENCY, $message, $context);
  51157. }
  51158. public function alert($message, array $context = array())
  51159. {
  51160. $this->log(LogLevel::ALERT, $message, $context);
  51161. }
  51162. public function critical($message, array $context = array())
  51163. {
  51164. $this->log(LogLevel::CRITICAL, $message, $context);
  51165. }
  51166. public function error($message, array $context = array())
  51167. {
  51168. $this->log(LogLevel::ERROR, $message, $context);
  51169. }
  51170. public function warning($message, array $context = array())
  51171. {
  51172. $this->log(LogLevel::WARNING, $message, $context);
  51173. }
  51174. public function notice($message, array $context = array())
  51175. {
  51176. $this->log(LogLevel::NOTICE, $message, $context);
  51177. }
  51178. public function info($message, array $context = array())
  51179. {
  51180. $this->log(LogLevel::INFO, $message, $context);
  51181. }
  51182. public function debug($message, array $context = array())
  51183. {
  51184. $this->log(LogLevel::DEBUG, $message, $context);
  51185. }
  51186. abstract public function log($level, $message, array $context = array());
  51187. }
  51188. <?php
  51189. namespace Psr\Log;
  51190. class NullLogger extends AbstractLogger
  51191. {
  51192. public function log($level, $message, array $context = array())
  51193. {
  51194. }
  51195. }
  51196. <?php
  51197. namespace Psr\Log\Test;
  51198. use Psr\Log\LoggerInterface;
  51199. use Psr\Log\LogLevel;
  51200. abstract class LoggerInterfaceTest extends \PHPUnit_Framework_TestCase
  51201. {
  51202. abstract public function getLogger();
  51203. abstract public function getLogs();
  51204. public function testImplements()
  51205. {
  51206. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  51207. }
  51208. public function testLogsAtAllLevels($level, $message)
  51209. {
  51210. $logger = $this->getLogger();
  51211. $logger->{$level}($message, array('user' => 'Bob'));
  51212. $logger->log($level, $message, array('user' => 'Bob'));
  51213. $expected = array(
  51214. $level.' message of level '.$level.' with context: Bob',
  51215. $level.' message of level '.$level.' with context: Bob',
  51216. );
  51217. $this->assertEquals($expected, $this->getLogs());
  51218. }
  51219. public function provideLevelsAndMessages()
  51220. {
  51221. return array(
  51222. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  51223. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  51224. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  51225. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  51226. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  51227. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  51228. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  51229. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  51230. );
  51231. }
  51232. public function testThrowsOnInvalidLevel()
  51233. {
  51234. $logger = $this->getLogger();
  51235. $logger->log('invalid level', 'Foo');
  51236. }
  51237. public function testContextReplacement()
  51238. {
  51239. $logger = $this->getLogger();
  51240. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  51241. $expected = array('info {Message {nothing} Bob Bar a}');
  51242. $this->assertEquals($expected, $this->getLogs());
  51243. }
  51244. public function testObjectCastToString()
  51245. {
  51246. if (method_exists($this, 'createPartialMock')) {
  51247. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  51248. } else {
  51249. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  51250. }
  51251. $dummy->expects($this->once())
  51252. ->method('__toString')
  51253. ->will($this->returnValue('DUMMY'));
  51254. $this->getLogger()->warning($dummy);
  51255. $expected = array('warning DUMMY');
  51256. $this->assertEquals($expected, $this->getLogs());
  51257. }
  51258. public function testContextCanContainAnything()
  51259. {
  51260. $closed = fopen('php://memory', 'r');
  51261. fclose($closed);
  51262. $context = array(
  51263. 'bool' => true,
  51264. 'null' => null,
  51265. 'string' => 'Foo',
  51266. 'int' => 0,
  51267. 'float' => 0.5,
  51268. 'nested' => array('with object' => new DummyTest),
  51269. 'object' => new \DateTime,
  51270. 'resource' => fopen('php://memory', 'r'),
  51271. 'closed' => $closed,
  51272. );
  51273. $this->getLogger()->warning('Crazy context data', $context);
  51274. $expected = array('warning Crazy context data');
  51275. $this->assertEquals($expected, $this->getLogs());
  51276. }
  51277. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  51278. {
  51279. $logger = $this->getLogger();
  51280. $logger->warning('Random message', array('exception' => 'oops'));
  51281. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  51282. $expected = array(
  51283. 'warning Random message',
  51284. 'critical Uncaught Exception!'
  51285. );
  51286. $this->assertEquals($expected, $this->getLogs());
  51287. }
  51288. }
  51289. class DummyTest
  51290. {
  51291. public function __toString()
  51292. {
  51293. }
  51294. }
  51295. <?php
  51296. namespace Psr\Log\Test;
  51297. use Psr\Log\AbstractLogger;
  51298. class TestLogger extends AbstractLogger
  51299. {
  51300. public $records = [];
  51301. public $recordsByLevel = [];
  51302. public function log($level, $message, array $context = [])
  51303. {
  51304. $record = [
  51305. 'level' => $level,
  51306. 'message' => $message,
  51307. 'context' => $context,
  51308. ];
  51309. $this->recordsByLevel[$record['level']][] = $record;
  51310. $this->records[] = $record;
  51311. }
  51312. public function hasRecords($level)
  51313. {
  51314. return isset($this->recordsByLevel[$level]);
  51315. }
  51316. public function hasRecord($record, $level)
  51317. {
  51318. if (is_string($record)) {
  51319. $record = ['message' => $record];
  51320. }
  51321. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  51322. if ($rec['message'] !== $record['message']) {
  51323. return false;
  51324. }
  51325. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  51326. return false;
  51327. }
  51328. return true;
  51329. }, $level);
  51330. }
  51331. public function hasRecordThatContains($message, $level)
  51332. {
  51333. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  51334. return strpos($rec['message'], $message) !== false;
  51335. }, $level);
  51336. }
  51337. public function hasRecordThatMatches($regex, $level)
  51338. {
  51339. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  51340. return preg_match($regex, $rec['message']) > 0;
  51341. }, $level);
  51342. }
  51343. public function hasRecordThatPasses(callable $predicate, $level)
  51344. {
  51345. if (!isset($this->recordsByLevel[$level])) {
  51346. return false;
  51347. }
  51348. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  51349. if (call_user_func($predicate, $rec, $i)) {
  51350. return true;
  51351. }
  51352. }
  51353. return false;
  51354. }
  51355. public function __call($method, $args)
  51356. {
  51357. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  51358. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  51359. $level = strtolower($matches[2]);
  51360. if (method_exists($this, $genericMethod)) {
  51361. $args[] = $level;
  51362. return call_user_func_array([$this, $genericMethod], $args);
  51363. }
  51364. }
  51365. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  51366. }
  51367. public function reset()
  51368. {
  51369. $this->records = [];
  51370. }
  51371. }
  51372. <?php
  51373. require_once __DIR__ . '/composer/autoload_real.php';
  51374. return ComposerAutoloaderInitComposerPhar1543829476::getLoader();
  51375. <?php
  51376. $vendorDir = dirname(dirname(__FILE__));
  51377. $baseDir = dirname($vendorDir);
  51378. return array(
  51379. );
  51380. <?php
  51381. $vendorDir = dirname(dirname(__FILE__));
  51382. $baseDir = dirname($vendorDir);
  51383. return array(
  51384. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  51385. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  51386. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  51387. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  51388. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  51389. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  51390. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  51391. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  51392. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  51393. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  51394. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  51395. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  51396. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  51397. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  51398. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  51399. 'Composer\\' => array($baseDir . '/src/Composer'),
  51400. );
  51401. <?php
  51402. $vendorDir = dirname(dirname(__FILE__));
  51403. $baseDir = dirname($vendorDir);
  51404. return array(
  51405. );
  51406. <?php
  51407. $vendorDir = dirname(dirname(__FILE__));
  51408. $baseDir = dirname($vendorDir);
  51409. return array(
  51410. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  51411. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  51412. );
  51413. <?php
  51414. class ComposerAutoloaderInitComposerPhar1543829476
  51415. {
  51416. private static $loader;
  51417. public static function loadClassLoader($class)
  51418. {
  51419. if ('Composer\Autoload\ClassLoader' === $class) {
  51420. require __DIR__ . '/ClassLoader.php';
  51421. }
  51422. }
  51423. public static function getLoader()
  51424. {
  51425. if (null !== self::$loader) {
  51426. return self::$loader;
  51427. }
  51428. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1543829476', 'loadClassLoader'), true, true);
  51429. self::$loader = $loader = new \Composer\Autoload\ClassLoader();
  51430. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1543829476', 'loadClassLoader'));
  51431. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  51432. if ($useStaticLoader) {
  51433. require_once __DIR__ . '/autoload_static.php';
  51434. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1543829476::getInitializer($loader));
  51435. } else {
  51436. $map = require __DIR__ . '/autoload_namespaces.php';
  51437. foreach ($map as $namespace => $path) {
  51438. $loader->set($namespace, $path);
  51439. }
  51440. $map = require __DIR__ . '/autoload_psr4.php';
  51441. foreach ($map as $namespace => $path) {
  51442. $loader->setPsr4($namespace, $path);
  51443. }
  51444. $classMap = require __DIR__ . '/autoload_classmap.php';
  51445. if ($classMap) {
  51446. $loader->addClassMap($classMap);
  51447. }
  51448. }
  51449. $loader->register(true);
  51450. if ($useStaticLoader) {
  51451. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1543829476::$files;
  51452. } else {
  51453. $includeFiles = require __DIR__ . '/autoload_files.php';
  51454. }
  51455. foreach ($includeFiles as $fileIdentifier => $file) {
  51456. composerRequireComposerPhar1543829476($fileIdentifier, $file);
  51457. }
  51458. return $loader;
  51459. }
  51460. }
  51461. function composerRequireComposerPhar1543829476($fileIdentifier, $file)
  51462. {
  51463. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  51464. require $file;
  51465. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  51466. }
  51467. }
  51468. <?php
  51469. namespace Composer\Autoload;
  51470. class ComposerStaticInitComposerPhar1543829476
  51471. {
  51472. public static $files = array (
  51473. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  51474. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  51475. );
  51476. public static $prefixLengthsPsr4 = array (
  51477. 'S' =>
  51478. array (
  51479. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  51480. 'Symfony\\Polyfill\\Ctype\\' => 23,
  51481. 'Symfony\\Component\\Process\\' => 26,
  51482. 'Symfony\\Component\\Finder\\' => 25,
  51483. 'Symfony\\Component\\Filesystem\\' => 29,
  51484. 'Symfony\\Component\\Debug\\' => 24,
  51485. 'Symfony\\Component\\Console\\' => 26,
  51486. 'Seld\\PharUtils\\' => 15,
  51487. 'Seld\\JsonLint\\' => 14,
  51488. ),
  51489. 'P' =>
  51490. array (
  51491. 'Psr\\Log\\' => 8,
  51492. ),
  51493. 'J' =>
  51494. array (
  51495. 'JsonSchema\\' => 11,
  51496. ),
  51497. 'C' =>
  51498. array (
  51499. 'Composer\\XdebugHandler\\' => 23,
  51500. 'Composer\\Spdx\\' => 14,
  51501. 'Composer\\Semver\\' => 16,
  51502. 'Composer\\CaBundle\\' => 18,
  51503. 'Composer\\' => 9,
  51504. ),
  51505. );
  51506. public static $prefixDirsPsr4 = array (
  51507. 'Symfony\\Polyfill\\Mbstring\\' =>
  51508. array (
  51509. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  51510. ),
  51511. 'Symfony\\Polyfill\\Ctype\\' =>
  51512. array (
  51513. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  51514. ),
  51515. 'Symfony\\Component\\Process\\' =>
  51516. array (
  51517. 0 => __DIR__ . '/..' . '/symfony/process',
  51518. ),
  51519. 'Symfony\\Component\\Finder\\' =>
  51520. array (
  51521. 0 => __DIR__ . '/..' . '/symfony/finder',
  51522. ),
  51523. 'Symfony\\Component\\Filesystem\\' =>
  51524. array (
  51525. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  51526. ),
  51527. 'Symfony\\Component\\Debug\\' =>
  51528. array (
  51529. 0 => __DIR__ . '/..' . '/symfony/debug',
  51530. ),
  51531. 'Symfony\\Component\\Console\\' =>
  51532. array (
  51533. 0 => __DIR__ . '/..' . '/symfony/console',
  51534. ),
  51535. 'Seld\\PharUtils\\' =>
  51536. array (
  51537. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  51538. ),
  51539. 'Seld\\JsonLint\\' =>
  51540. array (
  51541. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  51542. ),
  51543. 'Psr\\Log\\' =>
  51544. array (
  51545. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  51546. ),
  51547. 'JsonSchema\\' =>
  51548. array (
  51549. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  51550. ),
  51551. 'Composer\\XdebugHandler\\' =>
  51552. array (
  51553. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  51554. ),
  51555. 'Composer\\Spdx\\' =>
  51556. array (
  51557. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  51558. ),
  51559. 'Composer\\Semver\\' =>
  51560. array (
  51561. 0 => __DIR__ . '/..' . '/composer/semver/src',
  51562. ),
  51563. 'Composer\\CaBundle\\' =>
  51564. array (
  51565. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  51566. ),
  51567. 'Composer\\' =>
  51568. array (
  51569. 0 => __DIR__ . '/../..' . '/src/Composer',
  51570. ),
  51571. );
  51572. public static function getInitializer(ClassLoader $loader)
  51573. {
  51574. return \Closure::bind(function () use ($loader) {
  51575. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1543829476::$prefixLengthsPsr4;
  51576. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1543829476::$prefixDirsPsr4;
  51577. }, null, ClassLoader::class);
  51578. }
  51579. }
  51580. <?php
  51581. namespace Composer\Autoload;
  51582. class ClassLoader
  51583. {
  51584. private $prefixLengthsPsr4 = array();
  51585. private $prefixDirsPsr4 = array();
  51586. private $fallbackDirsPsr4 = array();
  51587. private $prefixesPsr0 = array();
  51588. private $fallbackDirsPsr0 = array();
  51589. private $useIncludePath = false;
  51590. private $classMap = array();
  51591. private $classMapAuthoritative = false;
  51592. private $missingClasses = array();
  51593. private $apcuPrefix;
  51594. public function getPrefixes()
  51595. {
  51596. if (!empty($this->prefixesPsr0)) {
  51597. return call_user_func_array('array_merge', $this->prefixesPsr0);
  51598. }
  51599. return array();
  51600. }
  51601. public function getPrefixesPsr4()
  51602. {
  51603. return $this->prefixDirsPsr4;
  51604. }
  51605. public function getFallbackDirs()
  51606. {
  51607. return $this->fallbackDirsPsr0;
  51608. }
  51609. public function getFallbackDirsPsr4()
  51610. {
  51611. return $this->fallbackDirsPsr4;
  51612. }
  51613. public function getClassMap()
  51614. {
  51615. return $this->classMap;
  51616. }
  51617. public function addClassMap(array $classMap)
  51618. {
  51619. if ($this->classMap) {
  51620. $this->classMap = array_merge($this->classMap, $classMap);
  51621. } else {
  51622. $this->classMap = $classMap;
  51623. }
  51624. }
  51625. public function add($prefix, $paths, $prepend = false)
  51626. {
  51627. if (!$prefix) {
  51628. if ($prepend) {
  51629. $this->fallbackDirsPsr0 = array_merge(
  51630. (array) $paths,
  51631. $this->fallbackDirsPsr0
  51632. );
  51633. } else {
  51634. $this->fallbackDirsPsr0 = array_merge(
  51635. $this->fallbackDirsPsr0,
  51636. (array) $paths
  51637. );
  51638. }
  51639. return;
  51640. }
  51641. $first = $prefix[0];
  51642. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  51643. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  51644. return;
  51645. }
  51646. if ($prepend) {
  51647. $this->prefixesPsr0[$first][$prefix] = array_merge(
  51648. (array) $paths,
  51649. $this->prefixesPsr0[$first][$prefix]
  51650. );
  51651. } else {
  51652. $this->prefixesPsr0[$first][$prefix] = array_merge(
  51653. $this->prefixesPsr0[$first][$prefix],
  51654. (array) $paths
  51655. );
  51656. }
  51657. }
  51658. public function addPsr4($prefix, $paths, $prepend = false)
  51659. {
  51660. if (!$prefix) {
  51661. if ($prepend) {
  51662. $this->fallbackDirsPsr4 = array_merge(
  51663. (array) $paths,
  51664. $this->fallbackDirsPsr4
  51665. );
  51666. } else {
  51667. $this->fallbackDirsPsr4 = array_merge(
  51668. $this->fallbackDirsPsr4,
  51669. (array) $paths
  51670. );
  51671. }
  51672. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  51673. $length = strlen($prefix);
  51674. if ('\\' !== $prefix[$length - 1]) {
  51675. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  51676. }
  51677. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  51678. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  51679. } elseif ($prepend) {
  51680. $this->prefixDirsPsr4[$prefix] = array_merge(
  51681. (array) $paths,
  51682. $this->prefixDirsPsr4[$prefix]
  51683. );
  51684. } else {
  51685. $this->prefixDirsPsr4[$prefix] = array_merge(
  51686. $this->prefixDirsPsr4[$prefix],
  51687. (array) $paths
  51688. );
  51689. }
  51690. }
  51691. public function set($prefix, $paths)
  51692. {
  51693. if (!$prefix) {
  51694. $this->fallbackDirsPsr0 = (array) $paths;
  51695. } else {
  51696. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  51697. }
  51698. }
  51699. public function setPsr4($prefix, $paths)
  51700. {
  51701. if (!$prefix) {
  51702. $this->fallbackDirsPsr4 = (array) $paths;
  51703. } else {
  51704. $length = strlen($prefix);
  51705. if ('\\' !== $prefix[$length - 1]) {
  51706. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  51707. }
  51708. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  51709. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  51710. }
  51711. }
  51712. public function setUseIncludePath($useIncludePath)
  51713. {
  51714. $this->useIncludePath = $useIncludePath;
  51715. }
  51716. public function getUseIncludePath()
  51717. {
  51718. return $this->useIncludePath;
  51719. }
  51720. public function setClassMapAuthoritative($classMapAuthoritative)
  51721. {
  51722. $this->classMapAuthoritative = $classMapAuthoritative;
  51723. }
  51724. public function isClassMapAuthoritative()
  51725. {
  51726. return $this->classMapAuthoritative;
  51727. }
  51728. public function setApcuPrefix($apcuPrefix)
  51729. {
  51730. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  51731. }
  51732. public function getApcuPrefix()
  51733. {
  51734. return $this->apcuPrefix;
  51735. }
  51736. public function register($prepend = false)
  51737. {
  51738. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  51739. }
  51740. public function unregister()
  51741. {
  51742. spl_autoload_unregister(array($this, 'loadClass'));
  51743. }
  51744. public function loadClass($class)
  51745. {
  51746. if ($file = $this->findFile($class)) {
  51747. includeFile($file);
  51748. return true;
  51749. }
  51750. }
  51751. public function findFile($class)
  51752. {
  51753. if (isset($this->classMap[$class])) {
  51754. return $this->classMap[$class];
  51755. }
  51756. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  51757. return false;
  51758. }
  51759. if (null !== $this->apcuPrefix) {
  51760. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  51761. if ($hit) {
  51762. return $file;
  51763. }
  51764. }
  51765. $file = $this->findFileWithExtension($class, '.php');
  51766. if (false === $file && defined('HHVM_VERSION')) {
  51767. $file = $this->findFileWithExtension($class, '.hh');
  51768. }
  51769. if (null !== $this->apcuPrefix) {
  51770. apcu_add($this->apcuPrefix.$class, $file);
  51771. }
  51772. if (false === $file) {
  51773. $this->missingClasses[$class] = true;
  51774. }
  51775. return $file;
  51776. }
  51777. private function findFileWithExtension($class, $ext)
  51778. {
  51779. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  51780. $first = $class[0];
  51781. if (isset($this->prefixLengthsPsr4[$first])) {
  51782. $subPath = $class;
  51783. while (false !== $lastPos = strrpos($subPath, '\\')) {
  51784. $subPath = substr($subPath, 0, $lastPos);
  51785. $search = $subPath . '\\';
  51786. if (isset($this->prefixDirsPsr4[$search])) {
  51787. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  51788. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  51789. if (file_exists($file = $dir . $pathEnd)) {
  51790. return $file;
  51791. }
  51792. }
  51793. }
  51794. }
  51795. }
  51796. foreach ($this->fallbackDirsPsr4 as $dir) {
  51797. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  51798. return $file;
  51799. }
  51800. }
  51801. if (false !== $pos = strrpos($class, '\\')) {
  51802. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  51803. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  51804. } else {
  51805. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  51806. }
  51807. if (isset($this->prefixesPsr0[$first])) {
  51808. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  51809. if (0 === strpos($class, $prefix)) {
  51810. foreach ($dirs as $dir) {
  51811. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  51812. return $file;
  51813. }
  51814. }
  51815. }
  51816. }
  51817. }
  51818. foreach ($this->fallbackDirsPsr0 as $dir) {
  51819. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  51820. return $file;
  51821. }
  51822. }
  51823. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  51824. return $file;
  51825. }
  51826. return false;
  51827. }
  51828. }
  51829. function includeFile($file)
  51830. {
  51831. include $file;
  51832. }
  51833. ##
  51834. ## Bundle of CA Root Certificates
  51835. ##
  51836. ## Certificate data from Mozilla as of: Wed Oct 17 03:12:10 2018 GMT
  51837. ##
  51838. ## This is a bundle of X.509 certificates of public Certificate Authorities
  51839. ## (CA). These were automatically extracted from Mozilla's root certificates
  51840. ## file (certdata.txt). This file can be found in the mozilla source tree:
  51841. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  51842. ##
  51843. ## It contains the certificates in PEM format and therefore
  51844. ## can be directly used with curl / libcurl / php_curl, or with
  51845. ## an Apache+mod_ssl webserver for SSL client authentication.
  51846. ## Just configure this file as the SSLCACertificateFile.
  51847. ##
  51848. ## Conversion done with mk-ca-bundle.pl version 1.27.
  51849. ## SHA256: 3f875d87fee4ce3d966c69f1d6c111aa95c0143ade59e4fa24882c582bb5f0ca
  51850. ##
  51851. GlobalSign Root CA
  51852. ==================
  51853. -----BEGIN CERTIFICATE-----
  51854. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  51855. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  51856. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  51857. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  51858. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  51859. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  51860. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  51861. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  51862. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  51863. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  51864. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  51865. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  51866. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  51867. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  51868. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  51869. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  51870. -----END CERTIFICATE-----
  51871. GlobalSign Root CA - R2
  51872. =======================
  51873. -----BEGIN CERTIFICATE-----
  51874. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  51875. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  51876. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  51877. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  51878. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  51879. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  51880. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  51881. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  51882. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  51883. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  51884. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  51885. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  51886. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  51887. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  51888. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  51889. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  51890. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  51891. -----END CERTIFICATE-----
  51892. Verisign Class 3 Public Primary Certification Authority - G3
  51893. ============================================================
  51894. -----BEGIN CERTIFICATE-----
  51895. MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQswCQYDVQQGEwJV
  51896. UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
  51897. cmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
  51898. IG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNh
  51899. dGlvbiBBdXRob3JpdHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQsw
  51900. CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRy
  51901. dXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhv
  51902. cml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWduIENsYXNzIDMgUHVibGljIFByaW1hcnkg
  51903. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  51904. ggEBAMu6nFL8eB8aHm8bN3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1
  51905. EUGO+i2tKmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGukxUc
  51906. cLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBmCC+Vk7+qRy+oRpfw
  51907. EuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJXwzw3sJ2zq/3avL6QaaiMxTJ5Xpj
  51908. 055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWuimi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA
  51909. ERSWwauSCPc/L8my/uRan2Te2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5f
  51910. j267Cz3qWhMeDGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC
  51911. /Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565pF4ErWjfJXir0
  51912. xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGtTxzhT5yvDwyd93gN2PQ1VoDa
  51913. t20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ==
  51914. -----END CERTIFICATE-----
  51915. Entrust.net Premium 2048 Secure Server CA
  51916. =========================================
  51917. -----BEGIN CERTIFICATE-----
  51918. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  51919. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  51920. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  51921. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  51922. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  51923. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  51924. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  51925. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  51926. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  51927. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  51928. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  51929. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  51930. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  51931. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  51932. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  51933. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  51934. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  51935. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  51936. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  51937. -----END CERTIFICATE-----
  51938. Baltimore CyberTrust Root
  51939. =========================
  51940. -----BEGIN CERTIFICATE-----
  51941. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  51942. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  51943. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  51944. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  51945. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  51946. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  51947. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  51948. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  51949. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  51950. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  51951. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  51952. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  51953. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  51954. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  51955. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  51956. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  51957. -----END CERTIFICATE-----
  51958. AddTrust External Root
  51959. ======================
  51960. -----BEGIN CERTIFICATE-----
  51961. MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEUMBIGA1UEChML
  51962. QWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYD
  51963. VQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEw
  51964. NDgzOFowbzELMAkGA1UEBhMCU0UxFDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRU
  51965. cnVzdCBFeHRlcm5hbCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0Eg
  51966. Um9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvtH7xsD821
  51967. +iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9uMq/NzgtHj6RQa1wVsfw
  51968. Tz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzXmk6vBbOmcZSccbNQYArHE504B4YCqOmo
  51969. aSYYkKtMsE8jqzpPhNjfzp/haW+710LXa0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy
  51970. 2xSoRcRdKn23tNbE7qzNE0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv7
  51971. 7+ldU9U0WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYDVR0P
  51972. BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0Jvf6xCZU7wO94CTL
  51973. VBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRk
  51974. VHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB
  51975. IFJvb3SCAQEwDQYJKoZIhvcNAQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZl
  51976. j7DYd7usQWxHYINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5
  51977. 6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvCNr4TDea9Y355
  51978. e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEXc4g/VhsxOBi0cQ+azcgOno4u
  51979. G+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5amnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ=
  51980. -----END CERTIFICATE-----
  51981. Entrust Root Certification Authority
  51982. ====================================
  51983. -----BEGIN CERTIFICATE-----
  51984. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  51985. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  51986. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  51987. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  51988. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  51989. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  51990. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  51991. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  51992. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  51993. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  51994. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  51995. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  51996. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  51997. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  51998. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  51999. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  52000. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  52001. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  52002. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  52003. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  52004. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  52005. -----END CERTIFICATE-----
  52006. GeoTrust Global CA
  52007. ==================
  52008. -----BEGIN CERTIFICATE-----
  52009. MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK
  52010. Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw
  52011. MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j
  52012. LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  52013. CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo
  52014. BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet
  52015. 8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc
  52016. T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU
  52017. vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD
  52018. AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk
  52019. DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q
  52020. zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4
  52021. d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2
  52022. mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p
  52023. XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm
  52024. Mw==
  52025. -----END CERTIFICATE-----
  52026. GeoTrust Universal CA
  52027. =====================
  52028. -----BEGIN CERTIFICATE-----
  52029. MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  52030. R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1
  52031. MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu
  52032. Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  52033. ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t
  52034. JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e
  52035. RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs
  52036. 7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d
  52037. 8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V
  52038. qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga
  52039. Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB
  52040. Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu
  52041. KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08
  52042. ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0
  52043. XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB
  52044. hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
  52045. aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2
  52046. qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL
  52047. oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK
  52048. xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF
  52049. KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2
  52050. DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK
  52051. xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU
  52052. p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI
  52053. P/rmMuGNG2+k5o7Y+SlIis5z/iw=
  52054. -----END CERTIFICATE-----
  52055. GeoTrust Universal CA 2
  52056. =======================
  52057. -----BEGIN CERTIFICATE-----
  52058. MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  52059. R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0
  52060. MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg
  52061. SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA
  52062. A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0
  52063. DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17
  52064. j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q
  52065. JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a
  52066. QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2
  52067. WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP
  52068. 20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn
  52069. ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC
  52070. SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG
  52071. 8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2
  52072. +/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E
  52073. BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z
  52074. dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ
  52075. 4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+
  52076. mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq
  52077. A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg
  52078. Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP
  52079. pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d
  52080. FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp
  52081. gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm
  52082. X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS
  52083. -----END CERTIFICATE-----
  52084. Visa eCommerce Root
  52085. ===================
  52086. -----BEGIN CERTIFICATE-----
  52087. MIIDojCCAoqgAwIBAgIQE4Y1TR0/BvLB+WUF1ZAcYjANBgkqhkiG9w0BAQUFADBrMQswCQYDVQQG
  52088. EwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMmVmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2Ug
  52089. QXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNvbW1lcmNlIFJvb3QwHhcNMDIwNjI2MDIxODM2
  52090. WhcNMjIwNjI0MDAxNjEyWjBrMQswCQYDVQQGEwJVUzENMAsGA1UEChMEVklTQTEvMC0GA1UECxMm
  52091. VmlzYSBJbnRlcm5hdGlvbmFsIFNlcnZpY2UgQXNzb2NpYXRpb24xHDAaBgNVBAMTE1Zpc2EgZUNv
  52092. bW1lcmNlIFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvV95WHm6h2mCxlCfL
  52093. F9sHP4CFT8icttD0b0/Pmdjh28JIXDqsOTPHH2qLJj0rNfVIsZHBAk4ElpF7sDPwsRROEW+1QK8b
  52094. RaVK7362rPKgH1g/EkZgPI2h4H3PVz4zHvtH8aoVlwdVZqW1LS7YgFmypw23RuwhY/81q6UCzyr0
  52095. TP579ZRdhE2o8mCP2w4lPJ9zcc+U30rq299yOIzzlr3xF7zSujtFWsan9sYXiwGd/BmoKoMWuDpI
  52096. /k4+oKsGGelT84ATB+0tvz8KPFUgOSwsAGl0lUq8ILKpeeUYiZGo3BxN77t+Nwtd/jmliFKMAGzs
  52097. GHxBvfaLdXe6YJ2E5/4tAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEG
  52098. MB0GA1UdDgQWBBQVOIMPPyw/cDMezUb+B4wg4NfDtzANBgkqhkiG9w0BAQUFAAOCAQEAX/FBfXxc
  52099. CLkr4NWSR/pnXKUTwwMhmytMiUbPWU3J/qVAtmPN3XEolWcRzCSs00Rsca4BIGsDoo8Ytyk6feUW
  52100. YFN4PMCvFYP3j1IzJL1kk5fui/fbGKhtcbP3LBfQdCVp9/5rPJS+TUtBjE7ic9DjkCJzQ83z7+pz
  52101. zkWKsKZJ/0x9nXGIxHYdkFsd7v3M9+79YKWxehZx0RbQfBI8bGmX265fOZpwLwU8GUYEmSA20GBu
  52102. YQa7FkKMcPcw++DbZqMAAb3mLNqRX6BGi01qnD093QVG/na/oAo85ADmJ7f/hC3euiInlhBx6yLt
  52103. 398znM/jra6O1I7mT1GvFpLgXPYHDw==
  52104. -----END CERTIFICATE-----
  52105. Comodo AAA Services root
  52106. ========================
  52107. -----BEGIN CERTIFICATE-----
  52108. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  52109. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  52110. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  52111. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  52112. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  52113. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  52114. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  52115. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  52116. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  52117. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  52118. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  52119. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  52120. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  52121. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  52122. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  52123. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  52124. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  52125. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  52126. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  52127. -----END CERTIFICATE-----
  52128. QuoVadis Root CA
  52129. ================
  52130. -----BEGIN CERTIFICATE-----
  52131. MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE
  52132. ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
  52133. eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz
  52134. MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp
  52135. cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD
  52136. EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF
  52137. AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk
  52138. J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL
  52139. F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL
  52140. YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen
  52141. AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w
  52142. PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y
  52143. ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7
  52144. MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj
  52145. YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs
  52146. ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh
  52147. Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW
  52148. Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu
  52149. BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw
  52150. FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0
  52151. aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6
  52152. tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo
  52153. fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul
  52154. LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x
  52155. gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi
  52156. 5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi
  52157. 5nrQNiOKSnQ2+Q==
  52158. -----END CERTIFICATE-----
  52159. QuoVadis Root CA 2
  52160. ==================
  52161. -----BEGIN CERTIFICATE-----
  52162. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  52163. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  52164. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  52165. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  52166. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  52167. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  52168. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  52169. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  52170. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  52171. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  52172. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  52173. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  52174. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  52175. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  52176. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  52177. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  52178. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  52179. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  52180. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  52181. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  52182. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  52183. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  52184. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  52185. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  52186. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  52187. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  52188. -----END CERTIFICATE-----
  52189. QuoVadis Root CA 3
  52190. ==================
  52191. -----BEGIN CERTIFICATE-----
  52192. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  52193. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  52194. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  52195. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  52196. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  52197. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  52198. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  52199. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  52200. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  52201. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  52202. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  52203. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  52204. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  52205. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  52206. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  52207. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  52208. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  52209. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  52210. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  52211. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  52212. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  52213. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  52214. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  52215. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  52216. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  52217. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  52218. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  52219. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  52220. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  52221. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  52222. -----END CERTIFICATE-----
  52223. Security Communication Root CA
  52224. ==============================
  52225. -----BEGIN CERTIFICATE-----
  52226. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  52227. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  52228. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  52229. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  52230. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  52231. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  52232. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  52233. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  52234. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  52235. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  52236. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  52237. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  52238. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  52239. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  52240. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  52241. FL39vmwLAw==
  52242. -----END CERTIFICATE-----
  52243. Sonera Class 2 Root CA
  52244. ======================
  52245. -----BEGIN CERTIFICATE-----
  52246. MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG
  52247. U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw
  52248. NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh
  52249. IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3
  52250. /Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT
  52251. dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG
  52252. f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P
  52253. tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH
  52254. nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT
  52255. XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt
  52256. 0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI
  52257. cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph
  52258. Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx
  52259. EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH
  52260. llpwrN9M
  52261. -----END CERTIFICATE-----
  52262. XRamp Global CA Root
  52263. ====================
  52264. -----BEGIN CERTIFICATE-----
  52265. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  52266. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  52267. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  52268. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  52269. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  52270. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  52271. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  52272. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  52273. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  52274. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  52275. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  52276. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  52277. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  52278. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  52279. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  52280. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  52281. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  52282. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  52283. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  52284. -----END CERTIFICATE-----
  52285. Go Daddy Class 2 CA
  52286. ===================
  52287. -----BEGIN CERTIFICATE-----
  52288. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  52289. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  52290. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  52291. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  52292. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  52293. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  52294. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  52295. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  52296. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  52297. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  52298. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  52299. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  52300. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  52301. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  52302. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  52303. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  52304. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  52305. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  52306. vZ8=
  52307. -----END CERTIFICATE-----
  52308. Starfield Class 2 CA
  52309. ====================
  52310. -----BEGIN CERTIFICATE-----
  52311. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  52312. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  52313. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  52314. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  52315. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  52316. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  52317. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  52318. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  52319. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  52320. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  52321. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  52322. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  52323. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  52324. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  52325. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  52326. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  52327. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  52328. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  52329. QBFGmh95DmK/D5fs4C8fF5Q=
  52330. -----END CERTIFICATE-----
  52331. Taiwan GRCA
  52332. ===========
  52333. -----BEGIN CERTIFICATE-----
  52334. MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQG
  52335. EwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4X
  52336. DTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1owPzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dv
  52337. dmVybm1lbnQgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQAD
  52338. ggIPADCCAgoCggIBAJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qN
  52339. w8XRIePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1qgQdW8or5
  52340. BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKyyhwOeYHWtXBiCAEuTk8O
  52341. 1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAtsF/tnyMKtsc2AtJfcdgEWFelq16TheEfO
  52342. htX7MfP6Mb40qij7cEwdScevLJ1tZqa2jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wov
  52343. J5pGfaENda1UhhXcSTvxls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7
  52344. Q3hub/FCVGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHKYS1t
  52345. B6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoHEgKXTiCQ8P8NHuJB
  52346. O9NAOueNXdpm5AKwB1KYXA6OM5zCppX7VRluTI6uSw+9wThNXo+EHWbNxWCWtFJaBYmOlXqYwZE8
  52347. lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1UdDgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNV
  52348. HRMEBTADAQH/MDkGBGcqBwAEMTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg2
  52349. 09yewDL7MTqKUWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ
  52350. TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyfqzvS/3WXy6Tj
  52351. Zwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaKZEk9GhiHkASfQlK3T8v+R0F2
  52352. Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFEJPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlU
  52353. D7gsL0u8qV1bYH+Mh6XgUmMqvtg7hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6Qz
  52354. DxARvBMB1uUO07+1EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+Hbk
  52355. Z6MmnD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WXudpVBrkk
  52356. 7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44VbnzssQwmSNOXfJIoRIM3BKQ
  52357. CZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDeLMDDav7v3Aun+kbfYNucpllQdSNpc5Oy
  52358. +fwC00fmcc4QAu4njIT/rEUNE1yDMuAlpYYsfPQS
  52359. -----END CERTIFICATE-----
  52360. DigiCert Assured ID Root CA
  52361. ===========================
  52362. -----BEGIN CERTIFICATE-----
  52363. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  52364. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  52365. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  52366. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  52367. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  52368. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  52369. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  52370. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  52371. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  52372. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  52373. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  52374. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  52375. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  52376. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  52377. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  52378. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  52379. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  52380. -----END CERTIFICATE-----
  52381. DigiCert Global Root CA
  52382. =======================
  52383. -----BEGIN CERTIFICATE-----
  52384. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  52385. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  52386. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  52387. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  52388. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  52389. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  52390. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  52391. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  52392. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  52393. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  52394. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  52395. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  52396. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  52397. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  52398. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  52399. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  52400. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  52401. -----END CERTIFICATE-----
  52402. DigiCert High Assurance EV Root CA
  52403. ==================================
  52404. -----BEGIN CERTIFICATE-----
  52405. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  52406. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  52407. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  52408. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  52409. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  52410. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  52411. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  52412. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  52413. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  52414. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  52415. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  52416. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  52417. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  52418. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  52419. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  52420. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  52421. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  52422. -----END CERTIFICATE-----
  52423. Certplus Class 2 Primary CA
  52424. ===========================
  52425. -----BEGIN CERTIFICATE-----
  52426. MIIDkjCCAnqgAwIBAgIRAIW9S/PY2uNp9pTXX8OlRCMwDQYJKoZIhvcNAQEFBQAwPTELMAkGA1UE
  52427. BhMCRlIxETAPBgNVBAoTCENlcnRwbHVzMRswGQYDVQQDExJDbGFzcyAyIFByaW1hcnkgQ0EwHhcN
  52428. OTkwNzA3MTcwNTAwWhcNMTkwNzA2MjM1OTU5WjA9MQswCQYDVQQGEwJGUjERMA8GA1UEChMIQ2Vy
  52429. dHBsdXMxGzAZBgNVBAMTEkNsYXNzIDIgUHJpbWFyeSBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEP
  52430. ADCCAQoCggEBANxQltAS+DXSCHh6tlJw/W/uz7kRy1134ezpfgSN1sxvc0NXYKwzCkTsA18cgCSR
  52431. 5aiRVhKC9+Ar9NuuYS6JEI1rbLqzAr3VNsVINyPi8Fo3UjMXEuLRYE2+L0ER4/YXJQyLkcAbmXuZ
  52432. Vg2v7tK8R1fjeUl7NIknJITesezpWE7+Tt9avkGtrAjFGA7v0lPubNCdEgETjdyAYveVqUSISnFO
  52433. YFWe2yMZeVYHDD9jC1yw4r5+FfyUM1hBOHTE4Y+L3yasH7WLO7dDWWuwJKZtkIvEcupdM5i3y95e
  52434. e++U8Rs+yskhwcWYAqqi9lt3m/V+llU0HGdpwPFC40es/CgcZlUCAwEAAaOBjDCBiTAPBgNVHRME
  52435. CDAGAQH/AgEKMAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQU43Mt38sOKAze3bOkynm4jrvoMIkwEQYJ
  52436. YIZIAYb4QgEBBAQDAgEGMDcGA1UdHwQwMC4wLKAqoCiGJmh0dHA6Ly93d3cuY2VydHBsdXMuY29t
  52437. L0NSTC9jbGFzczIuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQCnVM+IRBnL39R/AN9WM2K191EBkOvD
  52438. P9GIROkkXe/nFL0gt5o8AP5tn9uQ3Nf0YtaLcF3n5QRIqWh8yfFC82x/xXp8HVGIutIKPidd3i1R
  52439. TtMTZGnkLuPT55sJmabglZvOGtd/vjzOUrMRFcEPF80Du5wlFbqidon8BvEY0JNLDnyCt6X09l/+
  52440. 7UCmnYR0ObncHoUW2ikbhiMAybuJfm6AiB4vFLQDJKgybwOaRywwvlbGp0ICcBvqQNi6BQNwB6SW
  52441. //1IMwrh3KWBkJtN3X3n57LNXMhqlfil9o3EXXgIvnsG1knPGTZQIy4I5p4FTUcY1Rbpsda2ENW7
  52442. l7+ijrRU
  52443. -----END CERTIFICATE-----
  52444. DST Root CA X3
  52445. ==============
  52446. -----BEGIN CERTIFICATE-----
  52447. MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK
  52448. ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X
  52449. DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1
  52450. cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD
  52451. ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT
  52452. rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9
  52453. UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy
  52454. xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d
  52455. utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T
  52456. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ
  52457. MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug
  52458. dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE
  52459. GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw
  52460. RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS
  52461. fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
  52462. -----END CERTIFICATE-----
  52463. SwissSign Gold CA - G2
  52464. ======================
  52465. -----BEGIN CERTIFICATE-----
  52466. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  52467. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  52468. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  52469. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  52470. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  52471. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  52472. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  52473. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  52474. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  52475. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  52476. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  52477. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  52478. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  52479. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  52480. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  52481. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  52482. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  52483. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  52484. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  52485. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  52486. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  52487. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  52488. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  52489. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  52490. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  52491. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  52492. -----END CERTIFICATE-----
  52493. SwissSign Silver CA - G2
  52494. ========================
  52495. -----BEGIN CERTIFICATE-----
  52496. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  52497. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  52498. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  52499. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  52500. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  52501. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  52502. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  52503. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  52504. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  52505. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  52506. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  52507. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  52508. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  52509. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  52510. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  52511. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  52512. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  52513. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  52514. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  52515. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  52516. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  52517. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  52518. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  52519. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  52520. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  52521. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  52522. -----END CERTIFICATE-----
  52523. GeoTrust Primary Certification Authority
  52524. ========================================
  52525. -----BEGIN CERTIFICATE-----
  52526. MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG
  52527. EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD
  52528. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx
  52529. CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ
  52530. cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  52531. CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN
  52532. b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9
  52533. nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge
  52534. RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt
  52535. tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  52536. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI
  52537. hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K
  52538. Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN
  52539. NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa
  52540. Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG
  52541. 1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=
  52542. -----END CERTIFICATE-----
  52543. thawte Primary Root CA
  52544. ======================
  52545. -----BEGIN CERTIFICATE-----
  52546. MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE
  52547. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  52548. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  52549. cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3
  52550. MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg
  52551. SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv
  52552. KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT
  52553. FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs
  52554. oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ
  52555. 1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc
  52556. q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K
  52557. aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p
  52558. afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD
  52559. VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF
  52560. AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE
  52561. uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX
  52562. xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89
  52563. jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH
  52564. z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA==
  52565. -----END CERTIFICATE-----
  52566. VeriSign Class 3 Public Primary Certification Authority - G5
  52567. ============================================================
  52568. -----BEGIN CERTIFICATE-----
  52569. MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
  52570. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  52571. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  52572. IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
  52573. ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
  52574. yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
  52575. biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
  52576. dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
  52577. YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  52578. ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
  52579. j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
  52580. Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
  52581. Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
  52582. fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
  52583. BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
  52584. Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
  52585. aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
  52586. SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
  52587. X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
  52588. KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
  52589. Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
  52590. ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
  52591. -----END CERTIFICATE-----
  52592. SecureTrust CA
  52593. ==============
  52594. -----BEGIN CERTIFICATE-----
  52595. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  52596. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  52597. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  52598. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  52599. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  52600. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  52601. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  52602. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  52603. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  52604. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  52605. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  52606. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  52607. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  52608. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  52609. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  52610. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  52611. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  52612. -----END CERTIFICATE-----
  52613. Secure Global CA
  52614. ================
  52615. -----BEGIN CERTIFICATE-----
  52616. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  52617. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  52618. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  52619. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  52620. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  52621. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  52622. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  52623. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  52624. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  52625. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  52626. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  52627. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  52628. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  52629. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  52630. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  52631. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  52632. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  52633. -----END CERTIFICATE-----
  52634. COMODO Certification Authority
  52635. ==============================
  52636. -----BEGIN CERTIFICATE-----
  52637. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  52638. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  52639. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  52640. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  52641. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  52642. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  52643. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  52644. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  52645. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  52646. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  52647. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  52648. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  52649. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  52650. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  52651. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  52652. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  52653. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  52654. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  52655. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  52656. -----END CERTIFICATE-----
  52657. Network Solutions Certificate Authority
  52658. =======================================
  52659. -----BEGIN CERTIFICATE-----
  52660. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  52661. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  52662. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  52663. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  52664. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  52665. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  52666. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  52667. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  52668. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  52669. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  52670. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  52671. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  52672. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  52673. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  52674. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  52675. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  52676. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  52677. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  52678. -----END CERTIFICATE-----
  52679. COMODO ECC Certification Authority
  52680. ==================================
  52681. -----BEGIN CERTIFICATE-----
  52682. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  52683. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  52684. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  52685. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  52686. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  52687. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  52688. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  52689. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  52690. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  52691. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  52692. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  52693. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  52694. -----END CERTIFICATE-----
  52695. OISTE WISeKey Global Root GA CA
  52696. ===============================
  52697. -----BEGIN CERTIFICATE-----
  52698. MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCBijELMAkGA1UE
  52699. BhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHlyaWdodCAoYykgMjAwNTEiMCAG
  52700. A1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBH
  52701. bG9iYWwgUm9vdCBHQSBDQTAeFw0wNTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYD
  52702. VQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIw
  52703. IAYDVQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5
  52704. IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0+zAJs9
  52705. Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxRVVuuk+g3/ytr6dTqvirdqFEr12bDYVxg
  52706. Asj1znJ7O7jyTmUIms2kahnBAbtzptf2w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbD
  52707. d50kc3vkDIzh2TbhmYsFmQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ
  52708. /yxViJGg4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t94B3R
  52709. LoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw
  52710. AwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  52711. KoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOxSPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vIm
  52712. MMkQyh2I+3QZH4VFvbBsUfk2ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4
  52713. +vg1YFkCExh8vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa
  52714. hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZiFj4A4xylNoEY
  52715. okxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ/L7fCg0=
  52716. -----END CERTIFICATE-----
  52717. Certigna
  52718. ========
  52719. -----BEGIN CERTIFICATE-----
  52720. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  52721. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  52722. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  52723. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  52724. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  52725. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  52726. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  52727. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  52728. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  52729. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  52730. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  52731. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  52732. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  52733. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  52734. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  52735. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  52736. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  52737. -----END CERTIFICATE-----
  52738. Deutsche Telekom Root CA 2
  52739. ==========================
  52740. -----BEGIN CERTIFICATE-----
  52741. MIIDnzCCAoegAwIBAgIBJjANBgkqhkiG9w0BAQUFADBxMQswCQYDVQQGEwJERTEcMBoGA1UEChMT
  52742. RGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0GA1UECxMWVC1UZWxlU2VjIFRydXN0IENlbnRlcjEjMCEG
  52743. A1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBSb290IENBIDIwHhcNOTkwNzA5MTIxMTAwWhcNMTkwNzA5
  52744. MjM1OTAwWjBxMQswCQYDVQQGEwJERTEcMBoGA1UEChMTRGV1dHNjaGUgVGVsZWtvbSBBRzEfMB0G
  52745. A1UECxMWVC1UZWxlU2VjIFRydXN0IENlbnRlcjEjMCEGA1UEAxMaRGV1dHNjaGUgVGVsZWtvbSBS
  52746. b290IENBIDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCrC6M14IspFLEUha88EOQ5
  52747. bzVdSq7d6mGNlUn0b2SjGmBmpKlAIoTZ1KXleJMOaAGtuU1cOs7TuKhCQN/Po7qCWWqSG6wcmtoI
  52748. KyUn+WkjR/Hg6yx6m/UTAtB+NHzCnjwAWav12gz1MjwrrFDa1sPeg5TKqAyZMg4ISFZbavva4VhY
  52749. AUlfckE8FQYBjl2tqriTtM2e66foai1SNNs671x1Udrb8zH57nGYMsRUFUQM+ZtV7a3fGAigo4aK
  52750. Se5TBY8ZTNXeWHmb0mocQqvF1afPaA+W5OFhmHZhyJF81j4A4pFQh+GdCuatl9Idxjp9y7zaAzTV
  52751. jlsB9WoHtxa2bkp/AgMBAAGjQjBAMB0GA1UdDgQWBBQxw3kbuvVT1xfgiXotF2wKsyudMzAPBgNV
  52752. HRMECDAGAQH/AgEFMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAlGRZrTlk5ynr
  52753. E/5aw4sTV8gEJPB0d8Bg42f76Ymmg7+Wgnxu1MM9756AbrsptJh6sTtU6zkXR34ajgv8HzFZMQSy
  52754. zhfzLMdiNlXiItiJVbSYSKpk+tYcNthEeFpaIzpXl/V6ME+un2pMSyuOoAPjPuCp1NJ70rOo4nI8
  52755. rZ7/gFnkm0W09juwzTkZmDLl6iFhkOQxIY40sfcvNUqFENrnijchvllj4PKFiDFT1FQUhXB59C4G
  52756. dyd1Lx+4ivn+xbrYNuSD7Odlt79jWvNGr4GUN9RBjNYj1h7P9WgbRGOiWrqnNVmh5XAFmw4jV5mU
  52757. Cm26OWMohpLzGITY+9HPBVZkVw==
  52758. -----END CERTIFICATE-----
  52759. Cybertrust Global Root
  52760. ======================
  52761. -----BEGIN CERTIFICATE-----
  52762. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  52763. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  52764. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  52765. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  52766. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  52767. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  52768. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  52769. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  52770. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  52771. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  52772. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  52773. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  52774. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  52775. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  52776. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  52777. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  52778. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  52779. -----END CERTIFICATE-----
  52780. ePKI Root Certification Authority
  52781. =================================
  52782. -----BEGIN CERTIFICATE-----
  52783. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  52784. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  52785. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  52786. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  52787. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  52788. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  52789. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  52790. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  52791. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  52792. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  52793. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  52794. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  52795. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  52796. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  52797. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  52798. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  52799. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  52800. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  52801. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  52802. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  52803. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  52804. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  52805. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  52806. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  52807. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  52808. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  52809. -----END CERTIFICATE-----
  52810. certSIGN ROOT CA
  52811. ================
  52812. -----BEGIN CERTIFICATE-----
  52813. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  52814. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  52815. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  52816. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  52817. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  52818. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  52819. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  52820. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  52821. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  52822. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  52823. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  52824. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  52825. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  52826. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  52827. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  52828. -----END CERTIFICATE-----
  52829. GeoTrust Primary Certification Authority - G3
  52830. =============================================
  52831. -----BEGIN CERTIFICATE-----
  52832. MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE
  52833. BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0
  52834. IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy
  52835. eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz
  52836. NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo
  52837. YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT
  52838. LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI
  52839. hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j
  52840. K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE
  52841. c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C
  52842. IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu
  52843. dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC
  52844. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr
  52845. 2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9
  52846. cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE
  52847. Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD
  52848. AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s
  52849. t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt
  52850. -----END CERTIFICATE-----
  52851. thawte Primary Root CA - G2
  52852. ===========================
  52853. -----BEGIN CERTIFICATE-----
  52854. MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC
  52855. VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu
  52856. IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg
  52857. Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV
  52858. MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG
  52859. b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt
  52860. IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS
  52861. LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5
  52862. 8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU
  52863. mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN
  52864. G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K
  52865. rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==
  52866. -----END CERTIFICATE-----
  52867. thawte Primary Root CA - G3
  52868. ===========================
  52869. -----BEGIN CERTIFICATE-----
  52870. MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE
  52871. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  52872. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  52873. cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w
  52874. ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh
  52875. d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD
  52876. VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG
  52877. A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  52878. MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At
  52879. P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC
  52880. +BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY
  52881. 7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW
  52882. vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E
  52883. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ
  52884. KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK
  52885. A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu
  52886. t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC
  52887. 8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm
  52888. er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A=
  52889. -----END CERTIFICATE-----
  52890. GeoTrust Primary Certification Authority - G2
  52891. =============================================
  52892. -----BEGIN CERTIFICATE-----
  52893. MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC
  52894. VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu
  52895. Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD
  52896. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1
  52897. OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg
  52898. MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl
  52899. b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG
  52900. BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc
  52901. KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD
  52902. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+
  52903. EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m
  52904. ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2
  52905. npaqBA+K
  52906. -----END CERTIFICATE-----
  52907. VeriSign Universal Root Certification Authority
  52908. ===============================================
  52909. -----BEGIN CERTIFICATE-----
  52910. MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
  52911. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  52912. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  52913. IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
  52914. IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
  52915. UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
  52916. cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
  52917. IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
  52918. aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
  52919. 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
  52920. MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
  52921. 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
  52922. AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
  52923. tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
  52924. CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
  52925. a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
  52926. DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
  52927. Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
  52928. Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
  52929. P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
  52930. wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
  52931. mJO37M2CYfE45k+XmCpajQ==
  52932. -----END CERTIFICATE-----
  52933. VeriSign Class 3 Public Primary Certification Authority - G4
  52934. ============================================================
  52935. -----BEGIN CERTIFICATE-----
  52936. MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
  52937. VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
  52938. b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
  52939. ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
  52940. YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
  52941. MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
  52942. cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
  52943. b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
  52944. IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
  52945. Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
  52946. rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
  52947. /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
  52948. HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
  52949. Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
  52950. A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
  52951. AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
  52952. -----END CERTIFICATE-----
  52953. NetLock Arany (Class Gold) Főtanúsítvány
  52954. ========================================
  52955. -----BEGIN CERTIFICATE-----
  52956. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  52957. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  52958. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  52959. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  52960. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  52961. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  52962. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  52963. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  52964. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  52965. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  52966. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  52967. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  52968. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  52969. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  52970. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  52971. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  52972. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  52973. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  52974. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  52975. -----END CERTIFICATE-----
  52976. Staat der Nederlanden Root CA - G2
  52977. ==================================
  52978. -----BEGIN CERTIFICATE-----
  52979. MIIFyjCCA7KgAwIBAgIEAJiWjDANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
  52980. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  52981. Um9vdCBDQSAtIEcyMB4XDTA4MDMyNjExMTgxN1oXDTIwMDMyNTExMDMxMFowWjELMAkGA1UEBhMC
  52982. TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
  52983. ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMVZ
  52984. 5291qj5LnLW4rJ4L5PnZyqtdj7U5EILXr1HgO+EASGrP2uEGQxGZqhQlEq0i6ABtQ8SpuOUfiUtn
  52985. vWFI7/3S4GCI5bkYYCjDdyutsDeqN95kWSpGV+RLufg3fNU254DBtvPUZ5uW6M7XxgpT0GtJlvOj
  52986. CwV3SPcl5XCsMBQgJeN/dVrlSPhOewMHBPqCYYdu8DvEpMfQ9XQ+pV0aCPKbJdL2rAQmPlU6Yiil
  52987. e7Iwr/g3wtG61jj99O9JMDeZJiFIhQGp5Rbn3JBV3w/oOM2ZNyFPXfUib2rFEhZgF1XyZWampzCR
  52988. OME4HYYEhLoaJXhena/MUGDWE4dS7WMfbWV9whUYdMrhfmQpjHLYFhN9C0lK8SgbIHRrxT3dsKpI
  52989. CT0ugpTNGmXZK4iambwYfp/ufWZ8Pr2UuIHOzZgweMFvZ9C+X+Bo7d7iscksWXiSqt8rYGPy5V65
  52990. 48r6f1CGPqI0GAwJaCgRHOThuVw+R7oyPxjMW4T182t0xHJ04eOLoEq9jWYv6q012iDTiIJh8BIi
  52991. trzQ1aTsr1SIJSQ8p22xcik/Plemf1WvbibG/ufMQFxRRIEKeN5KzlW/HdXZt1bv8Hb/C3m1r737
  52992. qWmRRpdogBQ2HbN/uymYNqUg+oJgYjOk7Na6B6duxc8UpufWkjTYgfX8HV2qXB72o007uPc5AgMB
  52993. AAGjgZcwgZQwDwYDVR0TAQH/BAUwAwEB/zBSBgNVHSAESzBJMEcGBFUdIAAwPzA9BggrBgEFBQcC
  52994. ARYxaHR0cDovL3d3dy5wa2lvdmVyaGVpZC5ubC9wb2xpY2llcy9yb290LXBvbGljeS1HMjAOBgNV
  52995. HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJFoMocVHYnitfGsNig0jQt8YojrMA0GCSqGSIb3DQEBCwUA
  52996. A4ICAQCoQUpnKpKBglBu4dfYszk78wIVCVBR7y29JHuIhjv5tLySCZa59sCrI2AGeYwRTlHSeYAz
  52997. +51IvuxBQ4EffkdAHOV6CMqqi3WtFMTC6GY8ggen5ieCWxjmD27ZUD6KQhgpxrRW/FYQoAUXvQwj
  52998. f/ST7ZwaUb7dRUG/kSS0H4zpX897IZmflZ85OkYcbPnNe5yQzSipx6lVu6xiNGI1E0sUOlWDuYaN
  52999. kqbG9AclVMwWVxJKgnjIFNkXgiYtXSAfea7+1HAWFpWD2DU5/1JddRwWxRNVz0fMdWVSSt7wsKfk
  53000. CpYL+63C4iWEst3kvX5ZbJvw8NjnyvLplzh+ib7M+zkXYT9y2zqR2GUBGR2tUKRXCnxLvJxxcypF
  53001. URmFzI79R6d0lR2o0a9OF7FpJsKqeFdbxU2n5Z4FF5TKsl+gSRiNNOkmbEgeqmiSBeGCc1qb3Adb
  53002. CG19ndeNIdn8FCCqwkXfP+cAslHkwvgFuXkajDTznlvkN1trSt8sV4pAWja63XVECDdCcAz+3F4h
  53003. oKOKwJCcaNpQ5kUQR3i2TtJlycM33+FCY7BXN0Ute4qcvwXqZVUz9zkQxSgqIXobisQk+T8VyJoV
  53004. IPVVYpbtbZNQvOSqeK3Zywplh6ZmwcSBo3c6WB4L7oOLnR7SUqTMHW+wmG2UMbX4cQrcufx9MmDm
  53005. 66+KAQ==
  53006. -----END CERTIFICATE-----
  53007. Hongkong Post Root CA 1
  53008. =======================
  53009. -----BEGIN CERTIFICATE-----
  53010. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  53011. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  53012. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  53013. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  53014. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  53015. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  53016. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  53017. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  53018. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  53019. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  53020. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  53021. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  53022. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  53023. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  53024. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  53025. -----END CERTIFICATE-----
  53026. SecureSign RootCA11
  53027. ===================
  53028. -----BEGIN CERTIFICATE-----
  53029. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  53030. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  53031. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  53032. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  53033. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  53034. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  53035. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  53036. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  53037. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  53038. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  53039. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  53040. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  53041. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  53042. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  53043. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  53044. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  53045. -----END CERTIFICATE-----
  53046. Microsec e-Szigno Root CA 2009
  53047. ==============================
  53048. -----BEGIN CERTIFICATE-----
  53049. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  53050. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  53051. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  53052. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  53053. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  53054. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  53055. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  53056. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  53057. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  53058. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  53059. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  53060. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  53061. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  53062. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  53063. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  53064. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  53065. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  53066. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  53067. LXpUq3DDfSJlgnCW
  53068. -----END CERTIFICATE-----
  53069. GlobalSign Root CA - R3
  53070. =======================
  53071. -----BEGIN CERTIFICATE-----
  53072. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  53073. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  53074. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  53075. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  53076. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  53077. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  53078. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  53079. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  53080. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  53081. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  53082. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  53083. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  53084. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  53085. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  53086. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  53087. kpeDMdmztcpHWD9f
  53088. -----END CERTIFICATE-----
  53089. Autoridad de Certificacion Firmaprofesional CIF A62634068
  53090. =========================================================
  53091. -----BEGIN CERTIFICATE-----
  53092. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  53093. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  53094. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  53095. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  53096. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  53097. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  53098. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  53099. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  53100. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  53101. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  53102. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  53103. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  53104. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  53105. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  53106. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  53107. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  53108. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  53109. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  53110. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  53111. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  53112. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  53113. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  53114. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  53115. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  53116. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  53117. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  53118. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  53119. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  53120. -----END CERTIFICATE-----
  53121. Izenpe.com
  53122. ==========
  53123. -----BEGIN CERTIFICATE-----
  53124. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  53125. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  53126. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  53127. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  53128. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  53129. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  53130. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  53131. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  53132. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  53133. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  53134. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  53135. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  53136. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  53137. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  53138. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  53139. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  53140. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  53141. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  53142. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  53143. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  53144. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  53145. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  53146. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  53147. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  53148. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  53149. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  53150. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  53151. -----END CERTIFICATE-----
  53152. Chambers of Commerce Root - 2008
  53153. ================================
  53154. -----BEGIN CERTIFICATE-----
  53155. MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD
  53156. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  53157. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  53158. QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy
  53159. Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl
  53160. ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF
  53161. EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl
  53162. cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
  53163. AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA
  53164. XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj
  53165. h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/
  53166. ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk
  53167. NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g
  53168. D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331
  53169. lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ
  53170. 0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj
  53171. ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2
  53172. EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI
  53173. G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ
  53174. BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh
  53175. bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh
  53176. bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC
  53177. CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH
  53178. AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1
  53179. wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH
  53180. 3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU
  53181. RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6
  53182. M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1
  53183. YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF
  53184. 9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK
  53185. zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG
  53186. nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg
  53187. OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ
  53188. -----END CERTIFICATE-----
  53189. Global Chambersign Root - 2008
  53190. ==============================
  53191. -----BEGIN CERTIFICATE-----
  53192. MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD
  53193. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  53194. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  53195. QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx
  53196. NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg
  53197. Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ
  53198. QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD
  53199. aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf
  53200. VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf
  53201. XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0
  53202. ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB
  53203. /gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA
  53204. TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M
  53205. H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe
  53206. Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF
  53207. HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh
  53208. wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB
  53209. AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT
  53210. BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE
  53211. BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm
  53212. aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm
  53213. aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp
  53214. 1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0
  53215. dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG
  53216. /5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6
  53217. ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s
  53218. dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg
  53219. 9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH
  53220. foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du
  53221. qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr
  53222. P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq
  53223. c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z
  53224. 09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B
  53225. -----END CERTIFICATE-----
  53226. Go Daddy Root Certificate Authority - G2
  53227. ========================================
  53228. -----BEGIN CERTIFICATE-----
  53229. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  53230. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  53231. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  53232. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  53233. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  53234. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  53235. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  53236. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  53237. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  53238. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  53239. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  53240. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  53241. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  53242. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  53243. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  53244. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  53245. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  53246. -----END CERTIFICATE-----
  53247. Starfield Root Certificate Authority - G2
  53248. =========================================
  53249. -----BEGIN CERTIFICATE-----
  53250. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  53251. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  53252. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  53253. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  53254. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  53255. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  53256. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  53257. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  53258. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  53259. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  53260. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  53261. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  53262. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  53263. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  53264. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  53265. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  53266. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  53267. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  53268. -----END CERTIFICATE-----
  53269. Starfield Services Root Certificate Authority - G2
  53270. ==================================================
  53271. -----BEGIN CERTIFICATE-----
  53272. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  53273. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  53274. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  53275. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  53276. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  53277. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  53278. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  53279. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  53280. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  53281. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  53282. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  53283. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  53284. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  53285. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  53286. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  53287. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  53288. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  53289. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  53290. -----END CERTIFICATE-----
  53291. AffirmTrust Commercial
  53292. ======================
  53293. -----BEGIN CERTIFICATE-----
  53294. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  53295. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  53296. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  53297. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  53298. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  53299. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  53300. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  53301. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  53302. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  53303. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  53304. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  53305. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  53306. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  53307. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  53308. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  53309. -----END CERTIFICATE-----
  53310. AffirmTrust Networking
  53311. ======================
  53312. -----BEGIN CERTIFICATE-----
  53313. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  53314. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  53315. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  53316. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  53317. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  53318. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  53319. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  53320. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  53321. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  53322. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  53323. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  53324. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  53325. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  53326. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  53327. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  53328. -----END CERTIFICATE-----
  53329. AffirmTrust Premium
  53330. ===================
  53331. -----BEGIN CERTIFICATE-----
  53332. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  53333. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  53334. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  53335. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  53336. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  53337. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  53338. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  53339. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  53340. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  53341. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  53342. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  53343. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  53344. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  53345. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  53346. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  53347. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  53348. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  53349. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  53350. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  53351. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  53352. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  53353. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  53354. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  53355. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  53356. -----END CERTIFICATE-----
  53357. AffirmTrust Premium ECC
  53358. =======================
  53359. -----BEGIN CERTIFICATE-----
  53360. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  53361. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  53362. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  53363. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  53364. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  53365. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  53366. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  53367. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  53368. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  53369. eQ==
  53370. -----END CERTIFICATE-----
  53371. Certum Trusted Network CA
  53372. =========================
  53373. -----BEGIN CERTIFICATE-----
  53374. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  53375. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  53376. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  53377. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  53378. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  53379. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  53380. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  53381. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  53382. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  53383. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  53384. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  53385. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  53386. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  53387. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  53388. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  53389. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  53390. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  53391. -----END CERTIFICATE-----
  53392. TWCA Root Certification Authority
  53393. =================================
  53394. -----BEGIN CERTIFICATE-----
  53395. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  53396. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  53397. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  53398. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  53399. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  53400. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  53401. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  53402. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  53403. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  53404. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  53405. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  53406. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  53407. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  53408. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  53409. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  53410. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  53411. -----END CERTIFICATE-----
  53412. Security Communication RootCA2
  53413. ==============================
  53414. -----BEGIN CERTIFICATE-----
  53415. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  53416. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  53417. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  53418. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  53419. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  53420. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  53421. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  53422. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  53423. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  53424. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  53425. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  53426. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  53427. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  53428. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  53429. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  53430. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  53431. -----END CERTIFICATE-----
  53432. EC-ACC
  53433. ======
  53434. -----BEGIN CERTIFICATE-----
  53435. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  53436. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  53437. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  53438. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  53439. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  53440. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  53441. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  53442. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  53443. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  53444. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  53445. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  53446. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  53447. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  53448. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  53449. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  53450. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  53451. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  53452. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  53453. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  53454. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  53455. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  53456. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  53457. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  53458. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  53459. 5EI=
  53460. -----END CERTIFICATE-----
  53461. Hellenic Academic and Research Institutions RootCA 2011
  53462. =======================================================
  53463. -----BEGIN CERTIFICATE-----
  53464. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  53465. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  53466. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  53467. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  53468. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  53469. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  53470. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  53471. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  53472. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  53473. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  53474. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  53475. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  53476. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  53477. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  53478. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  53479. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  53480. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  53481. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  53482. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  53483. -----END CERTIFICATE-----
  53484. Actalis Authentication Root CA
  53485. ==============================
  53486. -----BEGIN CERTIFICATE-----
  53487. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  53488. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  53489. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  53490. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  53491. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  53492. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  53493. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  53494. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  53495. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  53496. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  53497. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  53498. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  53499. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  53500. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  53501. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  53502. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  53503. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  53504. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  53505. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  53506. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  53507. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  53508. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  53509. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  53510. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  53511. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  53512. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  53513. -----END CERTIFICATE-----
  53514. Trustis FPS Root CA
  53515. ===================
  53516. -----BEGIN CERTIFICATE-----
  53517. MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG
  53518. EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290
  53519. IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV
  53520. BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ
  53521. KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ
  53522. RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk
  53523. H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa
  53524. cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt
  53525. o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA
  53526. AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd
  53527. BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c
  53528. GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC
  53529. yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P
  53530. 8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV
  53531. l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl
  53532. iB6XzCGcKQENZetX2fNXlrtIzYE=
  53533. -----END CERTIFICATE-----
  53534. Buypass Class 2 Root CA
  53535. =======================
  53536. -----BEGIN CERTIFICATE-----
  53537. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  53538. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  53539. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  53540. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  53541. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  53542. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  53543. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  53544. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  53545. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  53546. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  53547. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  53548. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  53549. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  53550. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  53551. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  53552. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  53553. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  53554. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  53555. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  53556. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  53557. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  53558. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  53559. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  53560. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  53561. rJgWVqA=
  53562. -----END CERTIFICATE-----
  53563. Buypass Class 3 Root CA
  53564. =======================
  53565. -----BEGIN CERTIFICATE-----
  53566. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  53567. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  53568. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  53569. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  53570. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  53571. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  53572. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  53573. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  53574. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  53575. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  53576. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  53577. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  53578. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  53579. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  53580. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  53581. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  53582. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  53583. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  53584. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  53585. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  53586. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  53587. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  53588. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  53589. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  53590. Cp/HuZc=
  53591. -----END CERTIFICATE-----
  53592. T-TeleSec GlobalRoot Class 3
  53593. ============================
  53594. -----BEGIN CERTIFICATE-----
  53595. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  53596. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  53597. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  53598. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  53599. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  53600. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  53601. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  53602. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  53603. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  53604. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  53605. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  53606. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  53607. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  53608. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  53609. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  53610. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  53611. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  53612. -----END CERTIFICATE-----
  53613. EE Certification Centre Root CA
  53614. ===============================
  53615. -----BEGIN CERTIFICATE-----
  53616. MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQG
  53617. EwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1czEoMCYGA1UEAwwfRUUgQ2Vy
  53618. dGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYGCSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIw
  53619. MTAxMDMwMTAxMDMwWhgPMjAzMDEyMTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlB
  53620. UyBTZXJ0aWZpdHNlZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRy
  53621. ZSBSb290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEBAQUAA4IB
  53622. DwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUyeuuOF0+W2Ap7kaJjbMeM
  53623. TC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvObntl8jixwKIy72KyaOBhU8E2lf/slLo2
  53624. rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIwWFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw
  53625. 93X2PaRka9ZP585ArQ/dMtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtN
  53626. P2MbRMNE1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYDVR0T
  53627. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/zQas8fElyalL1BSZ
  53628. MEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEF
  53629. BQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEFBQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+Rj
  53630. xY6hUFaTlrg4wCQiZrxTFGGVv9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqM
  53631. lIpPnTX/dqQGE5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u
  53632. uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIWiAYLtqZLICjU
  53633. 3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/vGVCJYMzpJJUPwssd8m92kMfM
  53634. dcGWxZ0=
  53635. -----END CERTIFICATE-----
  53636. D-TRUST Root Class 3 CA 2 2009
  53637. ==============================
  53638. -----BEGIN CERTIFICATE-----
  53639. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  53640. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  53641. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  53642. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  53643. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  53644. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  53645. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  53646. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  53647. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  53648. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  53649. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  53650. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  53651. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  53652. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  53653. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  53654. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  53655. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  53656. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  53657. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  53658. -----END CERTIFICATE-----
  53659. D-TRUST Root Class 3 CA 2 EV 2009
  53660. =================================
  53661. -----BEGIN CERTIFICATE-----
  53662. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  53663. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  53664. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  53665. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  53666. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  53667. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  53668. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  53669. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  53670. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  53671. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  53672. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  53673. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  53674. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  53675. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  53676. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  53677. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  53678. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  53679. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  53680. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  53681. w9y4AyHqnxbxLFS1
  53682. -----END CERTIFICATE-----
  53683. CA Disig Root R2
  53684. ================
  53685. -----BEGIN CERTIFICATE-----
  53686. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  53687. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  53688. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  53689. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  53690. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  53691. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  53692. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  53693. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  53694. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  53695. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  53696. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  53697. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  53698. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  53699. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  53700. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  53701. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  53702. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  53703. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  53704. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  53705. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  53706. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  53707. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  53708. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  53709. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  53710. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  53711. -----END CERTIFICATE-----
  53712. ACCVRAIZ1
  53713. =========
  53714. -----BEGIN CERTIFICATE-----
  53715. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  53716. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  53717. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  53718. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  53719. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  53720. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  53721. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  53722. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  53723. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  53724. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  53725. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  53726. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  53727. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  53728. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  53729. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  53730. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  53731. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  53732. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  53733. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  53734. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  53735. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  53736. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  53737. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  53738. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  53739. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  53740. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  53741. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  53742. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  53743. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  53744. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  53745. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  53746. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  53747. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  53748. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  53749. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  53750. EfbRD0tVNEYqi4Y7
  53751. -----END CERTIFICATE-----
  53752. TWCA Global Root CA
  53753. ===================
  53754. -----BEGIN CERTIFICATE-----
  53755. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  53756. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  53757. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  53758. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  53759. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  53760. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  53761. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  53762. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  53763. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  53764. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  53765. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  53766. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  53767. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  53768. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  53769. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  53770. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  53771. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  53772. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  53773. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  53774. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  53775. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  53776. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  53777. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  53778. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  53779. -----END CERTIFICATE-----
  53780. TeliaSonera Root CA v1
  53781. ======================
  53782. -----BEGIN CERTIFICATE-----
  53783. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  53784. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  53785. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  53786. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  53787. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  53788. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  53789. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  53790. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  53791. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  53792. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  53793. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  53794. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  53795. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  53796. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  53797. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  53798. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  53799. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  53800. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  53801. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  53802. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  53803. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  53804. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  53805. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  53806. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  53807. -----END CERTIFICATE-----
  53808. E-Tugra Certification Authority
  53809. ===============================
  53810. -----BEGIN CERTIFICATE-----
  53811. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  53812. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  53813. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  53814. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  53815. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  53816. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  53817. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  53818. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  53819. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  53820. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  53821. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  53822. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  53823. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  53824. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  53825. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  53826. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  53827. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  53828. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  53829. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  53830. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  53831. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  53832. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  53833. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  53834. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  53835. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  53836. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  53837. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  53838. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  53839. C7TbO6Orb1wdtn7os4I07QZcJA==
  53840. -----END CERTIFICATE-----
  53841. T-TeleSec GlobalRoot Class 2
  53842. ============================
  53843. -----BEGIN CERTIFICATE-----
  53844. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  53845. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  53846. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  53847. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  53848. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  53849. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  53850. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  53851. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  53852. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  53853. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  53854. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  53855. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  53856. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  53857. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  53858. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  53859. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  53860. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  53861. -----END CERTIFICATE-----
  53862. Atos TrustedRoot 2011
  53863. =====================
  53864. -----BEGIN CERTIFICATE-----
  53865. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  53866. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  53867. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  53868. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  53869. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  53870. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  53871. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  53872. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  53873. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  53874. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  53875. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  53876. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  53877. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  53878. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  53879. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  53880. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  53881. -----END CERTIFICATE-----
  53882. QuoVadis Root CA 1 G3
  53883. =====================
  53884. -----BEGIN CERTIFICATE-----
  53885. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  53886. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  53887. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  53888. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  53889. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  53890. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  53891. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  53892. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  53893. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  53894. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  53895. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  53896. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  53897. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  53898. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  53899. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  53900. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  53901. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  53902. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  53903. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  53904. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  53905. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  53906. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  53907. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  53908. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  53909. hMJKzRwuJIczYOXD
  53910. -----END CERTIFICATE-----
  53911. QuoVadis Root CA 2 G3
  53912. =====================
  53913. -----BEGIN CERTIFICATE-----
  53914. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  53915. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  53916. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  53917. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  53918. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  53919. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  53920. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  53921. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  53922. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  53923. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  53924. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  53925. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  53926. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  53927. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  53928. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  53929. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  53930. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  53931. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  53932. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  53933. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  53934. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  53935. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  53936. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  53937. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  53938. O3jtZsSOeWmD3n+M
  53939. -----END CERTIFICATE-----
  53940. QuoVadis Root CA 3 G3
  53941. =====================
  53942. -----BEGIN CERTIFICATE-----
  53943. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  53944. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  53945. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  53946. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  53947. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  53948. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  53949. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  53950. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  53951. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  53952. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  53953. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  53954. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  53955. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  53956. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  53957. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  53958. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  53959. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  53960. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  53961. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  53962. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  53963. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  53964. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  53965. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  53966. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  53967. PpxxVJkES/1Y+Zj0
  53968. -----END CERTIFICATE-----
  53969. DigiCert Assured ID Root G2
  53970. ===========================
  53971. -----BEGIN CERTIFICATE-----
  53972. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  53973. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  53974. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  53975. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  53976. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  53977. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  53978. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  53979. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  53980. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  53981. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  53982. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  53983. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  53984. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  53985. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  53986. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  53987. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  53988. IhNzbM8m9Yop5w==
  53989. -----END CERTIFICATE-----
  53990. DigiCert Assured ID Root G3
  53991. ===========================
  53992. -----BEGIN CERTIFICATE-----
  53993. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  53994. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  53995. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  53996. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  53997. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  53998. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  53999. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  54000. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  54001. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  54002. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  54003. 1vUhZscv6pZjamVFkpUBtA==
  54004. -----END CERTIFICATE-----
  54005. DigiCert Global Root G2
  54006. =======================
  54007. -----BEGIN CERTIFICATE-----
  54008. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  54009. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  54010. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  54011. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  54012. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  54013. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  54014. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  54015. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  54016. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  54017. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  54018. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  54019. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  54020. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  54021. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  54022. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  54023. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  54024. MrY=
  54025. -----END CERTIFICATE-----
  54026. DigiCert Global Root G3
  54027. =======================
  54028. -----BEGIN CERTIFICATE-----
  54029. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  54030. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  54031. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  54032. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  54033. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  54034. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  54035. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  54036. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  54037. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  54038. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  54039. VOKa5Vt8sycX
  54040. -----END CERTIFICATE-----
  54041. DigiCert Trusted Root G4
  54042. ========================
  54043. -----BEGIN CERTIFICATE-----
  54044. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  54045. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  54046. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  54047. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  54048. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  54049. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  54050. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  54051. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  54052. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  54053. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  54054. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  54055. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  54056. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  54057. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  54058. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  54059. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  54060. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  54061. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  54062. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  54063. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  54064. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  54065. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  54066. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  54067. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  54068. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  54069. 82Z+
  54070. -----END CERTIFICATE-----
  54071. COMODO RSA Certification Authority
  54072. ==================================
  54073. -----BEGIN CERTIFICATE-----
  54074. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  54075. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  54076. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  54077. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  54078. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  54079. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  54080. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  54081. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  54082. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  54083. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  54084. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  54085. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  54086. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  54087. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  54088. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  54089. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  54090. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  54091. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  54092. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  54093. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  54094. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  54095. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  54096. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  54097. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  54098. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  54099. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  54100. LaZRfyHBNVOFBkpdn627G190
  54101. -----END CERTIFICATE-----
  54102. USERTrust RSA Certification Authority
  54103. =====================================
  54104. -----BEGIN CERTIFICATE-----
  54105. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  54106. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  54107. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  54108. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  54109. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  54110. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  54111. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  54112. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  54113. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  54114. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  54115. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  54116. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  54117. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  54118. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  54119. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  54120. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  54121. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  54122. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  54123. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  54124. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  54125. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  54126. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  54127. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  54128. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  54129. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  54130. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  54131. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  54132. -----END CERTIFICATE-----
  54133. USERTrust ECC Certification Authority
  54134. =====================================
  54135. -----BEGIN CERTIFICATE-----
  54136. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  54137. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  54138. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  54139. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  54140. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  54141. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  54142. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  54143. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  54144. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  54145. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  54146. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  54147. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  54148. -----END CERTIFICATE-----
  54149. GlobalSign ECC Root CA - R4
  54150. ===========================
  54151. -----BEGIN CERTIFICATE-----
  54152. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  54153. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  54154. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  54155. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  54156. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  54157. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  54158. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  54159. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  54160. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  54161. -----END CERTIFICATE-----
  54162. GlobalSign ECC Root CA - R5
  54163. ===========================
  54164. -----BEGIN CERTIFICATE-----
  54165. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  54166. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  54167. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  54168. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  54169. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  54170. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  54171. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  54172. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  54173. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  54174. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  54175. -----END CERTIFICATE-----
  54176. Staat der Nederlanden Root CA - G3
  54177. ==================================
  54178. -----BEGIN CERTIFICATE-----
  54179. MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
  54180. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  54181. Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
  54182. TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
  54183. ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
  54184. olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
  54185. x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
  54186. EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
  54187. Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
  54188. mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5
  54189. 1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp
  54190. 07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHPbMk7ccHViLVlvMDo
  54191. FxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXtBznaqB16nzaeErAMZRKQFWDZJkBE
  54192. 41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTtXUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMB
  54193. AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleu
  54194. yjWcLhL75LpdINyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD
  54195. U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwpLiniyMMB8jPq
  54196. KqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8Ipf3YF3qKS9Ysr1YvY2WTxB1
  54197. v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixpgZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA
  54198. 8KCWAg8zxXHzniN9lLf9OtMJgwYh/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b
  54199. 8KKaa8MFSu1BYBQw0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0r
  54200. mj1AfsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq4BZ+Extq
  54201. 1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR1VmiiXTTn74eS9fGbbeI
  54202. JG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV
  54203. tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk=
  54204. -----END CERTIFICATE-----
  54205. Staat der Nederlanden EV Root CA
  54206. ================================
  54207. -----BEGIN CERTIFICATE-----
  54208. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  54209. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  54210. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  54211. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  54212. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  54213. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  54214. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  54215. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  54216. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  54217. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  54218. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  54219. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  54220. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  54221. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  54222. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  54223. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  54224. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  54225. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  54226. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  54227. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  54228. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  54229. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  54230. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  54231. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  54232. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  54233. -----END CERTIFICATE-----
  54234. IdenTrust Commercial Root CA 1
  54235. ==============================
  54236. -----BEGIN CERTIFICATE-----
  54237. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  54238. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  54239. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  54240. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  54241. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  54242. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  54243. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  54244. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  54245. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  54246. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  54247. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  54248. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  54249. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  54250. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  54251. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  54252. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  54253. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  54254. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  54255. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  54256. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  54257. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  54258. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  54259. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  54260. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  54261. cGzM7vRX+Bi6hG6H
  54262. -----END CERTIFICATE-----
  54263. IdenTrust Public Sector Root CA 1
  54264. =================================
  54265. -----BEGIN CERTIFICATE-----
  54266. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  54267. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  54268. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  54269. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  54270. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  54271. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  54272. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  54273. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  54274. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  54275. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  54276. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  54277. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  54278. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  54279. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  54280. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  54281. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  54282. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  54283. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  54284. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  54285. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  54286. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  54287. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  54288. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  54289. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  54290. 3Wl9af0AVqW3rLatt8o+Ae+c
  54291. -----END CERTIFICATE-----
  54292. Entrust Root Certification Authority - G2
  54293. =========================================
  54294. -----BEGIN CERTIFICATE-----
  54295. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  54296. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  54297. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  54298. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  54299. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  54300. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  54301. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  54302. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  54303. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  54304. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  54305. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  54306. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  54307. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  54308. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  54309. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  54310. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  54311. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  54312. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  54313. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  54314. e4pIb4tF9g==
  54315. -----END CERTIFICATE-----
  54316. Entrust Root Certification Authority - EC1
  54317. ==========================================
  54318. -----BEGIN CERTIFICATE-----
  54319. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  54320. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  54321. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  54322. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  54323. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  54324. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  54325. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  54326. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  54327. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  54328. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  54329. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  54330. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  54331. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  54332. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  54333. -----END CERTIFICATE-----
  54334. CFCA EV ROOT
  54335. ============
  54336. -----BEGIN CERTIFICATE-----
  54337. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  54338. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  54339. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  54340. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  54341. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  54342. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  54343. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  54344. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  54345. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  54346. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  54347. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  54348. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  54349. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  54350. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  54351. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  54352. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  54353. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  54354. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  54355. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  54356. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  54357. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  54358. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  54359. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  54360. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  54361. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  54362. -----END CERTIFICATE-----
  54363. Certinomis - Root CA
  54364. ====================
  54365. -----BEGIN CERTIFICATE-----
  54366. MIIFkjCCA3qgAwIBAgIBATANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJGUjETMBEGA1UEChMK
  54367. Q2VydGlub21pczEXMBUGA1UECxMOMDAwMiA0MzM5OTg5MDMxHTAbBgNVBAMTFENlcnRpbm9taXMg
  54368. LSBSb290IENBMB4XDTEzMTAyMTA5MTcxOFoXDTMzMTAyMTA5MTcxOFowWjELMAkGA1UEBhMCRlIx
  54369. EzARBgNVBAoTCkNlcnRpbm9taXMxFzAVBgNVBAsTDjAwMDIgNDMzOTk4OTAzMR0wGwYDVQQDExRD
  54370. ZXJ0aW5vbWlzIC0gUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANTMCQos
  54371. P5L2fxSeC5yaah1AMGT9qt8OHgZbn1CF6s2Nq0Nn3rD6foCWnoR4kkjW4znuzuRZWJflLieY6pOo
  54372. d5tK8O90gC3rMB+12ceAnGInkYjwSond3IjmFPnVAy//ldu9n+ws+hQVWZUKxkd8aRi5pwP5ynap
  54373. z8dvtF4F/u7BUrJ1Mofs7SlmO/NKFoL21prbcpjp3vDFTKWrteoB4owuZH9kb/2jJZOLyKIOSY00
  54374. 8B/sWEUuNKqEUL3nskoTuLAPrjhdsKkb5nPJWqHZZkCqqU2mNAKthH6yI8H7KsZn9DS2sJVqM09x
  54375. RLWtwHkziOC/7aOgFLScCbAK42C++PhmiM1b8XcF4LVzbsF9Ri6OSyemzTUK/eVNfaoqoynHWmgE
  54376. 6OXWk6RiwsXm9E/G+Z8ajYJJGYrKWUM66A0ywfRMEwNvbqY/kXPLynNvEiCL7sCCeN5LLsJJwx3t
  54377. FvYk9CcbXFcx3FXuqB5vbKziRcxXV4p1VxngtViZSTYxPDMBbRZKzbgqg4SGm/lg0h9tkQPTYKbV
  54378. PZrdd5A9NaSfD171UkRpucC63M9933zZxKyGIjK8e2uR73r4F2iw4lNVYC2vPsKD2NkJK/DAZNuH
  54379. i5HMkesE/Xa0lZrmFAYb1TQdvtj/dBxThZngWVJKYe2InmtJiUZ+IFrZ50rlau7SZRFDAgMBAAGj
  54380. YzBhMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTvkUz1pcMw6C8I
  54381. 6tNxIqSSaHh02TAfBgNVHSMEGDAWgBTvkUz1pcMw6C8I6tNxIqSSaHh02TANBgkqhkiG9w0BAQsF
  54382. AAOCAgEAfj1U2iJdGlg+O1QnurrMyOMaauo++RLrVl89UM7g6kgmJs95Vn6RHJk/0KGRHCwPT5iV
  54383. WVO90CLYiF2cN/z7ZMF4jIuaYAnq1fohX9B0ZedQxb8uuQsLrbWwF6YSjNRieOpWauwK0kDDPAUw
  54384. Pk2Ut59KA9N9J0u2/kTO+hkzGm2kQtHdzMjI1xZSg081lLMSVX3l4kLr5JyTCcBMWwerx20RoFAX
  54385. lCOotQqSD7J6wWAsOMwaplv/8gzjqh8c3LigkyfeY+N/IZ865Z764BNqdeuWXGKRlI5nU7aJ+BIJ
  54386. y29SWwNyhlCVCNSNh4YVH5Uk2KRvms6knZtt0rJ2BobGVgjF6wnaNsIbW0G+YSrjcOa4pvi2WsS9
  54387. Iff/ql+hbHY5ZtbqTFXhADObE5hjyW/QASAJN1LnDE8+zbz1X5YnpyACleAu6AdBBR8Vbtaw5Bng
  54388. DwKTACdyxYvRVB9dSsNAl35VpnzBMwQUAR1JIGkLGZOdblgi90AMRgwjY/M50n92Uaf0yKHxDHYi
  54389. I0ZSKS3io0EHVmmY0gUJvGnHWmHNj4FgFU2A3ZDifcRQ8ow7bkrHxuaAKzyBvBGAFhAn1/DNP3nM
  54390. cyrDflOR1m749fPH0FFNjkulW+YZFzvWgQncItzujrnEj1PhZ7szuIgVRs/taTX/dQ1G885x4cVr
  54391. hkIGuUE=
  54392. -----END CERTIFICATE-----
  54393. OISTE WISeKey Global Root GB CA
  54394. ===============================
  54395. -----BEGIN CERTIFICATE-----
  54396. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  54397. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  54398. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  54399. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  54400. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  54401. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  54402. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  54403. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  54404. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  54405. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  54406. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  54407. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  54408. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  54409. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  54410. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  54411. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  54412. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  54413. -----END CERTIFICATE-----
  54414. SZAFIR ROOT CA2
  54415. ===============
  54416. -----BEGIN CERTIFICATE-----
  54417. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  54418. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  54419. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  54420. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  54421. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  54422. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  54423. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  54424. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  54425. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  54426. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  54427. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  54428. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  54429. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  54430. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  54431. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  54432. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  54433. -----END CERTIFICATE-----
  54434. Certum Trusted Network CA 2
  54435. ===========================
  54436. -----BEGIN CERTIFICATE-----
  54437. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  54438. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  54439. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  54440. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  54441. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  54442. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  54443. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  54444. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  54445. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  54446. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  54447. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  54448. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  54449. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  54450. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  54451. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  54452. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  54453. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  54454. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  54455. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  54456. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  54457. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  54458. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  54459. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  54460. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  54461. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  54462. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  54463. zAYspsbiDrW5viSP
  54464. -----END CERTIFICATE-----
  54465. Hellenic Academic and Research Institutions RootCA 2015
  54466. =======================================================
  54467. -----BEGIN CERTIFICATE-----
  54468. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  54469. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  54470. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  54471. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  54472. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  54473. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  54474. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  54475. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  54476. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  54477. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  54478. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  54479. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  54480. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  54481. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  54482. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  54483. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  54484. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  54485. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  54486. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  54487. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  54488. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  54489. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  54490. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  54491. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  54492. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  54493. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  54494. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  54495. p/UsQu0yrbYhnr68
  54496. -----END CERTIFICATE-----
  54497. Hellenic Academic and Research Institutions ECC RootCA 2015
  54498. ===========================================================
  54499. -----BEGIN CERTIFICATE-----
  54500. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  54501. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  54502. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  54503. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  54504. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  54505. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  54506. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  54507. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  54508. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  54509. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  54510. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  54511. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  54512. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  54513. -----END CERTIFICATE-----
  54514. ISRG Root X1
  54515. ============
  54516. -----BEGIN CERTIFICATE-----
  54517. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  54518. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  54519. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  54520. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  54521. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  54522. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  54523. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  54524. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  54525. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  54526. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  54527. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  54528. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  54529. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  54530. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  54531. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  54532. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  54533. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  54534. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  54535. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  54536. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  54537. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  54538. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  54539. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  54540. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  54541. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  54542. -----END CERTIFICATE-----
  54543. AC RAIZ FNMT-RCM
  54544. ================
  54545. -----BEGIN CERTIFICATE-----
  54546. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  54547. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  54548. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  54549. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  54550. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  54551. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  54552. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  54553. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  54554. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  54555. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  54556. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  54557. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  54558. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  54559. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  54560. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  54561. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  54562. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  54563. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  54564. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  54565. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  54566. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  54567. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  54568. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  54569. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  54570. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  54571. -----END CERTIFICATE-----
  54572. Amazon Root CA 1
  54573. ================
  54574. -----BEGIN CERTIFICATE-----
  54575. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  54576. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  54577. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  54578. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  54579. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  54580. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  54581. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  54582. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  54583. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  54584. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  54585. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  54586. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  54587. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  54588. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  54589. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  54590. -----END CERTIFICATE-----
  54591. Amazon Root CA 2
  54592. ================
  54593. -----BEGIN CERTIFICATE-----
  54594. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  54595. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  54596. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  54597. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  54598. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  54599. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  54600. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  54601. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  54602. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  54603. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  54604. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  54605. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  54606. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  54607. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  54608. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  54609. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  54610. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  54611. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  54612. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  54613. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  54614. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  54615. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  54616. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  54617. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  54618. -----END CERTIFICATE-----
  54619. Amazon Root CA 3
  54620. ================
  54621. -----BEGIN CERTIFICATE-----
  54622. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  54623. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  54624. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  54625. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  54626. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  54627. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  54628. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  54629. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  54630. -----END CERTIFICATE-----
  54631. Amazon Root CA 4
  54632. ================
  54633. -----BEGIN CERTIFICATE-----
  54634. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  54635. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  54636. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  54637. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  54638. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  54639. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  54640. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  54641. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  54642. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  54643. -----END CERTIFICATE-----
  54644. LuxTrust Global Root 2
  54645. ======================
  54646. -----BEGIN CERTIFICATE-----
  54647. MIIFwzCCA6ugAwIBAgIUCn6m30tEntpqJIWe5rgV0xZ/u7EwDQYJKoZIhvcNAQELBQAwRjELMAkG
  54648. A1UEBhMCTFUxFjAUBgNVBAoMDUx1eFRydXN0IFMuQS4xHzAdBgNVBAMMFkx1eFRydXN0IEdsb2Jh
  54649. bCBSb290IDIwHhcNMTUwMzA1MTMyMTU3WhcNMzUwMzA1MTMyMTU3WjBGMQswCQYDVQQGEwJMVTEW
  54650. MBQGA1UECgwNTHV4VHJ1c3QgUy5BLjEfMB0GA1UEAwwWTHV4VHJ1c3QgR2xvYmFsIFJvb3QgMjCC
  54651. AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANeFl78RmOnwYoNMPIf5U2o3C/IPPIfOb9wm
  54652. Kb3FibrJgz337spbxm1Jc7TJRqMbNBM/wYlFV/TZsfs2ZUv7COJIcRHIbjuend+JZTemhfY7RBi2
  54653. xjcwYkSSl2l9QjAk5A0MiWtj3sXh306pFGxT4GHO9hcvHTy95iJMHZP1EMShduxq3sVs35a0VkBC
  54654. wGKSMKEtFZSg0iAGCW5qbeXrt77U8PEVfIvmTroTzEsnXpk8F12PgX8zPU/TPxvsXD/wPEx1bvKm
  54655. 1Z3aLQdjAsZy6ZS8TEmVT4hSyNvoaYL4zDRbIvCGp4m9SAptZoFtyMhk+wHh9OHe2Z7d21vUKpkm
  54656. FRseTJIpgp7VkoGSQXAZ96Tlk0u8d2cx3Rz9MXANF5kM+Qw5GSoXtTBxVdUPrljhPS80m8+f9niF
  54657. wpN6cj5mj5wWEWCPnolvZ77gR1o7DJpni89Gxq44o/KnvObWhWszJHAiS8sIm7vI+AIpHb4gDEa/
  54658. a4ebsypmQjVGbKq6rfmYe+lQVRQxv7HaLe2ArWgk+2mr2HETMOZns4dA/Yl+8kPREd8vZS9kzl8U
  54659. ubG/Mb2HeFpZZYiq/FkySIbWTLkpS5XTdvN3JW1CHDiDTf2jX5t/Lax5Gw5CMZdjpPuKadUiDTSQ
  54660. MC6otOBttpSsvItO13D8xTiOZCXhTTmQzsmHhFhxAgMBAAGjgagwgaUwDwYDVR0TAQH/BAUwAwEB
  54661. /zBCBgNVHSAEOzA5MDcGByuBKwEBAQowLDAqBggrBgEFBQcCARYeaHR0cHM6Ly9yZXBvc2l0b3J5
  54662. Lmx1eHRydXN0Lmx1MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBT/GCh2+UgFLKGu8SsbK7JT
  54663. +Et8szAdBgNVHQ4EFgQU/xgodvlIBSyhrvErGyuyU/hLfLMwDQYJKoZIhvcNAQELBQADggIBAGoZ
  54664. FO1uecEsh9QNcH7X9njJCwROxLHOk3D+sFTAMs2ZMGQXvw/l4jP9BzZAcg4atmpZ1gDlaCDdLnIN
  54665. H2pkMSCEfUmmWjfrRcmF9dTHF5kH5ptV5AzoqbTOjFu1EVzPig4N1qx3gf4ynCSecs5U89BvolbW
  54666. 7MM3LGVYvlcAGvI1+ut7MV3CwRI9loGIlonBWVx65n9wNOeD4rHh4bhY79SV5GCc8JaXcozrhAIu
  54667. ZY+kt9J/Z93I055cqqmkoCUUBpvsT34tC38ddfEz2O3OuHVtPlu5mB0xDVbYQw8wkbIEa91WvpWA
  54668. VWe+2M2D2RjuLg+GLZKecBPs3lHJQ3gCpU3I+V/EkVhGFndadKpAvAefMLmx9xIX3eP/JEAdemrR
  54669. TxgKqpAd60Ae36EeRJIQmvKN4dFLRp7oRUKX6kWZ8+xm1QL68qZKJKrezrnK+T+Tb/mjuuqlPpmt
  54670. /f97mfVl7vBZKGfXkJWkE4SphMHozs51k2MavDzq1WQfLSoSOcbDWjLtR5EWDrw4wVDej8oqkDQc
  54671. 7kGUnF4ZLvhFSZl0kbAEb+MEWrGrKqv+x9CWttrhSmQGbmBNvUJO/3jaJMobtNeWOWyu8Q6qp31I
  54672. iyBMz2TWuJdGsE7RKlY6oJO9r4Ak4Ap+58rVyuiFVdw2KuGUaJPHZnJED4AhMmwlxyOAgwrr
  54673. -----END CERTIFICATE-----
  54674. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  54675. =============================================
  54676. -----BEGIN CERTIFICATE-----
  54677. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  54678. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  54679. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  54680. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  54681. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  54682. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  54683. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  54684. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  54685. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  54686. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  54687. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  54688. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  54689. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  54690. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  54691. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  54692. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  54693. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  54694. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  54695. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  54696. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  54697. -----END CERTIFICATE-----
  54698. GDCA TrustAUTH R5 ROOT
  54699. ======================
  54700. -----BEGIN CERTIFICATE-----
  54701. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  54702. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  54703. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  54704. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  54705. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  54706. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  54707. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  54708. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  54709. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  54710. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  54711. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  54712. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  54713. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  54714. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  54715. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  54716. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  54717. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  54718. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  54719. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  54720. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  54721. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  54722. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  54723. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  54724. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  54725. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  54726. -----END CERTIFICATE-----
  54727. TrustCor RootCert CA-1
  54728. ======================
  54729. -----BEGIN CERTIFICATE-----
  54730. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  54731. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  54732. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  54733. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  54734. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  54735. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  54736. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  54737. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  54738. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  54739. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  54740. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  54741. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  54742. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  54743. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  54744. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  54745. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  54746. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  54747. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  54748. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  54749. -----END CERTIFICATE-----
  54750. TrustCor RootCert CA-2
  54751. ======================
  54752. -----BEGIN CERTIFICATE-----
  54753. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  54754. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  54755. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  54756. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  54757. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  54758. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  54759. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  54760. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  54761. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  54762. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  54763. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  54764. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  54765. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  54766. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  54767. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  54768. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  54769. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  54770. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  54771. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  54772. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  54773. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  54774. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  54775. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  54776. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  54777. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  54778. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  54779. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  54780. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  54781. -----END CERTIFICATE-----
  54782. TrustCor ECA-1
  54783. ==============
  54784. -----BEGIN CERTIFICATE-----
  54785. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  54786. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  54787. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  54788. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  54789. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  54790. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  54791. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  54792. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  54793. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  54794. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  54795. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  54796. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  54797. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  54798. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  54799. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  54800. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  54801. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  54802. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  54803. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  54804. -----END CERTIFICATE-----
  54805. SSL.com Root Certification Authority RSA
  54806. ========================================
  54807. -----BEGIN CERTIFICATE-----
  54808. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  54809. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  54810. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  54811. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  54812. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  54813. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  54814. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  54815. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  54816. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  54817. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  54818. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  54819. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  54820. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  54821. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  54822. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  54823. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  54824. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  54825. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  54826. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  54827. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  54828. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  54829. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  54830. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  54831. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  54832. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  54833. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  54834. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  54835. -----END CERTIFICATE-----
  54836. SSL.com Root Certification Authority ECC
  54837. ========================================
  54838. -----BEGIN CERTIFICATE-----
  54839. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  54840. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  54841. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  54842. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  54843. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  54844. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  54845. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  54846. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  54847. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  54848. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  54849. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  54850. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  54851. -----END CERTIFICATE-----
  54852. SSL.com EV Root Certification Authority RSA R2
  54853. ==============================================
  54854. -----BEGIN CERTIFICATE-----
  54855. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  54856. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  54857. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  54858. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  54859. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  54860. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  54861. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  54862. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  54863. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  54864. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  54865. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  54866. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  54867. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  54868. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  54869. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  54870. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  54871. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  54872. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  54873. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  54874. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  54875. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  54876. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  54877. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  54878. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  54879. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  54880. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  54881. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  54882. -----END CERTIFICATE-----
  54883. SSL.com EV Root Certification Authority ECC
  54884. ===========================================
  54885. -----BEGIN CERTIFICATE-----
  54886. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  54887. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  54888. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  54889. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  54890. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  54891. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  54892. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  54893. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  54894. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  54895. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  54896. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  54897. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  54898. -----END CERTIFICATE-----
  54899. GlobalSign Root CA - R6
  54900. =======================
  54901. -----BEGIN CERTIFICATE-----
  54902. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  54903. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  54904. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  54905. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  54906. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  54907. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  54908. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  54909. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  54910. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  54911. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  54912. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  54913. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  54914. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  54915. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  54916. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  54917. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  54918. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  54919. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  54920. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  54921. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  54922. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  54923. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  54924. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  54925. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  54926. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  54927. -----END CERTIFICATE-----
  54928. OISTE WISeKey Global Root GC CA
  54929. ===============================
  54930. -----BEGIN CERTIFICATE-----
  54931. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  54932. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  54933. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  54934. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  54935. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  54936. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  54937. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  54938. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  54939. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  54940. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  54941. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  54942. -----END CERTIFICATE-----
  54943. <?php
  54944. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  54945. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  54946. }
  54947. setlocale(LC_ALL, 'C');
  54948. require __DIR__.'/../src/bootstrap.php';
  54949. use Composer\Console\Application;
  54950. use Composer\XdebugHandler\XdebugHandler;
  54951. error_reporting(-1);
  54952. // Restart without xdebug
  54953. $xdebug = new XdebugHandler('Composer', '--ansi');
  54954. $xdebug->check();
  54955. unset($xdebug);
  54956. if (function_exists('ini_set')) {
  54957. @ini_set('display_errors', 1);
  54958. $memoryInBytes = function ($value) {
  54959. $unit = strtolower(substr($value, -1, 1));
  54960. $value = (int) $value;
  54961. switch($unit) {
  54962. case 'g':
  54963. $value *= 1024;
  54964. // no break (cumulative multiplier)
  54965. case 'm':
  54966. $value *= 1024;
  54967. // no break (cumulative multiplier)
  54968. case 'k':
  54969. $value *= 1024;
  54970. }
  54971. return $value;
  54972. };
  54973. $memoryLimit = trim(ini_get('memory_limit'));
  54974. // Increase memory_limit if it is lower than 1.5GB
  54975. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  54976. @ini_set('memory_limit', '1536M');
  54977. }
  54978. // Set user defined memory limit
  54979. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  54980. @ini_set('memory_limit', $memoryLimit);
  54981. }
  54982. unset($memoryInBytes, $memoryLimit);
  54983. }
  54984. putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
  54985. // run the command application
  54986. $application = new Application();
  54987. $application->run();
  54988. Copyright (c) Nils Adermann, Jordi Boggiano
  54989. Permission is hereby granted, free of charge, to any person obtaining a copy
  54990. of this software and associated documentation files (the "Software"), to deal
  54991. in the Software without restriction, including without limitation the rights
  54992. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  54993. copies of the Software, and to permit persons to whom the Software is furnished
  54994. to do so, subject to the following conditions:
  54995. The above copyright notice and this permission notice shall be included in all
  54996. copies or substantial portions of the Software.
  54997. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  54998. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  54999. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55000. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55001. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55002. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  55003. THE SOFTWARE.
  55004. dŸÝ–š>q[Ko6ÐýBç°oj[���GBMB